X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_processor_selection.cc;h=50a8a75b9c96a490b04ba0561a32b3c7a91e5197;hb=8a2c82465938cd528781e7cdcb04e8a3530a0b51;hp=836e63fcfee0885f92a27d8c8464771e0add046b;hpb=8c1e06a5e909e56cc8712d3c18f12a584d52f027;p=ardour.git diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index 836e63fcfe..50a8a75b9c 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -19,10 +19,17 @@ #include #include + #include "pbd/error.h" +#include "ardour/selection.h" +#include "ardour/session.h" +#include "ardour/session_handle.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" @@ -32,19 +39,9 @@ using namespace std; using namespace ARDOUR; using namespace PBD; - -RouteProcessorSelection::RouteProcessorSelection() -{ -} - -RouteProcessorSelection& -RouteProcessorSelection::operator= (const RouteProcessorSelection& other) +RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap) + : shp (s), avp (ap) { - if (&other != this) { - processors = other.processors; - axes = other.axes; - } - return *this; } bool @@ -61,75 +58,122 @@ RouteProcessorSelection::clear () clear_routes (); } -void -RouteProcessorSelection::clear_processors () -{ - processors.clear (); - ProcessorsChanged (); -} - void RouteProcessorSelection::clear_routes () { - PresentationInfo::ChangeSuspender cs; - - for (AxisViewSelection::iterator i = axes.begin(); i != axes.end(); ++i) { - (*i)->set_selected (false); + if (shp.session()) { + PresentationInfo::ChangeSuspender cs; + shp.session()->selection().clear_stripables (); } - axes.clear (); - drop_connections (); } -void -RouteProcessorSelection::add (XMLNode* node) +std::list +RouteProcessorSelection::add_grouped_tracks (AxisView* r) const { - // XXX check for duplicate - processors.add (node); - ProcessorsChanged(); + 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 -RouteProcessorSelection::set (XMLNode* node) +RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed) { - clear_processors (); - processors.set (node); - ProcessorsChanged (); + Session* s = shp.session(); + + if (!s) { + /* too early ... session handle provider doesn't know about the + session yet. + */ + return; + } + + 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 -RouteProcessorSelection::add (AxisView* r) +RouteProcessorSelection::add (AxisView* r, bool with_groups) { - if (axes.insert (r).second) { - - r->set_selected (true); + if (!shp.session()) { + return; + } - MixerStrip* ms = dynamic_cast (r); + std::list avl; + if (with_groups) { + avl= add_grouped_tracks (r); + } + avl.push_back (r); - if (ms) { - ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context()); + 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 -RouteProcessorSelection::remove (AxisView* r) +RouteProcessorSelection::remove (AxisView* r, bool with_groups) { + if (!shp.session()) { + return; + } ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); - PresentationInfo::ChangeSuspender cs; - AxisViewSelection::iterator i; - if ((i = find (axes.begin(), axes.end(), r)) != axes.end()) { - (*i)->set_selected (false); - axes.erase (i); + 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) { + shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr()); } } void RouteProcessorSelection::set (AxisView* r) { + if (!shp.session()) { + return; + } PresentationInfo::ChangeSuspender cs; - clear_routes (); - add (r); + shp.session()->selection().clear_stripables (); + add (r, true); } bool