diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 36 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 4 | ||||
-rw-r--r-- | libs/surfaces/mackie/strip.h | 3 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.cc | 39 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.h | 4 |
5 files changed, 70 insertions, 16 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 82e9ea6df2..78fed5cb82 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -192,6 +192,17 @@ MackieControlProtocol::next_track() } } +bool +MackieControlProtocol::route_is_locked_to_strip (boost::shared_ptr<Route> r) const +{ + for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) { + if ((*si)->route_is_locked_to_strip (r)) { + return true; + } + } + return false; +} + // predicate for sort call in get_sorted_routes struct RouteByRemoteId { @@ -229,13 +240,19 @@ MackieControlProtocol::get_sorted_routes() for (RouteList::iterator it = routes->begin(); it != routes->end(); ++it) { - Route & route = **it; + boost::shared_ptr<Route> route = *it; - if (remote_ids.find (route.remote_control_id()) != remote_ids.end()) { + if (remote_ids.find (route->remote_control_id()) != remote_ids.end()) { continue; } - if (route.is_hidden() || route.is_master() || route.is_monitor()) { + if (route->is_hidden() || route->is_master() || route->is_monitor()) { + continue; + } + + /* don't include locked routes */ + + if (route_is_locked_to_strip(route)) { continue; } @@ -261,7 +278,7 @@ MackieControlProtocol::get_sorted_routes() } sorted.push_back (*it); - remote_ids.insert (route.remote_control_id()); + remote_ids.insert (route->remote_control_id()); } sort (sorted.begin(), sorted.end(), RouteByRemoteId()); @@ -275,12 +292,12 @@ MackieControlProtocol::refresh_current_bank() } uint32_t -MackieControlProtocol::n_strips() const +MackieControlProtocol::n_strips (bool with_locked_strips) const { uint32_t strip_count = 0; for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) { - strip_count += (*si)->n_strips (); + strip_count += (*si)->n_strips (with_locked_strips); } return strip_count; @@ -296,7 +313,8 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force) } Sorted sorted = get_sorted_routes(); - uint32_t strip_cnt = n_strips(); + uint32_t strip_cnt = n_strips (false); // do not include locked strips + // in this count if (sorted.size() <= strip_cnt && !force) { /* no banking - not enough routes to fill all strips */ @@ -327,9 +345,9 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force) vector<boost::shared_ptr<Route> > routes; uint32_t added = 0; - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface has %1 strips\n", (*si)->n_strips())); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface has %1 unlockedstrips\n", (*si)->n_strips (false))); - for (; r != sorted.end() && added < (*si)->n_strips(); ++r, ++added) { + for (; r != sorted.end() && added < (*si)->n_strips (false); ++r, ++added) { routes.push_back (*r); } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index d092a372cd..801434c30c 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -145,7 +145,7 @@ class MackieControlProtocol void set_master_on_surface_strip (uint32_t surface, uint32_t strip); void set_monitor_on_surface_strip (uint32_t surface, uint32_t strip); - uint32_t n_strips () const; + uint32_t n_strips (bool with_locked_strips = true) const; bool has_editor () const { return true; } void* get_gui () const; @@ -235,6 +235,8 @@ class MackieControlProtocol void thread_init (); void midi_connectivity_established (); + bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const; + private: struct ButtonHandlers { diff --git a/libs/surfaces/mackie/strip.h b/libs/surfaces/mackie/strip.h index 684d3a2108..d7e80c95e5 100644 --- a/libs/surfaces/mackie/strip.h +++ b/libs/surfaces/mackie/strip.h @@ -80,7 +80,8 @@ public: void lock_controls (); void unlock_controls (); - + bool locked() const { return _controls_locked; } + void gui_selection_changed (ARDOUR::RouteNotificationListPtr); private: diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 71198a7464..f27ac3893e 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -520,9 +520,20 @@ Surface::write_sysex (MIDI::byte msg) } uint32_t -Surface::n_strips () const +Surface::n_strips (bool with_locked_strips) const { - return strips.size(); + if (with_locked_strips) { + return strips.size(); + } + + uint32_t n = 0; + + for (Strips::const_iterator it = strips.begin(); it != strips.end(); ++it) { + if (!(*it)->locked()) { + ++n; + } + } + return n; } Strip* @@ -597,8 +608,17 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes) vector<boost::shared_ptr<Route> >::const_iterator r; Strips::iterator s; - for (r = routes.begin(), s = strips.begin(); r != routes.end() && s != strips.end(); ++r, ++s) { - (*s)->set_route (*r); + for (r = routes.begin(), s = strips.begin(); r != routes.end() && s != strips.end(); ++s) { + + /* don't try to assign routes to a locked strip. it won't + use it anyway, but if we do, then we get out of sync + with the proposed mapping. + */ + + if (!(*s)->locked()) { + (*s)->set_route (*r); + ++r; + } } for (; s != strips.end(); ++s) { @@ -803,3 +823,14 @@ void Surface::set_jog_mode (JogWheel::Mode m) { } + +bool +Surface::route_is_locked_to_strip (boost::shared_ptr<Route> r) const +{ + for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) { + if ((*s)->route() == r && (*s)->locked()) { + return true; + } + } + return false; +} diff --git a/libs/surfaces/mackie/surface.h b/libs/surfaces/mackie/surface.h index 5ef29ca72a..9f3ac0b8c6 100644 --- a/libs/surfaces/mackie/surface.h +++ b/libs/surfaces/mackie/surface.h @@ -67,9 +67,11 @@ public: typedef std::vector<Strip*> Strips; Strips strips; - uint32_t n_strips () const; + uint32_t n_strips (bool with_locked_strips = true) const; Strip* nth_strip (uint32_t n) const; + bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const; + /// This collection owns the groups typedef std::map<std::string,Group*> Groups; Groups groups; |