|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
Non-destructive chronological undo timeline. More...
#include "donner/editor/UndoTimeline.h"
Public Member Functions | |
| void | beginTransaction (std::string_view label, UndoSnapshot before) |
| Begin a drag transaction. The before snapshot is captured now; the after snapshot is captured on commit. Nested calls are ignored (outermost transaction wins). | |
| void | commitTransaction (UndoSnapshot after) |
| Commit the current transaction with the given after snapshot. | |
| void | abortTransaction () |
| Discard the current transaction without recording an entry. | |
| bool | inTransaction () const |
| Whether a transaction is currently open. | |
| void | record (std::string_view label, UndoSnapshot before, UndoSnapshot after) |
| Record a complete single-step action (breaks any active undo chain). | |
| std::optional< UndoSnapshot > | undo () |
| Undo the next entry in the current undo chain. If no chain is active, starts a new chain from the end of the timeline. Returns the snapshot the caller should apply, or nullopt if there is nothing to undo. | |
| bool | canUndo () const |
| Whether there is an entry to undo (either in the current chain or by starting a new one). | |
| std::optional< std::string_view > | nextUndoLabel () const |
| The label of the entry that would be undone next. | |
| size_t | entryCount () const |
| Number of entries in the timeline. | |
| void | breakUndoChain () |
| Break the current undo chain (called on any non-undo user action). | |
| void | clear () |
| Clear all history. | |
Non-destructive chronological undo timeline.
Uses an Emacs-style undo model: consecutive undos walk backward through the entry list, reversing each entry. Any non-undo action breaks the chain. After a break, subsequent undos traverse the entire list (including previous undo entries), allowing undo-of-undo to re-apply a previously reversed action.
No entries are ever removed. The full editing history is preserved indefinitely.