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>
23 #include "pbd/error.h"
26 #include "ardour/selection.h"
27 #include "ardour/session.h"
28 #include "ardour/session_handle.h"
30 #include "axis_provider.h"
31 #include "gui_thread.h"
32 #include "mixer_strip.h"
34 #include "route_processor_selection.h"
38 using namespace ARDOUR;
41 RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
46 RouteProcessorSelection&
47 RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
50 (*((ProcessorSelection*) this)) = (*((ProcessorSelection const *) &other));
57 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
59 // XXX MUST TEST PROCESSORS SOMEHOW
60 return a.axes == b.axes;
64 RouteProcessorSelection::clear ()
71 RouteProcessorSelection::clear_routes ()
74 PresentationInfo::ChangeSuspender cs;
75 shp.session()->selection().clear_stripables ();
80 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
82 Session* s = shp.session();
85 /* too early ... session handle provider doesn't know about the
92 pc.add (Properties::selected);
94 CoreSelection::StripableAutomationControls sc;
95 s->selection().get_stripables (sc);
97 for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
98 (*a)->set_selected (false);
103 for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
104 AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
107 av->set_selected (true);
113 RouteProcessorSelection::add (AxisView* r)
115 if (!shp.session()) {
119 if (axes.insert (r).second) {
121 shp.session()->selection().add (r->stripable(), boost::shared_ptr<AutomationControl>());
123 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
126 ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context());
132 RouteProcessorSelection::remove (AxisView* r)
134 if (!shp.session()) {
137 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
138 shp.session()->selection().remove (r->stripable(), boost::shared_ptr<AutomationControl>());
142 RouteProcessorSelection::set (AxisView* r)
144 if (!shp.session()) {
147 shp.session()->selection().set (r->stripable(), boost::shared_ptr<AutomationControl>());
151 RouteProcessorSelection::selected (AxisView* r)
153 return find (axes.begin(), axes.end(), r) != axes.end();
157 RouteProcessorSelection::empty ()
159 return processors.empty () && axes.empty ();