2 Copyright (C) 2002 Brett Viren & Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __lib_pbd_undo_h__
22 #define __lib_pbd_undo_h__
27 #include <sigc++/slot.h>
28 #include <sigc++/bind.h>
30 #include <pbd/command.h>
32 typedef sigc::slot<void> UndoAction;
34 class UndoTransaction : public Command
38 UndoTransaction (const UndoTransaction&);
39 UndoTransaction& operator= (const UndoTransaction&);
44 void add_command (Command* const);
52 void set_name (const std::string& str) {
55 const std::string& name() const { return _name; }
57 void set_timestamp (struct timeval &t) {
61 const struct timeval& timestamp() const {
66 std::list<Command*> actions;
67 struct timeval _timestamp;
70 void remove_command (Command* const);
79 void add (UndoTransaction* ut);
80 void undo (unsigned int n);
81 void redo (unsigned int n);
83 unsigned long undo_depth() const { return UndoList.size(); }
84 unsigned long redo_depth() const { return RedoList.size(); }
86 std::string next_undo() const { return (UndoList.empty() ? std::string("") : UndoList.back()->name()); }
87 std::string next_redo() const { return (RedoList.empty() ? std::string("") : RedoList.back()->name()); }
98 std::list<UndoTransaction*> UndoList;
99 std::list<UndoTransaction*> RedoList;
101 void remove (UndoTransaction*);
105 #endif /* __lib_pbd_undo_h__ */