Zoom session when the mouse pointer is moved up and down during a playhead drag.
[ardour2.git] / gtk2_ardour / route_processor_selection.cc
blobb3a6620f6bf1bca3f56fea40f7c90d7857ae642b
1 /*
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.
20 #include <algorithm>
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 "route_processor_selection.h"
29 #include "gui_thread.h"
31 #include "i18n.h"
33 using namespace std;
34 using namespace ARDOUR;
35 using namespace PBD;
37 RouteRedirectSelection&
38 RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
40 if (&other != this) {
41 processors = other.processors;
42 routes = other.routes;
44 return *this;
47 bool
48 operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
50 // XXX MUST TEST PROCESSORS SOMEHOW
51 return a.routes == b.routes;
54 void
55 RouteRedirectSelection::clear ()
57 clear_processors ();
58 clear_routes ();
61 void
62 RouteRedirectSelection::clear_processors ()
64 processors.clear ();
65 ProcessorsChanged ();
68 void
69 RouteRedirectSelection::clear_routes ()
71 routes.clear ();
72 drop_connections ();
73 RoutesChanged ();
76 void
77 RouteRedirectSelection::add (XMLNode* node)
79 // XXX check for duplicate
80 processors.add (node);
81 ProcessorsChanged();
84 void
85 RouteRedirectSelection::set (XMLNode* node)
87 clear_processors ();
88 processors.set (node);
89 ProcessorsChanged ();
92 void
93 RouteRedirectSelection::add (boost::shared_ptr<Route> r)
95 if (find (routes.begin(), routes.end(), r) == routes.end()) {
96 routes.push_back (r);
97 r->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&RouteRedirectSelection::removed, this, boost::weak_ptr<Route>(r)), gui_context());
98 RoutesChanged();
102 void
103 RouteRedirectSelection::removed (boost::weak_ptr<Route> wr)
105 boost::shared_ptr<Route> r (wr.lock());
107 if (!r) {
108 return;
111 remove (r);
114 void
115 RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
117 ENSURE_GUI_THREAD (*this, &RouteRedirectSelection::remove, r);
119 list<boost::shared_ptr<Route> >::iterator i;
120 if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
121 routes.erase (i);
122 RoutesChanged ();
126 void
127 RouteRedirectSelection::set (boost::shared_ptr<Route> r)
129 clear_routes ();
130 add (r);
133 bool
134 RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
136 return find (routes.begin(), routes.end(), r) != routes.end();
139 bool
140 RouteRedirectSelection::empty ()
142 return processors.empty () && routes.empty ();