2 * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <sigc++/bind.h>
24 #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"
40 using namespace ARDOUR;
43 RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
49 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
51 // XXX MUST TEST PROCESSORS SOMEHOW
52 return a.axes == b.axes;
56 RouteProcessorSelection::clear ()
63 RouteProcessorSelection::clear_routes ()
66 PresentationInfo::ChangeSuspender cs;
67 shp.session()->selection().clear_stripables ();
72 RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
74 std::list<AxisView*> rv;
76 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
78 ARDOUR::RouteGroup* rg = route->route_group ();
79 if (rg && rg->is_active() && rg->is_select ()) {
81 boost::shared_ptr<RouteList> rl = rg->route_list ();
82 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
83 AxisView* av = avp.axis_view_by_stripable (*i);
92 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
94 Session* s = shp.session();
97 /* too early ... session handle provider doesn't know about the
104 pc.add (Properties::selected);
106 CoreSelection::StripableAutomationControls sc;
107 s->selection().get_stripables (sc);
109 for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
110 (*a)->set_selected (false);
115 for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
116 AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
119 av->set_selected (true);
125 RouteProcessorSelection::add (AxisView* r, bool with_groups)
127 if (!shp.session()) {
131 std::list<AxisView*> avl;
133 avl= add_grouped_tracks (r);
137 PresentationInfo::ChangeSuspender cs;
138 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
139 if (axes.insert (*i).second) {
140 shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
141 MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
143 ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
150 RouteProcessorSelection::remove (AxisView* r, bool with_groups)
152 if (!shp.session()) {
155 ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
157 std::list<AxisView*> avl;
159 avl= add_grouped_tracks (r);
163 PresentationInfo::ChangeSuspender cs;
164 for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
165 shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
170 RouteProcessorSelection::set (AxisView* r)
172 if (!shp.session()) {
175 PresentationInfo::ChangeSuspender cs;
176 shp.session()->selection().clear_stripables ();
181 RouteProcessorSelection::selected (AxisView* r)
183 return find (axes.begin(), axes.end(), r) != axes.end();
187 RouteProcessorSelection::empty ()
189 return processors.empty () && axes.empty ();