From 3eaa6c038988776e3bab441b84de45b2a8364130 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 10 Jun 2016 13:47:41 -0400 Subject: [PATCH] remove certain ControlProtocol signals related to stripable selection includes change to Mackie support so that strips listen for PropertyChange on the stripables they represent, no global selection change used anymore. --- gtk2_ardour/editor.cc | 25 +----- .../control_protocol/control_protocol.cc | 3 +- .../control_protocol/control_protocol.h | 3 +- .../mackie/mackie_control_protocol.cc | 80 ++----------------- libs/surfaces/mackie/strip.cc | 25 +++--- libs/surfaces/mackie/strip.h | 2 - libs/surfaces/mackie/surface.cc | 8 -- libs/surfaces/mackie/surface.h | 1 - 8 files changed, 23 insertions(+), 124 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 9fac47af49..c0ab97d9a4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -803,11 +803,9 @@ Editor::Editor () ControlProtocol::VerticalZoomInSelected.connect (*this, invalidator (*this), boost::bind (&Editor::control_vertical_zoom_in_selected, this), gui_context()); ControlProtocol::VerticalZoomOutSelected.connect (*this, invalidator (*this), boost::bind (&Editor::control_vertical_zoom_out_selected, this), gui_context()); - ControlProtocol::AddStripableToSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Add), gui_context()); - ControlProtocol::RemoveStripableFromSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Toggle), gui_context()); - ControlProtocol::SetStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Set), gui_context()); + ControlProtocol::AddStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Add), gui_context()); ControlProtocol::ToggleStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Toggle), gui_context()); - ControlProtocol::ClearStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_unselect, this), gui_context()); + ControlProtocol::SetStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Set), gui_context()); BasicUI::AccessAction.connect (*this, invalidator (*this), boost::bind (&Editor::access_action, this, _1, _2), gui_context()); @@ -1011,7 +1009,7 @@ Editor::control_unselect () } void -Editor::control_select (PresentationInfo::order_t global_order, Selection::Operation op) +Editor::control_select (PresentationInfo::order_t order, Selection::Operation op) { /* handles the (static) signal from the ControlProtocol class that * requests setting the selected track to a given RID @@ -1021,22 +1019,7 @@ Editor::control_select (PresentationInfo::order_t global_order, Selection::Opera return; } - PresentationInfo::Flag select_flags; - - if (global_order & ~0xffffffff) { - /* some flags are set, so the PresentationInfo constructor - * will use them - */ - select_flags = PresentationInfo::Flag (0); - } else { - /* no type flags set in the global order ID, so assume caller - * wants to select a Route - */ - select_flags = PresentationInfo::Route; - } - - PresentationInfo pi (global_order, select_flags); - boost::shared_ptr s = _session->get_remote_nth_stripable (pi.order(), pi.flags()); + boost::shared_ptr s = _session->get_nth_stripable (order); /* selected object may not be a Route */ diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 15946240d7..8e86692241 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -50,10 +50,9 @@ PBD::Signal0 ControlProtocol::StepTracksDown; PBD::Signal0 ControlProtocol::StepTracksUp; PBD::Signal1 ControlProtocol::StripableSelectionChanged; -PBD::Signal1 ControlProtocol::AddStripableToSelection; +PBD::Signal1 ControlProtocol::AddStripableSelection; PBD::Signal1 ControlProtocol::SetStripableSelection; PBD::Signal1 ControlProtocol::ToggleStripableSelection; -PBD::Signal1 ControlProtocol::RemoveStripableFromSelection; PBD::Signal0 ControlProtocol::ClearStripableSelection; diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index b26f8c1d53..53fce840e0 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -78,10 +78,9 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope static PBD::Signal0 StepTracksDown; static PBD::Signal0 StepTracksUp; - static PBD::Signal1 AddStripableToSelection; + static PBD::Signal1 AddStripableSelection; static PBD::Signal1 SetStripableSelection; static PBD::Signal1 ToggleStripableSelection; - static PBD::Signal1 RemoveStripableFromSelection; static PBD::Signal0 ClearStripableSelection; /* signals that one UI (e.g. the GUI) can emit to get all other UI's to diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 89719d03e9..86af49cc09 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -138,7 +138,6 @@ MackieControlProtocol::MackieControlProtocol (Session& session) _last_bank[i] = 0; } - StripableSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::gui_track_selection_changed, this, _1, true), this); PresentationInfo::Change.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_presentation_info_changed, this), this); _instance = this; @@ -437,10 +436,6 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force) return -1; } - /* make sure selection is correct */ - - _gui_track_selection_changed (&_last_selected_stripables, false, false); - /* current bank has not been saved */ session->set_dirty(); @@ -1926,68 +1921,6 @@ MackieControlProtocol::force_special_stripable_to_strip (boost::shared_ptr unless we want to - handle the complexities of route deletion. So instead, the GUI sends - us a notification using weak_ptr, which we keep a copy - of. For efficiency's sake, however, we convert the weak_ptr's into - shared_ptr before passing them to however many surfaces (and - thus strips) that we have. - */ - - StrongStripableNotificationList srl; - - for (ARDOUR::StripableNotificationList::const_iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr r = (*i).lock(); - if (r) { - srl.push_back (r); - } - } - - { - Glib::Threads::Mutex::Lock lm (surfaces_lock); - - for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) { - (*s)->gui_selection_changed (srl); - } - } - - if (save_list) { - _last_selected_stripables = *rl; - } - - if (gui_selection_did_change) { - - check_fader_automation_state (); - - /* note: this method is also called when we switch banks. - * But ... we don't allow bank switching when in subview mode. - * - * so .. we only have to care about subview mode if the - * GUI selection has changed. - * - * It is possible that first_selected_stripable() may return null if we - * are no longer displaying/mapping that route. In that case, - * we will exit subview mode. If first_selected_stripable() is - * null, and subview mode is not None, then the first call to - * set_subview_mode() will fail, and we will reset to None. - */ - - if (set_subview_mode (_subview_mode, first_selected_stripable())) { - set_subview_mode (None, boost::shared_ptr()); - } - } -} - void MackieControlProtocol::check_fader_automation_state () { @@ -2102,18 +2035,21 @@ MackieControlProtocol::select_range () return; } + cerr << "Main modifier state = " << hex << main_modifier_state() << dec << endl; + for (StripableList::iterator s = stripables.begin(); s != stripables.end(); ++s) { - if (main_modifier_state() == MODIFIER_SHIFT) { - /* XXX can only use order part of PresentationInfo at present */ + if (main_modifier_state() == MODIFIER_CONTROL) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("toggle selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order())); + cerr << "Toggle selection\n"; ToggleStripableSelection ((*s)->presentation_info ().order()); } else { if (s == stripables.begin()) { - /* XXX can only use order part of PresentationInfo at present */ + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("set selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order())); SetStripableSelection ((*s)->presentation_info().order()); } else { - /* XXX can only use order part of PresentationInfo at present */ - AddStripableToSelection ((*s)->presentation_info().order()); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("add to selection %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order())); + AddStripableSelection ((*s)->presentation_info().order()); } } } diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index ec451bdab3..48d170e91c 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -215,6 +215,7 @@ Strip::set_stripable (boost::shared_ptr r, bool /*with_messages*/) _stripable->gain_control()->Changed.connect(stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_gain_changed, this, false), ui_context()); _stripable->PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context()); + _stripable->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context()); boost::shared_ptr rec_enable_control = _stripable->rec_enable_control (); @@ -275,6 +276,7 @@ Strip::notify_all() notify_mute_changed (); notify_gain_changed (); notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name)); + notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::selected)); notify_panner_azi_changed (); notify_panner_width_changed (); notify_record_enable_changed (); @@ -372,11 +374,15 @@ Strip::notify_processor_changed (bool force_update) void Strip::notify_property_changed (const PropertyChange& what_changed) { - if (!what_changed.contains (ARDOUR::Properties::name)) { - return; + if (what_changed.contains (ARDOUR::Properties::name)) { + show_stripable_name (); } - show_stripable_name (); + if (what_changed.contains (ARDOUR::Properties::selected)) { + if (_stripable) { + _surface->write (_select->set_state (_stripable->presentation_info().selected())); + } + } } void @@ -1306,19 +1312,6 @@ Strip::unlock_controls () _controls_locked = false; } -void -Strip::gui_selection_changed (const ARDOUR::StrongStripableNotificationList& rl) -{ - for (ARDOUR::StrongStripableNotificationList::const_iterator i = rl.begin(); i != rl.end(); ++i) { - if ((*i) == _stripable) { - _surface->write (_select->set_state (on)); - return; - } - } - - _surface->write (_select->set_state (off)); -} - string Strip::vpot_mode_string () { diff --git a/libs/surfaces/mackie/strip.h b/libs/surfaces/mackie/strip.h index 351f3cfa9b..a095f8ebe8 100644 --- a/libs/surfaces/mackie/strip.h +++ b/libs/surfaces/mackie/strip.h @@ -84,8 +84,6 @@ public: void unlock_controls (); bool locked() const { return _controls_locked; } - void gui_selection_changed (const ARDOUR::StrongStripableNotificationList&); - void notify_metering_state_changed(); void block_screen_display_for (uint32_t msecs); diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 52c89ae863..400dad85ab 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -1141,14 +1141,6 @@ Surface::update_view_mode_display (bool with_helpful_text) } } -void -Surface::gui_selection_changed (const ARDOUR::StrongStripableNotificationList& stripables) -{ - for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) { - (*s)->gui_selection_changed (stripables); - } -} - void Surface::say_hello () { diff --git a/libs/surfaces/mackie/surface.h b/libs/surfaces/mackie/surface.h index 2635df78e8..3225e23ba0 100644 --- a/libs/surfaces/mackie/surface.h +++ b/libs/surfaces/mackie/surface.h @@ -155,7 +155,6 @@ public: void update_view_mode_display (bool with_helpful_text); void update_flip_mode_display (); - void gui_selection_changed (const ARDOUR::StrongStripableNotificationList&); void subview_mode_changed (); MackieControlProtocol& mcp() const { return _mcp; } -- 2.30.2