DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
DekiEditor::CommandHistory Class Reference

The undo/redo history. Commands that arrive close together can merge. More...

#include <C:/Users/kirby/Documents/Github/deki/deki-editor/deki-editor/include/deki-editor/CommandHistory.h>

Public Member Functions

bool CanRedo () const
bool CanUndo () const
void Clear ()
void DiscardCommandsReferencing (const DeadMemory &dead)
 Drops history that points at objects about to be freed.
void Execute (std::unique_ptr< Command > command)
 Runs a command and adds it to the history, merging it with the last one when it can.
void ExecuteNoMerge (std::unique_ptr< Command > command)
 Runs a command and adds it to the history without merging.
uint64_t GetGeneration () const
 A counter bumped on every change (Execute, ExecuteNoMerge, Undo, Redo, Clear, MarkDirty, SaveAndClear, RestoreFromSave).
size_t GetRedoCount () const
std::string GetRedoDescription () const
 Description of the command Redo would redo.
size_t GetUndoCount () const
std::string GetUndoDescription () const
 Description of the command Undo would undo.
bool IsDirty () const
 Whether there are unsaved changes since the save point.
bool IsSavedAsideDirty () const
 While Play has the edit history set aside (SaveAndClear), whether THAT history has unsaved changes: the edit scene's state.
void MarkDirty ()
 Marks the scene as differing from its file, with nothing to undo.
void MarkSavePoint ()
 Marks the current state as saved, for IsDirty.
void Redo ()
void RestoreFromSave ()
 Brings back the stacks set aside, dropping the play mode ones.
void SaveAndClear ()
 Sets the stacks aside and starts empty ones, for play mode.
void SetMaxHistory (size_t max)
void SetOnHistoryChanged (std::function< void()> callback)
void Undo ()

Static Public Member Functions

static CommandHistory & Instance ()

Detailed Description

The undo/redo history. Commands that arrive close together can merge.

Member Function Documentation

◆ CanRedo()

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

◆ CanUndo()

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

◆ Clear()

void DekiEditor::CommandHistory::Clear ( )

◆ DiscardCommandsReferencing()

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

Drops history that points at objects about to be freed.

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

Truncates rather than removing single commands: undo walks the stack newest to oldest, so a dead command at index k makes everything at or below k unreachable. Those entries are dropped and the rest stays consistent.

◆ Execute()

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

Runs a command and adds it to the history, merging it with the last one when it can.

◆ ExecuteNoMerge()

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

Runs a command and adds it to the history without merging.

◆ GetGeneration()

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

A counter bumped on every change (Execute, ExecuteNoMerge, Undo, Redo, Clear, MarkDirty, SaveAndClear, RestoreFromSave).

Panels poll it to drop cached state (e.g. SceneView's edit-mode buffer) when the scene changes through commands.

◆ GetRedoCount()

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

◆ GetRedoDescription()

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

Description of the command Redo would redo.

◆ GetUndoCount()

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

◆ GetUndoDescription()

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

Description of the command Undo would undo.

◆ Instance()

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

◆ IsDirty()

bool DekiEditor::CommandHistory::IsDirty ( ) const

Whether there are unsaved changes since the save point.

◆ IsSavedAsideDirty()

bool DekiEditor::CommandHistory::IsSavedAsideDirty ( ) const

While Play has the edit history set aside (SaveAndClear), whether THAT history has unsaved changes: the edit scene's state.

Play's own edits are thrown away on Stop and say nothing about the file.

◆ MarkDirty()

void DekiEditor::CommandHistory::MarkDirty ( )

Marks the scene as differing from its file, with nothing to undo.

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

◆ MarkSavePoint()

void DekiEditor::CommandHistory::MarkSavePoint ( )

Marks the current state as saved, for IsDirty.

◆ Redo()

void DekiEditor::CommandHistory::Redo ( )

◆ RestoreFromSave()

void DekiEditor::CommandHistory::RestoreFromSave ( )

Brings back the stacks set aside, dropping the play mode ones.

◆ SaveAndClear()

void DekiEditor::CommandHistory::SaveAndClear ( )

Sets the stacks aside and starts empty ones, for play mode.

◆ SetMaxHistory()

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

◆ SetOnHistoryChanged()

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

◆ Undo()

void DekiEditor::CommandHistory::Undo ( )

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