trigger_ui: no need for right-clicking or extra menu levels for a single menu

This commit is contained in:
Ben Loftis 2022-01-27 13:06:50 -06:00
parent 3605f51e7e
commit 2e5a266d24
2 changed files with 30 additions and 12 deletions

View File

@ -580,31 +580,45 @@ TriggerUI::follow_context_menu ()
MenuList& items = _follow_context_menu->items ();
_follow_context_menu->set_name ("ArdourContextMenu");
Menu* follow_menu = manage (new Menu);
MenuList& fitems = follow_menu->items ();
RadioMenuItem::Group fagroup;
_ignore_menu_action = true;
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::None)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::None))));
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Stop)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Stop))));
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Again)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Again))));
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ForwardTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ForwardTrigger))));
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ReverseTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ReverseTrigger))));
items.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::None)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::None))));
if (trigger ()->follow_action0 ().type == FollowAction::None) {
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
}
items.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Stop)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Stop))));
if (trigger ()->follow_action0 ().type == FollowAction::Stop) {
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
}
items.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Again)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Again))));
if (trigger ()->follow_action0 ().type == FollowAction::Again) {
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
}
items.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ForwardTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ForwardTrigger))));
if (trigger ()->follow_action0 ().type == FollowAction::ForwardTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
}
items.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ReverseTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ReverseTrigger))));
if (trigger ()->follow_action0 ().type == FollowAction::ReverseTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
}
Menu* jump_menu = manage (new Menu);
MenuList& jitems = jump_menu->items ();
for (int i = 0; i < default_triggers_per_box; i++) {
FollowAction jump_fa = (FollowAction::JumpTrigger);
jump_fa.targets.set(i);
jitems.push_back (MenuElem (string_compose ("%1", (char)('A' + i)), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_follow_action), jump_fa)));
jitems.push_back (RadioMenuElem (fagroup, string_compose ("%1", (char)('A' + i)), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_follow_action), jump_fa)));
if (trigger ()->follow_action0 () == jump_fa) {
dynamic_cast<Gtk::CheckMenuItem*> (&jitems.back ())->set_active (true);
}
}
fitems.push_back (MenuElem (_("Jump..."), *jump_menu));
items.push_back (MenuElem (_("Jump..."), *jump_menu));
_ignore_menu_action = false;
items.push_back (MenuElem (_("Follow Action..."), *follow_menu));
_follow_context_menu->popup (1, gtk_get_current_event_time ());
}

View File

@ -658,8 +658,12 @@ bool
TriggerEntry::follow_button_event (GdkEvent* ev)
{
switch (ev->type) {
case GDK_BUTTON_PRESS:
return true; //wait for release to show the menu
break;
case GDK_BUTTON_RELEASE:
switch (ev->button.button) {
case 1:
case 3:
follow_context_menu ();
return true;