From 81bbc3be1e583d52a96ef535190327843bfed8ef Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Thu, 12 Sep 2019 09:39:38 -0700 Subject: [PATCH] foldback gui: simplify button code where possible use signal_clicked rather than signal_button_press_event for cases where a menu is not launched. --- gtk2_ardour/foldback_strip.cc | 137 ++++++++++++++-------------------- gtk2_ardour/foldback_strip.h | 6 +- 2 files changed, 59 insertions(+), 84 deletions(-) diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index 34bc4b635b..8d3f0f3e6e 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -447,10 +447,10 @@ FoldbackStrip::init () output_button.signal_button_release_event().connect (sigc::mem_fun(*this, &FoldbackStrip::output_release), false); name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::name_button_button_press), false); - _previous_button.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackStrip::previous_button_button_press), false); - _next_button.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackStrip::next_button_button_press), false); + _previous_button.signal_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::previous_button_clicked)); + _next_button.signal_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::next_button_clicked)); _hide_button.signal_clicked.connect (sigc::mem_fun(*this, &FoldbackStrip::hide_clicked)); - _show_sends_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::show_sends_press), false); + _show_sends_button.signal_clicked.connect (sigc::mem_fun(*this, &FoldbackStrip::show_sends_clicked)); send_scroller.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackStrip::send_button_press_event)); _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor)); @@ -1221,75 +1221,57 @@ FoldbackStrip::name_button_button_press (GdkEventButton* ev) } -gboolean -FoldbackStrip::previous_button_button_press (GdkEventButton* ev) +void +FoldbackStrip::previous_button_clicked () { - if (ev->button == 1 || ev->button == 3) { - bool past_current = false; - StripableList slist; - boost::shared_ptr previous = boost::shared_ptr (); - boost::shared_ptr last = boost::shared_ptr (); - _session->get_stripables (slist, PresentationInfo::FoldbackBus); - if (slist.size () > 1) { - for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) { - last = boost::dynamic_pointer_cast (*s); - if ((*s) == _route) { - past_current = true; - } - if (!past_current) { - previous = boost::dynamic_pointer_cast (*s); - } + bool past_current = false; + StripableList slist; + boost::shared_ptr previous = boost::shared_ptr (); + _session->get_stripables (slist, PresentationInfo::FoldbackBus); + if (slist.size () > 1) { + for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) { + if ((*s) == _route) { + past_current = true; + } + if (!past_current) { + previous = boost::dynamic_pointer_cast (*s); } - } else { - // only one route do nothing - return true; } - //use previous to set route - if (previous) { - set_route (previous); - } /*else { no wrap around - set_route (last); - }*/ - return true; + } else { + // only one route do nothing + return; + } + //use previous to set route + if (previous) { + set_route (previous); } - - return false; } -gboolean -FoldbackStrip::next_button_button_press (GdkEventButton* ev) +void +FoldbackStrip::next_button_clicked () { - if (ev->button == 1 || ev->button == 3) { - bool past_current = false; - StripableList slist; - boost::shared_ptr next = boost::shared_ptr (); - boost::shared_ptr first = boost::shared_ptr (); - _session->get_stripables (slist, PresentationInfo::FoldbackBus); - if (slist.size () > 1) { - first = boost::dynamic_pointer_cast (*(slist.begin())); - for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) { - if (past_current) { - next = boost::dynamic_pointer_cast (*s); - break; - } - if ((*s) == _route) { - past_current = true; - } + bool past_current = false; + StripableList slist; + boost::shared_ptr next = boost::shared_ptr (); + _session->get_stripables (slist, PresentationInfo::FoldbackBus); + if (slist.size () > 1) { + for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) { + if (past_current) { + next = boost::dynamic_pointer_cast (*s); + break; + } + if ((*s) == _route) { + past_current = true; } - } else { - // only one route do nothing - return true; } - //use next to set route - if (next) { - set_route (next); - } /*else { no wrap around - set_route (first); - }*/ - return true; + } else { + // only one route do nothing + return; + } + //use next to set route + if (next) { + set_route (next); } - - return false; } void @@ -1317,27 +1299,20 @@ FoldbackStrip::hide_clicked() _hide_button.set_sensitive(true); } -gboolean -FoldbackStrip::show_sends_press (GdkEventButton* ev) +void +FoldbackStrip::show_sends_clicked () { - if (ev->button == 1 || ev->button == 3) { - - if (_showing_sends) { - BusSendDisplayChanged (boost::shared_ptr ()); /* EMIT SIGNAL */ - _showing_sends = false; - _show_sends_button.set_active (false); - send_blink_connection.disconnect (); - } else { - BusSendDisplayChanged (_route); /* EMIT SIGNAL */ - _showing_sends = true; - _show_sends_button.set_active (true); - send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &FoldbackStrip::send_blink)); - - } - return true; + if (_showing_sends) { + BusSendDisplayChanged (boost::shared_ptr ()); /* EMIT SIGNAL */ + _showing_sends = false; + _show_sends_button.set_active (false); + send_blink_connection.disconnect (); + } else { + BusSendDisplayChanged (_route); /* EMIT SIGNAL */ + _showing_sends = true; + _show_sends_button.set_active (true); + send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &FoldbackStrip::send_blink)); } - - return false; } void diff --git a/gtk2_ardour/foldback_strip.h b/gtk2_ardour/foldback_strip.h index dffe549a9a..0e2753ad00 100644 --- a/gtk2_ardour/foldback_strip.h +++ b/gtk2_ardour/foldback_strip.h @@ -252,10 +252,10 @@ private: void build_route_select_menu (); void list_fb_routes (); - gboolean previous_button_button_press (GdkEventButton*); - gboolean next_button_button_press (GdkEventButton*); + void previous_button_clicked (); + void next_button_clicked (); void prev_next_changed (); - gboolean show_sends_press (GdkEventButton*); + void show_sends_clicked (); void send_blink (bool); Gtk::Menu *sends_menu;