switch to using boost::signals2 instead of sigc++, at least for libardour. not finish...
[ardour.git] / libs / surfaces / mackie / route_signal.cc
1 /*
2         Copyright (C) 2006,2007 John Anderson
3
4         This program is free software; you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation; either version 2 of the License, or
7         (at your option) any later version.
8
9         This program is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with this program; if not, write to the Free Software
16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #include "route_signal.h"
19
20 #include "ardour/route.h"
21 #include "ardour/track.h"
22 #include "ardour/panner.h"
23
24 #include "mackie_control_protocol.h"
25
26 #include <stdexcept>
27
28 using namespace ARDOUR;
29 using namespace Mackie;
30 using namespace std;
31
32 void RouteSignal::connect()
33 {
34         if (_strip.has_solo()) {
35                 connections.add_connection (_route->solo_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this)));
36         }
37
38         if (_strip.has_mute()) {
39                 connections.add_connection (_route->mute_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this)));
40         }
41
42         if (_strip.has_gain()) {
43                 connections.add_connection (_route->gain_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false)));
44         }
45
46         connections.add_connection (_route->NameChanged.connect (boost::bind (&MackieControlProtocol::notify_name_changed, &_mcp, this)));
47         
48         if (_route->panner()) {
49                 connections.add_connection (_route->panner()->Changed.connect(boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)));
50                 
51                 for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) {
52                         connections.add_connection (_route->panner()->streampanner(i).Changed.connect (boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)));
53                 }
54         }
55         
56         boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
57         if (trk) {
58                 connections.add_connection (trk->rec_enable_control()->Changed .connect(boost::bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this)));
59         }
60         
61         // TODO this works when a currently-banked route is made inactive, but not
62         // when a route is activated which should be currently banked.
63         connections.add_connection (_route->active_changed.connect (boost::bind (&MackieControlProtocol::notify_active_changed, &_mcp, this)));
64
65         // TODO
66         // SelectedChanged
67         // RemoteControlIDChanged. Better handled at Session level.
68 }
69
70 void RouteSignal::disconnect()
71 {
72         connections.drop_connections ();
73 }
74
75 void RouteSignal::notify_all()
76 {
77 #ifdef DEBUG
78         cout << "RouteSignal::notify_all for " << _strip << endl;
79 #endif
80         if ( _strip.has_solo() )
81                 _mcp.notify_solo_changed( this );
82         
83         if ( _strip.has_mute() )
84                 _mcp.notify_mute_changed( this );
85         
86         if ( _strip.has_gain() )
87                 _mcp.notify_gain_changed( this );
88         
89         _mcp.notify_name_changed( this );
90         
91         if ( _strip.has_vpot() )
92                 _mcp.notify_panner_changed( this );
93         
94         if ( _strip.has_recenable() )
95                 _mcp.notify_record_enable_changed( this );
96 #ifdef DEBUG
97         cout << "RouteSignal::notify_all finish" << endl;
98 #endif
99 }