the mega-properties/SequenceProperty patch. split is broken at present (right hand...
[ardour.git] / libs / surfaces / mackie / route_signal.cc
index d76a8c896b7d986a0574f607edf61d193680ff9a..984a6ccd9f4f6497ef14e4aa6a56dbf3fe193ea2 100644 (file)
 */
 #include "route_signal.h"
 
-#include <ardour/route.h>
-#include <ardour/track.h>
-#include <ardour/panner.h>
+#include "ardour/route.h"
+#include "ardour/track.h"
+#include "ardour/midi_ui.h"
+#include "ardour/panner.h"
+#include "ardour/session_object.h" // for Properties::name 
 
 #include "mackie_control_protocol.h"
 
@@ -29,37 +31,42 @@ using namespace ARDOUR;
 using namespace Mackie;
 using namespace std;
 
+#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
+#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
+
 void RouteSignal::connect()
 {
-       back_insert_iterator<Connections> cins = back_inserter( _connections );
+       if (_strip.has_solo()) {
+               _route->solo_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this), midi_ui_context());
+       }
 
-       if ( _strip.has_solo() )
-               cins = _route->solo_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), this ) );
-       
-       if ( _strip.has_mute() )
-               cins = _route->mute_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), this ) );
-       
-       if ( _strip.has_gain() )
-               cins = _route->gain_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), this, true ) );
-               
-       cins = _route->NameChanged.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), this ) );
+       if (_strip.has_mute()) {
+               _route->mute_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this), midi_ui_context());
+       }
+
+       if (_strip.has_gain()) {
+               _route->gain_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false), midi_ui_context());
+       }
+
+       _route->PropertyChanged.connect (connections, ui_bind (&MackieControlProtocol::notify_property_changed, &_mcp, _1, this), midi_ui_context());
        
        if (_route->panner()) {
-               cins = _route->panner()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this, true ) );
+               _route->panner()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context());
+               
                for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) {
-                       cins = _route->panner()->streampanner (i).Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this, true ) );
+                       _route->panner()->streampanner(i).Changed.connect (connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context());
                }
        }
        
        boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
        if (trk) {
-               cins = trk->rec_enable_control()->Changed .connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), this));
+               trk->rec_enable_control()->Changed .connect(connections, ui_bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this), midi_ui_context());
        }
        
        // TODO this works when a currently-banked route is made inactive, but not
        // when a route is activated which should be currently banked.
-       cins = _route->active_changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_active_changed ), this ) );
-
+       _route->active_changed.connect (connections, ui_bind (&MackieControlProtocol::notify_active_changed, &_mcp, this), midi_ui_context());
+       
        // TODO
        // SelectedChanged
        // RemoteControlIDChanged. Better handled at Session level.
@@ -67,10 +74,7 @@ void RouteSignal::connect()
 
 void RouteSignal::disconnect()
 {
-       for ( Connections::iterator it = _connections.begin(); it != _connections.end(); ++it )
-       {
-               it->disconnect();
-       }
+       connections.drop_connections ();
 }
 
 void RouteSignal::notify_all()
@@ -87,7 +91,7 @@ void RouteSignal::notify_all()
        if ( _strip.has_gain() )
                _mcp.notify_gain_changed( this );
        
-       _mcp.notify_name_changed( this );
+       _mcp.notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name), this );
        
        if ( _strip.has_vpot() )
                _mcp.notify_panner_changed( this );