2 Copyright (C) 2002 Paul Davis
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.
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.
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.
21 #include <sigc++/bind.h>
22 #include "pbd/error.h"
24 #include "ardour/playlist.h"
25 #include "ardour/processor.h"
26 #include "ardour/route.h"
28 #include "gui_thread.h"
29 #include "mixer_strip.h"
30 #include "route_processor_selection.h"
36 using namespace ARDOUR;
39 RouteProcessorSelection::RouteProcessorSelection()
40 : _no_route_change_signal (false)
44 RouteProcessorSelection&
45 RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
48 processors = other.processors;
49 routes = other.routes;
55 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
57 // XXX MUST TEST PROCESSORS SOMEHOW
58 return a.routes == b.routes;
62 RouteProcessorSelection::clear ()
69 RouteProcessorSelection::clear_processors ()
76 RouteProcessorSelection::clear_routes ()
78 for (RouteUISelection::iterator i = routes.begin(); i != routes.end(); ++i) {
79 (*i)->set_selected (false);
83 if (!_no_route_change_signal) {
89 RouteProcessorSelection::add (XMLNode* node)
91 // XXX check for duplicate
92 processors.add (node);
97 RouteProcessorSelection::set (XMLNode* node)
100 processors.set (node);
101 ProcessorsChanged ();
105 RouteProcessorSelection::add (RouteUI* r)
107 if (find (routes.begin(), routes.end(), r) == routes.end()) {
108 if (routes.insert (r).second) {
109 r->set_selected (true);
111 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
114 ms->CatchDeletion.connect (*this, invalidator (*this), ui_bind (&RouteProcessorSelection::remove, this, _1), gui_context());
117 if (!_no_route_change_signal) {
125 RouteProcessorSelection::remove (RouteUI* r)
127 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
129 RouteUISelection::iterator i;
130 if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
132 (*i)->set_selected (false);
133 if (!_no_route_change_signal) {
140 RouteProcessorSelection::set (RouteUI* r)
147 RouteProcessorSelection::selected (RouteUI* r)
149 return find (routes.begin(), routes.end(), r) != routes.end();
153 RouteProcessorSelection::empty ()
155 return processors.empty () && routes.empty ();
159 RouteProcessorSelection::block_routes_changed (bool yn)
161 _no_route_change_signal = yn;