Make MIDI region `automation' respect the automation mode so that it is
[ardour.git] / libs / ardour / automatable.cc
index 1ef39a61f0df82dfd81f9481b214c1c336cd9641..1e5b497bf7458901beb362a5e4c27f644e246505 100644 (file)
@@ -49,6 +49,18 @@ Automatable::Automatable(Session& session)
 {
 }
 
+Automatable::Automatable (const Automatable& other)
+        : ControlSet (other)
+        , _a_session (other._a_session)
+        , _last_automation_snapshot (0)
+{
+        Glib::Mutex::Lock lm (other._control_lock);
+
+        for (Controls::const_iterator i = other._controls.begin(); i != other._controls.end(); ++i) {
+                boost::shared_ptr<Evoral::Control> ac (control_factory (i->first));
+                _controls[ac->parameter()] = ac;
+        }
+}
 int
 Automatable::old_set_automation_state (const XMLNode& node)
 {
@@ -138,6 +150,16 @@ Automatable::add_control(boost::shared_ptr<Evoral::Control> ac)
        ControlSet::add_control(ac);
        _can_automate_list.insert(param);
        auto_state_changed(param); // sync everything up
+
+       /* connect to automation_state_changed so that we can emit a signal when one of our controls'
+          automation state changes
+       */
+       boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl> (ac);
+       if (c) {
+               c->alist()->automation_state_changed.connect_same_thread (
+                       _control_connections, boost::bind (&Automatable::automation_state_changed, this, c->parameter())
+                       );
+       }
 }
 
 void
@@ -457,3 +479,8 @@ Automatable::automation_control (const Evoral::Parameter& id) const
        return boost::dynamic_pointer_cast<const AutomationControl>(Evoral::ControlSet::control(id));
 }
 
+void
+Automatable::automation_state_changed (Evoral::Parameter const & p)
+{
+       AutomationStateChanged (p); /* EMIT SIGNAL */
+}