change the way ControlProtocols (control surfaces) are notified and handle Stripable selection changes

The Editor continues to notify them, but via a direct call to ControlProtocolManager, not a signal.
The CP Manager calls the ControlProtocol static method to set up static data structures holding
selection info for all surfaces and then notifies each surface/protocol that selection has changed.
This commit is contained in:
Paul Davis 2017-05-12 14:51:31 +01:00
parent efc2660fec
commit eb3f50e15c
23 changed files with 64 additions and 83 deletions

View file

@ -56,14 +56,10 @@ PBD::Signal1<void,boost::shared_ptr<ARDOUR::Stripable> > ControlProtocol::Toggle
PBD::Signal1<void,boost::shared_ptr<ARDOUR::Stripable> > ControlProtocol::RemoveStripableFromSelection;
PBD::Signal0<void> ControlProtocol::ClearStripableSelection;
PBD::Signal1<void,StripableNotificationListPtr> ControlProtocol::StripableSelectionChanged;
Glib::Threads::Mutex ControlProtocol::special_stripable_mutex;
boost::weak_ptr<Stripable> ControlProtocol::_first_selected_stripable;
boost::weak_ptr<Stripable> ControlProtocol::_leftmost_mixer_stripable;
StripableNotificationList ControlProtocol::_last_selected;
bool ControlProtocol::selection_connected = false;
PBD::ScopedConnection ControlProtocol::selection_connection;
const std::string ControlProtocol::state_node_name ("Protocol");
@ -72,12 +68,6 @@ ControlProtocol::ControlProtocol (Session& s, string str)
, _name (str)
, _active (false)
{
if (!selection_connected) {
/* this is all static, connect it only once (and early), for all ControlProtocols */
StripableSelectionChanged.connect_same_thread (selection_connection, boost::bind (&ControlProtocol::stripable_selection_changed, _1));
selection_connected = true;
}
}
ControlProtocol::~ControlProtocol ()
@ -374,7 +364,7 @@ ControlProtocol::set_first_selected_stripable (boost::shared_ptr<Stripable> s)
}
void
ControlProtocol::stripable_selection_changed (StripableNotificationListPtr sp)
ControlProtocol::notify_stripable_selection_changed (StripableNotificationListPtr sp)
{
bool had_selection = !_last_selected.empty();

View file

@ -57,6 +57,8 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
virtual void midi_connectivity_established () {}
virtual void stripable_selection_changed () = 0;
PBD::Signal0<void> ActiveChanged;
/* signals that a control protocol can emit and other (presumably graphical)
@ -85,13 +87,6 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Stripable> > RemoveStripableFromSelection;
static PBD::Signal0<void> ClearStripableSelection;
/* signals that one UI (e.g. the GUI) can emit to get all other UI's to
respond. Typically this will always be GUI->"others" - the GUI pays
no attention to these signals.
*/
static PBD::Signal1<void,StripableNotificationListPtr> StripableSelectionChanged;
static boost::shared_ptr<ARDOUR::Stripable> first_selected_stripable ();
static void set_first_selected_stripable (boost::shared_ptr<ARDOUR::Stripable>);
@ -146,6 +141,7 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
static const std::string state_node_name;
static StripableNotificationList const & last_selected() { return _last_selected; }
static void notify_stripable_selection_changed (StripableNotificationListPtr);
protected:
std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
@ -158,14 +154,10 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
LIBCONTROLCP_LOCAL ControlProtocol (const ControlProtocol&); /* noncopyable */
bool _active;
static Glib::Threads::Mutex special_stripable_mutex;
static boost::weak_ptr<ARDOUR::Stripable> _leftmost_mixer_stripable;
static boost::weak_ptr<ARDOUR::Stripable> _first_selected_stripable;
static StripableNotificationList _last_selected;
static void stripable_selection_changed (StripableNotificationListPtr);
static bool selection_connected;
static PBD::ScopedConnection selection_connection;
};
extern "C" {