X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_processor_selection.cc;h=ed182db415305a77697eed2a86c6040de9e37dcf;hb=d7cd457bdf5116a2ba4e211320065b0e3ad5afb4;hp=ae0ac380a4d8d15bbc76027d70efbea0743dd30b;hpb=c83389b8ec5fef9553a401e6123b7e55702af9e2;p=ardour.git diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index ae0ac380a4..ed182db415 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -19,126 +19,179 @@ #include #include + #include "pbd/error.h" +#include "pbd/i18n.h" -#include "ardour/playlist.h" -#include "ardour/processor.h" -#include "ardour/route.h" +#include "ardour/selection.h" +#include "ardour/session.h" +#include "ardour/session_handle.h" -#include "route_processor_selection.h" +#include "axis_provider.h" #include "gui_thread.h" - -#include "i18n.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; -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 () +std::list +RouteProcessorSelection::add_grouped_tracks (AxisView* r) const { - routes.clear (); - drop_connections (); - RoutesChanged (); + std::list rv; + + boost::shared_ptr route = boost::dynamic_pointer_cast(r->stripable()); + if (route) { + ARDOUR::RouteGroup* rg = route->route_group (); + if (rg && rg->is_active() && rg->is_select ()) { + + boost::shared_ptr 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 (XMLNode* node) +RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed) { - // XXX check for duplicate - processors.add (node); - ProcessorsChanged(); -} + Session* s = shp.session(); -void -RouteRedirectSelection::set (XMLNode* node) -{ - clear_processors (); - processors.set (node); - ProcessorsChanged (); -} + if (!s) { + /* too early ... session handle provider doesn't know about the + session yet. + */ + return; + } -void -RouteRedirectSelection::add (boost::shared_ptr r) -{ - if (find (routes.begin(), routes.end(), r) == routes.end()) { - routes.push_back (r); - r->DropReferences.connect (*this, boost::bind (&RouteRedirectSelection::removed, this, boost::weak_ptr(r)), gui_context()); - RoutesChanged(); + 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::removed (boost::weak_ptr wr) +RouteProcessorSelection::add (AxisView* r, bool with_groups) { - boost::shared_ptr r (wr.lock()); - - if (!r) { + if (!shp.session()) { return; } - remove (r); + std::list avl; + if (with_groups) { + avl= add_grouped_tracks (r); + } + avl.push_back (r); + + PresentationInfo::ChangeSuspender cs; + for (std::list::const_iterator i = avl.begin (); i != avl.end (); ++i) { + if (axes.insert (*i).second) { + shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr()); + MixerStrip* ms = dynamic_cast (*i); + if (ms) { + ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context()); + } + } + } } void -RouteRedirectSelection::remove (boost::shared_ptr r) +RouteProcessorSelection::remove (AxisView* r, bool with_groups) { - ENSURE_GUI_THREAD (*this, &RouteRedirectSelection::remove, r); + if (!shp.session()) { + return; + } + ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); + + std::list avl; + if (with_groups) { + avl= add_grouped_tracks (r); + } + avl.push_back (r); - list >::iterator i; - if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { - routes.erase (i); - RoutesChanged (); + PresentationInfo::ChangeSuspender cs; + for (std::list::const_iterator i = avl.begin (); i != avl.end (); ++i) { + shp.session()->selection().remove ((*i)->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().clear_stripables (); + add (r, true); } 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 (); } -