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>
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/processor.h"
|
|
|
|
#include "ardour/route.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
#include "route_processor_selection.h"
|
2009-12-17 13:24:23 -05:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
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
|
|
|
|
|
|
|
RouteRedirectSelection&
|
|
|
|
RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
|
|
|
|
{
|
|
|
|
if (&other != this) {
|
2007-06-27 16:23:48 -04:00
|
|
|
processors = other.processors;
|
2005-09-25 14:42:24 -04:00
|
|
|
routes = other.routes;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
|
|
|
|
{
|
2007-08-01 18:18:46 -04:00
|
|
|
// XXX MUST TEST PROCESSORS SOMEHOW
|
|
|
|
return a.routes == b.routes;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteRedirectSelection::clear ()
|
|
|
|
{
|
2007-06-27 16:23:48 -04:00
|
|
|
clear_processors ();
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_routes ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
RouteRedirectSelection::clear_processors ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-27 16:23:48 -04:00
|
|
|
processors.clear ();
|
|
|
|
ProcessorsChanged ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteRedirectSelection::clear_routes ()
|
|
|
|
{
|
|
|
|
routes.clear ();
|
2009-12-19 15:26:31 -05:00
|
|
|
drop_connections ();
|
2005-09-25 14:42:24 -04:00
|
|
|
RoutesChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-08-01 18:18:46 -04:00
|
|
|
RouteRedirectSelection::add (XMLNode* node)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-08-01 18:18:46 -04:00
|
|
|
// XXX check for duplicate
|
|
|
|
processors.add (node);
|
|
|
|
ProcessorsChanged();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-08-01 18:18:46 -04:00
|
|
|
RouteRedirectSelection::set (XMLNode* node)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-27 16:23:48 -04:00
|
|
|
clear_processors ();
|
2007-08-01 18:18:46 -04:00
|
|
|
processors.set (node);
|
|
|
|
ProcessorsChanged ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::add (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (find (routes.begin(), routes.end(), r) == routes.end()) {
|
|
|
|
routes.push_back (r);
|
2009-12-22 15:21:43 -05:00
|
|
|
r->DropReferences.connect (*this, boost::bind (&RouteRedirectSelection::removed, this, boost::weak_ptr<Route>(r)), gui_context());
|
2009-12-17 13:24:23 -05:00
|
|
|
RoutesChanged();
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
void
|
|
|
|
RouteRedirectSelection::removed (boost::weak_ptr<Route> wr)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Route> r (wr.lock());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!r) {
|
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-12-17 13:24:23 -05:00
|
|
|
|
|
|
|
remove (r);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &RouteRedirectSelection::remove, r);
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
list<boost::shared_ptr<Route> >::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
|
|
|
|
routes.erase (i);
|
|
|
|
RoutesChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::set (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_routes ();
|
|
|
|
add (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
return find (routes.begin(), routes.end(), r) != routes.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RouteRedirectSelection::empty ()
|
|
|
|
{
|
2007-06-27 16:23:48 -04:00
|
|
|
return processors.empty () && routes.empty ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|