fabric-engine/JSSceneGraph — pull request #137 by phtaylor (2012-02-10 16:12:11+00:00)
Title: Bracketed undo

@ Helge:

The undo system now works using a system of 'Transactions' which can contain 1 or more 'Actions'.

You can open a transaction, and then add as many actions as you like, and then close the transaction. This makes it possible for a single manipulation to cause multiple changes in the scene graph, and each of these changes can be registered as a separate action.

When an action is created, the initial value is stored, and the 'onClose' callback enables all the actions to store the value at the end of an interactive manipulation.

In general, this is not a big change from the previous system.

One other change.
Managers are now assumed to be 'singletons'. What this means is that you can only have 1 UndoManager, 1, SeleciotnManager, 1 LayerManager etc... The benefit is that we can request a given manager by type from anywhere in the code, meaning we don't have to pass references to managers around in our code.

by calling..

var undoManager = scene.getManager('UndoManager');

We can check that an undo manger has been created, and then open a transaction or register an action. This means that you can't accidentally forget to pass the undo manager to a manipulator and end up with some manipulators not working with undo. (of course is someone explicitly doesn't want a manipulation[e.g. camera manipulators based off of 'InstanceManipulator'] to create undos, we could provide an option for that. ).