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"
25 #include "ardour/selection.h"
26 #include "ardour/session.h"
27 #include "ardour/session_handle.h"
29 #include "axis_provider.h"
30 #include "gui_thread.h"
31 #include "mixer_strip.h"
33 #include "route_processor_selection.h"
39 using namespace ARDOUR;
42 RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
48 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
50 // XXX MUST TEST PROCESSORS SOMEHOW
51 return a.axes == b.axes;
55 RouteProcessorSelection::clear ()
62 RouteProcessorSelection::clear_routes ()
65 PresentationInfo::ChangeSuspender cs;
66 shp.session()->selection().clear_stripables ();
71 RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
73 std::list<AxisView*> rv;
75 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
77 ARDOUR::RouteGroup* rg = route->route_group ();
78 if (rg && rg->is_active() && rg->is_select ()) {
80 boost::shared_ptr<RouteList> rl = rg->route_list ();
81 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
82 AxisView* av = avp.axis_view_by_stripable (*i);
91 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
93 Session* s = shp.session();
96 /* too early ... session handle provider doesn't know about the
103 pc.add (Properties::selected);
105 CoreSelection::StripableAutomationControls sc;
106 s->selection().get_stripables (sc);
108 for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
109 (*a)->set_selected (false);
114 for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
115 AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
118 av->set_selected (true);
124 RouteProcessorSelection::add (AxisView* r, bool with_groups)
126 if (!shp.session()) {
130 std::list<AxisView*> avl;
132 avl= add_grouped_tracks (r);
136 PresentationInfo::ChangeSuspender cs;
137 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
138 if (axes.insert (*i).second) {
139 shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
140 MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
142 ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
149 RouteProcessorSelection::remove (AxisView* r, bool with_groups)
151 if (!shp.session()) {
154 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
156 std::list<AxisView*> avl;
158 avl= add_grouped_tracks (r);
162 PresentationInfo::ChangeSuspender cs;
163 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
164 shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
169 RouteProcessorSelection::set (AxisView* r)
171 if (!shp.session()) {
174 PresentationInfo::ChangeSuspender cs;
175 shp.session()->selection().clear_stripables ();
180 RouteProcessorSelection::selected (AxisView* r)
182 return find (axes.begin(), axes.end(), r) != axes.end();
186 RouteProcessorSelection::empty ()
188 return processors.empty () && axes.empty ();