/*
- Copyright (C) 2002 Paul Davis
+ Copyright (C) 2002 Paul Davis
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
#include <algorithm>
#include <sigc++/bind.h>
-#include <pbd/error.h>
-#include <ardour/playlist.h>
-#include <ardour/processor.h>
-#include <ardour/route.h>
+#include "pbd/error.h"
+#include "pbd/i18n.h"
-#include "route_processor_selection.h"
+#include "ardour/selection.h"
+#include "ardour/session.h"
+#include "ardour/session_handle.h"
-#include "i18n.h"
+#include "axis_provider.h"
+#include "gui_thread.h"
+#include "mixer_strip.h"
+#include "mixer_ui.h"
+#include "route_processor_selection.h"
+#include "route_ui.h"
+using namespace std;
using namespace ARDOUR;
using namespace PBD;
-using namespace sigc;
-RouteRedirectSelection&
-RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
+RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
+ : shp (s), avp (ap)
{
- if (&other != this) {
- processors = other.processors;
- routes = other.routes;
- }
- return *this;
}
bool
-operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
+operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
{
- return a.processors == b.processors &&
- a.routes == b.routes;
+ // XXX MUST TEST PROCESSORS SOMEHOW
+ return a.axes == b.axes;
}
void
-RouteRedirectSelection::clear ()
+RouteProcessorSelection::clear ()
{
clear_processors ();
clear_routes ();
}
void
-RouteRedirectSelection::clear_processors ()
+RouteProcessorSelection::clear_routes ()
{
- processors.clear ();
- ProcessorsChanged ();
+ if (shp.session()) {
+ PresentationInfo::ChangeSuspender cs;
+ shp.session()->selection().clear_stripables ();
+ }
}
-void
-RouteRedirectSelection::clear_routes ()
+std::list<AxisView*>
+RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
{
- routes.clear ();
- RoutesChanged ();
+ 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;
}
void
-RouteRedirectSelection::add (boost::shared_ptr<Processor> r)
+RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
{
- if (find (processors.begin(), processors.end(), r) == processors.end()) {
- processors.push_back (r);
+ Session* s = shp.session();
- // XXX SHAREDPTR FIXME
- // void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
- // r->GoingAway.connect (mem_fun(*this, pmf));
-
- ProcessorsChanged();
+ if (!s) {
+ /* too early ... session handle provider doesn't know about the
+ session yet.
+ */
+ return;
}
-}
-void
-RouteRedirectSelection::add (const vector<boost::shared_ptr<Processor> >& rlist)
-{
- bool changed = false;
+ PropertyChange pc;
+ pc.add (Properties::selected);
- for (vector<boost::shared_ptr<Processor> >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) {
- if (find (processors.begin(), processors.end(), *i) == processors.end()) {
- processors.push_back (*i);
-
- // XXX SHAREDPTR FIXME
+ CoreSelection::StripableAutomationControls sc;
+ s->selection().get_stripables (sc);
- //void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
- // (*i)->GoingAway.connect (mem_fun(*this, pmf));
- changed = true;
- }
+ for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
+ (*a)->set_selected (false);
}
- if (changed) {
- ProcessorsChanged();
- }
-}
+ axes.clear ();
-void
-RouteRedirectSelection::remove (boost::shared_ptr<Processor> r)
-{
- list<boost::shared_ptr<Processor> >::iterator i;
- if ((i = find (processors.begin(), processors.end(), r)) != processors.end()) {
- processors.erase (i);
- ProcessorsChanged ();
+ 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);
+ }
}
}
void
-RouteRedirectSelection::set (boost::shared_ptr<Processor> r)
+RouteProcessorSelection::add (AxisView* r, bool with_groups)
{
- clear_processors ();
- add (r);
-}
+ if (!shp.session()) {
+ return;
+ }
-void
-RouteRedirectSelection::set (const vector<boost::shared_ptr<Processor> >& rlist)
-{
- clear_processors ();
- add (rlist);
+ 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());
+ }
+ }
+ }
}
void
-RouteRedirectSelection::add (boost::shared_ptr<Route> r)
+RouteProcessorSelection::remove (AxisView* r, bool with_groups)
{
- if (find (routes.begin(), routes.end(), r) == routes.end()) {
- routes.push_back (r);
-
- // XXX SHAREDPTR FIXME
- // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
- // r->GoingAway.connect (bind (mem_fun(*this, pmf), r));
+ if (!shp.session()) {
+ return;
+ }
+ ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
- RoutesChanged();
+ std::list<AxisView*> avl;
+ if (with_groups) {
+ avl= add_grouped_tracks (r);
}
-}
+ avl.push_back (r);
-void
-RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
-{
- list<boost::shared_ptr<Route> >::iterator i;
- if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
- routes.erase (i);
- RoutesChanged ();
+ 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>());
}
}
void
-RouteRedirectSelection::set (boost::shared_ptr<Route> r)
+RouteProcessorSelection::set (AxisView* r)
{
- clear_routes ();
- add (r);
+ if (!shp.session()) {
+ return;
+ }
+ PresentationInfo::ChangeSuspender cs;
+ shp.session()->selection().clear_stripables ();
+ add (r, true);
}
bool
-RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
+RouteProcessorSelection::selected (AxisView* r)
{
- return find (routes.begin(), routes.end(), r) != routes.end();
+ return find (axes.begin(), axes.end(), r) != axes.end();
}
bool
-RouteRedirectSelection::empty ()
+RouteProcessorSelection::empty ()
{
- return processors.empty () && routes.empty ();
+ return processors.empty () && axes.empty ();
}
-