From ce28065421a9a588f8fa9a8cc09ec5b4d116b926 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 25 Mar 2021 21:38:10 +0100 Subject: [PATCH] Foldback: refactor spill logic Prefer to reuse spill logic from the mixer-ui. This allows to spill routes directly after spilling foldbacks. Previously that resulted in FB "show sends" to keep flashing even then no foldbacks were spilled anymore. It also simplifies various aspects of foldback prev/next logic. --- gtk2_ardour/foldback_strip.cc | 145 +++++++++++----------------------- gtk2_ardour/foldback_strip.h | 19 +++-- gtk2_ardour/mixer_ui.cc | 1 - gtk2_ardour/route_ui.cc | 6 +- 4 files changed, 61 insertions(+), 110 deletions(-) diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index 2d099b3baf..cf1cc0151e 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -128,8 +128,6 @@ FoldbackSend::FoldbackSend (boost::shared_ptr snd, \ _send_route->PropertyChanged.connect (_connections, invalidator (*this), boost::bind (&FoldbackSend::route_property_changed, this, _1), gui_context()); show (); - - } FoldbackSend::~FoldbackSend () @@ -519,8 +517,8 @@ 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_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::previous_button_clicked)); - _next_button.signal_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::next_button_clicked)); + _previous_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::cycle_foldbacks), false)); + _next_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::cycle_foldbacks), true)); _hide_button.signal_clicked.connect (sigc::mem_fun(*this, &FoldbackStrip::hide_clicked)); _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)); @@ -546,6 +544,7 @@ FoldbackStrip::init () signal_enter_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_enter_event )); signal_leave_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_leave_event )); + Mixer_UI::instance()->show_spill_change.connect (sigc::mem_fun (*this, &FoldbackStrip::spill_change)); } FoldbackStrip::~FoldbackStrip () @@ -604,31 +603,25 @@ FoldbackStrip::update_fb_level_control () void FoldbackStrip::set_route (boost::shared_ptr rt) { - bool sh_snd = _showing_sends; - if (_route) { - // before we do anything unset show sends - Mixer_UI::instance()->show_spill (boost::shared_ptr()); - BusSendDisplayChanged (boost::shared_ptr ()); /* EMIT SIGNAL */ - _showing_sends = false; - _show_sends_button.set_active (false); - send_blink_connection.disconnect (); - } + RouteUI::set_route (rt); - /// FIX NO route if (!rt) { clear_send_box (); + update_sensitivity (); + if (_showing_sends) { + Mixer_UI::instance()->show_spill (boost::shared_ptr()); + _showing_sends = false; + send_blink_connection.disconnect (); + } + RouteUI::set_route (rt); RouteUI::self_delete (); - return; } - RouteUI::set_route (rt); - insert_box->set_route (_route); revert_to_default_display (); update_fb_level_control(); - BusSendDisplayChanged (boost::shared_ptr ()); _showing_sends = false; _show_sends_button.set_active (false); send_blink_connection.disconnect (); @@ -661,7 +654,7 @@ FoldbackStrip::set_route (boost::shared_ptr rt) update_output_display (); add_events (Gdk::BUTTON_RELEASE_MASK); - prev_next_changed (); + update_sensitivity (); _previous_button.show(); _next_button.show(); _hide_button.show(); @@ -682,16 +675,6 @@ FoldbackStrip::set_route (boost::shared_ptr rt) map_frozen(); show (); - - if (sh_snd) { - // if last route had shows sends let it remain active - Mixer_UI::instance()->show_spill (_route); - 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)); - } - } // predicate for sort call in get_sorted_stripables @@ -1307,68 +1290,33 @@ FoldbackStrip::name_button_button_press (GdkEventButton* ev) } void -FoldbackStrip::previous_button_clicked () +FoldbackStrip::cycle_foldbacks (bool next) { - bool past_current = false; - boost::shared_ptr previous = boost::shared_ptr (); - RouteList fb_list; - fb_list = _session->get_routelist (true, PresentationInfo::FoldbackBus); - - if (fb_list.size () > 1) { - for (RouteList::iterator s = fb_list.begin(); s != fb_list.end(); ++s) { - if ((*s) == _route) { - past_current = true; - } - if (!past_current) { - previous = boost::dynamic_pointer_cast (*s); - } - } - } else { - // only one route do nothing + RouteList rl (_session->get_routelist (true, PresentationInfo::FoldbackBus)); + if (rl.size () < 2) { return; } - //use previous to set route - if (previous) { - set_route (previous); - if (_showing_sends) { - Mixer_UI::instance()->show_spill (_route); - } - } -} + RouteList::iterator i = find (rl.begin (), rl.end (), _route); + assert (i != rl.end ()); -void -FoldbackStrip::next_button_clicked () -{ - bool past_current = false; - boost::shared_ptr next = boost::shared_ptr (); - RouteList fb_list; - fb_list = _session->get_routelist (true, PresentationInfo::FoldbackBus); - - if (fb_list.size () > 1) { - for (RouteList::iterator s = fb_list.begin(); s != fb_list.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; - } - //use next to set route if (next) { - set_route (next); - if (_showing_sends) { - Mixer_UI::instance()->show_spill (_route); + if (++i == rl.end ()) { + i = rl.begin (); } + } else { + if (i == rl.begin ()) { + i = rl.end (); + } + --i; + } + set_route (*i); + if (_showing_sends) { + Mixer_UI::instance()->show_spill (_route); } } void -FoldbackStrip::prev_next_changed () +FoldbackStrip::update_sensitivity () { RouteList fb_list; fb_list = _session->get_routelist (true, PresentationInfo::FoldbackBus); @@ -1394,20 +1342,27 @@ FoldbackStrip::hide_clicked() } void -FoldbackStrip::show_sends_clicked () +FoldbackStrip::spill_change (boost::shared_ptr s) { - if (_showing_sends) { - Mixer_UI::instance()->show_spill (boost::shared_ptr()); - BusSendDisplayChanged (boost::shared_ptr ()); /* EMIT SIGNAL */ + if (s == _route) { + _showing_sends = true; + _show_sends_button.set_active (true); + send_blink_connection.disconnect (); + send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &FoldbackStrip::send_blink)); + } else { _showing_sends = false; _show_sends_button.set_active (false); send_blink_connection.disconnect (); + } +} + +void +FoldbackStrip::show_sends_clicked () +{ + if (_showing_sends) { + Mixer_UI::instance()->show_spill (boost::shared_ptr()); } else { Mixer_UI::instance()->show_spill (_route); - 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)); } } @@ -1759,13 +1714,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 (); - _session->remove_route (old_route); - } + + set_route (next); + _session->remove_route (old_route); } diff --git a/gtk2_ardour/foldback_strip.h b/gtk2_ardour/foldback_strip.h index 0819195872..89e7cfbddf 100644 --- a/gtk2_ardour/foldback_strip.h +++ b/gtk2_ardour/foldback_strip.h @@ -123,19 +123,19 @@ public: std::string name() const; - boost::shared_ptr stripable() const { return RouteUI::stripable(); } - - PannerUI& panner_ui() { return panners; } + PannerUI& panner_ui() { return panners; } PluginSelector* plugin_selector(); void set_embedded (bool); - void fast_update (); - void set_route (boost::shared_ptr); void set_button_names (); void revert_to_default_display (); + boost::shared_ptr stripable() const { + return RouteUI::stripable(); + } + /** @return the delivery that is being edited using our fader; it will be the * last send passed to show_send(), or our route's main out delivery. */ @@ -221,8 +221,7 @@ private: Gtk::Menu output_menu; std::list > output_menu_bundles; - void maybe_add_bundle_to_output_menu (boost::shared_ptr, ARDOUR::BundleList const &, - ARDOUR::DataType type = ARDOUR::DataType::NIL); + void maybe_add_bundle_to_output_menu (boost::shared_ptr, ARDOUR::BundleList const &, ARDOUR::DataType type = ARDOUR::DataType::NIL); void bundle_output_chosen (boost::shared_ptr); @@ -243,9 +242,9 @@ private: Gtk::Menu* build_route_ops_menu (); Gtk::Menu* build_route_select_menu (); - void previous_button_clicked (); - void next_button_clicked (); - void prev_next_changed (); + void cycle_foldbacks (bool next); + void update_sensitivity (); + void spill_change (boost::shared_ptr); void show_sends_clicked (); void send_blink (bool); diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index c9684ae318..878aa1d9bb 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -632,7 +632,6 @@ Mixer_UI::add_stripables (StripableList& slist) if (foldback_strip) { // last strip created is shown foldback_strip->set_route (route); - foldback_strip->prev_next_changed(); } else { foldback_strip = new FoldbackStrip (*this, _session, route); out_packer.pack_start (*foldback_strip, false, false); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index f295f8ee6e..89f16a7a8e 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -320,7 +320,11 @@ RouteUI::set_route (boost::shared_ptr rp) _route = rp; - if ( !_route->presentation_info().color_set() ) { + if (!_route) { + return; + } + + if (!_route->presentation_info().color_set()) { /* deal with older 4.x color, which was stored in the GUI object state */ string p = ARDOUR_UI::instance()->gui_object_state->get_string (route_state_id(), X_("color"));