Re: Undo stack for GTK+ (was: Re: undo in textview)
- From: Paul Davis <paul linuxaudiosystems com>
- To: Holger Berndt <berndth gmx de>
- Cc: gtk-devel-list gnome org, gtk-list gnome org
- Subject: Re: Undo stack for GTK+ (was: Re: undo in textview)
- Date: Tue, 29 Dec 2009 21:48:11 -0500
On Mon, Dec 28, 2009 at 12:02 PM, Holger Berndt <berndth gmx de> wrote:
> Cross-posting to move the discussion to gtk-devel-list. Anybody interested
> in the topic, please follow up there.
>
> On Do, 24.09.2009 19:23, A. Walton wrote:
>
>>It's definitely something many developers would love to see in Gtk+,
>>but only a few have stepped up to the bat with patches and actually
>>discussed the problem,
>
> Why don't we take the opportunity to discuss the problem now, then? I
> can start by offering my view on how an undo stack should look like,
> and provide a reference implementation as a basis of discussion.
We've been using a C++ type-safe Undo/Redo stack in Ardour for many
years. It was designed after looking at undo models in various other
applications, and finding them all to have various problems for what
we really needed (this included the GIMP). We've learned a number of
things over the years.
1) you need to be able to group individual actions into transactions
2) serialization/deserialization is good, and hard
3) its very hard to use only a Memento pattern without running into
efficiency problems
4) it can be quite hard to correctly implement object lifetime
mamagement for objects involved in callbacks on the undo/redo stack
5) deciding whether or not to support nested transactions can be important
To browse the current implementation:
http://subversion.ardour.org/svn/ardour2/branches/3.0/libs/pbd/undo.cc
http://subversion.ardour.org/svn/ardour2/branches/3.0/libs/pbd/pbd/undo.h
I am not suggesting this as an alternative to your proposal, its just
a real life, battle-tested implementation that avoids pre-registration
of actions that can be undone, and allows arbitrary functors to be
used in the undo/redo stack (note that it uses boost::bind for this
purpose).
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]