summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorHans Fugal <hans@fugal.net>2006-07-26 23:28:54 +0000
committerHans Fugal <hans@fugal.net>2006-07-26 23:28:54 +0000
commit8e301e875aacc4b7d37f6ed552e460511dafb7f2 (patch)
tree702f85ec8edf8a97a4509b6351e52650bd803504 /gtk2_ardour
parentb7bffbe7a249356a93d25a41f7c472cc9dd8f27f (diff)
r199@gandalf: fugalh | 2006-07-26 17:22:38 -0600
Memento(Redo|Undo)Command has a noop for the undo or redo respectively, and we don't need both before and after state. This is primarily useful for drag start/finish callbacks, and really only makes sense where wrapped by (begin|commit)_reversible_command (a composite command). Also a few more "normal" MementoCommands. git-svn-id: svn://localhost/ardour2/branches/undo@695 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/audio_time_axis.cc10
-rw-r--r--gtk2_ardour/automation_line.cc5
-rw-r--r--gtk2_ardour/automation_time_axis.cc14
-rw-r--r--gtk2_ardour/editor_mouse.cc17
-rw-r--r--gtk2_ardour/editor_ops.cc4
5 files changed, 27 insertions, 23 deletions
diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc
index 7fbe7c9fd8..ebc97be77b 100644
--- a/gtk2_ardour/audio_time_axis.cc
+++ b/gtk2_ardour/audio_time_axis.cc
@@ -1739,12 +1739,14 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
}
}
+ XMLNode &before, &after;
switch (op) {
case Cut:
- _session.add_undo (playlist->get_memento());
+ before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) {
editor.get_cut_buffer().add (what_we_got);
- _session.add_redo_no_execute (playlist->get_memento());
+ after = playlist->get_state();
+ _session.add_command (MementoCommand<Playlist>(*playlist, before, after));
ret = true;
}
break;
@@ -1755,9 +1757,9 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
break;
case Clear:
- _session.add_undo (playlist->get_memento());
+ before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) {
- _session.add_redo_no_execute (playlist->get_memento());
+ _session.add_command(MementoCommand<Playlist>(*playlist, before, after));
what_we_got->unref ();
ret = true;
}
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index f5b23f01ae..bd7ed326d8 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -887,7 +887,7 @@ AutomationLine::start_drag (ControlPoint* cp, float fraction)
}
trackview.editor.current_session()->begin_reversible_command (str);
- trackview.editor.current_session()->add_undo (get_memento());
+ trackview.editor.current_session()->add_command (MementoUndoCommand<AutomationLine>(*this, get_state()));
first_drag_fraction = fraction;
last_drag_fraction = fraction;
@@ -936,7 +936,7 @@ AutomationLine::end_drag (ControlPoint* cp)
update_pending = false;
- trackview.editor.current_session()->add_redo_no_execute (get_memento());
+ trackview.editor.current_session()->add_command (MementoRedoCommand<AutomationLine>(*this, get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
@@ -1226,7 +1226,6 @@ AutomationLine::clear ()
{
/* parent must create command */
XMLNode &before = get_state();
- trackview.editor.current_session()->add_undo (get_memento());
alist.clear();
trackview.editor.current_session()->add_command (MementoCommand<AutomationLine>(*this, before, get_state()));
trackview.editor.current_session()->commit_reversible_command ();
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index f4b9aaaf7b..4680e3a35f 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -500,13 +500,14 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
AutomationList& alist (line.the_list());
bool ret = false;
- _session.add_undo (alist.get_memento());
+ XMLNode &before, &after;
+ before = alist.get_state();
switch (op) {
case Cut:
if ((what_we_got = alist.cut (selection.time.front().start, selection.time.front().end)) != 0) {
editor.get_cut_buffer().add (what_we_got);
- _session.add_redo_no_execute (alist.get_memento());
+ _session.add_command(MementoCommand<AutomationList>(alist, before, alist.get_state()));
ret = true;
}
break;
@@ -518,7 +519,7 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
case Clear:
if ((what_we_got = alist.cut (selection.time.front().start, selection.time.front().end)) != 0) {
- _session.add_redo_no_execute (alist.get_memento());
+ _session.add_command(MementoCommand<AutomationList>(alist, before, alist.get_state()));
delete what_we_got;
what_we_got = 0;
ret = true;
@@ -580,8 +581,9 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
AutomationList* what_we_got = 0;
AutomationList& alist (line.the_list());
bool ret = false;
+ XMLNode &before, &after;
- _session.add_undo (alist.get_memento());
+ before = alist.get_state();
for (PointSelection::iterator i = selection.begin(); i != selection.end(); ++i) {
@@ -593,7 +595,7 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
case Cut:
if ((what_we_got = alist.cut ((*i).start, (*i).end)) != 0) {
editor.get_cut_buffer().add (what_we_got);
- _session.add_redo_no_execute (alist.get_memento());
+ _session.add_command (MementoCommand<AutomationList>(alist, before, alist.get_state()));
ret = true;
}
break;
@@ -605,7 +607,7 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
case Clear:
if ((what_we_got = alist.cut ((*i).start, (*i).end)) != 0) {
- _session.add_redo_no_execute (alist.get_memento());
+ _session.add_command (MementoCommand<AutomationList>(alist, before, alist.get_state()));
delete what_we_got;
what_we_got = 0;
ret = true;
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index e4d8ec6ce6..4b17c9e6b0 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -2787,7 +2787,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
insert_result = affected_playlists.insert (to_playlist);
if (insert_result.second) {
- session->add_undo (to_playlist->get_memento ());
+ session->add_command (MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
}
latest_regionview = 0;
@@ -3225,7 +3225,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) {
pl->freeze();
- session->add_undo(pl->get_memento());
+ session->add_command(MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -3353,7 +3353,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
insert_result = motion_frozen_playlists.insert(to_playlist);
if (insert_result.second) {
to_playlist->freeze();
- session->add_undo(to_playlist->get_memento());
+ session->add_command(MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
}
}
@@ -3435,7 +3435,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
out:
for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
(*p)->thaw ();
- session->add_redo_no_execute ((*p)->get_memento());
+ session->add_command (MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
}
motion_frozen_playlists.clear ();
@@ -3997,7 +3997,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
Playlist * pl = (*i)->region.playlist();
insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) {
- session->add_undo (pl->get_memento());
+ session->add_command(MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -4187,8 +4187,8 @@ Editor::trim_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
//(*p)->thaw ();
- session->add_redo_no_execute ((*p)->get_memento());
- }
+ session->add_command (MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
+ }
motion_frozen_playlists.clear ();
@@ -4293,7 +4293,8 @@ Editor::thaw_region_after_trim (AudioRegionView& rv)
}
region.thaw (_("trimmed region"));
- session->add_redo_no_execute (region.playlist()->get_memento());
+ XMLNode &after = region.playlist()->get_state();
+ session->add_command (MementoRedoCommand<Playlist>(*(region.playlist()), after));
rv.unhide_envelope ();
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 579b2403c6..815d50ae3e 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2997,7 +2997,7 @@ Editor::cut_copy_regions (CutCopyOp op)
insert_result = freezelist.insert (pl);
if (insert_result.second) {
pl->freeze ();
- session->add_undo (pl->get_memento());
+ session->add_command (MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -3055,7 +3055,7 @@ Editor::cut_copy_regions (CutCopyOp op)
for (set<Playlist*>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
(*pl)->thaw ();
- session->add_redo_no_execute ((*pl)->get_memento());
+ session->add_command (MementoRedoCommand<Playlist>(*(*pl), *(*pl)->get_state()));
}
}