open un-writable sessions without complaining, and desensitize all/most actions that...
[ardour.git] / gtk2_ardour / gain_automation_time_axis.cc
index 8f41f5def093092422a4418a11b2910ae6bb9cb4..9890854d4b91e2ec7e42ffd0b4c1e495955285f5 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <ardour/curve.h>
 #include <ardour/route.h>
+#include <pbd/memento_command.h>
 
 #include "gain_automation_time_axis.h"
 #include "automation_line.h"
@@ -31,7 +31,9 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace Gtk;
 
-GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, ArdourCanvas::Canvas& canvas, const 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, canvas, n, X_("gain"), ""),
@@ -45,7 +47,7 @@ GainAutomationTimeAxisView::~GainAutomationTimeAxisView ()
 }
 
 void
-GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* 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;
 
@@ -60,11 +62,10 @@ GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkE
        lines.front()->view_to_model_y (y);
 
        _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());
-       _session.commit_reversible_command ();
+        XMLNode& after = curve.get_state();
+       _session.commit_reversible_command (new MementoCommand<ARDOUR::Curve>(curve, &before, &after));
        _session.set_dirty ();
 }
 
@@ -72,6 +73,6 @@ void
 GainAutomationTimeAxisView::set_automation_state (AutoState state)
 {
        if (!ignore_state_request) {
-               route.set_gain_automation_state (state);
+               route->set_gain_automation_state (state);
        }
 }