summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/audio_time_axis.cc14
-rw-r--r--gtk2_ardour/automation_line.cc9
-rw-r--r--gtk2_ardour/automation_line.h5
-rw-r--r--gtk2_ardour/automation_time_axis.cc19
-rw-r--r--gtk2_ardour/editor.cc10
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_audio_import.cc3
-rw-r--r--gtk2_ardour/editor_keyboard.cc3
-rw-r--r--gtk2_ardour/editor_markers.cc25
-rw-r--r--gtk2_ardour/editor_mouse.cc118
-rw-r--r--gtk2_ardour/editor_ops.cc100
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc15
-rw-r--r--gtk2_ardour/editor_timefx.cc3
-rw-r--r--gtk2_ardour/gain_automation_time_axis.cc8
-rw-r--r--gtk2_ardour/location_ui.cc12
-rw-r--r--gtk2_ardour/pan_automation_time_axis.cc8
-rw-r--r--gtk2_ardour/redirect_automation_time_axis.cc8
-rw-r--r--gtk2_ardour/region_gain_line.cc9
-rw-r--r--gtk2_ardour/regionview.cc10
-rw-r--r--gtk2_ardour/route_ui.cc33
-rw-r--r--libs/ardour/ardour/automation_event.h8
-rw-r--r--libs/ardour/ardour/session.h10
-rw-r--r--libs/ardour/audio_diskstream.cc3
-rw-r--r--libs/ardour/session_command.cc2
-rw-r--r--libs/ardour/session_state.cc4
-rw-r--r--libs/ardour/session_transport.cc3
-rw-r--r--libs/pbd3/pbd/memento_command.h34
-rw-r--r--libs/pbd3/pbd/serializable.h1
-rw-r--r--libs/pbd3/pbd/undo.h9
-rw-r--r--libs/pbd3/undo.cc12
30 files changed, 257 insertions, 243 deletions
diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc
index ebc97be77b..857adff6b9 100644
--- a/gtk2_ardour/audio_time_axis.cc
+++ b/gtk2_ardour/audio_time_axis.cc
@@ -30,6 +30,7 @@
#include <pbd/error.h>
#include <pbd/stl_delete.h>
#include <pbd/whitespace.h>
+#include <pbd/memento_command.h>
#include <gtkmm2ext/bindable_button.h>
#include <gtkmm2ext/gtk_ui.h>
@@ -1739,14 +1740,13 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
}
}
- XMLNode &before, &after;
+ XMLNode &before = playlist->get_state();
switch (op) {
case Cut:
- before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) {
editor.get_cut_buffer().add (what_we_got);
- after = playlist->get_state();
- _session.add_command (MementoCommand<Playlist>(*playlist, before, after));
+ XMLNode &after = playlist->get_state();
+ _session.add_command (new MementoCommand<Playlist>(*playlist, before, after));
ret = true;
}
break;
@@ -1757,9 +1757,9 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
break;
case Clear:
- before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) {
- _session.add_command(MementoCommand<Playlist>(*playlist, before, after));
+ XMLNode &after = playlist->get_state();
+ _session.add_command(new MementoCommand<Playlist>(*playlist, before, after));
what_we_got->unref ();
ret = true;
}
@@ -1790,7 +1790,7 @@ AudioTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection,
XMLNode &before = playlist->get_state();
playlist->paste (**p, pos, times);
- _session.add_command(MementoCommand<Playlist>(*playlist, before,
+ _session.add_command(new MementoCommand<Playlist>(*playlist, before,
playlist->get_state()));
return true;
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index bd7ed326d8..a8f2952ed9 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -23,6 +23,7 @@
#include <vector>
#include <pbd/stl_delete.h>
+#include <pbd/memento_command.h>
#include <ardour/automation_event.h>
#include <ardour/curve.h>
@@ -887,7 +888,7 @@ AutomationLine::start_drag (ControlPoint* cp, float fraction)
}
trackview.editor.current_session()->begin_reversible_command (str);
- trackview.editor.current_session()->add_command (MementoUndoCommand<AutomationLine>(*this, get_state()));
+ trackview.editor.current_session()->add_command (new MementoUndoCommand<AutomationLine>(*this, get_state()));
first_drag_fraction = fraction;
last_drag_fraction = fraction;
@@ -936,7 +937,7 @@ AutomationLine::end_drag (ControlPoint* cp)
update_pending = false;
- trackview.editor.current_session()->add_command (MementoRedoCommand<AutomationLine>(*this, get_state()));
+ trackview.editor.current_session()->add_command (new MementoRedoCommand<AutomationLine>(*this, get_state()));
trackview.editor.current_session()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty ();
}
@@ -1017,7 +1018,7 @@ AutomationLine::remove_point (ControlPoint& cp)
alist.erase (mr.start, mr.end);
- trackview.editor.current_session()->add_command(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 ();
}
@@ -1227,7 +1228,7 @@ AutomationLine::clear ()
/* parent must create command */
XMLNode &before = get_state();
alist.clear();
- trackview.editor.current_session()->add_command (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_line.h b/gtk2_ardour/automation_line.h
index e922de6c80..9c6b932dfd 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -94,7 +94,7 @@ class ControlPoint
ShapeType _shape;
};
-class AutomationLine : public sigc::trackable
+class AutomationLine : public sigc::trackable, public Stateful
{
public:
AutomationLine (const string & name, TimeAxisView&, ArdourCanvas::Group&, ARDOUR::AutomationList&);
@@ -158,6 +158,9 @@ class AutomationLine : public sigc::trackable
bool is_last_point (ControlPoint &);
bool is_first_point (ControlPoint &);
+ XMLNode& get_state (void);
+ int set_state (const XMLNode&);
+
protected:
string _name;
guint32 _height;
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index 92c35cf185..080a440bc9 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -1,4 +1,5 @@
#include <ardour/route.h>
+#include <pbd/memento_command.h>
#include "ardour_ui.h"
#include "automation_time_axis.h"
@@ -500,14 +501,13 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
AutomationList& alist (line.the_list());
bool ret = false;
- XMLNode &before, &after;
- before = alist.get_state();
+ XMLNode &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_command(MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command(new MementoCommand<AutomationList>(alist, before, alist.get_state()));
ret = true;
}
break;
@@ -519,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_command(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;
@@ -551,7 +551,7 @@ AutomationTimeAxisView::reset_objects_one (AutomationLine& line, PointSelection&
{
AutomationList& alist (line.the_list());
- _session.add_command (MementoUndoCommand<AutomationList>(alist, alist.get_state()));
+ _session.add_command (new MementoUndoCommand<AutomationList>(alist, alist.get_state()));
for (PointSelection::iterator i = selection.begin(); i != selection.end(); ++i) {
@@ -581,9 +581,8 @@ 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;
- before = alist.get_state();
+ XMLNode &before = alist.get_state();
for (PointSelection::iterator i = selection.begin(); i != selection.end(); ++i) {
@@ -595,7 +594,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 (MementoCommand<AutomationList>(alist, before, alist.get_state()));
+ _session.add_command (new MementoCommand<AutomationList>(alist, before, alist.get_state()));
ret = true;
}
break;
@@ -607,7 +606,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 (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;
@@ -666,7 +665,7 @@ AutomationTimeAxisView::paste_one (AutomationLine& line, jack_nframes_t pos, flo
XMLNode &before = alist.get_state();
alist.paste (copy, pos, times);
- _session.add_command (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 0b9359bae7..6472974093 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -28,6 +28,7 @@
#include <pbd/convert.h>
#include <pbd/error.h>
+#include <pbd/memento_command.h>
#include <gtkmm/image.h>
#include <gdkmm/color.h>
@@ -2970,7 +2971,7 @@ void
Editor::begin_reversible_command (string name)
{
if (session) {
- before = get_state();
+ before = &get_state();
session->begin_reversible_command (name);
}
}
@@ -2979,12 +2980,7 @@ void
Editor::commit_reversible_command ()
{
if (session) {
- // yes, cmd lasts long enough to be copied onto the action
- // list in the history, but this has the potential to be a
- // problem if memory management of actions changes in
- // UndoTransaction
- MementoCommand<Editor> cmd(*this, before, get_state());
- session->commit_reversible_command (&cmd);
+ session->commit_reversible_command (new MementoCommand<Editor>(*this, *before, get_state()));
}
}
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 2ef475a5e4..478a8c96ab 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1608,7 +1608,7 @@ class Editor : public PublicEditor
UndoAction get_memento() const;
- XMLNode &before; /* used in *_reversible_command */
+ XMLNode *before; /* used in *_reversible_command */
void begin_reversible_command (string cmd_name);
void commit_reversible_command ();
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 4cdc38dcf3..2c64f2cf15 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -31,6 +31,7 @@
#include <ardour/audio_track.h>
#include <ardour/audioplaylist.h>
#include <ardour/audiofilesource.h>
+#include <pbd/memento_command.h>
#include "ardour_ui.h"
#include "editor.h"
@@ -320,7 +321,7 @@ int
begin_reversible_command (_("insert sndfile"));
XMLNode &before = playlist->get_state();
playlist->add_region (*copy, pos);
- session->add_command (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 df9bbf00ba..b665f8b0a6 100644
--- a/gtk2_ardour/editor_keyboard.cc
+++ b/gtk2_ardour/editor_keyboard.cc
@@ -20,6 +20,7 @@
#include <ardour/audioregion.h>
#include <ardour/playlist.h>
+#include <pbd/memento_command.h>
#include "editor.h"
#include "regionview.h"
@@ -107,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 (MementoCommand<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 96504cd0f8..c4d8f3143f 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -26,6 +26,7 @@
#include <gtkmm2ext/gtk_ui.h>
#include <ardour/location.h>
+#include <pbd/memento_command.h>
#include "editor.h"
#include "marker.h"
@@ -290,11 +291,10 @@ Editor::mouse_add_new_marker (jack_nframes_t where)
if (session) {
Location *location = new Location (where, where, "mark", Location::IsMark);
session->begin_reversible_command (_("add marker"));
- XMLNode &before, &after;
- before = session->locations()->get_state();
+ XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
- after = session->locations()->get_state();
- session->add_command (MementoCommand<Locations>(*(session->locations()), before, after));
+ XMLNode &after = session->locations()->get_state();
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
}
@@ -331,11 +331,10 @@ gint
Editor::really_remove_marker (Location* loc)
{
session->begin_reversible_command (_("remove marker"));
- XMLNode &before, &after;
- before = session->locations()->get_state();
+ XMLNode &before = session->locations()->get_state();
session->locations()->remove (loc);
- after = session->locations()->get_state();
- session->add_command (MementoCommand<Locations>(*(session->locations()), before, after));
+ XMLNode &after = session->locations()->get_state();
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
return FALSE;
}
@@ -848,7 +847,7 @@ Editor::marker_menu_rename ()
loc->set_name (txt);
XMLNode &after = session->locations()->get_state();
- session->add_command (MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
commit_reversible_command ();
}
@@ -877,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 (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 (MementoCommand<Location>(*tll, before, after));
+ session->add_command (new MementoCommand<Location>(*tll, before, after));
}
commit_reversible_command ();
@@ -905,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 (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 (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 4b17c9e6b0..c7199984a8 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -27,6 +27,7 @@
#include <pbd/error.h>
#include <gtkmm2ext/utils.h>
+#include <pbd/memento_command.h>
#include "ardour_ui.h"
#include "editor.h"
@@ -1812,15 +1813,14 @@ Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* even
}
begin_reversible_command (_("change fade in length"));
- XMLNode &before, &after;
- before = arv->region.get_state();
+ XMLNode &before = arv->region.get_state();
arv->region.set_fade_in_length (fade_length);
- after = arv->region.get_state();
- session->add_command(MementoCommand<ARDOUR::AudioRegion>(arv->region,
- before,
- after));
+ XMLNode &after = arv->region.get_state();
+ session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->region,
+ before,
+ after));
commit_reversible_command ();
fade_in_drag_motion_callback (item, event);
}
@@ -1910,13 +1910,12 @@ Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* eve
}
begin_reversible_command (_("change fade out length"));
- XMLNode &before, &after;
- before = arv->region.get_state();
+ XMLNode &before = arv->region.get_state();
arv->region.set_fade_out_length (fade_length);
- after = arv->region.get_state();
- session->add_command(MementoCommand<ARDOUR::AudioRegion>(arv->region, before, after));
+ XMLNode &after = arv->region.get_state();
+ session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->region, before, after));
commit_reversible_command ();
fade_out_drag_motion_callback (item, event);
@@ -2150,8 +2149,7 @@ Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
begin_reversible_command ( _("move marker") );
- XMLNode &before, &after;
- before = session->locations()->get_state();
+ XMLNode &before = session->locations()->get_state();
Location * location = find_location_from_marker (marker, is_start);
@@ -2159,8 +2157,8 @@ Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
location->set (drag_info.copied_location->start(), drag_info.copied_location->end());
}
- after = session->locations()->get_state();
- session->add_command(MementoCommand<Locations>(session->locations(), before, after));
+ XMLNode &after = session->locations()->get_state();
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
commit_reversible_command ();
marker_drag_line->hide();
@@ -2272,14 +2270,12 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
TempoMap& map (session->tempo_map());
map.bbt_time (drag_info.last_pointer_frame, when);
- XMLNode &before, &after;
-
if (drag_info.copy == true) {
begin_reversible_command (_("copy meter mark"));
- before = map.get_state();
+ XMLNode &before = map.get_state();
map.add_meter (marker->meter(), when);
- after = map.get_state();
- session->add_command(MementoCommand<TempoMap>(map, before, after));
+ XMLNode &after = map.get_state();
+ session->add_command(new MementoCommand<TempoMap>(map, before, after));
commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying.
@@ -2287,10 +2283,10 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
delete marker;
} else {
begin_reversible_command (_("move meter mark"));
- before = map.get_state();
+ XMLNode &before = map.get_state();
map.move_meter (marker->meter(), when);
- after = map.get_state();
- session->add_command(MementoCommand<TempoMap>(map, before, after));
+ XMLNode &after = map.get_state();
+ session->add_command(new MementoCommand<TempoMap>(map, before, after));
commit_reversible_command ();
}
}
@@ -2406,14 +2402,12 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
TempoMap& map (session->tempo_map());
map.bbt_time (drag_info.last_pointer_frame, when);
- XMLNode &before, &after;
-
if (drag_info.copy == true) {
begin_reversible_command (_("copy tempo mark"));
- before = map.get_state();
+ XMLNode &before = map.get_state();
map.add_tempo (marker->tempo(), when);
- after = map.get_state();
- session->add_command (MementoCommand<TempoMap>(map, before, after));
+ XMLNode &after = map.get_state();
+ session->add_command (new MementoCommand<TempoMap>(map, before, after));
commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying.
@@ -2421,10 +2415,10 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
delete marker;
} else {
begin_reversible_command (_("move tempo mark"));
- before = map.get_state();
+ XMLNode &before = map.get_state();
map.move_tempo (marker->tempo(), when);
- after = map.get_state();
- session->add_command (MementoCommand<TempoMap>(map, before, after));
+ XMLNode &after = map.get_state();
+ session->add_command (new MementoCommand<TempoMap>(map, before, after));
commit_reversible_command ();
}
}
@@ -2787,7 +2781,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 (MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
+ session->add_command (new MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
}
latest_regionview = 0;
@@ -3225,7 +3219,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(MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command(new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -3353,7 +3347,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(MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
+ session->add_command(new MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
}
}
@@ -3435,7 +3429,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 (MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
+ session->add_command (new MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
}
motion_frozen_playlists.clear ();
@@ -3630,10 +3624,10 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
Playlist* playlist = clicked_trackview->playlist();
- before = playlist->get_state();
+ before = &(playlist->get_state());
clicked_trackview->playlist()->add_region (*region, selection->time[clicked_selection].start);
- after = playlist->get_state();
- session->add_command(MementoCommand<Playlist>(*playlist, before, after));
+ XMLNode &after = playlist->get_state();
+ session->add_command(new MementoCommand<Playlist>(*playlist, *before, after));
commit_reversible_command ();
@@ -3997,7 +3991,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(MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command(new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -4187,7 +4181,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 (MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
+ session->add_command (new MementoRedoCommand<Playlist>(*(*p), (*p)->get_state()));
}
motion_frozen_playlists.clear ();
@@ -4221,24 +4215,22 @@ Editor::point_trim (GdkEvent* event)
i != selection->audio_regions.by_layer().end(); ++i)
{
if (!(*i)->region.locked()) {
- XMLNode &before, &after;
Playlist *pl = (*i)->region.playlist();
- before = pl->get_state();
+ XMLNode &before = pl->get_state();
(*i)->region.trim_front (new_bound, this);
- after = pl->get_state();
- session->add_command(MementoCommand<Playlist>(*pl, before, after));
+ XMLNode &after = pl->get_state();
+ session->add_command(new MementoCommand<Playlist>(*pl, before, after));
}
}
} else {
if (!rv->region.locked()) {
- XMLNode &before, &after;
Playlist *pl = rv->region.playlist();
- before = pl->get_state();
+ XMLNode &before = pl->get_state();
rv->region.trim_front (new_bound, this);
- after = pl->get_state();
- session->add_command(MementoCommand<Playlist>(*pl, before, after));
+ XMLNode &after = pl->get_state();
+ session->add_command(new MementoCommand<Playlist>(*pl, before, after));
}
}
@@ -4254,24 +4246,22 @@ Editor::point_trim (GdkEvent* event)
for (list<AudioRegionView*>::const_iterator i = selection->audio_regions.by_layer().begin(); i != selection->audio_regions.by_layer().end(); ++i)
{
if (!(*i)->region.locked()) {
- XMLNode &before, &after;
Playlist *pl = (*i)->region.playlist();
- before = pl->get_state();
+ XMLNode &before = pl->get_state();
(*i)->region.trim_end (new_bound, this);
- after = pl->get_state();
- session->add_command(MementoCommand<Playlist>(*pl, before, after));
+ XMLNode &after = pl->get_state();
+ session->add_command(new MementoCommand<Playlist>(*pl, before, after));
}
}
} else {
if (!rv->region.locked()) {
- XMLNode &before, &after;
Playlist *pl = rv->region.playlist();
- before = pl->get_state();
+ XMLNode &before = pl->get_state();
rv->region.trim_end (new_bound, this);
- after = pl->get_state();
- session->add_command (MementoCommand<Playlist>(*pl, before, after));
+ XMLNode &after = pl->get_state();
+ session->add_command (new MementoCommand<Playlist>(*pl, before, after));
}
}
@@ -4294,7 +4284,7 @@ Editor::thaw_region_after_trim (AudioRegionView& rv)
region.thaw (_("trimmed region"));
XMLNode &after = region.playlist()->get_state();
- session->add_command (MementoRedoCommand<Playlist>(*(region.playlist()), after));
+ session->add_command (new MementoRedoCommand<Playlist>(*(region.playlist()), after));
rv.unhide_envelope ();
}
@@ -4431,18 +4421,19 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
switch (range_marker_op) {
case CreateRangeMarker:
+ {
begin_reversible_command (_("new range marker"));
- XMLNode &before, &after;
- before = session->locations()->get_state();
+ XMLNode &before = session->locations()->get_state();
newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker);
session->locations()->add (newloc, true);
- after = session->locations()->get_state();
- session->add_command(MementoCommand<Locations>(session->locations(), before, after));
+ XMLNode &after = session->locations()->get_state();
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
commit_reversible_command ();
range_bar_drag_rect->hide();
range_marker_drag_rect->hide();
break;
+ }
case CreateTransportMarker:
// popup menu to pick loop or punch
@@ -4812,11 +4803,10 @@ Editor::mouse_brush_insert_region (AudioRegionView* rv, jack_nframes_t pos)
Playlist* playlist = atv->playlist();
double speed = atv->get_diskstream()->speed();
- XMLNode &before, &after;
- before = playlist->get_state();
+ XMLNode &before = playlist->get_state();
playlist->add_region (*(new AudioRegion (rv->region)), (jack_nframes_t) (pos * speed));
- after = playlist->get_state();
- session->add_command(MementoCommand<Playlist>(*playlist, before, after));
+ XMLNode &after = playlist->get_state();
+ 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 815d50ae3e..e9fcc028e6 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -28,6 +28,7 @@
#include <pbd/error.h>
#include <pbd/basename.h>
#include <pbd/pthread_utils.h>
+#include <pbd/memento_command.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/choice.h>
@@ -207,11 +208,10 @@ Editor::split_regions_at (jack_nframes_t where, AudioRegionSelection& regions)
_new_regionviews_show_envelope = (*a)->envelope_visible();
if (pl) {
- XMLNode &before, &after;
- before = pl->get_state();
+ XMLNode &before = pl->get_state();
pl->split_region ((*a)->region, where);
- after = pl->get_state();
- session->add_command(MementoCommand<Playlist>(*pl, before, after));
+ XMLNode &after = pl->get_state();
+ session->add_command(new MementoCommand<Playlist>(*pl, before, after));
}
a = tmp;
@@ -234,7 +234,7 @@ Editor::remove_clicked_region ()
XMLNode &before = playlist->get_state();
playlist->remove_region (&clicked_regionview->region);
XMLNode &after = playlist->get_state();
- session->add_command(MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
commit_reversible_command ();
}
@@ -410,7 +410,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 (MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command (new MementoCommand<Playlist>(*(r.playlist()), before, after));
}
commit_reversible_command ();
@@ -450,7 +450,7 @@ Editor::nudge_backward (bool next)
r.set_position (0, this);
}
XMLNode &after = r.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
}
commit_reversible_command ();
@@ -483,11 +483,10 @@ Editor::nudge_forward_capture_offset ()
for (AudioRegionSelection::iterator i = selection->audio_regions.begin(); i != selection->audio_regions.end(); ++i) {
AudioRegion& r ((*i)->region);
- XMLNode &before, &after;
- before = r.playlist()->get_state();
+ XMLNode &before = r.playlist()->get_state();
r.set_position (r.position() + distance, this);
- after = r.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(r.playlist()), before, after));
+ XMLNode &after = r.playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
}
commit_reversible_command ();
@@ -519,7 +518,7 @@ Editor::nudge_backward_capture_offset ()
r.set_position (0, this);
}
XMLNode &after = r.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(r.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(r.playlist()), before, after));
}
commit_reversible_command ();
@@ -1299,7 +1298,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(MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
@@ -1313,7 +1312,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(MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
@@ -1332,7 +1331,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(MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
@@ -1751,7 +1750,7 @@ Editor::clear_markers ()
XMLNode &before = session->locations()->get_state();
session->locations()->clear_markers ();
XMLNode &after = session->locations()->get_state();
- session->add_command(MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
}
@@ -1772,7 +1771,7 @@ Editor::clear_ranges ()
if (punchloc) session->locations()->add (punchloc);
XMLNode &after = session->locations()->get_state();
- session->add_command(MementoCommand<Locations>(*(session->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
}
}
@@ -1784,7 +1783,7 @@ Editor::clear_locations ()
XMLNode &before = session->locations()->get_state();
session->locations()->clear ();
XMLNode &after = session->locations()->get_state();
- session->add_command(MementoCommand<Locations>(*(sessions->locations()), before, after));
+ session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command ();
session->locations()->clear ();
}
@@ -1834,7 +1833,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(MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
commit_reversible_command ();
}
@@ -1870,7 +1869,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(MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
commit_reversible_command ();
}
@@ -2291,9 +2290,9 @@ Editor::separate_region_from_selection ()
begin_reversible_command (_("separate"));
doing_undo = true;
}
- XMLNode &before, &after;
+ XMLNode *before;
if (doing_undo)
- before = playlist->get_state();
+ before = &(playlist->get_state());
/* XXX need to consider musical time selections here at some point */
@@ -2304,7 +2303,7 @@ Editor::separate_region_from_selection ()
}
if (doing_undo)
- session->add_command(MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, *before, playlist->get_state()));
}
}
}
@@ -2339,13 +2338,13 @@ Editor::separate_regions_using_location (Location& loc)
if (atv->is_audio_track()) {
if ((playlist = atv->playlist()) != 0) {
- XMLNode &before, &after;
+ XMLNode *before;
if (!doing_undo) {
begin_reversible_command (_("separate"));
doing_undo = true;
}
if (doing_undo)
- before = playlist->get_state();
+ before = &(playlist->get_state());
/* XXX need to consider musical time selections here at some point */
@@ -2355,7 +2354,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(MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, *before, playlist->get_state()));
}
}
}
@@ -2429,7 +2428,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 (MementoCommand<Playlist>(*(*i), before, after));
+ session->add_command (new MementoCommand<Playlist>(*(*i), before, after));
}
commit_reversible_command ();
@@ -2466,7 +2465,7 @@ Editor::region_fill_track ()
XMLNode &before = pl->get_state();
pl->add_region (*(new AudioRegion (region)), region.last_frame(), times);
- session->add_command (MementoCommand<Playlist>(*pl, before, pl->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*pl, before, pl->get_state()));
}
commit_reversible_command ();
@@ -2516,7 +2515,7 @@ Editor::region_fill_selection ()
XMLNode &before = playlist->get_state();
playlist->add_region (*(createRegion (*region)), start, times);
- session->add_command (MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command (new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
}
commit_reversible_command ();
@@ -2534,7 +2533,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(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
commit_reversible_command ();
}
@@ -2555,7 +2554,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(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
commit_reversible_command ();
}
@@ -2568,7 +2567,7 @@ Editor::remove_region_sync ()
XMLNode &before = region.playlist()->get_state();
region.clear_sync_position ();
XMLNode &after = region.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
commit_reversible_command ();
}
}
@@ -2584,7 +2583,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 (MementoCommand<AudioRegion>((*i)->region, before, after));
+ session->add_command (new MementoCommand<AudioRegion>((*i)->region, before, after));
}
commit_reversible_command ();
}
@@ -2659,7 +2658,7 @@ Editor::align_selection_relative (RegionPoint point, jack_nframes_t position)
}
XMLNode &after = region.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
}
@@ -2693,8 +2692,7 @@ Editor::align_region (Region& region, RegionPoint point, jack_nframes_t position
void
Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t position)
{
- XMLNode &before, &after;
- before = region.playlist()->get_state();
+ XMLNode &before = region.playlist()->get_state();
switch (point) {
case SyncPoint:
@@ -2712,8 +2710,8 @@ Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t
break;
}
- after = region.playlist()->get_state();
- session->add_command(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ XMLNode &after = region.playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
}
void
@@ -2738,7 +2736,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(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
commit_reversible_command ();
}
@@ -2764,7 +2762,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(MementoCommand<Playlist>(*(region.playlist()), before, after));
+ session->add_command(new MementoCommand<Playlist>(*(region.playlist()), before, after));
commit_reversible_command ();
}
@@ -2879,7 +2877,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 (MementoCommand<Playlist> (*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist> (*playlist, before, after));
}
commit_reversible_command ();
@@ -2997,7 +2995,7 @@ Editor::cut_copy_regions (CutCopyOp op)
insert_result = freezelist.insert (pl);
if (insert_result.second) {
pl->freeze ();
- session->add_command (MementoUndoCommand<Playlist>(*pl, pl->get_state()));
+ session->add_command (new MementoUndoCommand<Playlist>(*pl, pl->get_state()));
}
}
}
@@ -3055,7 +3053,7 @@ Editor::cut_copy_regions (CutCopyOp op)
for (set<Playlist*>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
(*pl)->thaw ();
- session->add_command (MementoRedoCommand<Playlist>(*(*pl), *(*pl)->get_state()));
+ session->add_command (new MementoRedoCommand<Playlist>(*(*pl), (*pl)->get_state()));
}
}
@@ -3170,7 +3168,7 @@ Editor::paste_named_selection (float times)
XMLNode &before = apl->get_state();
apl->paste (**chunk, edit_cursor->current_frame, times);
- session->add_command(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;
@@ -3201,7 +3199,7 @@ Editor::duplicate_some_regions (AudioRegionSelection& regions, float times)
playlist = (*i)->region.playlist();
XMLNode &before = playlist->get_state();
playlist->duplicate (r, r.last_frame(), times);
- session->add_command(MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
+ session->add_command(new MementoCommand<Playlist>(*playlist, before, playlist->get_state()));
c.disconnect ();
@@ -3242,7 +3240,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 (MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
++ri;
if (ri == new_regions.end()) {
@@ -3293,7 +3291,7 @@ Editor::clear_playlist (Playlist& playlist)
XMLNode &before = playlist.get_state();
playlist.clear ();
XMLNode &after = playlist.get_state();
- session->add_command (MementoCommand<Playlist>(playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(playlist, before, after));
commit_reversible_command ();
}
@@ -3330,7 +3328,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 (MementoCommand<Playlist>(*playlist, before, after));
+ session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
}
commit_reversible_command ();
@@ -3384,7 +3382,7 @@ Editor::normalize_region ()
XMLNode &before = (*r)->region.get_state();
(*r)->region.normalize_to (0.0f);
XMLNode &after = (*r)->region.get_state();
- session->add_command (MementoCommand<AudioRegion>((*r)->region, before, after));
+ session->add_command (new MementoCommand<AudioRegion>((*r)->region, before, after));
}
commit_reversible_command ();
@@ -3409,7 +3407,7 @@ Editor::denormalize_region ()
XMLNode &before = (*r)->region.get_state();
(*r)->region.set_scale_amplitude (1.0f);
XMLNode &after = (*r)->region.get_state();
- session->add_command (MementoCommand<AudioRegion>((*r)->region, before, after));
+ session->add_command (new MementoCommand<AudioRegion>((*r)->region, before, after));
}
commit_reversible_command ();
@@ -3454,7 +3452,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
XMLNode &before = playlist->get_state();
playlist->replace_region (region, *(filter.results.front()), region.position());
XMLNode &after = playlist->get_state();
- session->add_command(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 0456087859..9f7fe7cf09 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -27,6 +27,7 @@
#include <libgnomecanvasmm.h>
#include <pbd/error.h>
+#include <pbd/memento_command.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/gtk_ui.h>
@@ -276,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(MementoCommand<TempoMap>(map, before, after));
+ session->add_command(new MementoCommand<TempoMap>(map, before, after));
commit_reversible_command ();
map.dump (cerr);
@@ -316,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(MementoCommand<TempoMap>(map, before, map.get_state()));
+ session->add_command(new MementoCommand<TempoMap>(map, before, map.get_state()));
commit_reversible_command ();
map.dump (cerr);
@@ -367,8 +368,8 @@ Editor::edit_meter_section (MeterSection* section)
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = session->tempo_map().get_state();
session->tempo_map().replace_meter (*section, Meter (bpb, note_type));
- XMLNode &before = session->tempo_map().get_state();
- session->add_command(MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ XMLNode &after = session->tempo_map().get_state();
+ session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), before, after));
commit_reversible_command ();
}
@@ -398,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 (MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), before, after));
commit_reversible_command ();
}
@@ -447,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(MementoCommand<TempoMap>(session->tempo_map(), before, after));
+ session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), before, after));
commit_reversible_command ();
return FALSE;
@@ -481,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(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 817a770fe5..27fa6c9651 100644
--- a/gtk2_ardour/editor_timefx.cc
+++ b/gtk2_ardour/editor_timefx.cc
@@ -25,6 +25,7 @@
#include <pbd/error.h>
#include <pbd/pthread_utils.h>
+#include <pbd/memento_command.h>
#include "editor.h"
#include "audio_time_axis.h"
@@ -206,7 +207,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
XMLNode &before = playlist->get_state();
playlist->replace_region (aregion, *new_region, aregion.position());
XMLNode &after = playlist->get_state();
- session->add_command (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 1697adbb9c..3e3d02bfc4 100644
--- a/gtk2_ardour/gain_automation_time_axis.cc
+++ b/gtk2_ardour/gain_automation_time_axis.cc
@@ -20,6 +20,7 @@
#include <ardour/curve.h>
#include <ardour/route.h>
+#include <pbd/memento_command.h>
#include "gain_automation_time_axis.h"
#include "automation_line.h"
@@ -61,11 +62,10 @@ GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkE
_session.begin_reversible_command (_("add gain automation event"));
- XMLNode &before, &after;
- before = curve.get_state();
+ XMLNode &before = curve.get_state();
curve.add (when, y);
- after = curve.get_state();
- _session.add_command(MementoCommand<ARDOUR::Curve>(curve, before, after));
+ XMLNode &after = curve.get_state();
+ _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 08d5a0b3af..deb4c1da36 100644
--- a/gtk2_ardour/location_ui.cc
+++ b/gtk2_ardour/location_ui.cc
@@ -27,6 +27,7 @@
#include <ardour/utils.h>
#include <ardour/configuration.h>
#include <ardour/session.h>
+#include <pbd/memento_command.h>
#include "ardour_ui.h"
#include "prompter.h"
@@ -654,11 +655,10 @@ gint LocationUI::do_location_remove (ARDOUR::Location *loc)
}
session->begin_reversible_command (_("remove marker"));
- XMLNode &before, &after;
- before = session->locations()->get_state();
+ XMLNode &before = session->locations()->get_state();
session->locations()->remove (loc);
- after = session->locations()->get_state();
- session->add_command(MementoCommand<Location>(*(session->locations()), before, after));
+ XMLNode &after = session->locations()->get_state();
+ 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 (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 (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 267bb6ef09..73d0f7f1aa 100644
--- a/gtk2_ardour/pan_automation_time_axis.cc
+++ b/gtk2_ardour/pan_automation_time_axis.cc
@@ -23,6 +23,7 @@
#include <ardour/panner.h>
#include <gtkmm2ext/popup.h>
+#include <pbd/memento_command.h>
#include "pan_automation_time_axis.h"
#include "automation_line.h"
@@ -78,11 +79,10 @@ PanAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEv
AutomationList& alist (lines.front()->the_list());
_session.begin_reversible_command (_("add pan automation event"));
- XMLNode &before, &after;
- before = alist.get_state();
+ XMLNode &before = alist.get_state();
alist.add (when, y);
- after = alist.get_state();
- _seession.add_command(MementoCommand<AutomationList>(alist, before, after));
+ XMLNode &after = alist.get_state();
+ _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 d6e2432338..e3ce4b08c6 100644
--- a/gtk2_ardour/redirect_automation_time_axis.cc
+++ b/gtk2_ardour/redirect_automation_time_axis.cc
@@ -21,6 +21,7 @@
#include <ardour/redirect.h>
#include <ardour/session.h>
#include <cstdlib>
+#include <pbd/memento_command.h>
#include "redirect_automation_time_axis.h"
#include "automation_line.h"
@@ -97,11 +98,10 @@ RedirectAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item,
lines.front()->view_to_model_y (y);
_session.begin_reversible_command (description);
- XMLNode &before, &after;
- before = alist.get_state();
+ XMLNode &before = alist.get_state();
alist.add (when, y);
- after = alist.get_state();
- _session.add_command(MementoCommand<AutomationList>(alist, before, after));
+ XMLNode &after = alist.get_state();
+ _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 2faa63151b..ebcf65cedd 100644
--- a/gtk2_ardour/region_gain_line.cc
+++ b/gtk2_ardour/region_gain_line.cc
@@ -1,5 +1,6 @@
#include <ardour/curve.h>
#include <ardour/audioregion.h>
+#include <pbd/memento_command.h>
#include "region_gain_line.h"
#include "regionview.h"
@@ -47,7 +48,7 @@ AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
{
AutomationLine::start_drag(cp,fraction);
if (!rv.region.envelope_active()) {
- trackview.session().add_command(MementoUndoCommand<AudioRegion>(rv.region, rv.region.get_state()));
+ trackview.session().add_command(new MementoUndoCommand<AudioRegion>(rv.region, rv.region.get_state()));
rv.region.set_envelope_active(false);
}
}
@@ -67,12 +68,12 @@ AudioRegionGainLine::remove_point (ControlPoint& cp)
XMLNode &before = rv.region.get_state();
rv.region.set_envelope_active(true);
XMLNode &after = rv.region.get_state();
- trackview.session().add_command(MementoCommand<AudioRegion>(rv.region, before, after));
+ trackview.session().add_command(new MementoCommand<AudioRegion>(rv.region, before, after));
}
alist.erase (mr.start, mr.end);
- trackview.editor.current_session()->add_command (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 ();
}
@@ -82,7 +83,7 @@ AudioRegionGainLine::end_drag (ControlPoint* cp)
{
if (!rv.region.envelope_active()) {
rv.region.set_envelope_active(true);
- trackview.session().add_command(MementoRedoCommand<AudioRegion>(rv.region, rv.region.get_state()));
+ trackview.session().add_command(new MementoRedoCommand<AudioRegion>(rv.region, rv.region.get_state()));
}
AutomationLine::end_drag(cp);
}
diff --git a/gtk2_ardour/regionview.cc b/gtk2_ardour/regionview.cc
index b8658d2e00..dcc71a03c4 100644
--- a/gtk2_ardour/regionview.cc
+++ b/gtk2_ardour/regionview.cc
@@ -29,6 +29,7 @@
#include <ardour/audioregion.h>
#include <ardour/audiosource.h>
#include <ardour/audio_diskstream.h>
+#include <pbd/memento_command.h>
#include "streamview.h"
#include "regionview.h"
@@ -1148,17 +1149,16 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
if (!region.envelope_active()) {
- XMLNode &before, &after;
- before = region.get_state();
+ XMLNode &before = region.get_state();
region.set_envelope_active(true);
- after = region.get_state();
- trackview.session().add_command(MementoCommand<AudioRegion>(region, before, after));
+ XMLNode &after = region.get_state();
+ trackview.session().add_command(new MementoCommand<AudioRegion>(region, before, after));
}
region.envelope().add (fx, y);
XMLNode &after = region.envelope().get_state();
- trackview.session().add_command(MementoCommand<Curve>(region.envelope(), before, after));
+ trackview.session().add_command(new MementoCommand<Curve>(region.envelope(), before, after));
trackview.session().commit_reversible_command ();
}
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc
index 6ecb4d6255..0dc25f3f7b 100644
--- a/gtk2_ardour/route_ui.cc
+++ b/gtk2_ardour/route_ui.cc
@@ -25,6 +25,7 @@
#include <gtkmm2ext/doi.h>
#include <ardour/route_group.h>
+#include <pbd/memento_command.h>
#include "route_ui.h"
#include "keyboard.h"
@@ -132,9 +133,9 @@ RouteUI::mute_press(GdkEventButton* ev)
/* ctrl-shift-click applies change to all routes */
_session.begin_reversible_command (_("mute change"));
- Session::GlobalMuteStateCommand cmd(this);
+ Session::GlobalMuteStateCommand *cmd = new Session::GlobalMuteStateCommand(this);
_session.set_all_mute (!_route.muted());
- cmd.mark();
+ cmd->mark();
_session.add_command(cmd);
_session.commit_reversible_command ();
@@ -208,9 +209,9 @@ RouteUI::solo_press(GdkEventButton* ev)
/* ctrl-shift-click applies change to all routes */
_session.begin_reversible_command (_("solo change"));
- Session::GlobalSoloStateCommand cmd(this);
+ Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand(this);
_session.set_all_solo (!_route.soloed());
- cmd.mark();
+ cmd->mark();
_session.add_command (cmd);
_session.commit_reversible_command ();
@@ -219,10 +220,10 @@ RouteUI::solo_press(GdkEventButton* ev)
// ctrl-alt-click: exclusively solo this track, not a toggle */
_session.begin_reversible_command (_("solo change"));
- Session::GlobalSoloStateCommand cmd(this);
+ Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand (this);
_session.set_all_solo (false);
_route.set_solo (true, this);
- cmd.mark();
+ cmd->mark();
_session.add_command(cmd);
_session.commit_reversible_command ();
@@ -283,7 +284,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev)
else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) {
_session.begin_reversible_command (_("rec-enable change"));
- Session::GlobalRecordEnableStateCommand cmd(this);
+ Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(this);
if (rec_enable_button->get_active()) {
_session.record_disenable_all ();
@@ -291,7 +292,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev)
_session.record_enable_all ();
}
- cmd.mark();
+ cmd->mark();
_session.add_command(cmd);
_session.commit_reversible_command ();
@@ -561,9 +562,9 @@ RouteUI::set_mix_group_solo(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group solo change"));
- Session::GlobalSoloStateCommand cmd(this);
+ Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand(this);
mix_group->apply(&Route::set_solo, yn, this);
- cmd.mark();
+ cmd->mark();
_session.add_command (cmd);
_session.commit_reversible_command ();
} else {
@@ -578,7 +579,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 (MementoCommand<Route>(_route, before, after));
+ _session.add_command (new MementoCommand<Route>(_route, before, after));
_session.commit_reversible_command ();
}
@@ -589,7 +590,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 (MementoCommand<AudioTrack>(*audio_track(), before, after));
+ _session.add_command (new MementoCommand<AudioTrack>(*audio_track(), before, after));
_session.commit_reversible_command ();
}
@@ -600,9 +601,9 @@ RouteUI::set_mix_group_mute(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group mute change"));
- Session::GlobalMuteStateCommand cmd(this);
+ Session::GlobalMuteStateCommand *cmd = new Session::GlobalMuteStateCommand (this);
mix_group->apply(&Route::set_mute, yn, this);
- cmd.mark();
+ cmd->mark();
_session.add_command(cmd);
_session.commit_reversible_command ();
} else {
@@ -617,9 +618,9 @@ RouteUI::set_mix_group_rec_enable(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group rec-enable change"));
- Session::GlobalRecordEnableStateCommand cmd(this);
+ Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(this);
mix_group->apply (&Route::set_record_enable, yn, this);
- cmd.mark();
+ cmd->mark();
_session.add_command(cmd);
_session.commit_reversible_command ();
} else {
diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h
index 78daa531dd..73aed389c1 100644
--- a/libs/ardour/ardour/automation_event.h
+++ b/libs/ardour/ardour/automation_event.h
@@ -51,7 +51,7 @@ struct ControlEvent {
};
-class AutomationList : public StateManager
+class AutomationList : public StateManager, public Stateful
{
public:
typedef std::list<ControlEvent*> AutomationEventList;
@@ -153,6 +153,12 @@ class AutomationList : public StateManager
virtual void store_state (XMLNode& node) const;
virtual void load_state (const XMLNode&);
+ XMLNode &get_state(void);
+ int set_state (const XMLNode &s) {
+ load_state(s);
+ return 1; /*XXX*/
+ }
+
void set_max_xval (double);
double get_max_xval() const { return max_xval; }
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 35c1a08e25..a809a2e479 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -844,7 +844,7 @@ class Session : public sigc::trackable, public Stateful
void begin_reversible_command (string cmd_name);
void commit_reversible_command (Command* cmd = 0);
- void add_command (const Command& cmd) {
+ void add_command (Command *const cmd) {
current_trans.add_command (cmd);
}
@@ -859,7 +859,7 @@ class Session : public sigc::trackable, public Stateful
void undo();
XMLNode &serialize();
void mark();
- }
+ };
class GlobalMuteStateCommand : public Command
{
@@ -871,7 +871,7 @@ class Session : public sigc::trackable, public Stateful
void undo();
XMLNode &serialize();
void mark();
- }
+ };
class GlobalRecordEnableStateCommand : public Command
{
@@ -883,7 +883,7 @@ class Session : public sigc::trackable, public Stateful
void undo();
XMLNode &serialize();
void mark();
- }
+ };
class GlobalMeteringStateCommand : public Command
{
@@ -895,7 +895,7 @@ class Session : public sigc::trackable, public Stateful
void undo();
XMLNode &serialize();
void mark();
- }
+ };
/* edit mode */
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index b0561eb05d..977616dd8b 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -35,6 +35,7 @@
#include <pbd/basename.h>
#include <glibmm/thread.h>
#include <pbd/xml++.h>
+#include <pbd/memento_command.h>
#include <ardour/ardour.h>
#include <ardour/audioengine.h>
@@ -1833,7 +1834,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
_playlist->thaw ();
XMLNode &after = _playlist->get_state();
- _session.add_command (MementoCommand<Playlist>(*_playlist, before, after));
+ _session.add_command (new MementoCommand<Playlist>(*_playlist, before, after));
}
mark_write_completed = true;
diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc
index 8693a9adc4..9e473fe233 100644
--- a/libs/ardour/session_command.cc
+++ b/libs/ardour/session_command.cc
@@ -1,5 +1,6 @@
#include <ardour/session.h>
+namespace ARDOUR {
// solo
Session::GlobalSoloStateCommand::GlobalSoloStateCommand(void *src) : src(src)
{
@@ -84,3 +85,4 @@ XMLNode &serialize()
{
}
+} // namespace ARDOUR
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index deda3363ab..0ae73291e0 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -2576,7 +2576,7 @@ Session::commit_reversible_command (Command *cmd)
struct timeval now;
if (cmd) {
- current_trans.add_command (*cmd);
+ current_trans.add_command (cmd);
}
gettimeofday (&now, 0);
@@ -2659,6 +2659,7 @@ Session::set_global_record_enable (GlobalRouteBooleanState s, void* src)
set_global_route_boolean (s, &Route::set_record_enable, src);
}
+#if 0
UndoAction
Session::global_mute_memento (void* src)
{
@@ -2682,6 +2683,7 @@ Session::global_record_enable_memento (void* src)
{
return sigc::bind (mem_fun (*this, &Session::set_global_record_enable), get_global_route_boolean (&Route::record_enabled), src);
}
+#endif
static bool
template_filter (const string &str, void *arg)
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 1d3da72ad8..55bdac064b 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -29,6 +29,7 @@
#include <pbd/error.h>
#include <glibmm/thread.h>
#include <pbd/pthread_utils.h>
+#include <pbd/memento_command.h>
#include <midi++/mmc.h>
#include <midi++/port.h>
@@ -323,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 (MementoCommand<Location>(*loc, before, after));
+ add_command (new MementoCommand<Location>(*loc, before, after));
}
_end_location_is_free = false;
diff --git a/libs/pbd3/pbd/memento_command.h b/libs/pbd3/pbd/memento_command.h
index 1419c904bb..fe10893de6 100644
--- a/libs/pbd3/pbd/memento_command.h
+++ b/libs/pbd3/pbd/memento_command.h
@@ -39,12 +39,12 @@ class MementoCommand : public Command
: obj(obj), before(before), after(after) {}
void operator() () { obj.set_state(after); }
void undo() { obj.set_state(before); }
- virtual XMLNode &serialize()
- {
+ virtual XMLNode &serialize() ;
+ //{
// obj.id
// key is "MementoCommand" or something
// before and after mementos
- }
+ //}
// TODO does this need a copy constructor?
protected:
obj_T &obj;
@@ -52,7 +52,7 @@ class MementoCommand : public Command
};
template <class obj_T>
-class MementoUndoCommand : public MementoCommand<obj_T>
+class MementoUndoCommand : public Command
{
public:
MementoUndoCommand(obj_T &obj,
@@ -60,29 +60,35 @@ public:
: obj(obj), before(before) {}
void operator() () { /* noop */ }
void undo() { obj.set_state(before); }
- virtual XMLNode &serialize()
- {
+ virtual XMLNode &serialize() ;
+ //{
// obj.id
// key is "MementoCommand" or something
// before and after mementos
- }
-}
+ //}
+protected:
+ obj_T &obj;
+ XMLNode &before;
+};
template <class obj_T>
-class MementoRedoCommand : public MementoCommand<obj_T>
+class MementoRedoCommand : public Command
{
public:
- MementoUndoCommand(obj_T &obj,
+ MementoRedoCommand(obj_T &obj,
XMLNode &after)
: obj(obj), after(after) {}
void operator() () { obj.set_state(after); }
void undo() { /* noop */ }
- virtual XMLNode &serialize()
- {
+ virtual XMLNode &serialize();
+ //{
// obj.id
// key is "MementoCommand" or something
// before and after mementos
- }
-}
+ //}
+protected:
+ obj_T &obj;
+ XMLNode &after;
+};
#endif // __lib_pbd_memento_h__
diff --git a/libs/pbd3/pbd/serializable.h b/libs/pbd3/pbd/serializable.h
index c0948b9933..4082b840f0 100644
--- a/libs/pbd3/pbd/serializable.h
+++ b/libs/pbd3/pbd/serializable.h
@@ -27,6 +27,7 @@ class Serializable
{
public:
virtual XMLNode &serialize() = 0;
+ virtual ~Serializable();
};
#endif // __lib_pbd_serializable_h__
diff --git a/libs/pbd3/pbd/undo.h b/libs/pbd3/pbd/undo.h
index b97c8d9249..33577ed4d7 100644
--- a/libs/pbd3/pbd/undo.h
+++ b/libs/pbd3/pbd/undo.h
@@ -32,7 +32,7 @@
using std::string;
using std::list;
-typedef Command UndoAction;
+typedef sigc::slot<void> UndoAction;
class UndoTransaction : public Command
{
@@ -43,10 +43,13 @@ class UndoTransaction : public Command
void clear ();
- void add_command (const UndoAction&);
+ void add_command (Command *const);
void operator() ();
void undo();
+ void redo();
+
+ XMLNode &serialize();
void set_name (const string& str) {
_name = str;
@@ -62,7 +65,7 @@ class UndoTransaction : public Command
}
private:
- list<UndoAction> actions;
+ list<Command*> actions;
struct timeval _timestamp;
string _name;
};
diff --git a/libs/pbd3/undo.cc b/libs/pbd3/undo.cc
index 0a09ffd1e7..43e98313a2 100644
--- a/libs/pbd3/undo.cc
+++ b/libs/pbd3/undo.cc
@@ -47,7 +47,7 @@ UndoTransaction::operator= (const UndoTransaction& rhs)
}
void
-UndoTransaction::add_command (const UndoAction& action)
+UndoTransaction::add_command (Command *const action)
{
actions.push_back (action);
}
@@ -61,8 +61,8 @@ UndoTransaction::clear ()
void
UndoTransaction::operator() ()
{
- for (list<UndoAction>::iterator i = actions.begin(); i != actions.end(); ++i) {
- (*i)();
+ for (list<Command*>::iterator i = actions.begin(); i != actions.end(); ++i) {
+ (*(*i))();
}
}
@@ -70,8 +70,8 @@ void
UndoTransaction::undo ()
{
cerr << "Undo " << _name << endl;
- for (list<UndoAction>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
- i->undo();
+ for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
+ (*i)->undo();
}
}
@@ -112,7 +112,7 @@ UndoHistory::redo (unsigned int n)
UndoTransaction ut = RedoList.back ();
RedoList.pop_back ();
ut.redo ();
- UndoList.push_back (trans);
+ UndoList.push_back (ut);
}
}