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.
obj = bld (features = 'cxx c cxxprogram')
obj.source = 'cfgtool.cc'
obj.target = 'cfgtool'
- obj.use = [ 'libpbd', 'libardour' ]
+ obj.use = [ 'libpbd', 'libardour', 'libardour_cp' ]
obj.uselib = [ 'GLIBMM', 'XML' ]
obj.install_path = None
#include "pbd/stacktrace.h"
#include "pbd/unwind.h"
+#include "ardour/control_protocol_manager.h"
#include "ardour/midi_region.h"
#include "ardour/playlist.h"
#include "ardour/profile.h"
#include "ardour/selection.h"
#include "ardour/session.h"
-#include "control_protocol/control_protocol.h"
-
#include "editor.h"
#include "editor_drag.h"
#include "editor_routes.h"
/* STEP 4: notify control protocols */
- ControlProtocol::StripableSelectionChanged (stripables);
+ ControlProtocolManager::instance().stripable_selection_changed (stripables);
if (sfbrowser && _session && !_session->deletion_in_progress()) {
uint32_t audio_track_cnt = 0;
#include <glibmm/threads.h>
#include "pbd/stateful.h"
+
+#include "control_protocol/types.h"
+
#include "ardour/session_handle.h"
namespace ARDOUR {
PBD::Signal1<void,ControlProtocolInfo*> ProtocolStatusChange;
+ void stripable_selection_changed (ARDOUR::StripableNotificationListPtr);
+
private:
ControlProtocolManager ();
static ControlProtocolManager* _instance;
}
}
}
+
+void
+ControlProtocolManager::stripable_selection_changed (StripableNotificationListPtr sp)
+{
+ /* this sets up the (static) data structures owned by ControlProtocol
+ that are "shared" across all control protocols.
+ */
+
+ DEBUG_TRACE (DEBUG::Selection, string_compose ("Surface manager: selection changed, now %1 stripables\n", sp ? sp->size() : -1));
+ ControlProtocol::notify_stripable_selection_changed (sp);
+
+ /* now give each protocol the chance to respond to the selection change
+ */
+
+ {
+ Glib::Threads::Mutex::Lock lm (protocols_lock);
+
+ for (list<ControlProtocol*>::iterator p = control_protocols.begin(); p != control_protocols.end(); ++p) {
+ DEBUG_TRACE (DEBUG::Selection, string_compose ("selection change notification for surface \"%1\"\n", (*p)->name()));
+ (*p)->stripable_selection_changed ();
+ }
+ }
+}
);
- StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&CC121::gui_track_selection_changed, this, _1), this);
-
/* Catch port connections and disconnections */
ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&CC121::connection_handler, this, _1, _2, _3, _4, _5), this);
buttons.insert (std::make_pair (EButton, Button (*this, _("EButton"), EButton)));
}
void
-CC121::gui_track_selection_changed (StripableNotificationListPtr stripables)
+CC121::stripable_selection_changed ()
{
- boost::shared_ptr<Stripable> r;
-
- if (!stripables->empty()) {
- r = stripables->front().lock();
- }
-
- set_current_stripable (r);
+ set_current_stripable (first_selected_stripable());
}
void
void drop_current_stripable ();
void use_master ();
void use_monitor ();
- void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr);
+ void stripable_selection_changed ();
PBD::ScopedConnection selection_connection;
PBD::ScopedConnectionList stripable_connections;
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");
, _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 ()
}
void
-ControlProtocol::stripable_selection_changed (StripableNotificationListPtr sp)
+ControlProtocol::notify_stripable_selection_changed (StripableNotificationListPtr sp)
{
bool had_selection = !_last_selected.empty();
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)
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>);
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;
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" {
session->engine().make_port_name_non_relative (outp->name())
);
-
- StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::gui_track_selection_changed, this, _1), this);
-
/* Catch port connections and disconnections */
ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::connection_handler, this, _1, _2, _3, _4, _5), this);
}
void
-FaderPort::gui_track_selection_changed (StripableNotificationListPtr stripables)
+FaderPort::stripable_selection_changed ()
{
set_current_stripable (ControlProtocol::first_selected_stripable());
}
void drop_current_stripable ();
void use_master ();
void use_monitor ();
- void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr);
+ void stripable_selection_changed ();
PBD::ScopedConnection selection_connection;
PBD::ScopedConnectionList stripable_connections;
ARDOUR::AudioEngine::instance()->Stopped.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::engine_reset, this), this);
ARDOUR::Port::PortDrop.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::engine_reset, this), this);
- StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_gui_track_selection_changed, this), this);
-
/* bind button events to call libardour actions */
setup_actions ();
case ModeTrack:
case ModePan:
assign_stripables ();
- notify_gui_track_selection_changed (); // update selection, automation-state
+ stripable_selection_changed (); // update selection, automation-state
break;
case ModePlugins:
if (_proc_params.size() > 0) {
}
if (s->is_selected () && s != first_selected_stripable ()) {
set_first_selected_stripable (s);
- notify_gui_track_selection_changed ();
+ stripable_selection_changed ();
} else {
ToggleStripableSelection (s);
}
}
void
-FaderPort8::notify_gui_track_selection_changed (/*ARDOUR::StripableNotificationListPtr*/)
+FaderPort8::stripable_selection_changed ()
{
if (!_device_active) {
/* this can be called anytime from the static
void notify_pi_property_changed (const PBD::PropertyChange&);
void notify_stripable_property_changed (boost::weak_ptr<ARDOUR::Stripable>, const PBD::PropertyChange&);
- void notify_gui_track_selection_changed ();
+ void stripable_selection_changed ();
PBD::ScopedConnection selection_connection;
PBD::ScopedConnectionList automation_state_connections;
int set_active (bool yn);
static bool probe() { return true; }
+ void stripable_selection_changed () {}
+
std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
boost::shared_ptr<ARDOUR::Port> input_port () const;
}
void
-MackieControlProtocol::update_selected (boost::shared_ptr<Stripable> s, bool became_selected)
+MackieControlProtocol::stripable_selection_changed ()
{
- if (became_selected) {
+ boost::shared_ptr<Stripable> s = first_selected_stripable ();
+ if (s) {
check_fader_automation_state ();
/* It is possible that first_selected_route() may return null if we
* set_subview_mode() will fail, and we will reset to None.
*/
- if (set_subview_mode (_subview_mode, first_selected_stripable())) {
+ if (set_subview_mode (_subview_mode, s)) {
set_subview_mode (None, boost::shared_ptr<Stripable>());
}
bool is_midi_track (boost::shared_ptr<ARDOUR::Stripable>) const;
bool is_mapped (boost::shared_ptr<ARDOUR::Stripable>) const;
boost::shared_ptr<ARDOUR::Stripable> first_selected_stripable () const;
- void update_selected (boost::shared_ptr<ARDOUR::Stripable>, bool selected);
void check_fader_automation_state ();
void update_fader_automation_state ();
void clear_surfaces ();
void force_special_stripable_to_strip (boost::shared_ptr<ARDOUR::Stripable> r, uint32_t surface, uint32_t strip_number);
void build_button_map ();
- void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr, bool save_list);
- void _gui_track_selection_changed (ARDOUR::StripableNotificationList*, bool save_list, bool gui_did_change);
+ void stripable_selection_changed ();
int ipmidi_restart ();
void initialize ();
int set_device_info (const std::string& device_name);
if (what_changed.contains (ARDOUR::Properties::selected)) {
if (_stripable) {
_surface->write (_select->set_state (_stripable->is_selected()));
- _surface->mcp().update_selected (_stripable, _stripable->is_selected());
}
}
}
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
periodic_timeout->attach (main_loop()->get_context());
- // catch changes to selection for GUI_select mode
- StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this), this);
-
// catch track reordering
// receive routes added
session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this);
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
+ void stripable_selection_changed () {}
+
bool has_editor () const { return true; }
void* get_gui () const;
void tear_down_gui ();
/* master cannot be removed, so no need to connect to going-away signal */
master = session->master_out ();
- ControlProtocol::StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&Push2::stripable_selection_change, this, _1), this);
-
/* allocate graphics layouts, even though we're not using them yet */
_canvas = new Push2Canvas (*this, 960, 160);
DEBUG_TRACE (DEBUG::Push2, "push2 control surface object being destroyed\n");
/* do this before stopping the event loop, so that we don't get any notifications */
- selection_connection.disconnect ();
port_reg_connection.disconnect ();
port_connection.disconnect ();
splash ();
/* catch current selection, if any so that we can wire up the pads if appropriate */
- {
- StripableNotificationListPtr sp (new StripableNotificationList (ControlProtocol::last_selected()));
- stripable_selection_change (sp);
- }
+ stripable_selection_changed ();
request_pressure_mode ();
}
void
-Push2::stripable_selection_change (StripableNotificationListPtr selected)
+Push2::stripable_selection_changed ()
{
boost::shared_ptr<MidiPort> pad_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in)->shadow_port();
boost::shared_ptr<MidiTrack> current_midi_track = current_pad_target.lock();
boost::shared_ptr<MidiTrack> new_pad_target;
+ StripableNotificationList const & selected (last_selected());
/* See if there's a MIDI track selected */
- for (StripableNotificationList::iterator si = selected->begin(); si != selected->end(); ++si) {
+ for (StripableNotificationList::const_iterator si = selected.begin(); si != selected.end(); ++si) {
new_pad_target = boost::dynamic_pointer_cast<MidiTrack> ((*si).lock());
}
reset_pad_colors ();
+
+ TrackMixLayout* tml = dynamic_cast<TrackMixLayout*> (mix_layout);
+ assert (tml);
+ tml->set_stripable (first_selected_stripable());
}
Push2::Button*
/* pad mapping */
- PBD::ScopedConnection selection_connection;
- void stripable_selection_change (ARDOUR::StripableNotificationListPtr);
+ void stripable_selection_changed ();
MusicalMode::Type _mode;
int _scale_root;
minsec_text->set_font_description (fd2);
minsec_text->set_color (p2.get_color (Push2::LightBackground));
minsec_text->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 90));
-
- ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
}
TrackMixLayout::~TrackMixLayout ()
}
}
-void
-TrackMixLayout::selection_changed ()
-{
- boost::shared_ptr<Stripable> s = ControlProtocol::first_selected_stripable();
-
- if (s) {
- set_stripable (s);
- }
-}
-
void
TrackMixLayout::show ()
{
void stripable_property_change (PBD::PropertyChange const& what_changed);
void simple_control_change (boost::shared_ptr<ARDOUR::AutomationControl> ac, Push2::ButtonID bid);
- PBD::ScopedConnection selection_connection;
- void selection_changed ();
void show_state ();
void drop_stripable ();
void wiimote_callback (int mesg_count, union cwiid_mesg mesg[]);
+ void stripable_selection_changed () {}
+
protected:
void do_request (WiimoteControlUIRequest*);
int start ();