X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_processor_selection.cc;h=0dc15e7f8a2b17a1d66013d4889d35ca10bc594a;hb=d9767b10ac4493cf1b76c6b8afd920e2584ef39e;hp=552de1b412028c75d3ad8eeb00f618c811f1a0f3;hpb=6698f5f686bef82b0c9568558c83a3b9b3344700;p=ardour.git diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index 552de1b412..0dc15e7f8a 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -1,5 +1,5 @@ /* - 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 @@ -19,114 +19,142 @@ #include #include -#include -#include -#include -#include +#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) +{ +} + +RouteProcessorSelection& +RouteProcessorSelection::operator= (const RouteProcessorSelection& other) { if (&other != this) { - processors = other.processors; - routes = other.routes; + (*((ProcessorSelection*) this)) = (*((ProcessorSelection const *) &other)); + axes = other.axes; } return *this; } bool -operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b) +operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b) { // XXX MUST TEST PROCESSORS SOMEHOW - return a.routes == b.routes; + 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 () +RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed) { - routes.clear (); - RoutesChanged (); -} + Session* s = shp.session(); -void -RouteRedirectSelection::add (XMLNode* node) -{ - // XXX check for duplicate - processors.add (node); - ProcessorsChanged(); -} + if (!s) { + /* too early ... session handle provider doesn't know about the + session yet. + */ + return; + } -void -RouteRedirectSelection::set (XMLNode* node) -{ - clear_processors (); - processors.set (node); - ProcessorsChanged (); + PropertyChange pc; + pc.add (Properties::selected); + + 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); + } + } } void -RouteRedirectSelection::add (boost::shared_ptr r) +RouteProcessorSelection::add (AxisView* r) { - if (find (routes.begin(), routes.end(), r) == routes.end()) { - routes.push_back (r); + if (!shp.session()) { + return; + } + + if (axes.insert (r).second) { - // XXX SHAREDPTR FIXME - // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove; - // r->GoingAway.connect (bind (mem_fun(*this, pmf), r)); + shp.session()->selection().add (r->stripable(), boost::shared_ptr()); - RoutesChanged(); + MixerStrip* ms = dynamic_cast (r); + + if (ms) { + ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context()); + } } } void -RouteRedirectSelection::remove (boost::shared_ptr r) +RouteProcessorSelection::remove (AxisView* r) { - list >::iterator i; - if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { - routes.erase (i); - RoutesChanged (); + if (!shp.session()) { + return; } + ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); + shp.session()->selection().remove (r->stripable(), boost::shared_ptr()); } void -RouteRedirectSelection::set (boost::shared_ptr r) +RouteProcessorSelection::set (AxisView* r) { - clear_routes (); - add (r); + if (!shp.session()) { + return; + } + shp.session()->selection().set (r->stripable(), boost::shared_ptr()); } bool -RouteRedirectSelection::selected (boost::shared_ptr 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 (); } -