From 2dafaad193f12d282076610ed1ebf1f1bf235ced Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 13 Nov 2006 00:50:28 +0000 Subject: [PATCH] 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 --- gtk2_ardour/audio_region_editor.cc | 45 +++++++++++++++++++++++++++--- 1 file 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 + #include +#include #include #include #include @@ -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(*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(*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(*pl, &before, &after)); + } + + _session.commit_reversible_command (); length_clock.set (_region->length()); }