![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Bounded stack of reversible editor commands. More...
#include <UndoRedoStack.h>
Public Member Functions | |
| UndoRedoStack () | |
| void | PushCommand (std::unique_ptr< ICommand > cmd, TaskGraphTemplate &graph) |
Executes the command on graph, then pushes it onto the undo stack. | |
| void | Undo (TaskGraphTemplate &graph) |
| Undoes the last command, moving it to the redo stack. | |
| void | Redo (TaskGraphTemplate &graph) |
| Re-applies the last undone command, moving it back to the undo stack. | |
| void | Clear () |
| Clears both undo and redo stacks (e.g. | |
| bool | CanUndo () const |
| Returns true if there is at least one command to undo. | |
| bool | CanRedo () const |
| Returns true if there is at least one command to redo. | |
| std::size_t | UndoSize () const |
| Returns the number of commands currently on the undo stack. | |
| std::size_t | RedoSize () const |
| Returns the number of commands currently on the redo stack. | |
| std::string | PeekUndoDescription () const |
| Returns the description of the top undo command, or "" if empty. | |
| std::string | PeekRedoDescription () const |
| Returns the description of the top redo command, or "" if empty. | |
Static Public Attributes | |
| static const std::size_t | MAX_STACK_SIZE = 100u |
| Maximum number of undo entries kept in memory. | |
Private Attributes | |
| std::vector< std::unique_ptr< ICommand > > | m_undoStack |
| std::vector< std::unique_ptr< ICommand > > | m_redoStack |
Bounded stack of reversible editor commands.
Usage:
When more than MAX_STACK_SIZE commands are pushed, the oldest undo entry is dropped (FIFO eviction). Pushing any new command clears the redo stack.
Definition at line 395 of file UndoRedoStack.h.
| Olympe::UndoRedoStack::UndoRedoStack | ( | ) |
Definition at line 513 of file UndoRedoStack.cpp.
| bool Olympe::UndoRedoStack::CanRedo | ( | ) | const |
Returns true if there is at least one command to redo.
Definition at line 572 of file UndoRedoStack.cpp.
References m_redoStack.
| bool Olympe::UndoRedoStack::CanUndo | ( | ) | const |
Returns true if there is at least one command to undo.
Definition at line 567 of file UndoRedoStack.cpp.
References m_undoStack.
| void Olympe::UndoRedoStack::Clear | ( | ) |
Clears both undo and redo stacks (e.g.
after save).
Definition at line 561 of file UndoRedoStack.cpp.
References m_redoStack, and m_undoStack.
| std::string Olympe::UndoRedoStack::PeekRedoDescription | ( | ) | const |
Returns the description of the top redo command, or "" if empty.
Definition at line 593 of file UndoRedoStack.cpp.
References m_redoStack.
| std::string Olympe::UndoRedoStack::PeekUndoDescription | ( | ) | const |
Returns the description of the top undo command, or "" if empty.
Definition at line 587 of file UndoRedoStack.cpp.
References m_undoStack.
| void Olympe::UndoRedoStack::PushCommand | ( | std::unique_ptr< ICommand > | cmd, |
| TaskGraphTemplate & | graph | ||
| ) |
Executes the command on graph, then pushes it onto the undo stack.
Clears the redo stack.
| cmd | Owning pointer to the command. Must not be null. |
| graph | Target graph on which Execute() is called immediately. |
Definition at line 517 of file UndoRedoStack.cpp.
References GetComponentTypeID_Static(), m_redoStack, m_undoStack, and MAX_STACK_SIZE.
Referenced by Olympe::VisualScriptEditorPanel::AddNode(), Olympe::VisualScriptEditorPanel::ConnectData(), Olympe::VisualScriptEditorPanel::ConnectExec(), Olympe::VisualScriptEditorPanel::RemoveLink(), Olympe::VisualScriptEditorPanel::RemoveNode(), Olympe::VisualScriptEditorPanel::RenderNodePropertiesPanelContent(), and Olympe::VisualScriptEditorPanel::RenderSwitchNodeProperties().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::UndoRedoStack::Redo | ( | TaskGraphTemplate & | graph | ) |
Re-applies the last undone command, moving it back to the undo stack.
Definition at line 549 of file UndoRedoStack.cpp.
References GetComponentTypeID_Static(), m_redoStack, and m_undoStack.
Here is the call graph for this function:| std::size_t Olympe::UndoRedoStack::RedoSize | ( | ) | const |
Returns the number of commands currently on the redo stack.
Definition at line 582 of file UndoRedoStack.cpp.
References m_redoStack.
| void Olympe::UndoRedoStack::Undo | ( | TaskGraphTemplate & | graph | ) |
Undoes the last command, moving it to the redo stack.
Definition at line 537 of file UndoRedoStack.cpp.
References GetComponentTypeID_Static(), m_redoStack, and m_undoStack.
Here is the call graph for this function:| std::size_t Olympe::UndoRedoStack::UndoSize | ( | ) | const |
Returns the number of commands currently on the undo stack.
Definition at line 577 of file UndoRedoStack.cpp.
References m_undoStack.
|
private |
Definition at line 456 of file UndoRedoStack.h.
Referenced by CanRedo(), Clear(), PeekRedoDescription(), PushCommand(), Redo(), RedoSize(), and Undo().
|
private |
Definition at line 455 of file UndoRedoStack.h.
Referenced by CanUndo(), Clear(), PeekUndoDescription(), PushCommand(), Redo(), Undo(), and UndoSize().
|
static |
Maximum number of undo entries kept in memory.
Definition at line 399 of file UndoRedoStack.h.
Referenced by PushCommand().