Adding undo and redo operations

Project Page Next project post Post History

As I'm getting closer to making a first small project with the Dark Room, I'm finding myself on the edge of needing to undo and redo certain actions. Up until now, I haven't troubled with an undo or redo stack, because I've been testing in a fairly tight environment.

But, as the program gets closer to being ready for a first run, I feel I need to introduce a simple undo stack system for usability.

Undoing an operation requires the program to know some sort of previous state of your project (whatever the program is). Microsoft Word for instance would probably have a pretty complicated undo system. My system doesn't need to be as complicated as that, but I do think I need one just so I can start working on projects in a more fluid way. Something that lets me undo an action if it's not the right one.

There are a few types of undo systems. The most common (and probably the easiest) is to just copy the project each time into some storage area before you make an edit. And when the user hits the undo, you just copy that older project back into the live one.

That's about all I've done here. Simples.

I've made a lot of under-the-hood things work automatically for the Dark Room. And for the undo system, I've tried to do the same. That way making tools and interfaces in the future don't need their own undo system for it to work. The Dark Room handles most undo things once a command (e.g., a button) has been clicked in an interface. But there is a function developers could call for other routines (e.g., something that changes the document that hasn't come from an interface command).

There is also an option to disable the auto undo for any command, on an individual basis. There may be times when you don't want an undo to be added to the system, for example, just opening another window in the viewport. I built in the option to ignore undo actions for commands that don't need one.

Seems to work OK. Barring any little niggles (which I'm sure there will be) hopefully it will be enough for my needs.

Things are coming along nicely.