From 2e5a266d24f0ea5b49033f165a0693b886886f64 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Thu, 27 Jan 2022 13:06:50 -0600 Subject: [PATCH] trigger_ui: no need for right-clicking or extra menu levels for a single menu --- gtk2_ardour/trigger_ui.cc | 38 ++++++++++++++++++++++++------------ gtk2_ardour/triggerbox_ui.cc | 4 ++++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 619ba37402..5c3e277eeb 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -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 (&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 (&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 (&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 (&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 (&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 (&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 ()); } diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index 0aee799736..3e72f14667 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -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;