BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
ActionStack Class Reference

Class that keeps track of all commands that have been run. Allows functionality for undo/redo. More...

Public Member Functions

unsigned int Size () const
 Returns the number of currently stored actions.
 
unsigned int MaxSize () const
 Returns the maximum number of undoes stored.
 
void SetMaxSize (unsigned int maxSize)
 Sets the maximum number of undoes.
 
ActionNodeGetAction (int index)
 Returns the node at the given index or nullptr if the index does not exist. Returns the last node for a negative index.
 
ActionNodeGetCurAction () const
 Returns the most recent action.
 
void Undo ()
 Attempts to undo the most recent command. Does nothing if the most recent command cannot be undone.
 
void Redo ()
 Attempts to redo the most recently undone command. Does nothing if used without undo.
 
void Execute (ICommand *command)
 Executes the given command, emplacing it as the most recent item in the stack.
 
void Save ()
 Saves the current state of the action stack.
 
bool IsSaved () const
 Returns whether the action stack is equal to the most recent save state.
 
void Clear ()
 Clears the action stack.
 
 ActionStack (unsigned int maxUndo=50)
 Constructs a new action stack with no actions.
 
 ~ActionStack ()
 Destructs the whole action stack.
 

Detailed Description

Class that keeps track of all commands that have been run. Allows functionality for undo/redo.

Constructor & Destructor Documentation

◆ ActionStack()

ActionStack::ActionStack ( unsigned int  maxUndo = 50)
inlineexplicit

Constructs a new action stack with no actions.

Parameters
maxUndoThe max number of undoes before old ones start being removed

◆ ~ActionStack()

ActionStack::~ActionStack ( )
inline

Destructs the whole action stack.

Member Function Documentation

◆ Clear()

void ActionStack::Clear ( )
inline

Clears the action stack.

◆ Execute()

void ActionStack::Execute ( ICommand command)
inline

Executes the given command, emplacing it as the most recent item in the stack.

Parameters
commandCommand to execute

◆ GetAction()

ActionNode * ActionStack::GetAction ( int  index)
inline

Returns the node at the given index or nullptr if the index does not exist. Returns the last node for a negative index.

Parameters
indexNode at the index or nullptr
Returns
Node at the given index

◆ GetCurAction()

ActionNode * ActionStack::GetCurAction ( ) const
inline

Returns the most recent action.

Returns

◆ IsSaved()

bool ActionStack::IsSaved ( ) const
inline

Returns whether the action stack is equal to the most recent save state.

Returns
Whether the action stack is saved

◆ MaxSize()

unsigned int ActionStack::MaxSize ( ) const
inline

Returns the maximum number of undoes stored.

Returns

◆ Redo()

void ActionStack::Redo ( )
inline

Attempts to redo the most recently undone command. Does nothing if used without undo.

◆ Save()

void ActionStack::Save ( )
inline

Saves the current state of the action stack.

◆ SetMaxSize()

void ActionStack::SetMaxSize ( unsigned int  maxSize)
inline

Sets the maximum number of undoes.

Parameters
maxSizeNew number of undoes allowed

◆ Size()

unsigned int ActionStack::Size ( ) const
inline

Returns the number of currently stored actions.

Returns

◆ Undo()

void ActionStack::Undo ( )
inline

Attempts to undo the most recent command. Does nothing if the most recent command cannot be undone.