Undo/redo interface in openframeworks

I need to implement undo/redo in my openframeworks app. Does Poco have anything ? Can anyone point me in the right direction? Thanks.

1 Like

What is the nature of your undo / redo? Is it text based? Graphics rendering?

There is nothing like this built into GLFW or Poco, so you’ll have to roll your own.

Generally what this means is that you’ll have to structure your editing as a set of reversible “operations”. Then as you are in your “editing” mode, you’ll accumulate these operations until your undo queue is full. When you undo queue is full, you’ll “render” your changes in a destructive way. For image operations, you might think of each operation as an additional layer. While editing, you composite the layers. When a layer goes past the end of the undo queue it is permanently merged with the base image.

For text, it is a little bit simpler. Basically you keep track of each string change operation as a list of inserted (or deleted) text + and the beginning and ending insertion points in the target string.

Anyway … maybe this has nothing to do with your problem, but I thought I’d take a try! :slight_smile: Good luck.

Thanks, My app is graphics based. I know how undo queues work, I just thought there might be something already out there that would save me time.

I found mention of this generic class for undo/redo in Alexandrescu’s Modern C++ Design book, worth a look:

1 Like