2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#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"
|
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
|
|
|
|
2018-09-21 13:05:57 -04:00
|
|
|
#include "pbd/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
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
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;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Route> route = std::dynamic_pointer_cast<Route>(r->stripable());
|
2017-07-12 00:55:44 -04:00
|
|
|
if (route) {
|
|
|
|
ARDOUR::RouteGroup* rg = route->route_group ();
|
|
|
|
if (rg && rg->is_active() && rg->is_select ()) {
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<RouteList> rl = rg->route_list ();
|
2017-07-12 00:55:44 -04:00
|
|
|
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) {
|
2023-02-16 18:33:28 -05:00
|
|
|
shp.session()->selection().add ((*i)->stripable(), std::shared_ptr<AutomationControl>());
|
2017-07-12 00:55:44 -04:00
|
|
|
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) {
|
2023-02-16 18:33:28 -05:00
|
|
|
shp.session()->selection().remove ((*i)->stripable(), std::shared_ptr<AutomationControl>());
|
2017-07-12 00:55:44 -04:00
|
|
|
}
|
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;
|
|
|
|
}
|
2024-05-07 18:14:00 -04:00
|
|
|
|
|
|
|
StripableList sl;
|
|
|
|
sl.push_back (r->stripable());
|
|
|
|
shp.session()->selection().set (sl);
|
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
|
|
|
}
|