From 16e1188a2f81758fb01a1e853fd5efc80b95fd61 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 28 Jul 2023 09:50:23 -0600 Subject: [PATCH] move logic for use-selection-as-group into ARDOUR_UI and use it everywhere --- gtk2_ardour/ardour_ui.h | 2 ++ gtk2_ardour/ardour_ui3.cc | 26 ++++++++++++++++++++++++++ gtk2_ardour/gain_meter.cc | 11 +++++------ gtk2_ardour/mixer_strip.cc | 3 ++- gtk2_ardour/route_ui.cc | 36 +++--------------------------------- gtk2_ardour/route_ui.h | 1 - 6 files changed, 38 insertions(+), 41 deletions(-) diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 91db46bd95..8f814714dd 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -399,6 +399,8 @@ public: void gui_idle_handler (); + bool maybe_use_select_as_group (ARDOUR::Route const&) const; + protected: friend class PublicEditor; diff --git a/gtk2_ardour/ardour_ui3.cc b/gtk2_ardour/ardour_ui3.cc index 0fddba2cdb..3b2181ce33 100644 --- a/gtk2_ardour/ardour_ui3.cc +++ b/gtk2_ardour/ardour_ui3.cc @@ -211,3 +211,29 @@ ARDOUR_UI::record_state_changed () big_clock->set_active (false); } } + +bool +ARDOUR_UI::maybe_use_select_as_group (Route const & route) const +{ + if (!UIConfiguration::instance().get_allow_selection_as_group()) { + return false; + } + + if (!route.is_selected()) { + /* Not selected, can't possibly use selection */ + return false; + } + + if (editor->get_selection().tracks.size() < 2) { + /* only this track selected */ + return false; + } + + if (route.route_group() && route.route_group()->is_active() && !route.route_group()->is_select()) { + /* active route group that does not share selection status */ + return false; + } + + return true; +} + diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 8241d98f74..a870e36bcc 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -48,6 +48,7 @@ #include "pbd/fastlog.h" +#include "ardour_ui.h" #include "gain_meter.h" #include "gui_thread.h" #include "keyboard.h" @@ -757,12 +758,10 @@ GainMeterBase::amp_start_touch (int state) { assert (_route); - if (UIConfiguration::instance().get_allow_selection_as_group()) { - if (_route->is_selected() && (!_route->route_group() || !_route->route_group()->is_gain())) { - _touch_control_group.reset (new GainControlGroup ()); - _touch_control_group->set_mode (ControlGroup::Relative); - _touch_control_group->fill_from_selection (_control->session().selection(), _control->parameter()); - } + if (ARDOUR_UI::instance()->maybe_use_select_as_group (*_route)) { + _touch_control_group.reset (new GainControlGroup ()); + _touch_control_group->set_mode (ControlGroup::Relative); + _touch_control_group->fill_from_selection (_control->session().selection(), _control->parameter()); } _control->start_touch (timepos_t (_control->session().transport_sample())); diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index c4344278bb..12f6316749 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -73,6 +73,7 @@ #include "widgets/tooltips.h" +#include "ardour_ui.h" #include "ardour_window.h" #include "automation_controller.h" #include "context_menu_helper.h" @@ -508,7 +509,7 @@ MixerStrip::trim_start_touch (int) std::shared_ptr control (route()->trim()->gain_control()); - if (maybe_use_select_as_group ()) { + if (ARDOUR_UI::instance()->maybe_use_select_as_group (*_route)) { _touch_control_group.reset (new GainControlGroup (TrimAutomation)); _touch_control_group->set_mode (ControlGroup::Relative); _touch_control_group->fill_from_selection (control->session().selection(), control->parameter()); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 3dcef3216a..c4a12268a3 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -566,7 +566,7 @@ RouteUI::mute_press (GdkEventButton* ev) Controllable::GroupControlDisposition gcd; std::shared_ptr rl (new RouteList); - if (maybe_use_select_as_group ()) { + if (ARDOUR_UI::instance()->maybe_use_select_as_group (*_route)) { gather_selected_routes (rl); gcd = Controllable::NoGroup; } else { @@ -745,7 +745,7 @@ RouteUI::solo_press(GdkEventButton* ev) std::shared_ptr rl (new RouteList); Controllable::GroupControlDisposition gcd; - if (maybe_use_select_as_group ()) { + if (ARDOUR_UI::instance()->maybe_use_select_as_group (*_route)) { gather_selected_routes (rl); gcd = Controllable::NoGroup; } else { @@ -842,7 +842,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev) Controllable::GroupControlDisposition gcd; rl.reset (new RouteList); - if (maybe_use_select_as_group ()) { + if (ARDOUR_UI::instance()->maybe_use_select_as_group (*_route)) { gather_selected_routes (rl); gcd = Controllable::NoGroup; } else { @@ -2883,36 +2883,6 @@ RouteUI::rename_current_playlist () } } -bool -RouteUI::maybe_use_select_as_group () const -{ - if (!UIConfiguration::instance().get_allow_selection_as_group()) { - return false; - } - - if (!route()) { - /* Shouldn't happen but protects conditionals below */ - return false; - } - - if (!route()->is_selected()) { - /* Not selected, can't possibly use selection */ - return false; - } - - if (ARDOUR_UI::instance()->the_editor().get_selection().tracks.size() < 2) { - /* only this track selected */ - return false; - } - - if (route()->route_group() && route()->route_group()->is_active() && !route()->route_group()->is_select()) { - /* active route group that does not share selection status */ - return false; - } - - return true; -} - void RouteUI::gather_selected_routes (std::shared_ptr& rl) const { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 1d11d259ca..3a16296800 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -263,7 +263,6 @@ protected: ARDOUR::SoloMuteRelease* _solo_release; ARDOUR::SoloMuteRelease* _mute_release; - bool maybe_use_select_as_group () const; void gather_selected_routes (std::shared_ptr& rl) const; private: