AudioUnit work.
[ardour.git] / gtk2_ardour / automation_line.cc
index 37244956927c7a419da05ec8d56512617b100c47..4cf6779c9827406ff76f672a2357e04d3dabd962 100644 (file)
@@ -23,6 +23,7 @@
 #include <vector>
 
 #include <pbd/stl_delete.h>
+#include <pbd/memento_command.h>
 
 #include <ardour/automation_event.h>
 #include <ardour/curve.h>
@@ -48,6 +49,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace Gnome; // for Canvas
 
@@ -217,7 +219,7 @@ ControlPoint::move_to (double x, double y, ShapeType shape)
 
 /*****/
 
-AutomationLine::AutomationLine (stringcr_t name, TimeAxisView& tv, ArdourCanvas::Group& parent, AutomationList& al)
+AutomationLine::AutomationLine (const string & name, TimeAxisView& tv, ArdourCanvas::Group& parent, AutomationList& al)
        : trackview (tv),
          _name (name),
          alist (al),
@@ -886,7 +888,7 @@ AutomationLine::start_drag (ControlPoint* cp, float fraction)
        }
 
        trackview.editor.current_session()->begin_reversible_command (str);
-       trackview.editor.current_session()->add_undo (get_memento());
+       trackview.editor.current_session()->add_command (new MementoUndoCommand<AutomationLine>(*this, get_state()));
        
        first_drag_fraction = fraction;
        last_drag_fraction = fraction;
@@ -935,7 +937,7 @@ AutomationLine::end_drag (ControlPoint* cp)
 
                update_pending = false;
 
-               trackview.editor.current_session()->add_redo_no_execute (get_memento());
+               trackview.editor.current_session()->add_command (new MementoRedoCommand<AutomationLine>(*this, get_state()));
                trackview.editor.current_session()->commit_reversible_command ();
                trackview.editor.current_session()->set_dirty ();
        }
@@ -1012,11 +1014,11 @@ AutomationLine::remove_point (ControlPoint& cp)
        model_representation (cp, mr);
 
        trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
-       trackview.editor.current_session()->add_undo (get_memento());
+        XMLNode &before = get_state();
 
        alist.erase (mr.start, mr.end);
 
-       trackview.editor.current_session()->add_redo_no_execute (get_memento());
+       trackview.editor.current_session()->add_command(new MementoCommand<AutomationLine>(*this, before, get_state()));
        trackview.editor.current_session()->commit_reversible_command ();
        trackview.editor.current_session()->set_dirty ();
 }
@@ -1224,9 +1226,9 @@ void
 AutomationLine::clear ()
 {
        /* parent must create command */
-       trackview.editor.current_session()->add_undo (get_memento());
+        XMLNode &before = get_state();
        alist.clear();
-       trackview.editor.current_session()->add_redo_no_execute (get_memento());
+       trackview.editor.current_session()->add_command (new MementoCommand<AutomationLine>(*this, before, get_state()));
        trackview.editor.current_session()->commit_reversible_command ();
        trackview.editor.current_session()->set_dirty ();
 }
@@ -1265,3 +1267,15 @@ AutomationLine::hide_all_but_selected_control_points ()
                }
        }
 }
+
+XMLNode &AutomationLine::get_state(void)
+{
+    // TODO
+    return alist.get_state();
+}
+
+int AutomationLine::set_state(const XMLNode &node)
+{
+    // TODO
+    alist.set_state(node);
+}