redesign/reimplement selection knowledge in MackieControlProtocol object
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 12 Jun 2016 12:19:16 +0000 (08:19 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 12 Jun 2016 12:19:16 +0000 (08:19 -0400)
strips listen to Stripable::presentation_info().PropertyChange, and forward selected status changes
to the MCP object

libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/mackie/strip.cc

index 40fe07b8ffbaac668eeb030d637d5cc5020c6501..65489e44e10150cd190409a10d35ca70fab9be48 100644 (file)
@@ -1728,12 +1728,16 @@ MackieControlProtocol::redisplay_subview_mode ()
 int
 MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Stripable> r)
 {
+       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("set subview mode %1 with stripable %2, current flip mode %3\n", sm, (r ? r->name() : string ("null")), _flip_mode));
+
        if (_flip_mode != Normal) {
                set_flip_mode (Normal);
        }
 
        if (!subview_mode_would_be_ok (sm, r)) {
 
+               DEBUG_TRACE (DEBUG::MackieControl, "subview mode not OK\n");
+
                if (r) {
 
                        Glib::Threads::Mutex::Lock lm (surfaces_lock);
@@ -2347,9 +2351,7 @@ MackieControlProtocol::is_midi_track (boost::shared_ptr<Stripable> r) const
 bool
 MackieControlProtocol::selected (boost::shared_ptr<Stripable> r) const
 {
-       const StripableNotificationList* rl = &_last_selected_stripables;
-
-       for (ARDOUR::StripableNotificationList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
+       for (Selection::const_iterator i = _last_selected_stripables.begin(); i != _last_selected_stripables.end(); ++i) {
                boost::shared_ptr<ARDOUR::Stripable> rt = (*i).lock();
                if (rt == r) {
                        return true;
@@ -2381,6 +2383,16 @@ MackieControlProtocol::is_mapped (boost::shared_ptr<Stripable> r) const
        return false;
 }
 
+void
+MackieControlProtocol::update_selected (boost::shared_ptr<Stripable> s, bool selected)
+{
+       if (selected) {
+               _last_selected_stripables.insert (boost::weak_ptr<Stripable> (s));
+       } else {
+               _last_selected_stripables.erase (boost::weak_ptr<Stripable> (s));
+       }
+}
+
 boost::shared_ptr<Stripable>
 MackieControlProtocol::first_selected_stripable () const
 {
@@ -2388,7 +2400,7 @@ MackieControlProtocol::first_selected_stripable () const
                return boost::shared_ptr<Stripable>();
        }
 
-       boost::shared_ptr<Stripable> r = _last_selected_stripables.front().lock();
+       boost::shared_ptr<Stripable> r = (*(_last_selected_stripables.begin())).lock();
 
        if (r) {
                /* check it is on one of our surfaces */
index 647d2fcdb38f3a80014fcf69dea6dca728a78f6f..20a3ff31ca969c98aa42fb3dcae2107239935ae0 100644 (file)
@@ -142,6 +142,7 @@ class MackieControlProtocol
        bool is_hidden (boost::shared_ptr<ARDOUR::Stripable>) const;
        bool is_mapped (boost::shared_ptr<ARDOUR::Stripable>) const;
        boost::shared_ptr<ARDOUR::Stripable> first_selected_stripable () const;
+       void update_selected (boost::shared_ptr<ARDOUR::Stripable>, bool selected);
 
        void check_fader_automation_state ();
        void update_fader_automation_state ();
@@ -334,7 +335,8 @@ class MackieControlProtocol
        bool                      needs_ipmidi_restart;
        bool                     _metering_active;
        bool                     _initialized;
-       ARDOUR::StripableNotificationList _last_selected_stripables;
+       typedef std::set<boost::weak_ptr<ARDOUR::Stripable> > Selection;
+       Selection                _last_selected_stripables;
        XMLNode*                 configuration_state;
        int                      state_version;
        int                      _last_bank[9];
index 48d170e91c6ee2b7fd4c88b895fdf611833d74a2..c43875028916d0c9ce9872f8d8bf372684b4738a 100644 (file)
@@ -381,6 +381,7 @@ Strip::notify_property_changed (const PropertyChange& what_changed)
        if (what_changed.contains (ARDOUR::Properties::selected)) {
                if (_stripable) {
                        _surface->write (_select->set_state (_stripable->presentation_info().selected()));
+                       _surface->mcp().update_selected (_stripable, _stripable->presentation_info().selected());
                }
        }
 }
@@ -1352,24 +1353,26 @@ Strip::flip_mode_changed ()
                boost::shared_ptr<AutomationControl> fader_control = _fader->control();
 
                if (pot_control && fader_control) {
+
                        _vpot->set_control (fader_control);
                        _fader->set_control (pot_control);
-               }
 
-               if (_surface->mcp().flip_mode() == MackieControlProtocol::Normal) {
-                       do_parameter_display (GainAutomation, fader_control->get_value());
-               } else {
-                       do_parameter_display (BusSendLevel, fader_control->get_value());
-               }
+                       /* update fader with pot value */
 
-               /* update fader */
+                       _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ())));
 
-               _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ())));
+                       /* update pot with fader value */
 
-               /* update pot */
+                       _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap));
 
-               _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap));
 
+                       if (_surface->mcp().flip_mode() == MackieControlProtocol::Normal) {
+                               do_parameter_display (GainAutomation, fader_control->get_value());
+                       } else {
+                               do_parameter_display (BusSendLevel, pot_control->get_value());
+                       }
+
+               }
 
        } else {
                /* do nothing */