From 109e7d6ea02aa23a33723aa8134c50d8bbf265ed Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 4 Sep 2022 20:25:51 +0200 Subject: [PATCH] When editig sends, show the send's polarity control on mixer-strip --- gtk2_ardour/foldback_strip.cc | 2 +- gtk2_ardour/mixer_strip.cc | 3 ++- gtk2_ardour/route_ui.cc | 45 +++++++++++++++++++++++++++++++++-- gtk2_ardour/route_ui.h | 5 ++-- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index 1f92ed12f0..ba908c4189 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -1006,7 +1006,7 @@ FoldbackStrip::reset_strip_style () set_name ("AudioBusStripBaseInactive"); } - set_invert_sensitive (active); + update_phase_invert_sensitivty (); update_sensitivity (); _comment_button.set_sensitive (active); diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index a09b9bf53a..7b5eecf6f2 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1604,6 +1604,7 @@ void MixerStrip::set_current_delivery (boost::shared_ptr d) { _current_delivery = d; + setup_invert_buttons (); DeliveryChanged (_current_delivery); update_sensitivity (); } @@ -1879,7 +1880,6 @@ MixerStrip::update_sensitivity () input_button.set_sensitive (en && !send); group_button.set_sensitive (en && !send); - set_invert_sensitive (en && !send); gpm.meter_point_button.set_sensitive (en && !send); mute_button->set_sensitive (en && !send); solo_button->set_sensitive (en && !send); @@ -1894,6 +1894,7 @@ MixerStrip::update_sensitivity () output_button.set_sensitive (en && !aux); + update_phase_invert_sensitivty (); map_frozen (); set_button_names (); // update solo button visual state } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index dcbc75a155..39b5773f3d 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -2050,7 +2050,23 @@ RouteUI::parameter_changed (string const & p) void RouteUI::setup_invert_buttons () { - uint32_t const N = _route ? _route->phase_control()->size() : 0; + uint32_t N = _route ? _route->phase_control()->size() : 0; + + boost::shared_ptr send = boost::dynamic_pointer_cast(_current_delivery); + send_connections.drop_connections (); + if (send) { + boost::shared_ptr ac = send->polarity_control (); + if (ac) { + N = 1; + ac->Changed.connect (send_connections, invalidator (*this), boost::bind (&RouteUI::update_polarity_display, this), gui_context()); + if (ac->alist ()) { + ac->alist()->automation_state_changed.connect (send_connections, invalidator (*this), boost::bind (&RouteUI::update_phase_invert_sensitivty, this), gui_context()); + update_phase_invert_sensitivty (); + } + } else { + N = 0; + } + } if (_n_polarity_invert == N) { /* buttons are already setup for this strip, but we should still set the values */ @@ -2107,6 +2123,15 @@ RouteUI::setup_invert_buttons () void RouteUI::update_polarity_display () { + boost::shared_ptr send = boost::dynamic_pointer_cast(_current_delivery); + if (send) { + if (send->polarity_control()) { + ArdourButton* b = _invert_buttons.front (); + b->set_active_state (send->polarity_control()->get_value () > 0 ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); + } + return; + } + if (!_route) { return; } @@ -2146,6 +2171,11 @@ RouteUI::invert_release (GdkEventButton* ev, uint32_t i) if (ev->button == 1 && i < _invert_buttons.size()) { uint32_t const N = _route->phase_control()->size(); if (N <= _max_invert_buttons) { + boost::shared_ptr send = boost::dynamic_pointer_cast(_current_delivery); + if (send) { + send->polarity_control ()->set_value (_invert_buttons[i]->get_active() ? 0 : 1, Controllable::NoGroup); + return false; + } /* left-click inverts phase so long as we have a button per channel */ _route->phase_control()->set_phase_invert (i, !_invert_buttons[i]->get_active()); return false; @@ -2197,8 +2227,19 @@ RouteUI::invert_menu_toggled (uint32_t c) } void -RouteUI::set_invert_sensitive (bool yn) +RouteUI::update_phase_invert_sensitivty () { + bool yn = false; + boost::shared_ptr send = boost::dynamic_pointer_cast(_current_delivery); + if (send) { + boost::shared_ptr ac = send->polarity_control (); + if (ac) { + yn = (ac->alist()->automation_state() & Play) == 0; + } + } else if (_route) { + yn = _route->active () || ARDOUR::Profile->get_mixbus(); + } + for (vector::iterator b = _invert_buttons.begin(); b != _invert_buttons.end(); ++b) { (*b)->set_sensitive (yn); } diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 5117167722..70907fb256 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -221,6 +221,7 @@ protected: static void help_count_plugins (boost::weak_ptr p, uint32_t*); PBD::ScopedConnectionList route_connections; + PBD::ScopedConnectionList send_connections; bool self_destruct; void init (); @@ -238,7 +239,8 @@ protected: virtual void bus_send_display_changed (boost::shared_ptr); bool mark_hidden (bool yn); - void set_invert_sensitive (bool); + void setup_invert_buttons (); + void update_phase_invert_sensitivty (); bool verify_new_route_name (const std::string& name); void check_rec_enable_sensitivity (); void route_gui_changed (PBD::PropertyChange const&); @@ -262,7 +264,6 @@ protected: ARDOUR::SoloMuteRelease* _mute_release; private: - void setup_invert_buttons (); void invert_menu_toggled (uint32_t); bool invert_press (GdkEventButton*); bool invert_release (GdkEventButton*, uint32_t i);