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)
47 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
49 // XXX MUST TEST PROCESSORS SOMEHOW
50 return a.axes == b.axes;
54 RouteProcessorSelection::clear ()
61 RouteProcessorSelection::clear_routes ()
64 PresentationInfo::ChangeSuspender cs;
65 shp.session()->selection().clear_stripables ();
70 RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
72 std::list<AxisView*> rv;
74 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
76 ARDOUR::RouteGroup* rg = route->route_group ();
77 if (rg && rg->is_active() && rg->is_select ()) {
79 boost::shared_ptr<RouteList> rl = rg->route_list ();
80 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
81 AxisView* av = avp.axis_view_by_stripable (*i);
90 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
92 Session* s = shp.session();
95 /* too early ... session handle provider doesn't know about the
102 pc.add (Properties::selected);
104 CoreSelection::StripableAutomationControls sc;
105 s->selection().get_stripables (sc);
107 for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
108 (*a)->set_selected (false);
113 for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
114 AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
117 av->set_selected (true);
123 RouteProcessorSelection::add (AxisView* r, bool with_groups)
125 if (!shp.session()) {
129 std::list<AxisView*> avl;
131 avl= add_grouped_tracks (r);
135 PresentationInfo::ChangeSuspender cs;
136 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
137 if (axes.insert (*i).second) {
138 shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
139 MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
141 ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
148 RouteProcessorSelection::remove (AxisView* r, bool with_groups)
150 if (!shp.session()) {
153 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
155 std::list<AxisView*> avl;
157 avl= add_grouped_tracks (r);
161 PresentationInfo::ChangeSuspender cs;
162 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
163 shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
168 RouteProcessorSelection::set (AxisView* r)
170 if (!shp.session()) {
173 PresentationInfo::ChangeSuspender cs;
174 shp.session()->selection().clear_stripables ();
179 RouteProcessorSelection::selected (AxisView* r)
181 return find (axes.begin(), axes.end(), r) != axes.end();
185 RouteProcessorSelection::empty ()
187 return processors.empty () && axes.empty ();