summaryrefslogtreecommitdiff
path: root/gtk2_ardour/audio_region_editor.cc
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2006-11-13 00:50:28 +0000
committerTim Mayberry <mojofunk@gmail.com>2006-11-13 00:50:28 +0000
commit2dafaad193f12d282076610ed1ebf1f1bf235ced (patch)
tree1a77728385e18af3566ece2fdeef01b1ab3cbcbb /gtk2_ardour/audio_region_editor.cc
parent3b42be5d4056bfa4125c3f76e9efa2be95e6462e (diff)
Fix for bug #255, Implement undo/redo when changing the region start position
in the Audio region editor, also added for when changing the end and length clocks. git-svn-id: svn://localhost/ardour2/trunk@1120 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/audio_region_editor.cc')
-rw-r--r--gtk2_ardour/audio_region_editor.cc45
1 files changed, 41 insertions, 4 deletions
diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc
index 77b73027d1..962225ed3b 100644
--- a/gtk2_ardour/audio_region_editor.cc
+++ b/gtk2_ardour/audio_region_editor.cc
@@ -18,7 +18,10 @@
$Id$
*/
+#include <pbd/memento_command.h>
+
#include <ardour/audioregion.h>
+#include <ardour/playlist.h>
#include <ardour/utils.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/stop_signal.h>
@@ -282,7 +285,7 @@ AudioRegionEditor::breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (Au
void
AudioRegionEditor::connect_editor_events ()
{
- name_entry.signal_changed().connect (mem_fun(*this, &AudioRegionEditor::name_entry_changed));
+ name_entry.signal_changed().connect (mem_fun(*this, &AudioRegionEditor::name_entry_changed));
start_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::start_clock_changed));
end_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::end_clock_changed));
@@ -303,13 +306,35 @@ AudioRegionEditor::connect_editor_events ()
void
AudioRegionEditor::start_clock_changed ()
{
- _region->set_position (start_clock.current_time(), this);
+ _session.begin_reversible_command (_("change region start position"));
+
+ Playlist* const pl = _region->playlist();
+
+ if (pl) {
+ XMLNode &before = pl->get_state();
+ _region->set_position (start_clock.current_time(), this);
+ XMLNode &after = pl->get_state();
+ _session.add_command(new MementoCommand<Playlist>(*pl, &before, &after));
+ }
+
+ _session.commit_reversible_command ();
}
void
AudioRegionEditor::end_clock_changed ()
{
- _region->trim_end (end_clock.current_time(), this);
+ _session.begin_reversible_command (_("change region end position"));
+
+ Playlist* const pl = _region->playlist();
+
+ if (pl) {
+ XMLNode &before = pl->get_state();
+ _region->trim_end (end_clock.current_time(), this);
+ XMLNode &after = pl->get_state();
+ _session.add_command(new MementoCommand<Playlist>(*pl, &before, &after));
+ }
+
+ _session.commit_reversible_command ();
end_clock.set (_region->position() + _region->length(), true);
}
@@ -318,7 +343,19 @@ void
AudioRegionEditor::length_clock_changed ()
{
nframes_t frames = length_clock.current_time();
- _region->trim_end (_region->position() + frames, this);
+
+ _session.begin_reversible_command (_("change region length"));
+
+ Playlist* const pl = _region->playlist();
+
+ if (pl) {
+ XMLNode &before = pl->get_state();
+ _region->trim_end (_region->position() + frames, this);
+ XMLNode &after = pl->get_state();
+ _session.add_command(new MementoCommand<Playlist>(*pl, &before, &after));
+ }
+
+ _session.commit_reversible_command ();
length_clock.set (_region->length());
}