X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Froute_processor_selection.cc;h=1b4c0c538bf7f769dc40b60b35621e04359b8887;hb=d9d0c6b0b31bda271df216a90b16c9b4b228af28;hp=4e934b0a3c7008fa8a17ad635e2df4357a5874cc;hpb=f450df300c9c057141a4caf79ff6dbfbf58492d9;p=ardour.git diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index 4e934b0a3c..1b4c0c538b 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -25,8 +25,10 @@ #include "ardour/processor.h" #include "ardour/route.h" -#include "route_processor_selection.h" #include "gui_thread.h" +#include "mixer_strip.h" +#include "route_processor_selection.h" +#include "route_ui.h" #include "i18n.h" @@ -34,8 +36,13 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -RouteRedirectSelection& -RouteRedirectSelection::operator= (const RouteRedirectSelection& other) +RouteProcessorSelection::RouteProcessorSelection() + : _no_route_change_signal (false) +{ +} + +RouteProcessorSelection& +RouteProcessorSelection::operator= (const RouteProcessorSelection& other) { if (&other != this) { processors = other.processors; @@ -45,36 +52,41 @@ RouteRedirectSelection::operator= (const RouteRedirectSelection& other) } 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; } void -RouteRedirectSelection::clear () +RouteProcessorSelection::clear () { clear_processors (); clear_routes (); } void -RouteRedirectSelection::clear_processors () +RouteProcessorSelection::clear_processors () { processors.clear (); ProcessorsChanged (); } void -RouteRedirectSelection::clear_routes () +RouteProcessorSelection::clear_routes () { + for (RouteUISelection::iterator i = routes.begin(); i != routes.end(); ++i) { + (*i)->set_selected (false); + } routes.clear (); drop_connections (); - RoutesChanged (); + if (!_no_route_change_signal) { + RoutesChanged (); + } } void -RouteRedirectSelection::add (XMLNode* node) +RouteProcessorSelection::add (XMLNode* node) { // XXX check for duplicate processors.add (node); @@ -82,7 +94,7 @@ RouteRedirectSelection::add (XMLNode* node) } void -RouteRedirectSelection::set (XMLNode* node) +RouteProcessorSelection::set (XMLNode* node) { clear_processors (); processors.set (node); @@ -90,55 +102,61 @@ RouteRedirectSelection::set (XMLNode* node) } void -RouteRedirectSelection::add (boost::shared_ptr r) +RouteProcessorSelection::add (RouteUI* r) { if (find (routes.begin(), routes.end(), r) == routes.end()) { - routes.push_back (r); - r->GoingAway.connect (*this, boost::bind (&RouteRedirectSelection::removed, this, boost::weak_ptr(r)), gui_context()); - RoutesChanged(); + if (routes.insert (r).second) { + r->set_selected (true); + + MixerStrip* ms = dynamic_cast (r); + + if (ms) { + ms->CatchDeletion.connect (*this, invalidator (*this), ui_bind (&RouteProcessorSelection::remove, this, _1), gui_context()); + } + + if (!_no_route_change_signal) { + RoutesChanged(); + } + } } } void -RouteRedirectSelection::removed (boost::weak_ptr wr) +RouteProcessorSelection::remove (RouteUI* r) { - boost::shared_ptr r (wr.lock()); - - if (!r) { - return; - } + ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); - remove (r); -} - -void -RouteRedirectSelection::remove (boost::shared_ptr r) -{ - ENSURE_GUI_THREAD (*this, &RouteRedirectSelection::remove, r); - - list >::iterator i; + RouteUISelection::iterator i; if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { routes.erase (i); - RoutesChanged (); + (*i)->set_selected (false); + if (!_no_route_change_signal) { + RoutesChanged (); + } } } void -RouteRedirectSelection::set (boost::shared_ptr r) +RouteProcessorSelection::set (RouteUI* r) { clear_routes (); add (r); } bool -RouteRedirectSelection::selected (boost::shared_ptr r) +RouteProcessorSelection::selected (RouteUI* r) { return find (routes.begin(), routes.end(), r) != routes.end(); } bool -RouteRedirectSelection::empty () +RouteProcessorSelection::empty () { return processors.empty () && routes.empty (); } +void +RouteProcessorSelection::block_routes_changed (bool yn) +{ + _no_route_change_signal = yn; +}