diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 40fe07b8ff..65489e44e1 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -1728,12 +1728,16 @@ MackieControlProtocol::redisplay_subview_mode () int MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr 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 r) const bool MackieControlProtocol::selected (boost::shared_ptr 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 rt = (*i).lock(); if (rt == r) { return true; @@ -2381,6 +2383,16 @@ MackieControlProtocol::is_mapped (boost::shared_ptr r) const return false; } +void +MackieControlProtocol::update_selected (boost::shared_ptr s, bool selected) +{ + if (selected) { + _last_selected_stripables.insert (boost::weak_ptr (s)); + } else { + _last_selected_stripables.erase (boost::weak_ptr (s)); + } +} + boost::shared_ptr MackieControlProtocol::first_selected_stripable () const { @@ -2388,7 +2400,7 @@ MackieControlProtocol::first_selected_stripable () const return boost::shared_ptr(); } - boost::shared_ptr r = _last_selected_stripables.front().lock(); + boost::shared_ptr r = (*(_last_selected_stripables.begin())).lock(); if (r) { /* check it is on one of our surfaces */ diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 647d2fcdb3..20a3ff31ca 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -142,6 +142,7 @@ class MackieControlProtocol bool is_hidden (boost::shared_ptr) const; bool is_mapped (boost::shared_ptr) const; boost::shared_ptr first_selected_stripable () const; + void update_selected (boost::shared_ptr, 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 > Selection; + Selection _last_selected_stripables; XMLNode* configuration_state; int state_version; int _last_bank[9]; diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 48d170e91c..c438750289 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -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,25 +1353,27 @@ Strip::flip_mode_changed () boost::shared_ptr fader_control = _fader->control(); if (pot_control && fader_control) { + _vpot->set_control (fader_control); _fader->set_control (pot_control); + + /* update fader with pot value */ + + _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ()))); + + /* update pot with fader value */ + + _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()); + } + } - 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 */ - - _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ()))); - - /* update pot */ - - _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap)); - - } else { /* do nothing */ }