From 3f6310ef9c8659fb62706a3e127aae4f5eeff090 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Tue, 10 Sep 2019 19:26:00 -0700 Subject: [PATCH] Foldback GUI: sort send controls by mixer order also found send button name did not follow sending route name after change and tool tip was wrong. Fixed both. --- gtk2_ardour/foldback_strip.cc | 67 ++++++++++++++++++++++++----------- gtk2_ardour/foldback_strip.h | 2 ++ 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index 12a8f9f833..17f271f1f1 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -82,8 +82,7 @@ FoldbackSend::FoldbackSend (boost::shared_ptr snd, \ _button.signal_led_clicked.connect (sigc::mem_fun (*this, &FoldbackSend::led_clicked)); _button.set_name ("processor prefader"); _button.set_layout_ellipsize_width (Wide * PANGO_SCALE); - string s_name = PBD::short_version (_send_route->name (), 8); - _button.set_text (s_name); + name_changed (); _button.set_text_ellipsize (Pango::ELLIPSIZE_END); snd_but_pan->pack_start (_button, true, true); _button.set_active (_send_proc->enabled ()); @@ -107,8 +106,6 @@ FoldbackSend::FoldbackSend (boost::shared_ptr snd, \ _slider.set_name ("ProcessorControlSlider"); _slider.set_text (_("Level")); - - pack_start (*snd_but_pan, Gtk::PACK_SHRINK); snd_but_pan->show(); pack_start (_slider, true, true); @@ -119,6 +116,7 @@ FoldbackSend::FoldbackSend (boost::shared_ptr snd, \ lc->Changed.connect (_connections, invalidator (*this), boost::bind (&FoldbackSend::level_changed, this), gui_context ()); _send_proc->ActiveChanged.connect (_connections, invalidator (*this), boost::bind (&FoldbackSend::send_state_changed, this), gui_context ()); _button.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackSend::button_press)); + _send_route->PropertyChanged.connect (_connections, invalidator (*this), boost::bind (&FoldbackSend::route_property_changed, this, _1), gui_context()); show (); @@ -138,6 +136,23 @@ FoldbackSend::~FoldbackSend () } +void +FoldbackSend::route_property_changed (const PropertyChange& what_changed) +{ + if (what_changed.contains (ARDOUR::Properties::name)) { + name_changed (); + } +} + +void +FoldbackSend::name_changed () +{ + string s_name = PBD::short_version (_send_route->name (), 8); + _button.set_text (s_name); + + ArdourWidgets::set_tooltip (_button, Gtkmm2ext::markup_escape_text(_send_route->name())); +} + void FoldbackSend::led_clicked(GdkEventButton *ev) { @@ -216,7 +231,6 @@ FoldbackSend::set_tooltip () std::string tt = ARDOUR::value_as_string (lc->desc(), lc->get_value ()); string sm = Gtkmm2ext::markup_escape_text (tt); _slider_persistant_tooltip.set_tip (sm); - ArdourWidgets::set_tooltip (_button, Gtkmm2ext::markup_escape_text (sm)); } Menu* @@ -586,6 +600,15 @@ FoldbackStrip::set_route (boost::shared_ptr rt) show (); } +// predicate for sort call in get_sorted_stripables +struct StripableByPresentationOrder +{ + bool operator () (const boost::shared_ptr & a, const boost::shared_ptr & b) const + { + return a->presentation_info().order() < b->presentation_info().order(); + } +}; + void FoldbackStrip::update_send_box () { @@ -593,17 +616,28 @@ FoldbackStrip::update_send_box () if (!_route) { return; } + StripableList stripables; + stripables.clear (); + Route::FedBy fed_by = _route->fed_by(); for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) { if (i->sends_only) { - boost::shared_ptr s_rt (i->r.lock()); - boost::shared_ptr snd = s_rt->internal_send_for (_route); - if (snd) { - FoldbackSend * fb_s = new FoldbackSend (snd, s_rt, _route); - send_display.pack_start (*fb_s, Gtk::PACK_SHRINK); - fb_s->show (); - s_rt->processors_changed.connect (_connections, invalidator (*this), boost::bind (&FoldbackStrip::processors_changed, this, _1), gui_context ()); - } + boost::shared_ptr rt (i->r.lock()); + boost::shared_ptr s = boost::dynamic_pointer_cast (rt); + stripables.push_back (s); + } + } + stripables.sort (StripableByPresentationOrder()); + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + + boost::shared_ptr s_sp = *it; + boost::shared_ptr s_rt = boost::dynamic_pointer_cast (s_sp); + boost::shared_ptr snd = s_rt->internal_send_for (_route); + if (snd) { + FoldbackSend * fb_s = new FoldbackSend (snd, s_rt, _route); + send_display.pack_start (*fb_s, Gtk::PACK_SHRINK); + fb_s->show (); + s_rt->processors_changed.connect (_connections, invalidator (*this), boost::bind (&FoldbackStrip::processors_changed, this, _1), gui_context ()); } } } @@ -632,13 +666,6 @@ FoldbackStrip::set_packed (bool yn) _packed = yn; } - -struct RouteCompareByName { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->name().compare (b->name()) < 0; - } -}; - gint FoldbackStrip::output_release (GdkEventButton *ev) { diff --git a/gtk2_ardour/foldback_strip.h b/gtk2_ardour/foldback_strip.h index 39adb59ca3..23467ed851 100644 --- a/gtk2_ardour/foldback_strip.h +++ b/gtk2_ardour/foldback_strip.h @@ -93,6 +93,8 @@ private: void set_gain (float new_gain); void remove_me (); + void route_property_changed (const PBD::PropertyChange&); + void name_changed (); void send_state_changed (); void level_adjusted (); void level_changed ();