remove certain ControlProtocol signals related to stripable selection
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 10 Jun 2016 17:47:41 +0000 (13:47 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 10 Jun 2016 17:57:18 +0000 (13:57 -0400)
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
libs/surfaces/control_protocol/control_protocol.cc
libs/surfaces/control_protocol/control_protocol/control_protocol.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/strip.cc
libs/surfaces/mackie/strip.h
libs/surfaces/mackie/surface.cc
libs/surfaces/mackie/surface.h

index 9fac47af4998a486248e147edd2fc69b15a0805d..c0ab97d9a42472795cf33a4afbad85e916e313ef 100644 (file)
@@ -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<Stripable> s = _session->get_remote_nth_stripable (pi.order(), pi.flags());
+       boost::shared_ptr<Stripable> s = _session->get_nth_stripable (order);
 
        /* selected object may not be a Route */
 
index 15946240d79f4532d770c02be949879bb1f9bad4..8e866922419f303fec0cafbf2407e46fb77ed23f 100644 (file)
@@ -50,10 +50,9 @@ PBD::Signal0<void>          ControlProtocol::StepTracksDown;
 PBD::Signal0<void>          ControlProtocol::StepTracksUp;
 
 PBD::Signal1<void,StripableNotificationListPtr> ControlProtocol::StripableSelectionChanged;
-PBD::Signal1<void,uint64_t> ControlProtocol::AddStripableToSelection;
+PBD::Signal1<void,uint64_t> ControlProtocol::AddStripableSelection;
 PBD::Signal1<void,uint64_t> ControlProtocol::SetStripableSelection;
 PBD::Signal1<void,uint64_t> ControlProtocol::ToggleStripableSelection;
-PBD::Signal1<void,uint64_t> ControlProtocol::RemoveStripableFromSelection;
 PBD::Signal0<void>          ControlProtocol::ClearStripableSelection;
 
 
index b26f8c1d5304273e57763d3cf1f8fad54656b9a8..53fce840e0c75739ffe44ddf2281f82d9a2ecdd6 100644 (file)
@@ -78,10 +78,9 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
        static PBD::Signal0<void> StepTracksDown;
        static PBD::Signal0<void> StepTracksUp;
 
-       static PBD::Signal1<void,uint64_t> AddStripableToSelection;
+       static PBD::Signal1<void,uint64_t> AddStripableSelection;
        static PBD::Signal1<void,uint64_t> SetStripableSelection;
        static PBD::Signal1<void,uint64_t> ToggleStripableSelection;
-       static PBD::Signal1<void,uint64_t> RemoveStripableFromSelection;
        static PBD::Signal0<void>          ClearStripableSelection;
 
        /* signals that one UI (e.g. the GUI) can emit to get all other UI's to
index 89719d03e9c9722fee1b761e4a14bbeeaa193712..86af49cc09a682d63404a81c4b383428bd1638bc 100644 (file)
@@ -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<Strip
        }
 }
 
-void
-MackieControlProtocol::gui_track_selection_changed (ARDOUR::StripableNotificationListPtr rl, bool save_list)
-{
-       _gui_track_selection_changed (rl.get(), save_list, true);
-}
-
-void
-MackieControlProtocol::_gui_track_selection_changed (ARDOUR::StripableNotificationList* rl, bool save_list, bool gui_selection_did_change)
-{
-       /* We need to keep a list of the most recently selected routes around,
-          but we are not allowed to keep shared_ptr<Stripable> unless we want to
-          handle the complexities of route deletion. So instead, the GUI sends
-          us a notification using weak_ptr<Stripable>, which we keep a copy
-          of. For efficiency's sake, however, we convert the weak_ptr's into
-          shared_ptr<Stripable> 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<ARDOUR::Stripable> 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<Stripable>());
-               }
-       }
-}
-
 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());
                        }
                }
        }
index ec451bdab3d0e9d5338ebe08f7c330f13d50fe30..48d170e91c6ee2b7fd4c88b895fdf611833d74a2 100644 (file)
@@ -215,6 +215,7 @@ Strip::set_stripable (boost::shared_ptr<Stripable> 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<AutomationControl> 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 ()
 {
index 351f3cfa9ba7e88ab7d38156476e70b42c27f3aa..a095f8ebe85f1fdbf84a17b8e9932914dea9787f 100644 (file)
@@ -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);
index 52c89ae8633a191bd44e21df46baacfaaa861889..400dad85abd85c1ff2500e969c4bac5a0871f2dc 100644 (file)
@@ -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 ()
 {
index 2635df78e8681f09b9d3fccd1b31c9d11501448d..3225e23ba06bfa2f7194b55f4752f5dcd1fa5f1e 100644 (file)
@@ -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; }