extensive changes to PresentationInfo API
[ardour.git] / libs / ardour / automatable.cc
index 3c5d610ce88eaf7f1b4ffccfca4d8846741c18fd..e108676fa7b5f6096b0a7667952b20d0031f5c50 100644 (file)
 #include "ardour/automatable.h"
 #include "ardour/event_type_map.h"
 #include "ardour/gain_control.h"
+#include "ardour/monitor_control.h"
 #include "ardour/midi_track.h"
 #include "ardour/pan_controllable.h"
 #include "ardour/pannable.h"
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
+#include "ardour/record_enable_control.h"
 #include "ardour/session.h"
 #include "ardour/uri_map.h"
 #include "ardour/value_as_string.h"
@@ -77,7 +79,7 @@ Automatable::~Automatable ()
 int
 Automatable::old_set_automation_state (const XMLNode& node)
 {
-       const XMLProperty *prop;
+       XMLProperty const * prop;
 
        if ((prop = node.property ("path")) != 0) {
                load_automation (prop->value());
@@ -148,7 +150,9 @@ Automatable::add_control(boost::shared_ptr<Evoral::Control> ac)
 
        boost::shared_ptr<AutomationList> al = boost::dynamic_pointer_cast<AutomationList> (ac->list ());
 
-       if (al) {
+       boost::shared_ptr<AutomationControl> actl (boost::dynamic_pointer_cast<AutomationControl> (ac));
+
+       if ((!actl || !(actl->flags() & Controllable::NotAutomatable)) && al) {
                al->automation_state_changed.connect_same_thread (
                        _list_connections,
                        boost::bind (&Automatable::automation_list_automation_state_changed,
@@ -157,7 +161,7 @@ Automatable::add_control(boost::shared_ptr<Evoral::Control> ac)
 
        ControlSet::add_control (ac);
 
-       if (al) {
+       if ((!actl || !(actl->flags() & Controllable::NotAutomatable)) && al) {
                _can_automate_list.insert (param);
                automation_list_automation_state_changed (param, al->automation_state ()); // sync everything up
        }
@@ -220,7 +224,7 @@ Automatable::set_automation_xml_state (const XMLNode& node, Evoral::Parameter le
 
                if ((*niter)->name() == "AutomationList") {
 
-                       const XMLProperty* id_prop = (*niter)->property("automation-id");
+                       XMLProperty const * id_prop = (*niter)->property("automation-id");
 
                        Evoral::Parameter param = (id_prop
                                        ? EventTypeMap::instance().from_symbol(id_prop->value())
@@ -420,6 +424,7 @@ Automatable::control_factory(const Evoral::Parameter& param)
        bool                              make_list = true;
        ParameterDescriptor               desc(param);
        boost::shared_ptr<AutomationList> list;
+
        if (param.type() >= MidiCCAutomation && param.type() <= MidiChannelPressureAutomation) {
                MidiTrack* mt = dynamic_cast<MidiTrack*>(this);
                if (mt) {
@@ -460,6 +465,27 @@ Automatable::control_factory(const Evoral::Parameter& param)
                } else {
                        warning << "PanAutomation for non-Pannable" << endl;
                }
+       } else if (param.type() == RecEnableAutomation) {
+               Recordable* re = dynamic_cast<Recordable*> (this);
+               if (re) {
+                       control = new RecordEnableControl (_a_session, X_("recenable"), *re);
+               }
+       } else if (param.type() == MonitoringAutomation) {
+               Monitorable* m = dynamic_cast<Monitorable*>(this);
+               if (m) {
+                       control = new MonitorControl (_a_session, X_("monitor"), *m);
+               }
+       } else if (param.type() == SoloAutomation) {
+               Soloable* s = dynamic_cast<Soloable*>(this);
+               Muteable* m = dynamic_cast<Muteable*>(this);
+               if (s && m) {
+                       control = new SoloControl (_a_session, X_("solo"), *s, *m);
+               }
+       } else if (param.type() == MuteAutomation) {
+               Muteable* m = dynamic_cast<Muteable*>(this);
+               if (m) {
+                       control = new MuteControl (_a_session, X_("mute"), *m);
+               }
        }
 
        if (make_list && !list) {
@@ -493,7 +519,7 @@ Automatable::clear_controls ()
 }
 
 string
-Automatable::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+Automatable::value_as_string (boost::shared_ptr<const AutomationControl> ac) const
 {
        return ARDOUR::value_as_string(ac->desc(), ac->get_value());
 }