Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::CommandHistory Class Reference

Manages undo/redo command history with support for command merging. More...

#include <CommandHistory.h>

Public Member Functions

void Execute (std::unique_ptr< Command > command)
 Execute a command and add it to history.
void ExecuteNoMerge (std::unique_ptr< Command > command)
 Execute a command without merge possibility.
void Undo ()
 Undo the last command.
void Redo ()
 Redo the last undone command.
void Clear ()
 Clear all history.
bool CanUndo () const
 Check if undo is available.
bool CanRedo () const
 Check if redo is available.
size_t GetUndoCount () const
 Get count of undo commands.
size_t GetRedoCount () const
 Get count of redo commands.
uint64_t GetGeneration () const
 Monotonic counter bumped on every state-changing operation (Execute, ExecuteNoMerge, Undo, Redo, Clear, MarkDirty, SaveAndClear, RestoreFromSave).
std::string GetUndoDescription () const
 Get description of next undo command.
std::string GetRedoDescription () const
 Get description of next redo command.
void SetOnHistoryChanged (std::function< void()> callback)
 Set callback for history changes.
void SaveAndClear ()
 Save current stacks aside and clear for play mode isolation.
void RestoreFromSave ()
 Restore saved stacks, discarding current (play mode) stacks.
void SetMaxHistory (size_t max)
 Set maximum history size.
void MarkSavePoint ()
 Mark current state as saved (for dirty tracking).
void MarkDirty ()
 Force the history into a "dirty vs disk" state with no undoable commands.
bool IsDirty () const
 Check if there are unsaved changes since last save point.
void DiscardCommandsReferencing (const DeadMemory &dead)
 Discard history that can no longer be safely replayed because the objects it points at are being freed.

Static Public Member Functions

static CommandHistory & Instance ()

Detailed Description

Manages undo/redo command history with support for command merging.

Member Function Documentation

◆ Instance()

CommandHistory & DekiEditor::CommandHistory::Instance ( )
static

◆ Execute()

void DekiEditor::CommandHistory::Execute ( std::unique_ptr< Command > command)

Execute a command and add it to history.

◆ ExecuteNoMerge()

void DekiEditor::CommandHistory::ExecuteNoMerge ( std::unique_ptr< Command > command)

Execute a command without merge possibility.

◆ Undo()

void DekiEditor::CommandHistory::Undo ( )

Undo the last command.

◆ Redo()

void DekiEditor::CommandHistory::Redo ( )

Redo the last undone command.

◆ Clear()

void DekiEditor::CommandHistory::Clear ( )

Clear all history.

◆ CanUndo()

bool DekiEditor::CommandHistory::CanUndo ( ) const
inline

Check if undo is available.

◆ CanRedo()

bool DekiEditor::CommandHistory::CanRedo ( ) const
inline

Check if redo is available.

◆ GetUndoCount()

size_t DekiEditor::CommandHistory::GetUndoCount ( ) const
inline

Get count of undo commands.

◆ GetRedoCount()

size_t DekiEditor::CommandHistory::GetRedoCount ( ) const
inline

Get count of redo commands.

◆ GetGeneration()

uint64_t DekiEditor::CommandHistory::GetGeneration ( ) const
inline

Monotonic counter bumped on every state-changing operation (Execute, ExecuteNoMerge, Undo, Redo, Clear, MarkDirty, SaveAndClear, RestoreFromSave).

Polled by panels that need to invalidate cached derived state (e.g. SceneView's edit-mode buffer) when the scene content changes through the command system.

◆ GetUndoDescription()

std::string DekiEditor::CommandHistory::GetUndoDescription ( ) const

Get description of next undo command.

◆ GetRedoDescription()

std::string DekiEditor::CommandHistory::GetRedoDescription ( ) const

Get description of next redo command.

◆ SetOnHistoryChanged()

void DekiEditor::CommandHistory::SetOnHistoryChanged ( std::function< void()> callback)
inline

Set callback for history changes.

◆ SaveAndClear()

void DekiEditor::CommandHistory::SaveAndClear ( )

Save current stacks aside and clear for play mode isolation.

◆ RestoreFromSave()

void DekiEditor::CommandHistory::RestoreFromSave ( )

Restore saved stacks, discarding current (play mode) stacks.

◆ SetMaxHistory()

void DekiEditor::CommandHistory::SetMaxHistory ( size_t max)
inline

Set maximum history size.

◆ MarkSavePoint()

void DekiEditor::CommandHistory::MarkSavePoint ( )

Mark current state as saved (for dirty tracking).

◆ MarkDirty()

void DekiEditor::CommandHistory::MarkDirty ( )

Force the history into a "dirty vs disk" state with no undoable commands.

Used after loading content (e.g. crash recovery) that differs from the file currently at m_CurrentScenePath, so the user is prompted to save.

◆ IsDirty()

bool DekiEditor::CommandHistory::IsDirty ( ) const

Check if there are unsaved changes since last save point.

◆ DiscardCommandsReferencing()

void DekiEditor::CommandHistory::DiscardCommandsReferencing ( const DeadMemory & dead)

Discard history that can no longer be safely replayed because the objects it points at are being freed.

Hook this to Scene's on_objects_about_to_be_destroyed. dead must contain the dying objects and all of their components.

Truncation, not surgical removal: undo walks the stack newest-to-oldest, so a dead command at index k makes everything at or below k unreachable without stepping through it. Those entries are dropped and the remaining suffix stays consistent.


The documentation for this class was generated from the following file: