Rudimentary automation touch undo/redo.
authornick_m <mainsbridge@gmail.com>
Sat, 13 Jun 2015 19:17:25 +0000 (05:17 +1000)
committernick_m <mainsbridge@gmail.com>
Tue, 16 Jun 2015 23:54:22 +0000 (09:54 +1000)
libs/ardour/ardour/automation_control.h
libs/ardour/automation_control.cc

index 24a9e0de3ee84fd497afad4abbf006d52c65f904..5d73e4aef959107d80613b5c96ac804a63eacdc1 100644 (file)
@@ -101,6 +101,7 @@ protected:
        ARDOUR::Session& _session;
 
        const ParameterDescriptor _desc;
+       XMLNode* _before; //used for undo of touch start/stop pairs.
 };
 
 
index da33ad12a52ed1b21e8d8f187cd6a4cb33d47667..4ece7902483cb3e1e116c3f8e9a4cc4d0d47db3d 100644 (file)
 */
 
 #include <iostream>
-
 #include "ardour/automation_control.h"
 #include "ardour/automation_watch.h"
 #include "ardour/event_type_map.h"
 #include "ardour/session.h"
 
+#include "pbd/memento_command.h"
+
+#include "i18n.h"
+
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
@@ -118,6 +121,7 @@ AutomationControl::start_touch(double when)
                if (alist()->automation_state() == Touch) {
                        /* subtle. aligns the user value with the playback */
                        set_value (get_value ());
+                       _before = &alist ()->get_state ();
                        alist()->start_touch (when);
                        if (!_desc.toggled) {
                                AutomationWatch::instance().add_automation_watch (shared_from_this());
@@ -138,6 +142,10 @@ AutomationControl::stop_touch(bool mark, double when)
                        if (!_desc.toggled) {
                                AutomationWatch::instance().remove_automation_watch (shared_from_this());
                        }
+
+                       _session.begin_reversible_command (_("record automation controller"));
+                       _session.add_command (new MementoCommand<AutomationList> (*alist ().get (), _before, &alist ()->get_state ()));
+                       _session.commit_reversible_command ();
                }
        }
 }