Merged with trunk R992.
[ardour.git] / gtk2_ardour / gain_automation_time_axis.cc
index d1780168d5c8fd013ccd7bf28c0b221c0ebf8eae..7e4a1b1fbf169eccdeb9802f7b54d499dbdf07a0 100644 (file)
 
 #include <ardour/curve.h>
 #include <ardour/route.h>
+#include <pbd/memento_command.h>
 
 #include "gain_automation_time_axis.h"
 #include "automation_line.h"
+#include "canvas.h"
 
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
-GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Widget* p, std::string n, ARDOUR::Curve& c)
+GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, 
+                                                       PublicEditor& e, TimeAxisView& parent, 
+                                                       ArdourCanvas::Canvas& canvas, const string & n, ARDOUR::Curve& c)
 
        : AxisView (s),
-         AutomationTimeAxisView (s, r, e, parent, p, n, X_("gain"), ""),
+         AutomationTimeAxisView (s, r, e, parent, canvas, n, X_("gain"), ""),
          curve (c)
        
 {
@@ -43,7 +48,7 @@ GainAutomationTimeAxisView::~GainAutomationTimeAxisView ()
 }
 
 void
-GainAutomationTimeAxisView::add_automation_event (GnomeCanvasItem* item, GdkEvent* event, jack_nframes_t when, double y)
+GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEvent* event, nframes_t when, double y)
 {
        double x = 0;
 
@@ -59,9 +64,10 @@ GainAutomationTimeAxisView::add_automation_event (GnomeCanvasItem* item, GdkEven
 
        _session.begin_reversible_command (_("add gain automation event"));
 
-       _session.add_undo (curve.get_memento());
+        XMLNode &before = curve.get_state();
        curve.add (when, y);
-       _session.add_redo_no_execute (curve.get_memento());
+        XMLNode &after = curve.get_state();
+        _session.add_command(new MementoCommand<ARDOUR::Curve>(curve, &before, &after));
        _session.commit_reversible_command ();
        _session.set_dirty ();
 }
@@ -70,6 +76,6 @@ void
 GainAutomationTimeAxisView::set_automation_state (AutoState state)
 {
        if (!ignore_state_request) {
-               route.set_gain_automation_state (state);
+               route->set_gain_automation_state (state);
        }
 }