MCP: share add-marker code with BasicUI; don't allow route locking if the strip has...
[ardour.git] / libs / surfaces / mackie / strip.cc
index 9c688628726e3bba05d2fc43e0d452b90fb008ae..24d3e4ac31fb5755c944d9824d5284893360238a 100644 (file)
@@ -69,6 +69,7 @@ Strip::Strip (Surface& s, const std::string& name, int index, StripControlDefini
        , _gain (0)
        , _index (index)
        , _surface (&s)
+       , _route_locked (false)
 {
        /* build the controls for this track, which will automatically add them
           to the Group 
@@ -250,6 +251,10 @@ std::ostream & Mackie::operator <<  (std::ostream & os, const Strip & strip)
 void
 Strip::set_route (boost::shared_ptr<Route> r)
 {
+       if (_route_locked) {
+               return;
+       }
+
        route_connections.drop_connections ();
 
        _route = r;
@@ -333,7 +338,7 @@ void
 Strip::notify_solo_changed ()
 {
        if (_route && _solo) {
-               _surface->write (_solo->led().set_state (_route->soloed() ? on : off));
+               _surface->write (_solo->set_state (_route->soloed() ? on : off));
        }
 }
 
@@ -343,9 +348,9 @@ Strip::notify_mute_changed ()
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Strip %1 mute changed\n", _index));
        if (_route && _mute) {
                DEBUG_TRACE (DEBUG::MackieControl, string_compose ("\troute muted ? %1\n", _route->muted()));
-               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("mute message: %1\n", _mute->led().set_state (_route->muted() ? on : off)));
+               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("mute message: %1\n", _mute->set_state (_route->muted() ? on : off)));
 
-               _surface->write (_mute->led().set_state (_route->muted() ? on : off));
+               _surface->write (_mute->set_state (_route->muted() ? on : off));
        }
 }
 
@@ -353,7 +358,7 @@ void
 Strip::notify_record_enable_changed ()
 {
        if (_route && _recenable)  {
-               _surface->write (_recenable->led().set_state (_route->record_enabled() ? on : off));
+               _surface->write (_recenable->set_state (_route->record_enabled() ? on : off));
        }
 }
 
@@ -404,7 +409,6 @@ Strip::notify_property_changed (const PropertyChange& what_changed)
                }
                
                _surface->write (display (0, line1));
-               _surface->write (blank_display (1));
        }
 }
 
@@ -444,7 +448,7 @@ Strip::handle_button (Button& button, ButtonState bs)
        if (!_route) {
                // no route so always switch the light off
                // because no signals will be emitted by a non-route
-               _surface->write (button.led().set_state  (off));
+               _surface->write (button.set_state  (off));
                return;
        }
 
@@ -467,7 +471,15 @@ Strip::handle_button (Button& button, ButtonState bs)
                } else if (button.id() >= Button::select_base_id &&
                           button.id() < Button::select_base_id + 8) {
 
-                       _surface->mcp().select_track (_route);
+                       int lock_mod = (MackieControlProtocol::MODIFIER_CONTROL|MackieControlProtocol::MODIFIER_SHIFT);
+
+                       if ((_surface->mcp().modifier_state() & lock_mod) == lock_mod) {
+                               if (_route) {
+                                       _route_locked = !_route_locked;
+                               }
+                       } else {
+                               _surface->mcp().select_track (_route);
+                       }
 
                } else if (button.id() >= Button::vselect_base_id &&
                           button.id() < Button::vselect_base_id + 8) {
@@ -652,3 +664,18 @@ Strip::display (uint32_t line_number, const std::string& line)
 
        return retval;
 }
+
+void
+Strip::lock_route ()
+{
+       /* don't lock unless we have a route */
+       if (_route) {
+               _route_locked = true;
+       }
+}
+
+void
+Strip::unlock_route ()
+{
+       _route_locked = false;
+}