control surfaces: make it possible to keep display of current GUI/selection state as we bank through tracks/bussses. note careful use of weak_ptr<Route> to avoid messing with Route lifetimes. this scheme may change
git-svn-id: svn://localhost/ardour2/branches/3.0@12115 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
e65d84d37c
commit
edad92a944
@ -27,8 +27,10 @@
|
||||
namespace ARDOUR {
|
||||
class Route;
|
||||
|
||||
typedef std::vector<boost::shared_ptr<ARDOUR::Route> > RouteNotificationList;
|
||||
typedef std::vector<boost::weak_ptr<ARDOUR::Route> > RouteNotificationList;
|
||||
typedef boost::shared_ptr<RouteNotificationList> RouteNotificationListPtr;
|
||||
|
||||
typedef std::vector<boost::shared_ptr<ARDOUR::Route> > StrongRouteNotificationList;
|
||||
}
|
||||
|
||||
#endif /* __ardour_control_protocol_types_h__ */
|
||||
|
@ -113,7 +113,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
|
||||
DeviceInfo::reload_device_info ();
|
||||
DeviceProfile::reload_device_profiles ();
|
||||
|
||||
TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::gui_track_selection_changed, this, _1), this);
|
||||
TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::gui_track_selection_changed, this, _1, true), this);
|
||||
|
||||
_instance = this;
|
||||
|
||||
@ -357,7 +357,7 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
|
||||
/* make sure selection is correct */
|
||||
|
||||
// gui_track_selection_changed (_last_selected_routes);
|
||||
_gui_track_selection_changed (&_last_selected_routes, false);
|
||||
|
||||
/* current bank has not been saved */
|
||||
session->set_dirty();
|
||||
@ -1204,13 +1204,40 @@ MackieControlProtocol::force_special_route_to_strip (boost::shared_ptr<Route> r,
|
||||
}
|
||||
|
||||
void
|
||||
MackieControlProtocol::gui_track_selection_changed (ARDOUR::RouteNotificationListPtr rl)
|
||||
MackieControlProtocol::gui_track_selection_changed (ARDOUR::RouteNotificationListPtr rl, bool save_list)
|
||||
{
|
||||
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
|
||||
(*s)->gui_selection_changed (rl);
|
||||
_gui_track_selection_changed (rl.get(), save_list);
|
||||
}
|
||||
|
||||
// _last_selected_routes = *rl;
|
||||
void
|
||||
MackieControlProtocol::_gui_track_selection_changed (ARDOUR::RouteNotificationList* rl, bool save_list)
|
||||
{
|
||||
|
||||
/* We need to keep a list of the most recently selected routes around,
|
||||
but we are not allowed to keep shared_ptr<Route> unless we want to
|
||||
handle the complexities of route deletion. So instead, the GUI sends
|
||||
us a notification using weak_ptr<Route>, which we keep a copy
|
||||
of. For efficiency's sake, however, we convert the weak_ptr's into
|
||||
shared_ptr<Route> before passing them to however many surfaces (and
|
||||
thus strips) that we have.
|
||||
*/
|
||||
|
||||
StrongRouteNotificationList srl;
|
||||
|
||||
for (ARDOUR::RouteNotificationList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
|
||||
boost::shared_ptr<ARDOUR::Route> r = (*i).lock();
|
||||
if (r) {
|
||||
srl.push_back (r);
|
||||
}
|
||||
}
|
||||
|
||||
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
|
||||
(*s)->gui_selection_changed (srl);
|
||||
}
|
||||
|
||||
if (save_list) {
|
||||
_last_selected_routes = *rl;
|
||||
}
|
||||
}
|
||||
|
||||
framepos_t
|
||||
|
@ -286,6 +286,8 @@ class MackieControlProtocol
|
||||
int16_t _ipmidi_base;
|
||||
bool needs_ipmidi_restart;
|
||||
|
||||
ARDOUR::RouteNotificationList _last_selected_routes;
|
||||
|
||||
void create_surfaces ();
|
||||
bool periodic();
|
||||
void build_gui ();
|
||||
@ -293,7 +295,8 @@ class MackieControlProtocol
|
||||
void clear_ports ();
|
||||
void force_special_route_to_strip (boost::shared_ptr<ARDOUR::Route> r, uint32_t surface, uint32_t strip_number);
|
||||
void build_button_map ();
|
||||
void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr);
|
||||
void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr, bool save_list);
|
||||
void _gui_track_selection_changed (ARDOUR::RouteNotificationList*, bool save_list);
|
||||
void ipmidi_restart ();
|
||||
|
||||
/* BUTTON HANDLING */
|
||||
|
@ -756,9 +756,9 @@ Strip::unlock_controls ()
|
||||
}
|
||||
|
||||
void
|
||||
Strip::gui_selection_changed (ARDOUR::RouteNotificationListPtr rl)
|
||||
Strip::gui_selection_changed (const ARDOUR::StrongRouteNotificationList& rl)
|
||||
{
|
||||
for (ARDOUR::RouteNotificationList::iterator i = rl->begin(); i != rl->end(); ++i) {
|
||||
for (ARDOUR::StrongRouteNotificationList::const_iterator i = rl.begin(); i != rl.end(); ++i) {
|
||||
if ((*i) == _route) {
|
||||
_surface->write (_select->set_state (on));
|
||||
return;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
void unlock_controls ();
|
||||
bool locked() const { return _controls_locked; }
|
||||
|
||||
void gui_selection_changed (ARDOUR::RouteNotificationListPtr);
|
||||
void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
|
||||
|
||||
private:
|
||||
Button* _solo;
|
||||
|
@ -793,7 +793,7 @@ Surface::update_view_mode_display ()
|
||||
}
|
||||
|
||||
void
|
||||
Surface::gui_selection_changed (ARDOUR::RouteNotificationListPtr routes)
|
||||
Surface::gui_selection_changed (const ARDOUR::StrongRouteNotificationList& routes)
|
||||
{
|
||||
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
||||
(*s)->gui_selection_changed (routes);
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
void update_view_mode_display ();
|
||||
void update_flip_mode_display ();
|
||||
|
||||
void gui_selection_changed (ARDOUR::RouteNotificationListPtr);
|
||||
void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
|
||||
|
||||
MackieControlProtocol& mcp() const { return _mcp; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user