Fix relative grouped + VCA slaved gain
[ardour.git] / libs / ardour / selection.cc
index 1c0e89fdf035b1ffae1271b29ae1512e90750164..3193b12b20d29dbf39acd5aca631db98be0828af 100644 (file)
@@ -17,6 +17,8 @@
 
 */
 
+#include <vector>
+
 #include "pbd/compose.h"
 #include "pbd/signals.h"
 
@@ -79,6 +81,13 @@ CoreSelection::add (boost::shared_ptr<Stripable> s, boost::shared_ptr<Automation
 
        if (send) {
                send_selection_change ();
+               /* send per-object signal to notify interested parties
+                  the selection status has changed
+               */
+               if (s) {
+                       PropertyChange pc (Properties::selected);
+                       s->PropertyChanged (pc);
+               }
        }
 }
 
@@ -102,6 +111,13 @@ CoreSelection::remove (boost::shared_ptr<Stripable> s, boost::shared_ptr<Automat
 
        if (send) {
                send_selection_change ();
+               /* send per-object signal to notify interested parties
+                  the selection status has changed
+               */
+               if (s) {
+                       PropertyChange pc (Properties::selected);
+                       s->PropertyChanged (pc);
+               }
        }
 }
 
@@ -123,20 +139,39 @@ CoreSelection::set (boost::shared_ptr<Stripable> s, boost::shared_ptr<Automation
        }
 
        send_selection_change ();
+
+       /* send per-object signal to notify interested parties
+          the selection status has changed
+       */
+       if (s) {
+               PropertyChange pc (Properties::selected);
+               s->PropertyChanged (pc);
+       }
 }
 
 void
 CoreSelection::clear_stripables ()
 {
        bool send = false;
+       std::vector<boost::shared_ptr<Stripable> > 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<Stripable> 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");
                }
@@ -144,6 +179,13 @@ CoreSelection::clear_stripables ()
 
        if (send) {
                send_selection_change ();
+
+               PropertyChange pc (Properties::selected);
+
+               for (std::vector<boost::shared_ptr<Stripable> >::iterator ss = s.begin(); ss != s.end(); ++ss) {
+                       (*ss)->PropertyChanged (pc);
+               }
+
        }
 }
 
@@ -217,9 +259,11 @@ CoreSelection::get_stripables (StripableAutomationControls& sc) const
                boost::shared_ptr<AutomationControl> c;
 
                if (!s) {
+                       /* some global automation control, not owned by a Stripable */
                        c = session.automation_control_by_id ((*x).controllable);
                } else {
-                       c = s->automation_control ((*x).controllable);
+                       /* automation control owned by a Stripable or one of its children */
+                       c = s->automation_control_recurse ((*x).controllable);
                }
 
                if (s || c) {
@@ -325,4 +369,3 @@ CoreSelection::selected () const
        Glib::Threads::RWLock::ReaderLock lm (_lock);
        return _stripables.size();
 }
-