Compiles, but doesn't link. The link errors are mostly expected and are

tomorrow's task.

git-svn-id: svn://localhost/ardour2/branches/undo@719 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Fugal 2006-07-29 03:17:11 +00:00
parent 277b771a97
commit 1f1c4981de
30 changed files with 257 additions and 243 deletions

View file

@ -30,6 +30,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/stl_delete.h> #include <pbd/stl_delete.h>
#include <pbd/whitespace.h> #include <pbd/whitespace.h>
#include <pbd/memento_command.h>
#include <gtkmm2ext/bindable_button.h> #include <gtkmm2ext/bindable_button.h>
#include <gtkmm2ext/gtk_ui.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) { switch (op) {
case Cut: case Cut:
before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) { if ((what_we_got = playlist->cut (time)) != 0) {
editor.get_cut_buffer().add (what_we_got); editor.get_cut_buffer().add (what_we_got);
after = playlist->get_state(); XMLNode &after = playlist->get_state();
_session.add_command (MementoCommand<Playlist>(*playlist, before, after)); _session.add_command (new MementoCommand<Playlist>(*playlist, before, after));
ret = true; ret = true;
} }
break; break;
@ -1757,9 +1757,9 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
break; break;
case Clear: case Clear:
before = playlist->get_state();
if ((what_we_got = playlist->cut (time)) != 0) { 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 (); what_we_got->unref ();
ret = true; ret = true;
} }
@ -1790,7 +1790,7 @@ AudioTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection,
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->paste (**p, pos, times); playlist->paste (**p, pos, times);
_session.add_command(MementoCommand<Playlist>(*playlist, before, _session.add_command(new MementoCommand<Playlist>(*playlist, before,
playlist->get_state())); playlist->get_state()));
return true; return true;

View file

@ -23,6 +23,7 @@
#include <vector> #include <vector>
#include <pbd/stl_delete.h> #include <pbd/stl_delete.h>
#include <pbd/memento_command.h>
#include <ardour/automation_event.h> #include <ardour/automation_event.h>
#include <ardour/curve.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()->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; first_drag_fraction = fraction;
last_drag_fraction = fraction; last_drag_fraction = fraction;
@ -936,7 +937,7 @@ AutomationLine::end_drag (ControlPoint* cp)
update_pending = false; 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()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty (); trackview.editor.current_session()->set_dirty ();
} }
@ -1017,7 +1018,7 @@ AutomationLine::remove_point (ControlPoint& cp)
alist.erase (mr.start, mr.end); 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()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty (); trackview.editor.current_session()->set_dirty ();
} }
@ -1227,7 +1228,7 @@ AutomationLine::clear ()
/* parent must create command */ /* parent must create command */
XMLNode &before = get_state(); XMLNode &before = get_state();
alist.clear(); 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()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty (); trackview.editor.current_session()->set_dirty ();
} }

View file

@ -94,7 +94,7 @@ class ControlPoint
ShapeType _shape; ShapeType _shape;
}; };
class AutomationLine : public sigc::trackable class AutomationLine : public sigc::trackable, public Stateful
{ {
public: public:
AutomationLine (const string & name, TimeAxisView&, ArdourCanvas::Group&, ARDOUR::AutomationList&); 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_last_point (ControlPoint &);
bool is_first_point (ControlPoint &); bool is_first_point (ControlPoint &);
XMLNode& get_state (void);
int set_state (const XMLNode&);
protected: protected:
string _name; string _name;
guint32 _height; guint32 _height;

View file

@ -1,4 +1,5 @@
#include <ardour/route.h> #include <ardour/route.h>
#include <pbd/memento_command.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "automation_time_axis.h" #include "automation_time_axis.h"
@ -500,14 +501,13 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
AutomationList& alist (line.the_list()); AutomationList& alist (line.the_list());
bool ret = false; bool ret = false;
XMLNode &before, &after; XMLNode &before = alist.get_state();
before = alist.get_state();
switch (op) { switch (op) {
case Cut: case Cut:
if ((what_we_got = alist.cut (selection.time.front().start, selection.time.front().end)) != 0) { if ((what_we_got = alist.cut (selection.time.front().start, selection.time.front().end)) != 0) {
editor.get_cut_buffer().add (what_we_got); 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; ret = true;
} }
break; break;
@ -519,7 +519,7 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
case Clear: case Clear:
if ((what_we_got = alist.cut (selection.time.front().start, selection.time.front().end)) != 0) { 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; delete what_we_got;
what_we_got = 0; what_we_got = 0;
ret = true; ret = true;
@ -551,7 +551,7 @@ AutomationTimeAxisView::reset_objects_one (AutomationLine& line, PointSelection&
{ {
AutomationList& alist (line.the_list()); 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) { 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* what_we_got = 0;
AutomationList& alist (line.the_list()); AutomationList& alist (line.the_list());
bool ret = false; 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) { 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: case Cut:
if ((what_we_got = alist.cut ((*i).start, (*i).end)) != 0) { if ((what_we_got = alist.cut ((*i).start, (*i).end)) != 0) {
editor.get_cut_buffer().add (what_we_got); 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; ret = true;
} }
break; break;
@ -607,7 +606,7 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
case Clear: case Clear:
if ((what_we_got = alist.cut ((*i).start, (*i).end)) != 0) { 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; delete what_we_got;
what_we_got = 0; what_we_got = 0;
ret = true; ret = true;
@ -666,7 +665,7 @@ AutomationTimeAxisView::paste_one (AutomationLine& line, jack_nframes_t pos, flo
XMLNode &before = alist.get_state(); XMLNode &before = alist.get_state();
alist.paste (copy, pos, times); 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; return true;
} }

View file

@ -28,6 +28,7 @@
#include <pbd/convert.h> #include <pbd/convert.h>
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/memento_command.h>
#include <gtkmm/image.h> #include <gtkmm/image.h>
#include <gdkmm/color.h> #include <gdkmm/color.h>
@ -2970,7 +2971,7 @@ void
Editor::begin_reversible_command (string name) Editor::begin_reversible_command (string name)
{ {
if (session) { if (session) {
before = get_state(); before = &get_state();
session->begin_reversible_command (name); session->begin_reversible_command (name);
} }
} }
@ -2979,12 +2980,7 @@ void
Editor::commit_reversible_command () Editor::commit_reversible_command ()
{ {
if (session) { if (session) {
// yes, cmd lasts long enough to be copied onto the action session->commit_reversible_command (new MementoCommand<Editor>(*this, *before, get_state()));
// 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);
} }
} }

View file

@ -1608,7 +1608,7 @@ class Editor : public PublicEditor
UndoAction get_memento() const; UndoAction get_memento() const;
XMLNode &before; /* used in *_reversible_command */ XMLNode *before; /* used in *_reversible_command */
void begin_reversible_command (string cmd_name); void begin_reversible_command (string cmd_name);
void commit_reversible_command (); void commit_reversible_command ();

View file

@ -31,6 +31,7 @@
#include <ardour/audio_track.h> #include <ardour/audio_track.h>
#include <ardour/audioplaylist.h> #include <ardour/audioplaylist.h>
#include <ardour/audiofilesource.h> #include <ardour/audiofilesource.h>
#include <pbd/memento_command.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "editor.h" #include "editor.h"
@ -320,7 +321,7 @@ int
begin_reversible_command (_("insert sndfile")); begin_reversible_command (_("insert sndfile"));
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->add_region (*copy, pos); 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 (); commit_reversible_command ();
pos += region.length(); pos += region.length();

View file

@ -20,6 +20,7 @@
#include <ardour/audioregion.h> #include <ardour/audioregion.h>
#include <ardour/playlist.h> #include <ardour/playlist.h>
#include <pbd/memento_command.h>
#include "editor.h" #include "editor.h"
#include "regionview.h" #include "regionview.h"
@ -107,7 +108,7 @@ Editor::kbd_mute_unmute_region ()
entered_regionview->region.set_muted (!entered_regionview->region.muted()); entered_regionview->region.set_muted (!entered_regionview->region.muted());
XMLNode &after = entered_regionview->region.playlist()->get_state(); 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(); commit_reversible_command();
} }
} }

View file

@ -26,6 +26,7 @@
#include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/gtk_ui.h>
#include <ardour/location.h> #include <ardour/location.h>
#include <pbd/memento_command.h>
#include "editor.h" #include "editor.h"
#include "marker.h" #include "marker.h"
@ -290,11 +291,10 @@ Editor::mouse_add_new_marker (jack_nframes_t where)
if (session) { if (session) {
Location *location = new Location (where, where, "mark", Location::IsMark); Location *location = new Location (where, where, "mark", Location::IsMark);
session->begin_reversible_command (_("add marker")); session->begin_reversible_command (_("add marker"));
XMLNode &before, &after; XMLNode &before = session->locations()->get_state();
before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
} }
@ -331,11 +331,10 @@ gint
Editor::really_remove_marker (Location* loc) Editor::really_remove_marker (Location* loc)
{ {
session->begin_reversible_command (_("remove marker")); session->begin_reversible_command (_("remove marker"));
XMLNode &before, &after; XMLNode &before = session->locations()->get_state();
before = session->locations()->get_state();
session->locations()->remove (loc); session->locations()->remove (loc);
after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
return FALSE; return FALSE;
} }
@ -848,7 +847,7 @@ Editor::marker_menu_rename ()
loc->set_name (txt); loc->set_name (txt);
XMLNode &after = session->locations()->get_state(); 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 (); commit_reversible_command ();
} }
@ -877,14 +876,14 @@ Editor::new_transport_marker_menu_set_loop ()
session->locations()->add (loc, true); session->locations()->add (loc, true);
session->set_auto_loop_location (loc); session->set_auto_loop_location (loc);
XMLNode &after = session->locations()->get_state(); 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 { else {
XMLNode &before = tll->get_state(); XMLNode &before = tll->get_state();
tll->set_hidden (false, this); tll->set_hidden (false, this);
tll->set (temp_location->start(), temp_location->end()); tll->set (temp_location->start(), temp_location->end());
XMLNode &after = tll->get_state(); 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 (); commit_reversible_command ();
@ -905,13 +904,13 @@ Editor::new_transport_marker_menu_set_punch ()
session->locations()->add (tpl, true); session->locations()->add (tpl, true);
session->set_auto_punch_location (tpl); session->set_auto_punch_location (tpl);
XMLNode &after = session->locations()->get_state(); 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 { } else {
XMLNode &before = tpl->get_state(); XMLNode &before = tpl->get_state();
tpl->set_hidden(false, this); tpl->set_hidden(false, this);
tpl->set(temp_location->start(), temp_location->end()); tpl->set(temp_location->start(), temp_location->end());
XMLNode &after = tpl->get_state(); 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 (); commit_reversible_command ();

View file

@ -27,6 +27,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <pbd/memento_command.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "editor.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")); begin_reversible_command (_("change fade in length"));
XMLNode &before, &after; XMLNode &before = arv->region.get_state();
before = arv->region.get_state();
arv->region.set_fade_in_length (fade_length); arv->region.set_fade_in_length (fade_length);
after = arv->region.get_state(); XMLNode &after = arv->region.get_state();
session->add_command(MementoCommand<ARDOUR::AudioRegion>(arv->region, session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->region,
before, before,
after)); after));
commit_reversible_command (); commit_reversible_command ();
fade_in_drag_motion_callback (item, event); 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")); begin_reversible_command (_("change fade out length"));
XMLNode &before, &after; XMLNode &before = arv->region.get_state();
before = arv->region.get_state();
arv->region.set_fade_out_length (fade_length); arv->region.set_fade_out_length (fade_length);
after = arv->region.get_state(); XMLNode &after = arv->region.get_state();
session->add_command(MementoCommand<ARDOUR::AudioRegion>(arv->region, before, after)); session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->region, before, after));
commit_reversible_command (); commit_reversible_command ();
fade_out_drag_motion_callback (item, event); 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") ); begin_reversible_command ( _("move marker") );
XMLNode &before, &after; XMLNode &before = session->locations()->get_state();
before = session->locations()->get_state();
Location * location = find_location_from_marker (marker, is_start); 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()); location->set (drag_info.copied_location->start(), drag_info.copied_location->end());
} }
after = session->locations()->get_state(); 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 (); commit_reversible_command ();
marker_drag_line->hide(); marker_drag_line->hide();
@ -2272,14 +2270,12 @@ Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
TempoMap& map (session->tempo_map()); TempoMap& map (session->tempo_map());
map.bbt_time (drag_info.last_pointer_frame, when); map.bbt_time (drag_info.last_pointer_frame, when);
XMLNode &before, &after;
if (drag_info.copy == true) { if (drag_info.copy == true) {
begin_reversible_command (_("copy meter mark")); begin_reversible_command (_("copy meter mark"));
before = map.get_state(); XMLNode &before = map.get_state();
map.add_meter (marker->meter(), when); map.add_meter (marker->meter(), when);
after = map.get_state(); 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 (); commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying. // 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; delete marker;
} else { } else {
begin_reversible_command (_("move meter mark")); begin_reversible_command (_("move meter mark"));
before = map.get_state(); XMLNode &before = map.get_state();
map.move_meter (marker->meter(), when); map.move_meter (marker->meter(), when);
after = map.get_state(); 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 (); commit_reversible_command ();
} }
} }
@ -2406,14 +2402,12 @@ Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent*
TempoMap& map (session->tempo_map()); TempoMap& map (session->tempo_map());
map.bbt_time (drag_info.last_pointer_frame, when); map.bbt_time (drag_info.last_pointer_frame, when);
XMLNode &before, &after;
if (drag_info.copy == true) { if (drag_info.copy == true) {
begin_reversible_command (_("copy tempo mark")); begin_reversible_command (_("copy tempo mark"));
before = map.get_state(); XMLNode &before = map.get_state();
map.add_tempo (marker->tempo(), when); map.add_tempo (marker->tempo(), when);
after = map.get_state(); 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 (); commit_reversible_command ();
// delete the dummy marker we used for visual representation of copying. // 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; delete marker;
} else { } else {
begin_reversible_command (_("move tempo mark")); begin_reversible_command (_("move tempo mark"));
before = map.get_state(); XMLNode &before = map.get_state();
map.move_tempo (marker->tempo(), when); map.move_tempo (marker->tempo(), when);
after = map.get_state(); 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 (); commit_reversible_command ();
} }
} }
@ -2787,7 +2781,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
insert_result = affected_playlists.insert (to_playlist); insert_result = affected_playlists.insert (to_playlist);
if (insert_result.second) { 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; latest_regionview = 0;
@ -3225,7 +3219,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
insert_result = motion_frozen_playlists.insert (pl); insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) { if (insert_result.second) {
pl->freeze(); 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); insert_result = motion_frozen_playlists.insert(to_playlist);
if (insert_result.second) { if (insert_result.second) {
to_playlist->freeze(); 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: out:
for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) { for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
(*p)->thaw (); (*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 (); motion_frozen_playlists.clear ();
@ -3630,10 +3624,10 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
Playlist* playlist = clicked_trackview->playlist(); Playlist* playlist = clicked_trackview->playlist();
before = playlist->get_state(); before = &(playlist->get_state());
clicked_trackview->playlist()->add_region (*region, selection->time[clicked_selection].start); clicked_trackview->playlist()->add_region (*region, selection->time[clicked_selection].start);
after = playlist->get_state(); 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 (); commit_reversible_command ();
@ -3997,7 +3991,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
Playlist * pl = (*i)->region.playlist(); Playlist * pl = (*i)->region.playlist();
insert_result = motion_frozen_playlists.insert (pl); insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) { 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) { for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
//(*p)->thaw (); //(*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 (); motion_frozen_playlists.clear ();
@ -4221,24 +4215,22 @@ Editor::point_trim (GdkEvent* event)
i != selection->audio_regions.by_layer().end(); ++i) i != selection->audio_regions.by_layer().end(); ++i)
{ {
if (!(*i)->region.locked()) { if (!(*i)->region.locked()) {
XMLNode &before, &after;
Playlist *pl = (*i)->region.playlist(); Playlist *pl = (*i)->region.playlist();
before = pl->get_state(); XMLNode &before = pl->get_state();
(*i)->region.trim_front (new_bound, this); (*i)->region.trim_front (new_bound, this);
after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(MementoCommand<Playlist>(*pl, before, after)); session->add_command(new MementoCommand<Playlist>(*pl, before, after));
} }
} }
} else { } else {
if (!rv->region.locked()) { if (!rv->region.locked()) {
XMLNode &before, &after;
Playlist *pl = rv->region.playlist(); Playlist *pl = rv->region.playlist();
before = pl->get_state(); XMLNode &before = pl->get_state();
rv->region.trim_front (new_bound, this); rv->region.trim_front (new_bound, this);
after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(MementoCommand<Playlist>(*pl, before, after)); 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) for (list<AudioRegionView*>::const_iterator i = selection->audio_regions.by_layer().begin(); i != selection->audio_regions.by_layer().end(); ++i)
{ {
if (!(*i)->region.locked()) { if (!(*i)->region.locked()) {
XMLNode &before, &after;
Playlist *pl = (*i)->region.playlist(); Playlist *pl = (*i)->region.playlist();
before = pl->get_state(); XMLNode &before = pl->get_state();
(*i)->region.trim_end (new_bound, this); (*i)->region.trim_end (new_bound, this);
after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(MementoCommand<Playlist>(*pl, before, after)); session->add_command(new MementoCommand<Playlist>(*pl, before, after));
} }
} }
} else { } else {
if (!rv->region.locked()) { if (!rv->region.locked()) {
XMLNode &before, &after;
Playlist *pl = rv->region.playlist(); Playlist *pl = rv->region.playlist();
before = pl->get_state(); XMLNode &before = pl->get_state();
rv->region.trim_end (new_bound, this); rv->region.trim_end (new_bound, this);
after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command (MementoCommand<Playlist>(*pl, before, after)); session->add_command (new MementoCommand<Playlist>(*pl, before, after));
} }
} }
@ -4294,7 +4284,7 @@ Editor::thaw_region_after_trim (AudioRegionView& rv)
region.thaw (_("trimmed region")); region.thaw (_("trimmed region"));
XMLNode &after = region.playlist()->get_state(); 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 (); rv.unhide_envelope ();
} }
@ -4431,18 +4421,19 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
switch (range_marker_op) { switch (range_marker_op) {
case CreateRangeMarker: case CreateRangeMarker:
{
begin_reversible_command (_("new range marker")); begin_reversible_command (_("new range marker"));
XMLNode &before, &after; XMLNode &before = session->locations()->get_state();
before = session->locations()->get_state();
newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker); newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker);
session->locations()->add (newloc, true); session->locations()->add (newloc, true);
after = session->locations()->get_state(); 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 (); commit_reversible_command ();
range_bar_drag_rect->hide(); range_bar_drag_rect->hide();
range_marker_drag_rect->hide(); range_marker_drag_rect->hide();
break; break;
}
case CreateTransportMarker: case CreateTransportMarker:
// popup menu to pick loop or punch // 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(); Playlist* playlist = atv->playlist();
double speed = atv->get_diskstream()->speed(); double speed = atv->get_diskstream()->speed();
XMLNode &before, &after; XMLNode &before = playlist->get_state();
before = playlist->get_state();
playlist->add_region (*(new AudioRegion (rv->region)), (jack_nframes_t) (pos * speed)); playlist->add_region (*(new AudioRegion (rv->region)), (jack_nframes_t) (pos * speed));
after = playlist->get_state(); XMLNode &after = playlist->get_state();
session->add_command(MementoCommand<Playlist>(*playlist, before, after)); session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
// playlist is frozen, so we have to update manually // playlist is frozen, so we have to update manually

View file

@ -28,6 +28,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/basename.h> #include <pbd/basename.h>
#include <pbd/pthread_utils.h> #include <pbd/pthread_utils.h>
#include <pbd/memento_command.h>
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <gtkmm2ext/choice.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(); _new_regionviews_show_envelope = (*a)->envelope_visible();
if (pl) { if (pl) {
XMLNode &before, &after; XMLNode &before = pl->get_state();
before = pl->get_state();
pl->split_region ((*a)->region, where); pl->split_region ((*a)->region, where);
after = pl->get_state(); XMLNode &after = pl->get_state();
session->add_command(MementoCommand<Playlist>(*pl, before, after)); session->add_command(new MementoCommand<Playlist>(*pl, before, after));
} }
a = tmp; a = tmp;
@ -234,7 +234,7 @@ Editor::remove_clicked_region ()
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->remove_region (&clicked_regionview->region); playlist->remove_region (&clicked_regionview->region);
XMLNode &after = playlist->get_state(); 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 (); commit_reversible_command ();
} }
@ -410,7 +410,7 @@ Editor::nudge_forward (bool next)
XMLNode &before = r.playlist()->get_state(); XMLNode &before = r.playlist()->get_state();
r.set_position (r.position() + distance, this); r.set_position (r.position() + distance, this);
XMLNode &after = r.playlist()->get_state(); 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 (); commit_reversible_command ();
@ -450,7 +450,7 @@ Editor::nudge_backward (bool next)
r.set_position (0, this); r.set_position (0, this);
} }
XMLNode &after = r.playlist()->get_state(); 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 (); 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) { for (AudioRegionSelection::iterator i = selection->audio_regions.begin(); i != selection->audio_regions.end(); ++i) {
AudioRegion& r ((*i)->region); AudioRegion& r ((*i)->region);
XMLNode &before, &after; XMLNode &before = r.playlist()->get_state();
before = r.playlist()->get_state();
r.set_position (r.position() + distance, this); r.set_position (r.position() + distance, this);
after = r.playlist()->get_state(); 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 (); commit_reversible_command ();
@ -519,7 +518,7 @@ Editor::nudge_backward_capture_offset ()
r.set_position (0, this); r.set_position (0, this);
} }
XMLNode &after = r.playlist()->get_state(); 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 (); commit_reversible_command ();
@ -1299,7 +1298,7 @@ Editor::add_location_from_selection ()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
@ -1313,7 +1312,7 @@ Editor::add_location_from_playhead_cursor ()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
@ -1332,7 +1331,7 @@ Editor::add_location_from_audio_region ()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
@ -1751,7 +1750,7 @@ Editor::clear_markers ()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->clear_markers (); session->locations()->clear_markers ();
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
} }
@ -1772,7 +1771,7 @@ Editor::clear_ranges ()
if (punchloc) session->locations()->add (punchloc); if (punchloc) session->locations()->add (punchloc);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
} }
@ -1784,7 +1783,7 @@ Editor::clear_locations ()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->clear (); session->locations()->clear ();
XMLNode &after = session->locations()->get_state(); 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->commit_reversible_command ();
session->locations()->clear (); session->locations()->clear ();
} }
@ -1834,7 +1833,7 @@ Editor::insert_region_list_drag (AudioRegion& region, int x, int y)
begin_reversible_command (_("insert dragged region")); begin_reversible_command (_("insert dragged region"));
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->add_region (*(new AudioRegion (region)), where, 1.0); 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 (); commit_reversible_command ();
} }
@ -1870,7 +1869,7 @@ Editor::insert_region_list_selection (float times)
begin_reversible_command (_("insert region")); begin_reversible_command (_("insert region"));
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->add_region (*(createRegion (*region)), edit_cursor->current_frame, times); 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 (); commit_reversible_command ();
} }
@ -2291,9 +2290,9 @@ Editor::separate_region_from_selection ()
begin_reversible_command (_("separate")); begin_reversible_command (_("separate"));
doing_undo = true; doing_undo = true;
} }
XMLNode &before, &after; XMLNode *before;
if (doing_undo) if (doing_undo)
before = playlist->get_state(); before = &(playlist->get_state());
/* XXX need to consider musical time selections here at some point */ /* XXX need to consider musical time selections here at some point */
@ -2304,7 +2303,7 @@ Editor::separate_region_from_selection ()
} }
if (doing_undo) 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 (atv->is_audio_track()) {
if ((playlist = atv->playlist()) != 0) { if ((playlist = atv->playlist()) != 0) {
XMLNode &before, &after; XMLNode *before;
if (!doing_undo) { if (!doing_undo) {
begin_reversible_command (_("separate")); begin_reversible_command (_("separate"));
doing_undo = true; doing_undo = true;
} }
if (doing_undo) if (doing_undo)
before = playlist->get_state(); before = &(playlist->get_state());
/* XXX need to consider musical time selections here at some point */ /* 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); playlist->partition ((jack_nframes_t)(loc.start() * speed), (jack_nframes_t)(loc.end() * speed), true);
if (doing_undo) 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(); XMLNode &before = (*i)->get_state();
region->trim_to (start, cnt, this); region->trim_to (start, cnt, this);
XMLNode &after = (*i)->get_state(); 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 (); commit_reversible_command ();
@ -2466,7 +2465,7 @@ Editor::region_fill_track ()
XMLNode &before = pl->get_state(); XMLNode &before = pl->get_state();
pl->add_region (*(new AudioRegion (region)), region.last_frame(), times); 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 (); commit_reversible_command ();
@ -2516,7 +2515,7 @@ Editor::region_fill_selection ()
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->add_region (*(createRegion (*region)), start, times); 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 (); 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(); XMLNode &before = region.playlist()->get_state();
region.set_sync_position (position); region.set_sync_position (position);
XMLNode &after = region.playlist()->get_state(); 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 (); commit_reversible_command ();
} }
@ -2555,7 +2554,7 @@ Editor::set_region_sync_from_edit_cursor ()
XMLNode &before = region.playlist()->get_state(); XMLNode &before = region.playlist()->get_state();
region.set_sync_position (edit_cursor->current_frame); region.set_sync_position (edit_cursor->current_frame);
XMLNode &after = region.playlist()->get_state(); 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 (); commit_reversible_command ();
} }
@ -2568,7 +2567,7 @@ Editor::remove_region_sync ()
XMLNode &before = region.playlist()->get_state(); XMLNode &before = region.playlist()->get_state();
region.clear_sync_position (); region.clear_sync_position ();
XMLNode &after = region.playlist()->get_state(); 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 (); commit_reversible_command ();
} }
} }
@ -2584,7 +2583,7 @@ Editor::naturalize ()
XMLNode &before = (*i)->region.get_state(); XMLNode &before = (*i)->region.get_state();
(*i)->region.move_to_natural_position (this); (*i)->region.move_to_natural_position (this);
XMLNode &after = (*i)->region.get_state(); 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 (); commit_reversible_command ();
} }
@ -2659,7 +2658,7 @@ Editor::align_selection_relative (RegionPoint point, jack_nframes_t position)
} }
XMLNode &after = region.playlist()->get_state(); 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 void
Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t position) Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t position)
{ {
XMLNode &before, &after; XMLNode &before = region.playlist()->get_state();
before = region.playlist()->get_state();
switch (point) { switch (point) {
case SyncPoint: case SyncPoint:
@ -2712,8 +2710,8 @@ Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t
break; break;
} }
after = region.playlist()->get_state(); 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));
} }
void void
@ -2738,7 +2736,7 @@ Editor::trim_region_to_edit_cursor ()
XMLNode &before = region.playlist()->get_state(); XMLNode &before = region.playlist()->get_state();
region.trim_end( session_frame_to_track_frame(edit_cursor->current_frame, speed), this); region.trim_end( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
XMLNode &after = region.playlist()->get_state(); 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 (); commit_reversible_command ();
} }
@ -2764,7 +2762,7 @@ Editor::trim_region_from_edit_cursor ()
XMLNode &before = region.playlist()->get_state(); XMLNode &before = region.playlist()->get_state();
region.trim_front ( session_frame_to_track_frame(edit_cursor->current_frame, speed), this); region.trim_front ( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
XMLNode &after = region.playlist()->get_state(); 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 (); commit_reversible_command ();
} }
@ -2879,7 +2877,7 @@ Editor::bounce_range_selection ()
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
atv->audio_track()->bounce_range (start, cnt, itt); atv->audio_track()->bounce_range (start, cnt, itt);
XMLNode &after = playlist->get_state(); 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 (); commit_reversible_command ();
@ -2997,7 +2995,7 @@ Editor::cut_copy_regions (CutCopyOp op)
insert_result = freezelist.insert (pl); insert_result = freezelist.insert (pl);
if (insert_result.second) { if (insert_result.second) {
pl->freeze (); 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) { for (set<Playlist*>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
(*pl)->thaw (); (*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(); XMLNode &before = apl->get_state();
apl->paste (**chunk, edit_cursor->current_frame, times); 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()) { if (tmp != ns->playlists.end()) {
chunk = tmp; chunk = tmp;
@ -3201,7 +3199,7 @@ Editor::duplicate_some_regions (AudioRegionSelection& regions, float times)
playlist = (*i)->region.playlist(); playlist = (*i)->region.playlist();
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->duplicate (r, r.last_frame(), times); 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 (); c.disconnect ();
@ -3242,7 +3240,7 @@ Editor::duplicate_selection (float times)
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->duplicate (**ri, selection->time[clicked_selection].end, times); playlist->duplicate (**ri, selection->time[clicked_selection].end, times);
XMLNode &after = playlist->get_state(); XMLNode &after = playlist->get_state();
session->add_command (MementoCommand<Playlist>(*playlist, before, after)); session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
++ri; ++ri;
if (ri == new_regions.end()) { if (ri == new_regions.end()) {
@ -3293,7 +3291,7 @@ Editor::clear_playlist (Playlist& playlist)
XMLNode &before = playlist.get_state(); XMLNode &before = playlist.get_state();
playlist.clear (); playlist.clear ();
XMLNode &after = playlist.get_state(); 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 (); commit_reversible_command ();
} }
@ -3330,7 +3328,7 @@ Editor::nudge_track (bool use_edit_cursor, bool forwards)
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->nudge_after (start, distance, forwards); playlist->nudge_after (start, distance, forwards);
XMLNode &after = playlist->get_state(); 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 (); commit_reversible_command ();
@ -3384,7 +3382,7 @@ Editor::normalize_region ()
XMLNode &before = (*r)->region.get_state(); XMLNode &before = (*r)->region.get_state();
(*r)->region.normalize_to (0.0f); (*r)->region.normalize_to (0.0f);
XMLNode &after = (*r)->region.get_state(); 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 (); commit_reversible_command ();
@ -3409,7 +3407,7 @@ Editor::denormalize_region ()
XMLNode &before = (*r)->region.get_state(); XMLNode &before = (*r)->region.get_state();
(*r)->region.set_scale_amplitude (1.0f); (*r)->region.set_scale_amplitude (1.0f);
XMLNode &after = (*r)->region.get_state(); 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 (); commit_reversible_command ();
@ -3454,7 +3452,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->replace_region (region, *(filter.results.front()), region.position()); playlist->replace_region (region, *(filter.results.front()), region.position());
XMLNode &after = playlist->get_state(); XMLNode &after = playlist->get_state();
session->add_command(MementoCommand<Playlist>(*playlist, before, after)); session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
} else { } else {
goto out; goto out;
} }

View file

@ -27,6 +27,7 @@
#include <libgnomecanvasmm.h> #include <libgnomecanvasmm.h>
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/memento_command.h>
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <gtkmm2ext/gtk_ui.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(); XMLNode &before = map.get_state();
map.add_tempo (Tempo (bpm), requested); map.add_tempo (Tempo (bpm), requested);
XMLNode &after = map.get_state(); 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 (); commit_reversible_command ();
map.dump (cerr); map.dump (cerr);
@ -316,7 +317,7 @@ Editor::mouse_add_new_meter_event (jack_nframes_t frame)
begin_reversible_command (_("add meter mark")); begin_reversible_command (_("add meter mark"));
XMLNode &before = map.get_state(); XMLNode &before = map.get_state();
map.add_meter (Meter (bpb, note_type), requested); 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 (); commit_reversible_command ();
map.dump (cerr); map.dump (cerr);
@ -367,8 +368,8 @@ Editor::edit_meter_section (MeterSection* section)
begin_reversible_command (_("replace tempo mark")); begin_reversible_command (_("replace tempo mark"));
XMLNode &before = session->tempo_map().get_state(); XMLNode &before = session->tempo_map().get_state();
session->tempo_map().replace_meter (*section, Meter (bpb, note_type)); session->tempo_map().replace_meter (*section, Meter (bpb, note_type));
XMLNode &before = session->tempo_map().get_state(); 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 (); commit_reversible_command ();
} }
@ -398,7 +399,7 @@ Editor::edit_tempo_section (TempoSection* section)
session->tempo_map().replace_tempo (*section, Tempo (bpm)); session->tempo_map().replace_tempo (*section, Tempo (bpm));
session->tempo_map().move_tempo (*section, when); session->tempo_map().move_tempo (*section, when);
XMLNode &after = session->tempo_map().get_state(); 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 (); commit_reversible_command ();
} }
@ -447,7 +448,7 @@ Editor::real_remove_tempo_marker (TempoSection *section)
XMLNode &before = session->tempo_map().get_state(); XMLNode &before = session->tempo_map().get_state();
session->tempo_map().remove_tempo (*section); session->tempo_map().remove_tempo (*section);
XMLNode &after = session->tempo_map().get_state(); 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 (); commit_reversible_command ();
return FALSE; return FALSE;
@ -481,7 +482,7 @@ Editor::real_remove_meter_marker (MeterSection *section)
XMLNode &before = session->tempo_map().get_state(); XMLNode &before = session->tempo_map().get_state();
session->tempo_map().remove_meter (*section); session->tempo_map().remove_meter (*section);
XMLNode &after = session->tempo_map().get_state(); 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 (); commit_reversible_command ();
return FALSE; return FALSE;
} }

View file

@ -25,6 +25,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/pthread_utils.h> #include <pbd/pthread_utils.h>
#include <pbd/memento_command.h>
#include "editor.h" #include "editor.h"
#include "audio_time_axis.h" #include "audio_time_axis.h"
@ -206,7 +207,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
XMLNode &before = playlist->get_state(); XMLNode &before = playlist->get_state();
playlist->replace_region (aregion, *new_region, aregion.position()); playlist->replace_region (aregion, *new_region, aregion.position());
XMLNode &after = playlist->get_state(); XMLNode &after = playlist->get_state();
session->add_command (MementoCommand<Playlist>(*playlist, before, after)); session->add_command (new MementoCommand<Playlist>(*playlist, before, after));
i = tmp; i = tmp;
} }

View file

@ -20,6 +20,7 @@
#include <ardour/curve.h> #include <ardour/curve.h>
#include <ardour/route.h> #include <ardour/route.h>
#include <pbd/memento_command.h>
#include "gain_automation_time_axis.h" #include "gain_automation_time_axis.h"
#include "automation_line.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")); _session.begin_reversible_command (_("add gain automation event"));
XMLNode &before, &after; XMLNode &before = curve.get_state();
before = curve.get_state();
curve.add (when, y); curve.add (when, y);
after = curve.get_state(); XMLNode &after = curve.get_state();
_session.add_command(MementoCommand<ARDOUR::Curve>(curve, before, after)); _session.add_command(new MementoCommand<ARDOUR::Curve>(curve, before, after));
_session.commit_reversible_command (); _session.commit_reversible_command ();
_session.set_dirty (); _session.set_dirty ();
} }

View file

@ -27,6 +27,7 @@
#include <ardour/utils.h> #include <ardour/utils.h>
#include <ardour/configuration.h> #include <ardour/configuration.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <pbd/memento_command.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "prompter.h" #include "prompter.h"
@ -654,11 +655,10 @@ gint LocationUI::do_location_remove (ARDOUR::Location *loc)
} }
session->begin_reversible_command (_("remove marker")); session->begin_reversible_command (_("remove marker"));
XMLNode &before, &after; XMLNode &before = session->locations()->get_state();
before = session->locations()->get_state();
session->locations()->remove (loc); session->locations()->remove (loc);
after = session->locations()->get_state(); XMLNode &after = session->locations()->get_state();
session->add_command(MementoCommand<Location>(*(session->locations()), before, after)); session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
session->commit_reversible_command (); session->commit_reversible_command ();
return FALSE; return FALSE;
@ -777,7 +777,7 @@ LocationUI::add_new_location()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
@ -794,7 +794,7 @@ LocationUI::add_new_range()
XMLNode &before = session->locations()->get_state(); XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true); session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state(); 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 (); session->commit_reversible_command ();
} }
} }

View file

@ -23,6 +23,7 @@
#include <ardour/panner.h> #include <ardour/panner.h>
#include <gtkmm2ext/popup.h> #include <gtkmm2ext/popup.h>
#include <pbd/memento_command.h>
#include "pan_automation_time_axis.h" #include "pan_automation_time_axis.h"
#include "automation_line.h" #include "automation_line.h"
@ -78,11 +79,10 @@ PanAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEv
AutomationList& alist (lines.front()->the_list()); AutomationList& alist (lines.front()->the_list());
_session.begin_reversible_command (_("add pan automation event")); _session.begin_reversible_command (_("add pan automation event"));
XMLNode &before, &after; XMLNode &before = alist.get_state();
before = alist.get_state();
alist.add (when, y); alist.add (when, y);
after = alist.get_state(); XMLNode &after = alist.get_state();
_seession.add_command(MementoCommand<AutomationList>(alist, before, after)); _session.add_command(new MementoCommand<AutomationList>(alist, before, after));
_session.commit_reversible_command (); _session.commit_reversible_command ();
_session.set_dirty (); _session.set_dirty ();
} }

View file

@ -21,6 +21,7 @@
#include <ardour/redirect.h> #include <ardour/redirect.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <cstdlib> #include <cstdlib>
#include <pbd/memento_command.h>
#include "redirect_automation_time_axis.h" #include "redirect_automation_time_axis.h"
#include "automation_line.h" #include "automation_line.h"
@ -97,11 +98,10 @@ RedirectAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item,
lines.front()->view_to_model_y (y); lines.front()->view_to_model_y (y);
_session.begin_reversible_command (description); _session.begin_reversible_command (description);
XMLNode &before, &after; XMLNode &before = alist.get_state();
before = alist.get_state();
alist.add (when, y); alist.add (when, y);
after = alist.get_state(); XMLNode &after = alist.get_state();
_session.add_command(MementoCommand<AutomationList>(alist, before, after)); _session.add_command(new MementoCommand<AutomationList>(alist, before, after));
_session.commit_reversible_command (); _session.commit_reversible_command ();
_session.set_dirty (); _session.set_dirty ();
} }

View file

@ -1,5 +1,6 @@
#include <ardour/curve.h> #include <ardour/curve.h>
#include <ardour/audioregion.h> #include <ardour/audioregion.h>
#include <pbd/memento_command.h>
#include "region_gain_line.h" #include "region_gain_line.h"
#include "regionview.h" #include "regionview.h"
@ -47,7 +48,7 @@ AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
{ {
AutomationLine::start_drag(cp,fraction); AutomationLine::start_drag(cp,fraction);
if (!rv.region.envelope_active()) { 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); rv.region.set_envelope_active(false);
} }
} }
@ -67,12 +68,12 @@ AudioRegionGainLine::remove_point (ControlPoint& cp)
XMLNode &before = rv.region.get_state(); XMLNode &before = rv.region.get_state();
rv.region.set_envelope_active(true); rv.region.set_envelope_active(true);
XMLNode &after = rv.region.get_state(); 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); 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()->commit_reversible_command ();
trackview.editor.current_session()->set_dirty (); trackview.editor.current_session()->set_dirty ();
} }
@ -82,7 +83,7 @@ AudioRegionGainLine::end_drag (ControlPoint* cp)
{ {
if (!rv.region.envelope_active()) { if (!rv.region.envelope_active()) {
rv.region.set_envelope_active(true); 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); AutomationLine::end_drag(cp);
} }

View file

@ -29,6 +29,7 @@
#include <ardour/audioregion.h> #include <ardour/audioregion.h>
#include <ardour/audiosource.h> #include <ardour/audiosource.h>
#include <ardour/audio_diskstream.h> #include <ardour/audio_diskstream.h>
#include <pbd/memento_command.h>
#include "streamview.h" #include "streamview.h"
#include "regionview.h" #include "regionview.h"
@ -1148,17 +1149,16 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
if (!region.envelope_active()) { if (!region.envelope_active()) {
XMLNode &before, &after; XMLNode &before = region.get_state();
before = region.get_state();
region.set_envelope_active(true); region.set_envelope_active(true);
after = region.get_state(); XMLNode &after = region.get_state();
trackview.session().add_command(MementoCommand<AudioRegion>(region, before, after)); trackview.session().add_command(new MementoCommand<AudioRegion>(region, before, after));
} }
region.envelope().add (fx, y); region.envelope().add (fx, y);
XMLNode &after = region.envelope().get_state(); 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 (); trackview.session().commit_reversible_command ();
} }

View file

@ -25,6 +25,7 @@
#include <gtkmm2ext/doi.h> #include <gtkmm2ext/doi.h>
#include <ardour/route_group.h> #include <ardour/route_group.h>
#include <pbd/memento_command.h>
#include "route_ui.h" #include "route_ui.h"
#include "keyboard.h" #include "keyboard.h"
@ -132,9 +133,9 @@ RouteUI::mute_press(GdkEventButton* ev)
/* ctrl-shift-click applies change to all routes */ /* ctrl-shift-click applies change to all routes */
_session.begin_reversible_command (_("mute change")); _session.begin_reversible_command (_("mute change"));
Session::GlobalMuteStateCommand cmd(this); Session::GlobalMuteStateCommand *cmd = new Session::GlobalMuteStateCommand(this);
_session.set_all_mute (!_route.muted()); _session.set_all_mute (!_route.muted());
cmd.mark(); cmd->mark();
_session.add_command(cmd); _session.add_command(cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
@ -208,9 +209,9 @@ RouteUI::solo_press(GdkEventButton* ev)
/* ctrl-shift-click applies change to all routes */ /* ctrl-shift-click applies change to all routes */
_session.begin_reversible_command (_("solo change")); _session.begin_reversible_command (_("solo change"));
Session::GlobalSoloStateCommand cmd(this); Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand(this);
_session.set_all_solo (!_route.soloed()); _session.set_all_solo (!_route.soloed());
cmd.mark(); cmd->mark();
_session.add_command (cmd); _session.add_command (cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
@ -219,10 +220,10 @@ RouteUI::solo_press(GdkEventButton* ev)
// ctrl-alt-click: exclusively solo this track, not a toggle */ // ctrl-alt-click: exclusively solo this track, not a toggle */
_session.begin_reversible_command (_("solo change")); _session.begin_reversible_command (_("solo change"));
Session::GlobalSoloStateCommand cmd(this); Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand (this);
_session.set_all_solo (false); _session.set_all_solo (false);
_route.set_solo (true, this); _route.set_solo (true, this);
cmd.mark(); cmd->mark();
_session.add_command(cmd); _session.add_command(cmd);
_session.commit_reversible_command (); _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))) { else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) {
_session.begin_reversible_command (_("rec-enable change")); _session.begin_reversible_command (_("rec-enable change"));
Session::GlobalRecordEnableStateCommand cmd(this); Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(this);
if (rec_enable_button->get_active()) { if (rec_enable_button->get_active()) {
_session.record_disenable_all (); _session.record_disenable_all ();
@ -291,7 +292,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev)
_session.record_enable_all (); _session.record_enable_all ();
} }
cmd.mark(); cmd->mark();
_session.add_command(cmd); _session.add_command(cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
@ -561,9 +562,9 @@ RouteUI::set_mix_group_solo(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){ if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group solo change")); _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); mix_group->apply(&Route::set_solo, yn, this);
cmd.mark(); cmd->mark();
_session.add_command (cmd); _session.add_command (cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
} else { } else {
@ -578,7 +579,7 @@ RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool,
XMLNode &before = _route.get_state(); XMLNode &before = _route.get_state();
bind(mem_fun(_route, func), yn, arg)(); bind(mem_fun(_route, func), yn, arg)();
XMLNode &after = _route.get_state(); 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 (); _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(); XMLNode &before = audio_track()->get_state();
bind (mem_fun (*audio_track(), func), yn, arg)(); bind (mem_fun (*audio_track(), func), yn, arg)();
XMLNode &after = audio_track()->get_state(); 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 (); _session.commit_reversible_command ();
} }
@ -600,9 +601,9 @@ RouteUI::set_mix_group_mute(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){ if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group mute change")); _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); mix_group->apply(&Route::set_mute, yn, this);
cmd.mark(); cmd->mark();
_session.add_command(cmd); _session.add_command(cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
} else { } else {
@ -617,9 +618,9 @@ RouteUI::set_mix_group_rec_enable(Route& route, bool yn)
if((mix_group = route.mix_group()) != 0){ if((mix_group = route.mix_group()) != 0){
_session.begin_reversible_command (_("mix group rec-enable change")); _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); mix_group->apply (&Route::set_record_enable, yn, this);
cmd.mark(); cmd->mark();
_session.add_command(cmd); _session.add_command(cmd);
_session.commit_reversible_command (); _session.commit_reversible_command ();
} else { } else {

View file

@ -51,7 +51,7 @@ struct ControlEvent {
}; };
class AutomationList : public StateManager class AutomationList : public StateManager, public Stateful
{ {
public: public:
typedef std::list<ControlEvent*> AutomationEventList; typedef std::list<ControlEvent*> AutomationEventList;
@ -153,6 +153,12 @@ class AutomationList : public StateManager
virtual void store_state (XMLNode& node) const; virtual void store_state (XMLNode& node) const;
virtual void load_state (const XMLNode&); 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); void set_max_xval (double);
double get_max_xval() const { return max_xval; } double get_max_xval() const { return max_xval; }

View file

@ -844,7 +844,7 @@ class Session : public sigc::trackable, public Stateful
void begin_reversible_command (string cmd_name); void begin_reversible_command (string cmd_name);
void commit_reversible_command (Command* cmd = 0); void commit_reversible_command (Command* cmd = 0);
void add_command (const Command& cmd) { void add_command (Command *const cmd) {
current_trans.add_command (cmd); current_trans.add_command (cmd);
} }
@ -859,7 +859,7 @@ class Session : public sigc::trackable, public Stateful
void undo(); void undo();
XMLNode &serialize(); XMLNode &serialize();
void mark(); void mark();
} };
class GlobalMuteStateCommand : public Command class GlobalMuteStateCommand : public Command
{ {
@ -871,7 +871,7 @@ class Session : public sigc::trackable, public Stateful
void undo(); void undo();
XMLNode &serialize(); XMLNode &serialize();
void mark(); void mark();
} };
class GlobalRecordEnableStateCommand : public Command class GlobalRecordEnableStateCommand : public Command
{ {
@ -883,7 +883,7 @@ class Session : public sigc::trackable, public Stateful
void undo(); void undo();
XMLNode &serialize(); XMLNode &serialize();
void mark(); void mark();
} };
class GlobalMeteringStateCommand : public Command class GlobalMeteringStateCommand : public Command
{ {
@ -895,7 +895,7 @@ class Session : public sigc::trackable, public Stateful
void undo(); void undo();
XMLNode &serialize(); XMLNode &serialize();
void mark(); void mark();
} };
/* edit mode */ /* edit mode */

View file

@ -35,6 +35,7 @@
#include <pbd/basename.h> #include <pbd/basename.h>
#include <glibmm/thread.h> #include <glibmm/thread.h>
#include <pbd/xml++.h> #include <pbd/xml++.h>
#include <pbd/memento_command.h>
#include <ardour/ardour.h> #include <ardour/ardour.h>
#include <ardour/audioengine.h> #include <ardour/audioengine.h>
@ -1833,7 +1834,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
_playlist->thaw (); _playlist->thaw ();
XMLNode &after = _playlist->get_state(); 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; mark_write_completed = true;

View file

@ -1,5 +1,6 @@
#include <ardour/session.h> #include <ardour/session.h>
namespace ARDOUR {
// solo // solo
Session::GlobalSoloStateCommand::GlobalSoloStateCommand(void *src) : src(src) Session::GlobalSoloStateCommand::GlobalSoloStateCommand(void *src) : src(src)
{ {
@ -84,3 +85,4 @@ XMLNode &serialize()
{ {
} }
} // namespace ARDOUR

View file

@ -2576,7 +2576,7 @@ Session::commit_reversible_command (Command *cmd)
struct timeval now; struct timeval now;
if (cmd) { if (cmd) {
current_trans.add_command (*cmd); current_trans.add_command (cmd);
} }
gettimeofday (&now, 0); 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); set_global_route_boolean (s, &Route::set_record_enable, src);
} }
#if 0
UndoAction UndoAction
Session::global_mute_memento (void* src) 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); return sigc::bind (mem_fun (*this, &Session::set_global_record_enable), get_global_route_boolean (&Route::record_enabled), src);
} }
#endif
static bool static bool
template_filter (const string &str, void *arg) template_filter (const string &str, void *arg)

View file

@ -29,6 +29,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <glibmm/thread.h> #include <glibmm/thread.h>
#include <pbd/pthread_utils.h> #include <pbd/pthread_utils.h>
#include <pbd/memento_command.h>
#include <midi++/mmc.h> #include <midi++/mmc.h>
#include <midi++/port.h> #include <midi++/port.h>
@ -323,7 +324,7 @@ Session::non_realtime_stop (bool abort)
XMLNode &before = loc->get_state(); XMLNode &before = loc->get_state();
loc->set_end(_transport_frame); loc->set_end(_transport_frame);
XMLNode &after = loc->get_state(); 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; _end_location_is_free = false;

View file

@ -39,12 +39,12 @@ class MementoCommand : public Command
: obj(obj), before(before), after(after) {} : obj(obj), before(before), after(after) {}
void operator() () { obj.set_state(after); } void operator() () { obj.set_state(after); }
void undo() { obj.set_state(before); } void undo() { obj.set_state(before); }
virtual XMLNode &serialize() virtual XMLNode &serialize() ;
{ //{
// obj.id // obj.id
// key is "MementoCommand" or something // key is "MementoCommand" or something
// before and after mementos // before and after mementos
} //}
// TODO does this need a copy constructor? // TODO does this need a copy constructor?
protected: protected:
obj_T &obj; obj_T &obj;
@ -52,7 +52,7 @@ class MementoCommand : public Command
}; };
template <class obj_T> template <class obj_T>
class MementoUndoCommand : public MementoCommand<obj_T> class MementoUndoCommand : public Command
{ {
public: public:
MementoUndoCommand(obj_T &obj, MementoUndoCommand(obj_T &obj,
@ -60,29 +60,35 @@ public:
: obj(obj), before(before) {} : obj(obj), before(before) {}
void operator() () { /* noop */ } void operator() () { /* noop */ }
void undo() { obj.set_state(before); } void undo() { obj.set_state(before); }
virtual XMLNode &serialize() virtual XMLNode &serialize() ;
{ //{
// obj.id // obj.id
// key is "MementoCommand" or something // key is "MementoCommand" or something
// before and after mementos // before and after mementos
} //}
} protected:
obj_T &obj;
XMLNode &before;
};
template <class obj_T> template <class obj_T>
class MementoRedoCommand : public MementoCommand<obj_T> class MementoRedoCommand : public Command
{ {
public: public:
MementoUndoCommand(obj_T &obj, MementoRedoCommand(obj_T &obj,
XMLNode &after) XMLNode &after)
: obj(obj), after(after) {} : obj(obj), after(after) {}
void operator() () { obj.set_state(after); } void operator() () { obj.set_state(after); }
void undo() { /* noop */ } void undo() { /* noop */ }
virtual XMLNode &serialize() virtual XMLNode &serialize();
{ //{
// obj.id // obj.id
// key is "MementoCommand" or something // key is "MementoCommand" or something
// before and after mementos // before and after mementos
} //}
} protected:
obj_T &obj;
XMLNode &after;
};
#endif // __lib_pbd_memento_h__ #endif // __lib_pbd_memento_h__

View file

@ -27,6 +27,7 @@ class Serializable
{ {
public: public:
virtual XMLNode &serialize() = 0; virtual XMLNode &serialize() = 0;
virtual ~Serializable();
}; };
#endif // __lib_pbd_serializable_h__ #endif // __lib_pbd_serializable_h__

View file

@ -32,7 +32,7 @@
using std::string; using std::string;
using std::list; using std::list;
typedef Command UndoAction; typedef sigc::slot<void> UndoAction;
class UndoTransaction : public Command class UndoTransaction : public Command
{ {
@ -43,10 +43,13 @@ class UndoTransaction : public Command
void clear (); void clear ();
void add_command (const UndoAction&); void add_command (Command *const);
void operator() (); void operator() ();
void undo(); void undo();
void redo();
XMLNode &serialize();
void set_name (const string& str) { void set_name (const string& str) {
_name = str; _name = str;
@ -62,7 +65,7 @@ class UndoTransaction : public Command
} }
private: private:
list<UndoAction> actions; list<Command*> actions;
struct timeval _timestamp; struct timeval _timestamp;
string _name; string _name;
}; };

View file

@ -47,7 +47,7 @@ UndoTransaction::operator= (const UndoTransaction& rhs)
} }
void void
UndoTransaction::add_command (const UndoAction& action) UndoTransaction::add_command (Command *const action)
{ {
actions.push_back (action); actions.push_back (action);
} }
@ -61,8 +61,8 @@ UndoTransaction::clear ()
void void
UndoTransaction::operator() () UndoTransaction::operator() ()
{ {
for (list<UndoAction>::iterator i = actions.begin(); i != actions.end(); ++i) { for (list<Command*>::iterator i = actions.begin(); i != actions.end(); ++i) {
(*i)(); (*(*i))();
} }
} }
@ -70,8 +70,8 @@ void
UndoTransaction::undo () UndoTransaction::undo ()
{ {
cerr << "Undo " << _name << endl; cerr << "Undo " << _name << endl;
for (list<UndoAction>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) { for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
i->undo(); (*i)->undo();
} }
} }
@ -112,7 +112,7 @@ UndoHistory::redo (unsigned int n)
UndoTransaction ut = RedoList.back (); UndoTransaction ut = RedoList.back ();
RedoList.pop_back (); RedoList.pop_back ();
ut.redo (); ut.redo ();
UndoList.push_back (trans); UndoList.push_back (ut);
} }
} }