summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Fugal <hans@fugal.net>2006-08-12 21:49:20 +0000
committerHans Fugal <hans@fugal.net>2006-08-12 21:49:20 +0000
commit57f7f71ce3c1acae5a50e903d2dd472743df8043 (patch)
tree6bb6ea6e16a17bbc5e96ecdc70d839ef7b3a955c
parentf995ac37860140c513e29c3bc58701474a7ed336 (diff)
r316@gandalf: fugalh | 2006-08-11 17:06:48 -0600
Reconstitution. Comiples, untested. git-svn-id: svn://localhost/ardour2/branches/undo@797 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/ardour_ui.cc1
-rw-r--r--gtk2_ardour/audio_region_view.cc4
-rw-r--r--gtk2_ardour/automation_line.cc11
-rw-r--r--gtk2_ardour/automation_time_axis.cc12
-rw-r--r--gtk2_ardour/editor.cc6
-rw-r--r--gtk2_ardour/editor_audio_import.cc2
-rw-r--r--gtk2_ardour/editor_keyboard.cc2
-rw-r--r--gtk2_ardour/editor_markers.cc14
-rw-r--r--gtk2_ardour/editor_mouse.cc48
-rw-r--r--gtk2_ardour/editor_ops.cc76
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc12
-rw-r--r--gtk2_ardour/editor_timefx.cc2
-rw-r--r--gtk2_ardour/gain_automation_time_axis.cc2
-rw-r--r--gtk2_ardour/location_ui.cc6
-rw-r--r--gtk2_ardour/pan_automation_time_axis.cc2
-rw-r--r--gtk2_ardour/redirect_automation_time_axis.cc2
-rw-r--r--gtk2_ardour/region_gain_line.cc8
-rw-r--r--gtk2_ardour/route_time_axis.cc6
-rw-r--r--gtk2_ardour/route_ui.cc4
-rw-r--r--libs/ardour/ardour/automation_event.h2
-rw-r--r--libs/ardour/ardour/curve.h2
-rw-r--r--libs/ardour/ardour/location.h1
-rw-r--r--libs/ardour/ardour/session.h11
-rw-r--r--libs/ardour/audio_diskstream.cc2
-rw-r--r--libs/ardour/automation_event.cc4
-rw-r--r--libs/ardour/curve.cc3
-rw-r--r--libs/ardour/session.cc25
-rw-r--r--libs/ardour/session_command.cc79
-rw-r--r--libs/ardour/session_state.cc62
-rw-r--r--libs/ardour/session_transport.cc2
-rw-r--r--libs/pbd/pbd/memento_command.h82
-rw-r--r--libs/pbd/pbd/stateful.h3
-rw-r--r--libs/pbd/undo.cc8
33 files changed, 335 insertions, 171 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 12c2d63b80..8a75396ed2 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -1488,6 +1488,7 @@ ARDOUR_UI::restore_state (string name)
name = session->name();
}
session->restore_state (name);
+ session->restore_history (name);
}
}
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc
index bdea3d39a2..915fa05750 100644
--- a/gtk2_ardour/audio_region_view.cc
+++ b/gtk2_ardour/audio_region_view.cc
@@ -906,13 +906,13 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
XMLNode &before = audio_region().get_state();
audio_region().set_envelope_active(true);
XMLNode &after = audio_region().get_state();
- trackview.session().add_command (new MementoCommand<AudioRegion>(audio_region(), before, after));
+ trackview.session().add_command (new MementoCommand<AudioRegion>(audio_region(), &before, &after));
}
audio_region().envelope().add (fx, y);
XMLNode &after = audio_region().envelope().get_state();
- trackview.session().add_command (new MementoCommand<Curve>(audio_region().envelope(), before, after));
+ trackview.session().add_command (new MementoCommand<Curve>(audio_region().envelope(), &before, &after));
trackview.session().commit_reversible_command ();
}
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index f3e30c4523..c0ba957af8 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -244,6 +244,9 @@ AutomationLine::AutomationLine (const string & name, TimeAxisView& tv, ArdourCan
line->signal_event().connect (mem_fun (*this, &AutomationLine::event_handler));
alist.StateChanged.connect (mem_fun(*this, &AutomationLine::list_changed));
+
+ trackview.session().register_with_memento_command_factory(_id, this);
+
}
AutomationLine::~AutomationLine ()
@@ -888,7 +891,7 @@ AutomationLine::start_drag (ControlPoint* cp, float fraction)
}
trackview.editor.current_session()->begin_reversible_command (str);
- trackview.editor.current_session()->add_command (new MementoUndoCommand<AutomationLine>(*this, get_state()));
+ trackview.editor.current_session()->add_command (new MementoCommand<AutomationLine>(*this, &get_state(), 0));
first_drag_fraction = fraction;
last_drag_fraction = fraction;
@@ -937,7 +940,7 @@ AutomationLine::end_drag (ControlPoint* cp)
update_pending = false;
- trackview.editor.current_session()->add_command (new MementoRedoCommand<AutomationLine>(*this, get_state()));
+ trackview.editor.current_session()->add_command (new MementoCommand<AutomationLine>(*this, 0, &get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
@@ -1018,7 +1021,7 @@ AutomationLine::remove_point (ControlPoint& cp)
alist.erase (mr.start, mr.end);
- trackview.editor.current_session()->add_command(new MementoCommand<AutomationLine>(*this, before, get_state()));
+ trackview.editor.current_session()->add_command(new MementoCommand<AutomationLine>(*this, &before, &get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
@@ -1228,7 +1231,7 @@ AutomationLine::clear ()
/* parent must create command */
XMLNode &before = get_state();
alist.clear();
- trackview.editor.current_session()->add_command (new MementoCommand<AutomationLine>(*this, before, get_state()));
+ trackview.editor.current_session()->add_command (new MementoCommand<AutomationLine>(*this, &before, &get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index 7025a11178..80ed2acd16 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -482,7 +482,7 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
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_command(new MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command(new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
ret = true;
}
break;
@@ -494,7 +494,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_command(new MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command(new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
delete what_we_got;
what_we_got = 0;
ret = true;
@@ -526,7 +526,7 @@ AutomationTimeAxisView::reset_objects_one (AutomationLine& line, PointSelection&
{
AutomationList& alist (line.the_list());
- _session.add_command (new MementoUndoCommand<AutomationList>(alist, alist.get_state()));
+ _session.add_command (new MementoCommand<AutomationList>(alist, &alist.get_state(), 0));
for (PointSelection::iterator i = selection.begin(); i != selection.end(); ++i) {
@@ -569,7 +569,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_command (new MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command (new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
ret = true;
}
break;
@@ -581,7 +581,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_command (new MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command (new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
delete what_we_got;
what_we_got = 0;
ret = true;
@@ -640,7 +640,7 @@ AutomationTimeAxisView::paste_one (AutomationLine& line, jack_nframes_t pos, flo
XMLNode &before = alist.get_state();
alist.paste (copy, pos, times);
- _session.add_command (new MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command (new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
return true;
}
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 513251085c..74822fc7ea 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -705,6 +705,7 @@ Editor::Editor (AudioEngine& eng)
ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
constructed = true;
instant_save ();
+
}
Editor::~Editor()
@@ -1339,6 +1340,9 @@ Editor::connect_to_session (Session *t)
no_route_list_redisplay = false;
redisplay_route_list ();
}
+
+ /* register for undo history */
+ session->register_with_memento_command_factory(_id, this);
}
void
@@ -2888,7 +2892,7 @@ void
Editor::commit_reversible_command ()
{
if (session) {
- session->commit_reversible_command (new MementoCommand<Editor>(*this, *before, get_state()));
+ session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
}
}
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 7524f9605c..8887135374 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -323,7 +323,7 @@ Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32
begin_reversible_command (_("insert sndfile"));
XMLNode &before = playlist->get_state();
playlist->add_region (*copy, pos);
- session->add_command (new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
pos += region.length();
diff --git a/gtk2_ardour/editor_keyboard.cc b/gtk2_ardour/editor_keyboard.cc
index f48d860d15..95289c7f5a 100644
--- a/gtk2_ardour/editor_keyboard.cc
+++ b/gtk2_ardour/editor_keyboard.cc
@@ -108,7 +108,7 @@ Editor::kbd_mute_unmute_region ()
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 MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region().playlist()), &before, &after));
commit_reversible_command();
}
}
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index ccc1415888..40f00c2e10 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -294,7 +294,7 @@ Editor::mouse_add_new_marker (jack_nframes_t where)
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
}
@@ -334,7 +334,7 @@ Editor::really_remove_marker (Location* loc)
XMLNode &before = session->locations()->get_state();
session->locations()->remove (loc);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
return FALSE;
}
@@ -847,7 +847,7 @@ Editor::marker_menu_rename ()
loc->set_name (txt);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
commit_reversible_command ();
}
@@ -876,14 +876,14 @@ Editor::new_transport_marker_menu_set_loop ()
session->locations()->add (loc, true);
session->set_auto_loop_location (loc);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
}
else {
XMLNode &before = tll->get_state();
tll->set_hidden (false, this);
tll->set (temp_location->start(), temp_location->end());
XMLNode &after = tll->get_state();
- session->add_command (new MementoCommand<Location>(*tll, before, after));
+ session->add_command (new MementoCommand<Location>(*tll, &before, &after));
}
commit_reversible_command ();
@@ -904,13 +904,13 @@ Editor::new_transport_marker_menu_set_punch ()
session->locations()->add (tpl, true);
session->set_auto_punch_location (tpl);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
} else {
XMLNode &before = tpl->get_state();
tpl->set_hidden(false, this);
tpl->set(temp_location->start(), temp_location->end());
XMLNode &after = tpl->get_state();
- session->add_command (new MementoCommand<Location>(*tpl, before, after));
+ session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
}
commit_reversible_command ();
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 18c7f0727d..db42e0c414 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1824,8 +1824,8 @@ Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* even
XMLNode &after = arv->audio_region().get_state();
session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->audio_region(),
- before,
- after));
+ &before,
+ &after));
commit_reversible_command ();
fade_in_drag_motion_callback (item, event);
}
@@ -1920,7 +1920,7 @@ Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* eve
arv->audio_region().set_fade_out_length (fade_length);
XMLNode &after = arv->region().get_state();
- session->add_command(new MementoCommand<ARDOUR::Region>(arv->region(), before, after));
+ session->add_command(new MementoCommand<ARDOUR::Region>(arv->region(), &before, &after));
commit_reversible_command ();
fade_out_drag_motion_callback (item, event);
@@ -2175,7 +2175,7 @@ Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
}
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
commit_reversible_command ();
marker_drag_line->hide();
@@ -2292,7 +2292,7 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
XMLNode &before = map.get_state();
map.add_meter (marker->meter(), when);
XMLNode &after = map.get_state();
- session->add_command(new MementoCommand<TempoMap>(map, before, after));
+ session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying.
@@ -2303,7 +2303,7 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
XMLNode &before = map.get_state();
map.move_meter (marker->meter(), when);
XMLNode &after = map.get_state();
- session->add_command(new MementoCommand<TempoMap>(map, before, after));
+ session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
}
}
@@ -2424,7 +2424,7 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
XMLNode &before = map.get_state();
map.add_tempo (marker->tempo(), when);
XMLNode &after = map.get_state();
- session->add_command (new MementoCommand<TempoMap>(map, before, after));
+ session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying.
@@ -2435,7 +2435,7 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
XMLNode &before = map.get_state();
map.move_tempo (marker->tempo(), when);
XMLNode &after = map.get_state();
- session->add_command (new MementoCommand<TempoMap>(map, before, after));
+ session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
}
}
@@ -2799,7 +2799,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
insert_result = affected_playlists.insert (to_playlist);
if (insert_result.second) {
- session->add_command (new MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
}
latest_regionview = 0;
@@ -3235,7 +3235,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_command(new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
}
}
}
@@ -3363,7 +3363,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_command(new MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
}
}
@@ -3445,7 +3445,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_command (new MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*(*p), 0, & (*p)->get_state()));
}
motion_frozen_playlists.clear ();
@@ -3640,10 +3640,10 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
Playlist* playlist = clicked_trackview->playlist();
- before = &(playlist->get_state());
+ XMLNode *before = &(playlist->get_state());
clicked_trackview->playlist()->add_region (*region, selection->time[clicked_selection].start);
- XMLNode &after = playlist->get_state();
- session->add_command(new MementoCommand<Playlist>(*playlist, *before, after));
+ XMLNode *after = &(playlist->get_state());
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
commit_reversible_command ();
@@ -4010,7 +4010,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_command(new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
}
}
}
@@ -4200,7 +4200,7 @@ 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_command (new MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*(*p), 0, &(*p)->get_state()));
}
motion_frozen_playlists.clear ();
@@ -4238,7 +4238,7 @@ Editor::point_trim (GdkEvent* event)
XMLNode &before = pl->get_state();
(*i)->region().trim_front (new_bound, this);
XMLNode &after = pl->get_state();
- session->add_command(new MementoCommand<Playlist>(*pl, before, after));
+ session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
}
@@ -4249,7 +4249,7 @@ Editor::point_trim (GdkEvent* event)
XMLNode &before = pl->get_state();
rv->region().trim_front (new_bound, this);
XMLNode &after = pl->get_state();
- session->add_command(new MementoCommand<Playlist>(*pl, before, after));
+ session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
}
@@ -4269,7 +4269,7 @@ Editor::point_trim (GdkEvent* event)
XMLNode &before = pl->get_state();
(*i)->region().trim_end (new_bound, this);
XMLNode &after = pl->get_state();
- session->add_command(new MementoCommand<Playlist>(*pl, before, after));
+ session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
}
@@ -4280,7 +4280,7 @@ Editor::point_trim (GdkEvent* event)
XMLNode &before = pl->get_state();
rv->region().trim_end (new_bound, this);
XMLNode &after = pl->get_state();
- session->add_command (new MementoCommand<Playlist>(*pl, before, after));
+ session->add_command (new MementoCommand<Playlist>(*pl, &before, &after));
}
}
@@ -4303,7 +4303,7 @@ Editor::thaw_region_after_trim (RegionView& rv)
region.thaw (_("trimmed region"));
XMLNode &after = region.playlist()->get_state();
- session->add_command (new MementoRedoCommand<Playlist>(*(region.playlist()), after));
+ session->add_command (new MementoCommand<Playlist>(*(region.playlist()), 0, &after));
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
if (arv)
@@ -4448,7 +4448,7 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker);
session->locations()->add (newloc, true);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
commit_reversible_command ();
range_bar_drag_rect->hide();
@@ -4831,7 +4831,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, jack_nframes_t pos)
XMLNode &before = playlist->get_state();
playlist->add_region (*(new AudioRegion (arv->audio_region())), (jack_nframes_t) (pos * speed));
XMLNode &after = playlist->get_state();
- session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
// playlist is frozen, so we have to update manually
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 1e5f336e52..55a863c6e3 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -213,7 +213,7 @@ Editor::split_regions_at (jack_nframes_t where, RegionSelection& regions)
XMLNode &before = pl->get_state();
pl->split_region ((*a)->region(), where);
XMLNode &after = pl->get_state();
- session->add_command(new MementoCommand<Playlist>(*pl, before, after));
+ session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
a = tmp;
@@ -236,7 +236,7 @@ Editor::remove_clicked_region ()
XMLNode &before = playlist->get_state();
playlist->remove_region (&clicked_regionview->region());
XMLNode &after = playlist->get_state();
- session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
commit_reversible_command ();
}
@@ -412,7 +412,7 @@ Editor::nudge_forward (bool next)
XMLNode &before = r.playlist()->get_state();
r.set_position (r.position() + distance, this);
XMLNode &after = r.playlist()->get_state();
- session->add_command (new MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command (new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
}
commit_reversible_command ();
@@ -452,7 +452,7 @@ Editor::nudge_backward (bool next)
r.set_position (0, this);
}
XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
}
commit_reversible_command ();
@@ -488,7 +488,7 @@ Editor::nudge_forward_capture_offset ()
XMLNode &before = r.playlist()->get_state();
r.set_position (r.position() + distance, this);
XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
}
commit_reversible_command ();
@@ -520,7 +520,7 @@ Editor::nudge_backward_capture_offset ()
r.set_position (0, this);
}
XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
}
commit_reversible_command ();
@@ -1300,7 +1300,7 @@ Editor::add_location_from_selection ()
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
@@ -1314,7 +1314,7 @@ Editor::add_location_from_playhead_cursor ()
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
@@ -1333,7 +1333,7 @@ Editor::add_location_from_audio_region ()
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
@@ -1752,7 +1752,7 @@ Editor::clear_markers ()
XMLNode &before = session->locations()->get_state();
session->locations()->clear_markers ();
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
}
@@ -1773,7 +1773,7 @@ Editor::clear_ranges ()
if (punchloc) session->locations()->add (punchloc);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
}
@@ -1785,7 +1785,7 @@ Editor::clear_locations ()
XMLNode &before = session->locations()->get_state();
session->locations()->clear ();
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
session->locations()->clear ();
}
@@ -1835,7 +1835,7 @@ Editor::insert_region_list_drag (AudioRegion& region, int x, int y)
begin_reversible_command (_("insert dragged region"));
XMLNode &before = playlist->get_state();
playlist->add_region (*(new AudioRegion (region)), where, 1.0);
- session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
}
@@ -1871,7 +1871,7 @@ Editor::insert_region_list_selection (float times)
begin_reversible_command (_("insert region"));
XMLNode &before = playlist->get_state();
playlist->add_region (*(createRegion (*region)), edit_cursor->current_frame, times);
- session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
}
@@ -2308,7 +2308,7 @@ Editor::separate_region_from_selection ()
}
if (doing_undo)
- session->add_command(new MementoCommand<Playlist>(*playlist, *before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, &playlist->get_state()));
}
}
}
@@ -2359,7 +2359,7 @@ Editor::separate_regions_using_location (Location& loc)
playlist->partition ((jack_nframes_t)(loc.start() * speed), (jack_nframes_t)(loc.end() * speed), true);
if (doing_undo)
- session->add_command(new MementoCommand<Playlist>(*playlist, *before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, &playlist->get_state()));
}
}
}
@@ -2433,7 +2433,7 @@ Editor::crop_region_to_selection ()
XMLNode &before = (*i)->get_state();
region->trim_to (start, cnt, this);
XMLNode &after = (*i)->get_state();
- session->add_command (new MementoCommand<Playlist>(*(*i), before, after));
+ session->add_command (new MementoCommand<Playlist>(*(*i), &before, &after));
}
commit_reversible_command ();
@@ -2476,7 +2476,7 @@ Editor::region_fill_track ()
XMLNode &before = pl->get_state();
pl->add_region (*(new AudioRegion (*ar)), ar->last_frame(), times);
- session->add_command (new MementoCommand<Playlist>(*pl, before, pl->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*pl, &before, &pl->get_state()));
}
commit_reversible_command ();
@@ -2526,7 +2526,7 @@ Editor::region_fill_selection ()
XMLNode &before = playlist->get_state();
playlist->add_region (*(createRegion (*region)), start, times);
- session->add_command (new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
}
commit_reversible_command ();
@@ -2544,7 +2544,7 @@ Editor::set_a_regions_sync_position (Region& region, jack_nframes_t position)
XMLNode &before = region.playlist()->get_state();
region.set_sync_position (position);
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2565,7 +2565,7 @@ Editor::set_region_sync_from_edit_cursor ()
XMLNode &before = region.playlist()->get_state();
region.set_sync_position (edit_cursor->current_frame);
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2578,7 +2578,7 @@ Editor::remove_region_sync ()
XMLNode &before = region.playlist()->get_state();
region.clear_sync_position ();
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
commit_reversible_command ();
}
}
@@ -2594,7 +2594,7 @@ Editor::naturalize ()
XMLNode &before = (*i)->region().get_state();
(*i)->region().move_to_natural_position (this);
XMLNode &after = (*i)->region().get_state();
- session->add_command (new MementoCommand<Region>((*i)->region(), before, after));
+ session->add_command (new MementoCommand<Region>((*i)->region(), &before, &after));
}
commit_reversible_command ();
}
@@ -2669,7 +2669,7 @@ Editor::align_selection_relative (RegionPoint point, jack_nframes_t position)
}
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
}
@@ -2722,7 +2722,7 @@ Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t
}
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
}
void
@@ -2747,7 +2747,7 @@ Editor::trim_region_to_edit_cursor ()
XMLNode &before = region.playlist()->get_state();
region.trim_end( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2773,7 +2773,7 @@ Editor::trim_region_from_edit_cursor ()
XMLNode &before = region.playlist()->get_state();
region.trim_front ( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2888,7 +2888,7 @@ Editor::bounce_range_selection ()
XMLNode &before = playlist->get_state();
atv->audio_track()->bounce_range (start, cnt, itt);
XMLNode &after = playlist->get_state();
- session->add_command (new MementoCommand<Playlist> (*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist> (*playlist, &before, &after));
}
commit_reversible_command ();
@@ -3006,7 +3006,7 @@ Editor::cut_copy_regions (CutCopyOp op)
insert_result = freezelist.insert (pl);
if (insert_result.second) {
pl->freeze ();
- session->add_command (new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
}
}
}
@@ -3070,7 +3070,7 @@ Editor::cut_copy_regions (CutCopyOp op)
for (set<Playlist*>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
(*pl)->thaw ();
- session->add_command (new MementoRedoCommand<Playlist>(*(*pl), (*pl)->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*(*pl), 0, &(*pl)->get_state()));
}
}
@@ -3185,7 +3185,7 @@ Editor::paste_named_selection (float times)
XMLNode &before = apl->get_state();
apl->paste (**chunk, edit_cursor->current_frame, times);
- session->add_command(new MementoCommand<AudioPlaylist>(*apl, before, apl->get_state()));
+ session->add_command(new MementoCommand<AudioPlaylist>(*apl, &before, &apl->get_state()));
if (tmp != ns->playlists.end()) {
chunk = tmp;
@@ -3216,7 +3216,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
playlist = (*i)->region().playlist();
XMLNode &before = playlist->get_state();
playlist->duplicate (r, r.last_frame(), times);
- session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
c.disconnect ();
@@ -3257,7 +3257,7 @@ Editor::duplicate_selection (float times)
XMLNode &before = playlist->get_state();
playlist->duplicate (**ri, selection->time[clicked_selection].end, times);
XMLNode &after = playlist->get_state();
- session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
++ri;
if (ri == new_regions.end()) {
@@ -3308,7 +3308,7 @@ Editor::clear_playlist (Playlist& playlist)
XMLNode &before = playlist.get_state();
playlist.clear ();
XMLNode &after = playlist.get_state();
- session->add_command (new MementoCommand<Playlist>(playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(playlist, &before, &after));
commit_reversible_command ();
}
@@ -3345,7 +3345,7 @@ Editor::nudge_track (bool use_edit_cursor, bool forwards)
XMLNode &before = playlist->get_state();
playlist->nudge_after (start, distance, forwards);
XMLNode &after = playlist->get_state();
- session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
}
commit_reversible_command ();
@@ -3401,7 +3401,7 @@ Editor::normalize_region ()
continue;
XMLNode &before = arv->region().get_state();
arv->audio_region().normalize_to (0.0f);
- session->add_command (new MementoCommand<Region>(arv->region(), before, arv->region().get_state()));
+ session->add_command (new MementoCommand<Region>(arv->region(), &before, &arv->region().get_state()));
}
commit_reversible_command ();
@@ -3428,7 +3428,7 @@ Editor::denormalize_region ()
continue;
XMLNode &before = arv->region().get_state();
arv->audio_region().set_scale_amplitude (1.0f);
- session->add_command (new MementoCommand<Region>(arv->region(), before, arv->region().get_state()));
+ session->add_command (new MementoCommand<Region>(arv->region(), &before, &arv->region().get_state()));
}
commit_reversible_command ();
@@ -3475,7 +3475,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
XMLNode &before = playlist->get_state();
playlist->replace_region (arv->region(), *(filter.results.front()), arv->region().position());
XMLNode &after = playlist->get_state();
- session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
} else {
goto out;
}
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index 9f7fe7cf09..91710c5fc9 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -277,7 +277,7 @@ Editor::mouse_add_new_tempo_event (jack_nframes_t frame)
XMLNode &before = map.get_state();
map.add_tempo (Tempo (bpm), requested);
XMLNode &after = map.get_state();
- session->add_command(new MementoCommand<TempoMap>(map, before, after));
+ session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
commit_reversible_command ();
map.dump (cerr);
@@ -317,7 +317,7 @@ Editor::mouse_add_new_meter_event (jack_nframes_t frame)
begin_reversible_command (_("add meter mark"));
XMLNode &before = map.get_state();
map.add_meter (Meter (bpb, note_type), requested);
- session->add_command(new MementoCommand<TempoMap>(map, before, map.get_state()));
+ session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
commit_reversible_command ();
map.dump (cerr);
@@ -369,7 +369,7 @@ Editor::edit_meter_section (MeterSection* section)
XMLNode &before = session->tempo_map().get_state();
session->tempo_map().replace_meter (*section, Meter (bpb, note_type));
XMLNode &after = session->tempo_map().get_state();
- session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
}
@@ -399,7 +399,7 @@ Editor::edit_tempo_section (TempoSection* section)
session->tempo_map().replace_tempo (*section, Tempo (bpm));
session->tempo_map().move_tempo (*section, when);
XMLNode &after = session->tempo_map().get_state();
- session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
}
@@ -448,7 +448,7 @@ Editor::real_remove_tempo_marker (TempoSection *section)
XMLNode &before = session->tempo_map().get_state();
session->tempo_map().remove_tempo (*section);
XMLNode &after = session->tempo_map().get_state();
- session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
return FALSE;
@@ -482,7 +482,7 @@ Editor::real_remove_meter_marker (MeterSection *section)
XMLNode &before = session->tempo_map().get_state();
session->tempo_map().remove_meter (*section);
XMLNode &after = session->tempo_map().get_state();
- session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
return FALSE;
}
diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc
index 3fe0023d07..a3288ea8d0 100644
--- a/gtk2_ardour/editor_timefx.cc
+++ b/gtk2_ardour/editor_timefx.cc
@@ -210,7 +210,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
XMLNode &before = playlist->get_state();
playlist->replace_region (region, *new_region, region.position());
XMLNode &after = playlist->get_state();
- session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
i = tmp;
}
diff --git a/gtk2_ardour/gain_automation_time_axis.cc b/gtk2_ardour/gain_automation_time_axis.cc
index c86c1390f3..47657e3292 100644
--- a/gtk2_ardour/gain_automation_time_axis.cc
+++ b/gtk2_ardour/gain_automation_time_axis.cc
@@ -67,7 +67,7 @@ GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkE
XMLNode &before = curve.get_state();
curve.add (when, y);
XMLNode &after = curve.get_state();
- _session.add_command(new MementoCommand<ARDOUR::Curve>(curve, before, after));
+ _session.add_command(new MementoCommand<ARDOUR::Curve>(curve, &before, &after));
_session.commit_reversible_command ();
_session.set_dirty ();
}
diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc
index deb4c1da36..12e7079de2 100644
--- a/gtk2_ardour/location_ui.cc
+++ b/gtk2_ardour/location_ui.cc
@@ -658,7 +658,7 @@ gint LocationUI::do_location_remove (ARDOUR::Location *loc)
XMLNode &before = session->locations()->get_state();
session->locations()->remove (loc);
XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
return FALSE;
@@ -777,7 +777,7 @@ LocationUI::add_new_location()
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
@@ -794,7 +794,7 @@ LocationUI::add_new_range()
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
}
}
diff --git a/gtk2_ardour/pan_automation_time_axis.cc b/gtk2_ardour/pan_automation_time_axis.cc
index ec884151b5..bbd4b3b06c 100644
--- a/gtk2_ardour/pan_automation_time_axis.cc
+++ b/gtk2_ardour/pan_automation_time_axis.cc
@@ -92,7 +92,7 @@ PanAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEv
XMLNode &before = alist.get_state();
alist.add (when, y);
XMLNode &after = alist.get_state();
- _session.add_command(new MementoCommand<AutomationList>(alist, before, after));
+ _session.add_command(new MementoCommand<AutomationList>(alist, &before, &after));
_session.commit_reversible_command ();
_session.set_dirty ();
}
diff --git a/gtk2_ardour/redirect_automation_time_axis.cc b/gtk2_ardour/redirect_automation_time_axis.cc
index e527fd1d5e..f1e8eae9eb 100644
--- a/gtk2_ardour/redirect_automation_time_axis.cc
+++ b/gtk2_ardour/redirect_automation_time_axis.cc
@@ -102,7 +102,7 @@ RedirectAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item,
XMLNode &before = alist.get_state();
alist.add (when, y);
XMLNode &after = alist.get_state();
- _session.add_command(new MementoCommand<AutomationList>(alist, before, after));
+ _session.add_command(new MementoCommand<AutomationList>(alist, &before, &after));
_session.commit_reversible_command ();
_session.set_dirty ();
}
diff --git a/gtk2_ardour/region_gain_line.cc b/gtk2_ardour/region_gain_line.cc
index 0a4a3d29ea..e2b1d6c826 100644
--- a/gtk2_ardour/region_gain_line.cc
+++ b/gtk2_ardour/region_gain_line.cc
@@ -48,7 +48,7 @@ AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
{
AutomationLine::start_drag(cp,fraction);
if (!rv.audio_region().envelope_active()) {
- trackview.session().add_command(new MementoUndoCommand<AudioRegion>(rv.audio_region(), rv.audio_region().get_state()));
+ trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), &rv.audio_region().get_state(), 0));
rv.audio_region().set_envelope_active(false);
}
}
@@ -68,12 +68,12 @@ AudioRegionGainLine::remove_point (ControlPoint& cp)
XMLNode &before = rv.audio_region().get_state();
rv.audio_region().set_envelope_active(true);
XMLNode &after = rv.audio_region().get_state();
- trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), before, after));
+ trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), &before, &after));
}
alist.erase (mr.start, mr.end);
- trackview.editor.current_session()->add_command (new MementoCommand<AudioRegionGainLine>(*this, before, get_state()));
+ trackview.editor.current_session()->add_command (new MementoCommand<AudioRegionGainLine>(*this, &before, &get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
@@ -83,7 +83,7 @@ AudioRegionGainLine::end_drag (ControlPoint* cp)
{
if (!rv.audio_region().envelope_active()) {
rv.audio_region().set_envelope_active(true);
- trackview.session().add_command(new MementoRedoCommand<AudioRegion>(rv.audio_region(), rv.audio_region().get_state()));
+ trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), 0, &rv.audio_region().get_state()));
}
AutomationLine::end_drag(cp);
}
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index 82d5b53cba..0d7405e4f6 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -1056,7 +1056,7 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
case Cut:
if ((what_we_got = playlist->cut (time)) != 0) {
editor.get_cut_buffer().add (what_we_got);
- _session.add_command( new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
ret = true;
}
break;
@@ -1068,7 +1068,7 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
case Clear:
if ((what_we_got = playlist->cut (time)) != 0) {
- _session.add_command( new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
what_we_got->unref ();
ret = true;
}
@@ -1099,7 +1099,7 @@ RouteTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection,
XMLNode &before = playlist->get_state();
playlist->paste (**p, pos, times);
- _session.add_command( new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
return true;
}
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc
index 863e73d33e..998385f66b 100644
--- a/gtk2_ardour/route_ui.cc
+++ b/gtk2_ardour/route_ui.cc
@@ -575,7 +575,7 @@ RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool,
XMLNode &before = _route->get_state();
bind(mem_fun(*_route, func), yn, arg)();
XMLNode &after = _route->get_state();
- _session.add_command (new MementoCommand<Route>(*_route, before, after));
+ _session.add_command (new MementoCommand<Route>(*_route, &before, &after));
_session.commit_reversible_command ();
}
@@ -586,7 +586,7 @@ RouteUI::reversibly_apply_audio_track_boolean (string name, void (AudioTrack::*f
XMLNode &before = audio_track()->get_state();
bind (mem_fun (*audio_track(), func), yn, arg)();
XMLNode &after = audio_track()->get_state();
- _session.add_command (new MementoCommand<AudioTrack>(*audio_track(), before, after));
+ _session.add_command (new MementoCommand<AudioTrack>(*audio_track(), &before, &after));
_session.commit_reversible_command ();
}
diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h
index 5864de73c6..dad94161d0 100644
--- a/libs/ardour/ardour/automation_event.h
+++ b/libs/ardour/ardour/automation_event.h
@@ -183,6 +183,8 @@ class AutomationList : public StateManager, public Stateful
}
};
+ static sigc::signal<void, AutomationList*> AutomationListCreated;
+
protected:
PBD::ID _id;
struct State : public ARDOUR::StateManager::State {
diff --git a/libs/ardour/ardour/curve.h b/libs/ardour/ardour/curve.h
index 7f8a43cfe1..7ba6b5fa6c 100644
--- a/libs/ardour/ardour/curve.h
+++ b/libs/ardour/ardour/curve.h
@@ -59,6 +59,8 @@ class Curve : public AutomationList
AutomationEventList::iterator closest_control_point_after (double xval);
void solve ();
+
+ static sigc::signal<void, Curve*> CurveCreated;
protected:
ControlEvent* point_factory (double,double) const;
diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h
index ff953d1d78..beae4a6e07 100644
--- a/libs/ardour/ardour/location.h
+++ b/libs/ardour/ardour/location.h
@@ -149,6 +149,7 @@ class Locations : public Stateful, public StateManager
XMLNode& get_state (void);
int set_state (const XMLNode&);
PBD::ID id() { return _id; }
+ Location *get_location_by_id(PBD::ID);
Location* auto_loop_location () const;
Location* auto_punch_location () const;
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index e2b14eccfa..d067de4e68 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -302,6 +302,7 @@ class Session : public sigc::trackable, public Stateful
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
boost::shared_ptr<Route> route_by_name (string);
+ boost::shared_ptr<Route> route_by_id (PBD::ID);
boost::shared_ptr<Route> route_by_remote_id (uint32_t id);
bool route_name_unique (string) const;
@@ -478,6 +479,7 @@ class Session : public sigc::trackable, public Stateful
int restore_state (string snapshot_name);
int save_template (string template_name);
int save_history (string snapshot_name = "");
+ int restore_history (string snapshot_name);
static int rename_template (string old_name, string new_name);
@@ -713,6 +715,10 @@ class Session : public sigc::trackable, public Stateful
sigc::signal<void> NamedSelectionAdded;
sigc::signal<void> NamedSelectionRemoved;
+ /* Curves and AutomationLists (TODO when they go away) */
+ void add_curve(Curve*);
+ void add_automation_list(AutomationList*);
+
/* fade curves */
float get_default_fade_length () const { return default_fade_msecs; }
@@ -840,6 +846,7 @@ class Session : public sigc::trackable, public Stateful
// these commands are implemented in libs/ardour/session_command.cc
Command *memento_command_factory(XMLNode *n);
+ void register_with_memento_command_factory(PBD::ID, Stateful *);
class GlobalSoloStateCommand : public Command
{
GlobalRouteBooleanState before, after;
@@ -1586,6 +1593,10 @@ class Session : public sigc::trackable, public Stateful
NamedSelection *named_selection_factory (string name);
NamedSelection *XMLNamedSelectionFactory (const XMLNode&);
+ /* CURVES and AUTOMATION LISTS */
+ std::map<PBD::ID, Curve*> curves;
+ std::map<PBD::ID, AutomationList*> automation_lists;
+
/* DEFAULT FADE CURVES */
float default_fade_steepness;
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 9619f404fa..d3e64104a0 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -1614,7 +1614,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
_playlist->thaw ();
XMLNode &after = _playlist->get_state();
- _session.add_command (new MementoCommand<Playlist>(*_playlist, before, after));
+ _session.add_command (new MementoCommand<Playlist>(*_playlist, &before, &after));
}
mark_write_completed = true;
diff --git a/libs/ardour/automation_event.cc b/libs/ardour/automation_event.cc
index dc1767d1e7..cf69c634b1 100644
--- a/libs/ardour/automation_event.cc
+++ b/libs/ardour/automation_event.cc
@@ -64,6 +64,8 @@ AutomationList::AutomationList (double defval, bool with_state)
if (!no_state) {
save_state (_("initial"));
}
+
+ AutomationListCreated(this);
}
AutomationList::AutomationList (const AutomationList& other)
@@ -91,6 +93,7 @@ AutomationList::AutomationList (const AutomationList& other)
}
mark_dirty ();
+ AutomationListCreated(this);
}
AutomationList::AutomationList (const AutomationList& other, double start, double end)
@@ -123,6 +126,7 @@ AutomationList::AutomationList (const AutomationList& other, double start, doubl
delete section;
mark_dirty ();
+ AutomationListCreated(this);
}
AutomationList::~AutomationList()
diff --git a/libs/ardour/curve.cc b/libs/ardour/curve.cc
index 977b6dfd7b..5879cb5988 100644
--- a/libs/ardour/curve.cc
+++ b/libs/ardour/curve.cc
@@ -45,6 +45,7 @@ Curve::Curve (double minv, double maxv, double canv, bool nostate)
{
min_yval = minv;
max_yval = maxv;
+ CurveCreated(this);
}
Curve::Curve (const Curve& other)
@@ -52,6 +53,7 @@ Curve::Curve (const Curve& other)
{
min_yval = other.min_yval;
max_yval = other.max_yval;
+ CurveCreated(this);
}
Curve::Curve (const Curve& other, double start, double end)
@@ -59,6 +61,7 @@ Curve::Curve (const Curve& other, double start, double end)
{
min_yval = other.min_yval;
max_yval = other.max_yval;
+ CurveCreated(this);
}
Curve::~Curve ()
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 4a0d820381..1bd11cacc0 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -2227,6 +2227,20 @@ Session::route_by_name (string name)
}
shared_ptr<Route>
+Session::route_by_id (PBD::ID id)
+{
+ shared_ptr<RouteList> r = routes.reader ();
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->id() == id) {
+ return *i;
+ }
+ }
+
+ return shared_ptr<Route> ((Route*) 0);
+}
+
+shared_ptr<Route>
Session::route_by_remote_id (uint32_t id)
{
shared_ptr<RouteList> r = routes.reader ();
@@ -3794,3 +3808,14 @@ Session::set_xfade_model (CrossfadeModel xm)
}
}
+void
+Session::add_curve(Curve *curve)
+{
+ curves[curve->id()] = curve;
+}
+
+void
+Session::add_automation_list(AutomationList *al)
+{
+ automation_lists[al->id()] = al;
+}
diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc
index 556c6ea9a3..4021fae573 100644
--- a/libs/ardour/session_command.cc
+++ b/libs/ardour/session_command.cc
@@ -2,24 +2,85 @@
#include <ardour/route.h>
#include <pbd/memento_command.h>
#include <ardour/diskstream.h>
+#include <ardour/playlist.h>
+#include <ardour/tempo.h>
+#include <ardour/audiosource.h>
+#include <ardour/audioregion.h>
+#include <pbd/error.h>
+using namespace PBD;
+#include "i18n.h"
+
namespace ARDOUR {
+static map<PBD::ID, Stateful*> registry;
+
+void Session::register_with_memento_command_factory(PBD::ID id, Stateful *ptr)
+{
+ registry[id] = ptr;
+}
+
Command *Session::memento_command_factory(XMLNode *n)
{
PBD::ID id;
- XMLNode *before, *after;
+ XMLNode *before = 0, *after = 0;
+
+ /* get id */
+ id = PBD::ID(n->property("obj_id")->value());
+
+ /* get before/after */
+ if (n->name() == "MementoCommand")
+ {
+ before = n->children().front();
+ after = n->children().back();
+ } else if (n->name() == "MementoUndoCommand")
+ before = n->children().front();
+ else if (n->name() == "MementoRedoCommand")
+ after = n->children().front();
- /* get obj_id */
- /* get before and/or after */
+ /* create command */
+ string obj_T = n->children().front()->name();
+ if (obj_T == "AudioRegion" || obj_T == "Region")
+ {
+ if (audio_regions.count(id))
+ return new MementoCommand<AudioRegion>(*audio_regions[id], before, after);
+ }
+ else if (obj_T == "AudioSource")
+ {
+ if (audio_sources.count(id))
+ return new MementoCommand<AudioSource>(*audio_sources[id], before, after);
+ }
+ else if (obj_T == "Location")
+ return new MementoCommand<Location>(*_locations.get_location_by_id(id), before, after);
+ else if (obj_T == "Locations")
+ return new MementoCommand<Locations>(_locations, before, after);
+ else if (obj_T == "TempoMap")
+ return new MementoCommand<TempoMap>(*_tempo_map, before, after);
+ else if (obj_T == "Playlist" || obj_T == "AudioPlaylist")
+ {
+ if (Playlist *pl = playlist_by_name(before->property("name")->value()))
+ return new MementoCommand<Playlist>(*pl, before, after);
+ }
+ else if (obj_T == "Route") // inlcudes AudioTrack
+ return new MementoCommand<Route>(*route_by_id(id), before, after);
+ // For Editor and AutomationLine which are off-limits here
+ else if (registry.count(id))
+ return new MementoCommand<Stateful>(*registry[id], before, after);
+ else if (obj_T == "Curve")
+ {
+ if (curves.count(id))
+ return new MementoCommand<Curve>(*curves[id], before, after);
+ }
+ else if (obj_T == "AutomationList")
+ {
+ if (automation_lists.count(id))
+ return new MementoCommand<AutomationList>(*automation_lists[id], before, after);
+ }
- /* get an object by id by trial and error, and use it to construct an
- * appropriate memento command */
- // e.g.
- if (Diskstream *obj = diskstream_by_id(id))
- return new MementoCommand<Diskstream>(*obj, *before, *after);
- // etc.
+ /* we failed */
+ error << _("could not reconstitute MementoCommand from XMLNode. id=") << id.to_s() << endmsg;
+ return 0;
}
// solo
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index ebf2b6efd5..903d6f558a 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -266,6 +266,8 @@ Session::first_stage_init (string fullpath, string snapshot_name)
Redirect::RedirectCreated.connect (mem_fun (*this, &Session::add_redirect));
AudioDiskstream::DiskstreamCreated.connect (mem_fun (*this, &Session::add_diskstream));
NamedSelection::NamedSelectionCreated.connect (mem_fun (*this, &Session::add_named_selection));
+ Curve::CurveCreated.connect (mem_fun (*this, &Session::add_curve));
+ AutomationList::AutomationListCreated.connect (mem_fun (*this, &Session::add_automation_list));
Controllable::Created.connect (mem_fun (*this, &Session::add_controllable));
Controllable::GoingAway.connect (mem_fun (*this, &Session::remove_controllable));
@@ -3328,3 +3330,63 @@ Session::save_history (string snapshot_name)
return 0;
}
+
+int
+Session::restore_history (string snapshot_name)
+{
+ XMLTree tree;
+ string xmlpath;
+
+ /* read xml */
+ xmlpath = _path + snapshot_name + ".history";
+
+ if (access (xmlpath.c_str(), F_OK)) {
+ error << string_compose(_("%1: session history file \"%2\" doesn't exist!"), _name, xmlpath) << endmsg;
+ return 1;
+ }
+
+ if (!tree.read (xmlpath)) {
+ error << string_compose(_("Could not understand ardour file %1"), xmlpath) << endmsg;
+ return -1;
+ }
+
+ /* replace history */
+ history.clear();
+ for (XMLNodeConstIterator it = tree.root()->children().begin();
+ it != tree.root()->children().end();
+ it++)
+ {
+ XMLNode *t = *it;
+ UndoTransaction ut;
+ struct timeval tv;
+
+ ut.set_name(t->property("name")->value());
+ stringstream ss(t->property("tv_sec")->value());
+ ss >> tv.tv_sec;
+ ss.str(t->property("tv_usec")->value());
+ ss >> tv.tv_usec;
+ ut.set_timestamp(tv);
+
+ for (XMLNodeConstIterator child_it = t->children().begin();
+ child_it != t->children().end();
+ child_it++)
+ {
+ XMLNode *n = *child_it;
+ Command *c;
+ if (n->name() == "MementoCommand" ||
+ n->name() == "MementoUndoCommand" ||
+ n->name() == "MementoRedoCommand")
+ {
+ c = memento_command_factory(n);
+ if (c)
+ ut.add_command(c);
+ }
+ else
+ {
+ error << string_compose(_("Couldn't figure out how to make a Command out of a %1 XMLNode."), n->name()) << endmsg;
+ }
+ }
+ history.add(ut);
+ }
+ return 0;
+}
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 1f70a9ebb8..0e3895caf1 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -324,7 +324,7 @@ Session::non_realtime_stop (bool abort)
XMLNode &before = loc->get_state();
loc->set_end(_transport_frame);
XMLNode &after = loc->get_state();
- add_command (new MementoCommand<Location>(*loc, before, after));
+ add_command (new MementoCommand<Location>(*loc, &before, &after));
}
_end_location_is_free = false;
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h
index 122dcb4c86..3a72fc9841 100644
--- a/libs/pbd/pbd/memento_command.h
+++ b/libs/pbd/pbd/memento_command.h
@@ -36,70 +36,44 @@ class MementoCommand : public Command
public:
MementoCommand(XMLNode &state);
MementoCommand(obj_T &obj,
- XMLNode &before,
- XMLNode &after
+ XMLNode *before,
+ XMLNode *after
)
: obj(obj), before(before), after(after) {}
- void operator() () { obj.set_state(after); }
- void undo() { obj.set_state(before); }
+ void operator() ()
+ {
+ if (after)
+ obj.set_state(*after);
+ }
+ void undo()
+ {
+ if (before)
+ obj.set_state(*before);
+ }
virtual XMLNode &get_state()
{
- XMLNode *node = new XMLNode("MementoCommand");
+ string name;
+ if (before && after)
+ name = "MementoCommand";
+ else if (before)
+ name = "MementoUndoCommand";
+ else
+ name = "MementoRedoCommand";
+
+ XMLNode *node = new XMLNode(name);
node->add_property("obj_id", obj.id().to_s());
node->add_property("type_name", typeid(obj).name());
- node->add_child_copy(before);
- node->add_child_copy(after);
+
+ if (before)
+ node->add_child_copy(*before);
+ if (after)
+ node->add_child_copy(*after);
+
return *node;
}
protected:
obj_T &obj;
- XMLNode &before, &after;
-};
-
-template <class obj_T>
-class MementoUndoCommand : public Command
-{
-public:
- MementoUndoCommand(XMLNode &state);
- MementoUndoCommand(obj_T &obj,
- XMLNode &before)
- : obj(obj), before(before) {}
- void operator() () { /* noop */ }
- void undo() { obj.set_state(before); }
- virtual XMLNode &get_state()
- {
- XMLNode *node = new XMLNode("MementoUndoCommand");
- node->add_property("obj_id", obj.id().to_s());
- node->add_property("type_name", typeid(obj).name());
- node->add_child_copy(before);
- return *node;
- }
-protected:
- obj_T &obj;
- XMLNode &before;
-};
-
-template <class obj_T>
-class MementoRedoCommand : public Command
-{
-public:
- MementoRedoCommand(XMLNode &state);
- MementoRedoCommand(obj_T &obj,
- XMLNode &after)
- : obj(obj), after(after) {}
- void operator() () { obj.set_state(after); }
- void undo() { /* noop */ }
- virtual XMLNode &get_state()
- {
- XMLNode *node = new XMLNode("MementoRedoCommand");
- node->add_property("obj_id", obj.id().to_s());
- node->add_property("type_name", typeid(obj).name());
- node->add_child_copy(after);
- return *node;
- }
-protected:
- obj_T &obj;
- XMLNode &after;
+ XMLNode *before, *after;
};
#endif // __lib_pbd_memento_h__
diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
index 3038f16b4f..5adddfc1c0 100644
--- a/libs/pbd/pbd/stateful.h
+++ b/libs/pbd/pbd/stateful.h
@@ -22,6 +22,7 @@
#define __pbd_stateful_h__
#include <string>
+#include <pbd/id.h>
class XMLNode;
@@ -41,10 +42,12 @@ class Stateful {
virtual void add_instant_xml (XMLNode&, const std::string& dir);
XMLNode *instant_xml (const std::string& str, const std::string& dir);
+ PBD::ID id() { return _id; }
protected:
XMLNode *_extra_xml;
XMLNode *_instant_xml;
+ PBD::ID _id;
};
#endif /* __pbd_stateful_h__ */
diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
index 8d1b416c16..6f421de84e 100644
--- a/libs/pbd/undo.cc
+++ b/libs/pbd/undo.cc
@@ -23,6 +23,7 @@
#include <pbd/undo.h>
#include <pbd/xml++.h>
#include <string>
+#include <sstream>
using namespace std;
using namespace sigc;
@@ -87,6 +88,13 @@ UndoTransaction::redo ()
XMLNode &UndoTransaction::get_state()
{
XMLNode *node = new XMLNode ("UndoTransaction");
+ stringstream ss;
+ ss << _timestamp.tv_sec;
+ node->add_property("tv_sec", ss.str());
+ ss.str("");
+ ss << _timestamp.tv_usec;
+ node->add_property("tv_usec", ss.str());
+ node->add_property("name", _name);
list<Command*>::iterator it;
for (it=actions.begin(); it!=actions.end(); it++)