class UndoRedo

Inherits: IScriptExportable

Provides functionality to undo or redo recently performed operations in the editor.

Public

Constructors

UndoRedo

UndoRedo()

Methods

~UndoRedo

~UndoRedo() noexcept

Undo

void Undo()

Executes the last command on the undo stack, undoing its operations.

Redo

void Redo()

Executes the last command on the redo stack (last command we called undo on), re-applying its operation.

PushGroup

void PushGroup(const String &name)

Creates a new undo/redo group.

All new commands will be registered to this group. You may remove the group and all of its commands by calling popGroup().

For example you might require global editor-wide undo/redo operations, and also more specific ones like input in an input box. When the user is done with the input box you no longer require its undo operations and you may use groups to easily remove them.

name
Unique name for the group.

PopGroup

void PopGroup(const String &name)

Removes all the command registered to the current undo/redo group.

name
Unique name for the group.

RegisterOperation

void RegisterOperation(const SPtr<UndoableOperation> &command)

Registers a new undo command.

GetTopCommandId

u32 GetTopCommandId() const

Returns the unique identifier for the command on top of the undo stack.

PopCommand

void PopCommand(u32 id)

Removes a command from the undo/redo list, without executing it.

id
Identifier of the command returned by getTopCommandIdx().

Clear

void Clear()

Resets the undo/redo stacks.

Private

Methods

RemoveLastFromUndoStack

SPtr<UndoableOperation> RemoveLastFromUndoStack()

Removes the last undo command from the undo stack, and returns it.

AddToUndoStack

SPtr<UndoableOperation> AddToUndoStack(const SPtr<UndoableOperation> &command)

Adds a new command to the undo stack.

Returns the command that was replaced.

ClearUndoStack

void ClearUndoStack()

Removes all entries from the undo stack.

ClearRedoStack

void ClearRedoStack()

Removes all entries from the redo stack.

Fields

mUndoStack

SPtr<UndoableOperation> * mUndoStack

mRedoStack

SPtr<UndoableOperation> * mRedoStack

mUndoStackPtr

u32 mUndoStackPtr

mUndoNumElements

u32 mUndoNumElements

mRedoStackPtr

u32 mRedoStackPtr

mRedoNumElements

u32 mRedoNumElements

mNextCommandId

u32 mNextCommandId

mGroups

Vector<GroupData> mGroups