Rudimentary ghost note when adding MIDI notes to a region, as per #3180.
[ardour.git] / gtk2_ardour / editor_keyboard.cc
index 69bfb3ba8af94bd395413ff016fd26ce0e30ae30..da6fadfe16bb4db7b5e93a3502669b087ca61b71 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2004 Paul Davis 
+    Copyright (C) 2004 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 */
 
+#include "pbd/memento_command.h"
+#include "pbd/stateful_diff_command.h"
+
 #include "ardour/audioregion.h"
 #include "ardour/playlist.h"
+#include "ardour/session.h"
 #include "ardour/location.h"
 
-#include "pbd/memento_command.h"
-
 #include "editor.h"
 #include "region_view.h"
 #include "selection.h"
@@ -32,6 +34,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 void
 Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, bool use_time_canvas, bool can_select)
@@ -51,11 +54,9 @@ Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, b
 
        /* any use of "keyboard mouse buttons" invalidates an existing grab
        */
-       
-       if (_drag) {
-               _drag->item()->ungrab (GDK_CURRENT_TIME);
-               delete _drag;
-               _drag = 0;
+
+       if (_drags->active ()) {
+               _drags->abort ();
        }
 
        if (doit) {
@@ -65,7 +66,7 @@ Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, b
                }
 
                track_canvas->window_to_world (x, y, worldx, worldy);
-               worldx += horizontal_adjustment.get_value();
+               worldx += horizontal_position();
                worldy += vertical_adjustment.get_value();
 
                ev.type = GDK_BUTTON_PRESS;
@@ -90,27 +91,22 @@ Editor::kbd_mute_unmute_region ()
 
                for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
 
-                       XMLNode &before = (*i)->region()->playlist()->get_state ();
+                       (*i)->region()->playlist()->clear_history ();
                        (*i)->region()->set_muted (!(*i)->region()->muted ());
-                       XMLNode &after = (*i)->region()->playlist()->get_state ();
-
-                       session->add_command (new MementoCommand<ARDOUR::Playlist>(*((*i)->region()->playlist()), &before, &after));
+                       _session->add_command (new StatefulDiffCommand ((*i)->region()->playlist()));
 
                }
 
                commit_reversible_command ();
 
        } else if (entered_regionview) {
-               
+
                begin_reversible_command (_("mute region"));
-               XMLNode &before = entered_regionview->region()->playlist()->get_state();
-               
+                entered_regionview->region()->playlist()->clear_history ();
                entered_regionview->region()->set_muted (!entered_regionview->region()->muted());
-               
-               XMLNode &after = entered_regionview->region()->playlist()->get_state();
-               session->add_command (new MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region()->playlist()), &before, &after));
+               _session->add_command (new StatefulDiffCommand (entered_regionview->region()->playlist()));
                commit_reversible_command();
-               
+
        }
 }
 
@@ -123,6 +119,6 @@ Editor::kbd_do_brush (GdkEvent *ev)
 void
 Editor::kbd_brush ()
 {
-       kbd_driver (mem_fun(*this, &Editor::kbd_do_brush), true, true, false);
+       kbd_driver (sigc::mem_fun(*this, &Editor::kbd_do_brush), true, true, false);
 }