mackie: ensure that the strip where select was pressed ends up as the first_selected_...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Jul 2016 01:40:29 +0000 (21:40 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Jul 2016 01:40:29 +0000 (21:40 -0400)
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/mackie/strip.cc

index c1786756a4c4b2319a1b790d535ec00e70fe7481..224590aa5437c7ab4b9a3cc94c3c4cfd5e471dc0 100644 (file)
@@ -2027,13 +2027,13 @@ MackieControlProtocol::remove_down_select_button (int surface, int strip)
 }
 
 void
-MackieControlProtocol::select_range ()
+MackieControlProtocol::select_range (uint32_t pressed)
 {
        StripableList stripables;
 
-       pull_stripable_range (_down_select_buttons, stripables);
+       pull_stripable_range (_down_select_buttons, stripables, pressed);
 
-       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("select range: found %1 stripables\n", stripables.size()));
+       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("select range: found %1 stripables, first = %2\n", stripables.size(), stripables.front()->name()));
 
        if (stripables.empty()) {
                return;
@@ -2093,7 +2093,7 @@ MackieControlProtocol::remove_down_button (AutomationType a, int surface, int st
 }
 
 MackieControlProtocol::ControlList
-MackieControlProtocol::down_controls (AutomationType p)
+MackieControlProtocol::down_controls (AutomationType p, uint32_t pressed)
 {
        ControlList controls;
        StripableList stripables;
@@ -2107,7 +2107,7 @@ MackieControlProtocol::down_controls (AutomationType p)
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("looking for down buttons for %1, got %2\n",
                                                           p, m->second.size()));
 
-       pull_stripable_range (m->second, stripables);
+       pull_stripable_range (m->second, stripables, pressed);
 
        switch (p) {
        case GainAutomation:
@@ -2150,7 +2150,7 @@ struct ButtonRangeSorter {
 };
 
 void
-MackieControlProtocol::pull_stripable_range (DownButtonList& down, StripableList& selected)
+MackieControlProtocol::pull_stripable_range (DownButtonList& down, StripableList& selected, uint32_t pressed)
 {
        ButtonRangeSorter cmp;
 
@@ -2200,13 +2200,19 @@ MackieControlProtocol::pull_stripable_range (DownButtonList& down, StripableList
                                                                           (*s)->number(), fs, ls));
 
                        for (uint32_t n = fs; n < ls; ++n) {
-                               boost::shared_ptr<Stripable> r = (*s)->nth_strip (n)->stripable();
+                               Strip* strip = (*s)->nth_strip (n);
+                               boost::shared_ptr<Stripable> r = strip->stripable();
                                if (r) {
-                                       selected.push_back (r);
+                                       if (global_index_locked (*strip) == pressed) {
+                                               selected.push_front (r);
+                                       } else {
+                                               selected.push_back (r);
+                                       }
                                }
                        }
                }
        }
+
 }
 
 void
@@ -2415,6 +2421,12 @@ uint32_t
 MackieControlProtocol::global_index (Strip& strip)
 {
        Glib::Threads::Mutex::Lock lm (surfaces_lock);
+       return global_index_locked (strip);
+}
+
+uint32_t
+MackieControlProtocol::global_index_locked (Strip& strip)
+{
        uint32_t global = 0;
 
        for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
index 56ead71b50d26554274aebeb106f45c683c841ca..8d63162ffcea806fe8ac278dbe4993be51891111 100644 (file)
@@ -170,6 +170,7 @@ class MackieControlProtocol
        boost::shared_ptr<Mackie::Surface> nth_surface (uint32_t) const;
 
        uint32_t global_index (Mackie::Strip&);
+       uint32_t global_index_locked (Mackie::Strip&);
 
        std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
 
@@ -228,11 +229,11 @@ class MackieControlProtocol
 
        void add_down_button (ARDOUR::AutomationType, int surface, int strip);
        void remove_down_button (ARDOUR::AutomationType, int surface, int strip);
-       ControlList down_controls (ARDOUR::AutomationType);
+       ControlList down_controls (ARDOUR::AutomationType, uint32_t pressed);
 
        void add_down_select_button (int surface, int strip);
        void remove_down_select_button (int surface, int strip);
-       void select_range ();
+       void select_range (uint32_t pressed);
 
        int16_t ipmidi_base() const { return _ipmidi_base; }
        void    set_ipmidi_base (int16_t);
@@ -378,7 +379,7 @@ class MackieControlProtocol
        DownButtonMap  _down_buttons;
        DownButtonList _down_select_buttons;
 
-       void pull_stripable_range (DownButtonList&, ARDOUR::StripableList&);
+       void pull_stripable_range (DownButtonList&, ARDOUR::StripableList&, uint32_t pressed);
 
        /* implemented button handlers */
        Mackie::LedState stop_press(Mackie::Button &);
index 08f4b489c61b500ee5687e08b3edc069e8ddc9db..1c2fe8d1b9cbd80f5ccfe735fab80a999b207a0f 100644 (file)
@@ -683,7 +683,7 @@ Strip::select_event (Button&, ButtonState bs)
 
                DEBUG_TRACE (DEBUG::MackieControl, "add select button on press\n");
                _surface->mcp().add_down_select_button (_surface->number(), _index);
-               _surface->mcp().select_range ();
+               _surface->mcp().select_range (_surface->mcp().global_index (*this));
 
        } else {
                DEBUG_TRACE (DEBUG::MackieControl, "remove select button on release\n");
@@ -882,7 +882,8 @@ Strip::handle_button (Button& button, ButtonState bs)
                                 * several down buttons
                                 */
 
-                               MackieControlProtocol::ControlList controls = _surface->mcp().down_controls ((AutomationType) control->parameter().type());
+                               MackieControlProtocol::ControlList controls = _surface->mcp().down_controls ((AutomationType) control->parameter().type(),
+                                                                                                            _surface->mcp().global_index(*this));
 
 
                                DEBUG_TRACE (DEBUG::MackieControl, string_compose ("there are %1 buttons down for control type %2, new value = %3\n",