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
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
#include "gui_thread.h"
|
2011-11-04 13:53:21 -04:00
|
|
|
#include "mixer_strip.h"
|
|
|
|
#include "route_processor_selection.h"
|
|
|
|
#include "route_ui.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
|
|
|
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::RouteProcessorSelection()
|
|
|
|
: _no_route_change_signal (false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RouteProcessorSelection&
|
|
|
|
RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
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
|
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
|
|
|
|
return a.routes == b.routes;
|
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
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::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
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::clear_routes ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2011-11-04 13:53:21 -04:00
|
|
|
for (RouteUISelection::iterator i = routes.begin(); i != routes.end(); ++i) {
|
|
|
|
(*i)->set_selected (false);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
routes.clear ();
|
2009-12-19 15:26:31 -05:00
|
|
|
drop_connections ();
|
2011-11-15 14:33:09 -05:00
|
|
|
if (!_no_route_change_signal) {
|
|
|
|
RoutesChanged ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::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
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::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
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::add (RouteUI* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (find (routes.begin(), routes.end(), r) == routes.end()) {
|
2011-11-04 13:53:21 -04:00
|
|
|
if (routes.insert (r).second) {
|
|
|
|
r->set_selected (true);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-11-04 13:53:21 -04:00
|
|
|
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
|
|
|
|
|
|
|
|
if (ms) {
|
2012-04-25 08:58:19 -04:00
|
|
|
ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context());
|
2011-11-15 14:33:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!_no_route_change_signal) {
|
|
|
|
RoutesChanged();
|
2011-11-04 13:53:21 -04:00
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::remove (RouteUI* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2011-11-15 14:33:09 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
|
2009-12-17 13:24:23 -05:00
|
|
|
|
2011-11-04 13:53:21 -04:00
|
|
|
RouteUISelection::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
|
|
|
|
routes.erase (i);
|
2011-11-04 13:53:21 -04:00
|
|
|
(*i)->set_selected (false);
|
2011-11-15 14:33:09 -05:00
|
|
|
if (!_no_route_change_signal) {
|
|
|
|
RoutesChanged ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::set (RouteUI* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_routes ();
|
|
|
|
add (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::selected (RouteUI* 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
|
2011-11-15 14:33:09 -05:00
|
|
|
RouteProcessorSelection::empty ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
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
|
|
|
|
2011-11-15 14:33:09 -05:00
|
|
|
void
|
|
|
|
RouteProcessorSelection::block_routes_changed (bool yn)
|
|
|
|
{
|
|
|
|
_no_route_change_signal = yn;
|
|
|
|
}
|