diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index bdfe2b6b71..98285a87e6 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -1618,18 +1618,35 @@ MackieControlProtocol::clear_ports () } } +void +MackieControlProtocol::notify_subview_route_deleted () +{ + /* return to global/mixer view */ + _subview_route.reset (); + set_view_mode (Mixer); +} + void MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr r) { - SubViewMode old = _subview_mode; + SubViewMode old_mode = _subview_mode; + boost::shared_ptr old_route = _subview_route; _subview_mode = sm; if (r) { - _subview_route = r; + /* retain _subview_route even if it is reset to null implicitly */ + _subview_route = r; } - if (_subview_mode != old) { + if ((_subview_mode != old_mode) || (_subview_route != old_route)) { + + if (r != old_route) { + subview_route_connections.drop_connections (); + if (_subview_route) { + _subview_route->DropReferences.connect (subview_route_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_subview_route_deleted, this), this); + } + } /* subview mode did actually change */ @@ -1642,18 +1659,35 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptrsubview_mode_changed (); + (*s)->subview_mode_changed (); } } - /* turn buttons related to vpot mode on or off as required */ + if (_subview_mode != old_mode) { - if (_subview_mode != None) { - update_global_button (Button::Trim, off); - update_global_button (Button::Send, off); - update_global_button (Button::Pan, off); - } else { - pot_mode_globals (); + /* turn buttons related to vpot mode on or off as required */ + + switch (_subview_mode) { + case MackieControlProtocol::None: + pot_mode_globals (); + break; + case MackieControlProtocol::EQ: + update_global_button (Button::Eq, on); + update_global_button (Button::Dyn, off); + update_global_button (Button::AudioInstruments, off); /* faking up Dyn */ + update_global_button (Button::Trim, off); + update_global_button (Button::Send, off); + update_global_button (Button::Pan, off); + break; + case MackieControlProtocol::Dynamics: + update_global_button (Button::Eq, off); + update_global_button (Button::Dyn, on); + update_global_button (Button::AudioInstruments, on); /* faking up Dyn */ + update_global_button (Button::Trim, off); + update_global_button (Button::Send, off); + update_global_button (Button::Pan, off); + break; + } } } } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index b8940d650c..a1cee8ec7f 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -201,6 +201,7 @@ class MackieControlProtocol void handle_button_event (Mackie::Surface&, Mackie::Button& button, Mackie::ButtonState); + void notify_subview_route_deleted (); void notify_route_added_or_removed (); void notify_route_added (ARDOUR::RouteList &); void notify_remote_id_changed(); @@ -318,6 +319,7 @@ class MackieControlProtocol PBD::ScopedConnectionList audio_engine_connections; PBD::ScopedConnectionList session_connections; PBD::ScopedConnectionList route_connections; + PBD::ScopedConnectionList subview_route_connections; PBD::ScopedConnectionList gui_connections; // timer for two quick marker left presses Mackie::Timer _frm_left_last; diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index f2f2b0f27b..b2fd79bcdf 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -711,7 +711,7 @@ MackieControlProtocol::eq_press (Button &) boost::shared_ptr r = first_selected_route (); if (r && r->eq_band_cnt() > 0) { set_subview_mode (EQ, r); - return on; + return none; /* led state handled by set_subview_mode() */ } } return none; @@ -730,7 +730,7 @@ MackieControlProtocol::dyn_press (Button &) if (r) { set_subview_mode (Dynamics, r); - return on; + return none; /* led state handled by set_subview_mode() */ } }