From 2e857e9143e588ea629ea3a9f9e570d57825bbc1 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Tue, 10 Sep 2019 21:09:54 -0700 Subject: Foldback gui: previous and next buttons don't wrap around I had set the previous next buttons to wrap around but Robin felt dead ending was better. The previous button becomes insensitive when the first foldback bus is displayed and next is insensitive when the last is displayed. --- gtk2_ardour/foldback_strip.cc | 99 ++++++++++++++++++++++++++----------------- gtk2_ardour/foldback_strip.h | 1 + 2 files changed, 61 insertions(+), 39 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index 17f271f1f1..3f39e32fd5 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -321,9 +321,12 @@ FoldbackStrip::init () _previous_button.set_name ("mixer strip button"); _previous_button.set_icon (ArdourIcon::NudgeLeft); _previous_button.set_tweaks (ArdourButton::Square); + _previous_button.set_sensitive (false); + _next_button.set_name ("mixer strip button"); _next_button.set_icon (ArdourIcon::NudgeRight); _next_button.set_tweaks (ArdourButton::Square); + _next_button.set_sensitive (false); prev_next_box.pack_start (_previous_button, false, true); prev_next_box.pack_end (_next_button, false, true); @@ -576,7 +579,7 @@ FoldbackStrip::set_route (boost::shared_ptr rt) update_output_display (); add_events (Gdk::BUTTON_RELEASE_MASK); - + prev_next_changed (); _previous_button.show(); _next_button.show(); prev_next_box.show (); @@ -1228,21 +1231,74 @@ FoldbackStrip::previous_button_button_press (GdkEventButton* ev) } } } else { - // only one route or none do nothing + // only one route do nothing return true; } //use previous to set route if (previous) { set_route (previous); - } else { + } /*else { no wrap around set_route (last); + }*/ + return true; + } + + return false; +} + +gboolean +FoldbackStrip::next_button_button_press (GdkEventButton* ev) +{ + 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; + } + } + } 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; } return false; } +void +FoldbackStrip::prev_next_changed () +{ + StripableList slist; + _session->get_stripables (slist, PresentationInfo::FoldbackBus); + if ((slist.size() < 2) || (boost::dynamic_pointer_cast (_route) == *(slist.begin()))) { + _previous_button.set_sensitive (false); + } else { + _previous_button.set_sensitive (true); + } + if ((slist.size () < 2) || boost::dynamic_pointer_cast (_route) == *(--slist.end())) { + _next_button.set_sensitive (false); + } else { + _next_button.set_sensitive (true); + } +} + gboolean FoldbackStrip::show_sends_press (GdkEventButton* ev) { @@ -1280,42 +1336,6 @@ FoldbackStrip::send_blink (bool onoff) } } -gboolean -FoldbackStrip::next_button_button_press (GdkEventButton* ev) -{ - 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; - } - } - } else { - // only one or no route do nothing - return true; - } - //use next to set route - if (next) { - set_route (next); - } else { - set_route (first); - } - return true; - } - - return false; -} - void FoldbackStrip::list_route_operations () { @@ -1651,6 +1671,7 @@ FoldbackStrip::remove_current_fb () if (next) { set_route (next); _session->remove_route (old_route); + prev_next_changed (); } else { clear_send_box (); RouteUI::self_delete (); diff --git a/gtk2_ardour/foldback_strip.h b/gtk2_ardour/foldback_strip.h index 23467ed851..2a9f23d2ad 100644 --- a/gtk2_ardour/foldback_strip.h +++ b/gtk2_ardour/foldback_strip.h @@ -252,6 +252,7 @@ private: gboolean previous_button_button_press (GdkEventButton*); gboolean next_button_button_press (GdkEventButton*); + void prev_next_changed (); gboolean show_sends_press (GdkEventButton*); void send_blink (bool); -- cgit v1.2.3