DEKI/ENGINE docs
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
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

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.
void Undo ()
void Redo ()
void Clear ()
bool CanUndo () const
bool CanRedo () const
size_t GetUndoCount () const
size_t GetRedoCount () const
uint64_t GetGeneration () const
 A counter bumped on every change (Execute, ExecuteNoMerge, Undo, Redo, Clear, MarkDirty, SaveAndClear, RestoreFromSave).
std::string GetUndoDescription () const
 Description of the command Undo would undo.
std::string GetRedoDescription () const
 Description of the command Redo would redo.
void SetOnHistoryChanged (std::function< void()> callback)
void SaveAndClear ()
 Sets the stacks aside and starts empty ones, for play mode.
void RestoreFromSave ()
 Brings back the stacks set aside, dropping the play mode ones.
void SetMaxHistory (size_t max)
void MarkSavePoint ()
 Marks the current state as saved, for IsDirty.
void MarkDirty ()
 Marks the scene as differing from its file, with nothing to 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 DiscardCommandsReferencing (const DeadMemory &dead)
 Drops history that points at objects about to be freed.

Static Public Member Functions

static CommandHistory & Instance ()

Detailed Description

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

Member Function Documentation

◆ Instance()

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

◆ 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.

◆ Undo()

void DekiEditor::CommandHistory::Undo ( )

◆ Redo()

void DekiEditor::CommandHistory::Redo ( )

◆ Clear()

void DekiEditor::CommandHistory::Clear ( )

◆ CanUndo()

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

◆ CanRedo()

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

◆ GetUndoCount()

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

◆ GetRedoCount()

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

◆ 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.

◆ GetUndoDescription()

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

Description of the command Undo would undo.

◆ GetRedoDescription()

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

Description of the command Redo would redo.

◆ SetOnHistoryChanged()

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

◆ SaveAndClear()

void DekiEditor::CommandHistory::SaveAndClear ( )

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

◆ RestoreFromSave()

void DekiEditor::CommandHistory::RestoreFromSave ( )

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

◆ SetMaxHistory()

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

◆ MarkSavePoint()

void DekiEditor::CommandHistory::MarkSavePoint ( )

Marks the current state as saved, for IsDirty.

◆ 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.

◆ 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.

◆ 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.


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