From 5830ddfec2f9a4293d3eef55f3817099d5e74fde Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 May 2017 10:04:07 +0100 Subject: emit per-Stateful PropertyChanged signal when Stripables become selected --- libs/ardour/selection.cc | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/libs/ardour/selection.cc b/libs/ardour/selection.cc index 2286c83751..6ae32d497e 100644 --- a/libs/ardour/selection.cc +++ b/libs/ardour/selection.cc @@ -17,6 +17,8 @@ */ +#include + #include "pbd/compose.h" #include "pbd/signals.h" @@ -71,6 +73,13 @@ CoreSelection::add (boost::shared_ptr s, boost::shared_ptrname(), c)); + /* send per-object signal to notify interested parties + the selection status has changed + */ + if (s) { + PropertyChange pc (Properties::selected); + s->PropertyChanged (pc); + } send = true; } else { DEBUG_TRACE (DEBUG::Selection, string_compose ("%1/%2 already in s/c selection\n", s->name(), c)); @@ -96,6 +105,13 @@ CoreSelection::remove (boost::shared_ptr s, boost::shared_ptrPropertyChanged (pc); + } send = true; } } @@ -120,6 +136,13 @@ CoreSelection::set (boost::shared_ptr s, boost::shared_ptrname(), c)); + /* send per-object signal to notify interested parties + the selection status has changed + */ + if (s) { + PropertyChange pc (Properties::selected); + s->PropertyChanged (pc); + } } send_selection_change (); @@ -129,20 +152,37 @@ void CoreSelection::clear_stripables () { bool send = false; + std::vector > s; DEBUG_TRACE (DEBUG::Selection, "clearing s/c selection\n"); - { Glib::Threads::RWLock::WriterLock lm (_lock); if (!_stripables.empty()) { + + s.reserve (_stripables.size()); + + for (SelectedStripables::const_iterator x = _stripables.begin(); x != _stripables.end(); ++x) { + boost::shared_ptr sp = session.stripable_by_id ((*x).stripable); + if (sp) { + s.push_back (sp); + } + } + _stripables.clear (); + send = true; DEBUG_TRACE (DEBUG::Selection, "cleared s/c selection\n"); } } if (send) { + PropertyChange pc (Properties::selected); + + for (std::vector >::iterator ss = s.begin(); ss != s.end(); ++ss) { + (*ss)->PropertyChanged (pc); + } + send_selection_change (); } } @@ -327,4 +367,3 @@ CoreSelection::selected () const Glib::Threads::RWLock::ReaderLock lm (_lock); return _stripables.size(); } - -- cgit v1.2.3