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::add_grouped_tracks (AxisView* r) const
82 std::list<AxisView*> rv;
84 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
86 ARDOUR::RouteGroup* rg = route->route_group ();
87 if (rg && rg->is_active() && rg->is_select ()) {
89 boost::shared_ptr<RouteList> rl = rg->route_list ();
90 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
91 AxisView* av = avp.axis_view_by_stripable (*i);
100 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
102 Session* s = shp.session();
105 /* too early ... session handle provider doesn't know about the
112 pc.add (Properties::selected);
114 CoreSelection::StripableAutomationControls sc;
115 s->selection().get_stripables (sc);
117 for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
118 (*a)->set_selected (false);
123 for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
124 AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
127 av->set_selected (true);
133 RouteProcessorSelection::add (AxisView* r, bool with_groups)
135 if (!shp.session()) {
139 std::list<AxisView*> avl;
141 avl= add_grouped_tracks (r);
145 PresentationInfo::ChangeSuspender cs;
146 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
147 if (axes.insert (*i).second) {
148 shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
149 MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
151 ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
158 RouteProcessorSelection::remove (AxisView* r, bool with_groups)
160 if (!shp.session()) {
163 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
165 std::list<AxisView*> avl;
167 avl= add_grouped_tracks (r);
171 PresentationInfo::ChangeSuspender cs;
172 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
173 shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
178 RouteProcessorSelection::set (AxisView* r)
180 if (!shp.session()) {
183 shp.session()->selection().clear_stripables ();
188 RouteProcessorSelection::selected (AxisView* r)
190 return find (axes.begin(), axes.end(), r) != axes.end();
194 RouteProcessorSelection::empty ()
196 return processors.empty () && axes.empty ();