2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2002 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <sigc++/bind.h>
|
2017-05-05 07:31:49 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "ardour/selection.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/session_handle.h"
|
|
|
|
|
|
|
|
#include "axis_provider.h"
|
2009-12-17 13:24:23 -05:00
|
|
|
#include "gui_thread.h"
|
2011-11-04 13:53:21 -04:00
|
|
|
#include "mixer_strip.h"
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "mixer_ui.h"
|
2011-11-04 13:53:21 -04:00
|
|
|
#include "route_processor_selection.h"
|
|
|
|
#include "route_ui.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
|
|
|
|
: shp (s), avp (ap)
|
2011-11-15 14:33:09 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RouteProcessorSelection&
|
|
|
|
RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (&other != this) {
|
2017-05-05 07:31:49 -04:00
|
|
|
(*((ProcessorSelection*) this)) = (*((ProcessorSelection const *) &other));
|
2016-07-06 13:37:30 -04:00
|
|
|
axes = other.axes;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-11-15 14:33:09 -05:00
|
|
|
operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-08-01 18:18:46 -04:00
|
|
|
// XXX MUST TEST PROCESSORS SOMEHOW
|
2016-07-06 13:37:30 -04:00
|
|
|
return a.axes == b.axes;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::clear ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-27 16:23:48 -04:00
|
|
|
clear_processors ();
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_routes ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-05-05 07:31:49 -04:00
|
|
|
RouteProcessorSelection::clear_routes ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (shp.session()) {
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
shp.session()->selection().clear_stripables ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2017-07-12 00:55:44 -04:00
|
|
|
std::list<AxisView*>
|
|
|
|
RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
|
|
|
|
{
|
|
|
|
std::list<AxisView*> rv;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
|
|
|
|
if (route) {
|
|
|
|
ARDOUR::RouteGroup* rg = route->route_group ();
|
|
|
|
if (rg && rg->is_active() && rg->is_select ()) {
|
|
|
|
|
|
|
|
boost::shared_ptr<RouteList> rl = rg->route_list ();
|
|
|
|
for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
|
|
|
|
AxisView* av = avp.axis_view_by_stripable (*i);
|
|
|
|
rv.push_back (av);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2017-05-05 07:31:49 -04:00
|
|
|
RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
Session* s = shp.session();
|
2017-01-27 13:18:33 -05:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!s) {
|
|
|
|
/* too early ... session handle provider doesn't know about the
|
|
|
|
session yet.
|
|
|
|
*/
|
|
|
|
return;
|
2011-11-04 13:53:21 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
PropertyChange pc;
|
|
|
|
pc.add (Properties::selected);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
CoreSelection::StripableAutomationControls sc;
|
|
|
|
s->selection().get_stripables (sc);
|
|
|
|
|
|
|
|
for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
|
|
|
|
(*a)->set_selected (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
axes.clear ();
|
|
|
|
|
|
|
|
for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
|
|
|
|
AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
|
|
|
|
if (av) {
|
|
|
|
axes.insert (av);
|
|
|
|
av->set_selected (true);
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-12 00:55:44 -04:00
|
|
|
RouteProcessorSelection::add (AxisView* r, bool with_groups)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!shp.session()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-12 00:55:44 -04:00
|
|
|
std::list<AxisView*> avl;
|
|
|
|
if (with_groups) {
|
|
|
|
avl= add_grouped_tracks (r);
|
|
|
|
}
|
|
|
|
avl.push_back (r);
|
|
|
|
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
|
|
|
|
if (axes.insert (*i).second) {
|
|
|
|
shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
|
|
|
|
MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
|
|
|
|
if (ms) {
|
|
|
|
ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
|
|
|
|
}
|
2016-07-06 13:37:30 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-12 00:55:44 -04:00
|
|
|
RouteProcessorSelection::remove (AxisView* r, bool with_groups)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!shp.session()) {
|
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2017-05-05 07:31:49 -04:00
|
|
|
ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
|
2017-07-12 00:55:44 -04:00
|
|
|
|
|
|
|
std::list<AxisView*> avl;
|
|
|
|
if (with_groups) {
|
|
|
|
avl= add_grouped_tracks (r);
|
|
|
|
}
|
|
|
|
avl.push_back (r);
|
|
|
|
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
|
|
|
|
shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-07-06 13:37:30 -04:00
|
|
|
RouteProcessorSelection::set (AxisView* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!shp.session()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-12 00:55:44 -04:00
|
|
|
shp.session()->selection().clear_stripables ();
|
|
|
|
add (r, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-07-06 13:37:30 -04:00
|
|
|
RouteProcessorSelection::selected (AxisView* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2016-07-06 13:37:30 -04:00
|
|
|
return find (axes.begin(), axes.end(), r) != axes.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::empty ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2016-07-06 13:37:30 -04:00
|
|
|
return processors.empty () && axes.empty ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|