13
0

MCP: properly (?) handle bank/channel scrolling with locked strips

git-svn-id: svn://localhost/ardour2/branches/3.0@12095 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-26 14:28:41 +00:00
parent 42d018ffa8
commit 3b7e2f7d67
5 changed files with 70 additions and 16 deletions

View File

@ -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);
}

View File

@ -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 {

View File

@ -80,7 +80,8 @@ public:
void lock_controls ();
void unlock_controls ();
bool locked() const { return _controls_locked; }
void gui_selection_changed (ARDOUR::RouteNotificationListPtr);
private:

View File

@ -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;
}

View File

@ -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;