yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::UndoManager Class Reference

Manages undo/redo stacks for a single editor. More...

#include <undo_manager.h>

Public Member Functions

 UndoManager ()=default
 
 ~UndoManager ()=default
 
 UndoManager (const UndoManager &)=delete
 
UndoManageroperator= (const UndoManager &)=delete
 
 UndoManager (UndoManager &&)=default
 
UndoManageroperator= (UndoManager &&)=default
 
void Push (std::unique_ptr< UndoAction > action)
 
absl::Status Undo ()
 Undo the top action. Returns error if stack is empty.
 
absl::Status Redo ()
 Redo the top action. Returns error if stack is empty.
 
bool CanUndo () const
 
bool CanRedo () const
 
std::string GetUndoDescription () const
 Description of the action that would be undone (for UI)
 
std::string GetRedoDescription () const
 Description of the action that would be redone (for UI)
 
void SetMaxStackSize (size_t max)
 
size_t GetMaxStackSize () const
 
size_t UndoStackSize () const
 
size_t RedoStackSize () const
 
void Clear ()
 

Private Member Functions

void EnforceStackLimit ()
 

Private Attributes

std::deque< std::unique_ptr< UndoAction > > undo_stack_
 
std::deque< std::unique_ptr< UndoAction > > redo_stack_
 
size_t max_stack_size_ = 50
 

Detailed Description

Manages undo/redo stacks for a single editor.

Each editor gets its own UndoManager (via EditorDependencies). Supports bounded stacks, action merging, and description queries for status bar / toast feedback.

Definition at line 23 of file undo_manager.h.

Constructor & Destructor Documentation

◆ UndoManager() [1/3]

yaze::editor::UndoManager::UndoManager ( )
default

◆ ~UndoManager()

yaze::editor::UndoManager::~UndoManager ( )
default

◆ UndoManager() [2/3]

yaze::editor::UndoManager::UndoManager ( const UndoManager & )
delete

◆ UndoManager() [3/3]

yaze::editor::UndoManager::UndoManager ( UndoManager && )
default

Member Function Documentation

◆ operator=() [1/2]

UndoManager & yaze::editor::UndoManager::operator= ( const UndoManager & )
delete

◆ operator=() [2/2]

UndoManager & yaze::editor::UndoManager::operator= ( UndoManager && )
default

◆ Push()

void yaze::editor::UndoManager::Push ( std::unique_ptr< UndoAction > action)

Push a new action. Clears the redo stack. If the action can merge with the top of the undo stack, merges instead.

Definition at line 12 of file undo_manager.cc.

References EnforceStackLimit(), redo_stack_, and undo_stack_.

Referenced by yaze::editor::OverworldEditor::FinalizePaintOperation(), yaze::editor::MessageEditor::FinalizePendingUndo(), yaze::editor::MusicEditor::FinalizePendingUndo(), yaze::editor::Tile16Editor::FinalizePendingUndo(), and yaze::editor::PixelEditorPanel::FinalizeUndoAction().

Here is the call graph for this function:

◆ Undo()

absl::Status yaze::editor::UndoManager::Undo ( )

◆ Redo()

absl::Status yaze::editor::UndoManager::Redo ( )

◆ CanUndo()

bool yaze::editor::UndoManager::CanUndo ( ) const
inline

◆ CanRedo()

bool yaze::editor::UndoManager::CanRedo ( ) const
inline

◆ GetUndoDescription()

std::string yaze::editor::UndoManager::GetUndoDescription ( ) const

Description of the action that would be undone (for UI)

Definition at line 58 of file undo_manager.cc.

References undo_stack_.

Referenced by yaze::editor::Editor::GetUndoDescription(), and yaze::editor::DungeonEditorV2::Initialize().

◆ GetRedoDescription()

std::string yaze::editor::UndoManager::GetRedoDescription ( ) const

Description of the action that would be redone (for UI)

Definition at line 63 of file undo_manager.cc.

References redo_stack_.

Referenced by yaze::editor::Editor::GetRedoDescription(), and yaze::editor::DungeonEditorV2::Initialize().

◆ SetMaxStackSize()

void yaze::editor::UndoManager::SetMaxStackSize ( size_t max)
inline

Definition at line 53 of file undo_manager.h.

References max_stack_size_.

◆ GetMaxStackSize()

size_t yaze::editor::UndoManager::GetMaxStackSize ( ) const
inline

Definition at line 54 of file undo_manager.h.

References max_stack_size_.

◆ UndoStackSize()

size_t yaze::editor::UndoManager::UndoStackSize ( ) const
inline

Definition at line 56 of file undo_manager.h.

References undo_stack_.

Referenced by yaze::editor::DungeonEditorV2::Initialize().

◆ RedoStackSize()

size_t yaze::editor::UndoManager::RedoStackSize ( ) const
inline

Definition at line 57 of file undo_manager.h.

References redo_stack_.

◆ Clear()

void yaze::editor::UndoManager::Clear ( )

Definition at line 68 of file undo_manager.cc.

References redo_stack_, and undo_stack_.

Referenced by yaze::editor::OverworldEditor::Load().

◆ EnforceStackLimit()

void yaze::editor::UndoManager::EnforceStackLimit ( )
private

Definition at line 73 of file undo_manager.cc.

References max_stack_size_, and undo_stack_.

Referenced by Push().

Member Data Documentation

◆ undo_stack_

std::deque<std::unique_ptr<UndoAction> > yaze::editor::UndoManager::undo_stack_
private

◆ redo_stack_

std::deque<std::unique_ptr<UndoAction> > yaze::editor::UndoManager::redo_stack_
private

Definition at line 65 of file undo_manager.h.

Referenced by CanRedo(), Clear(), GetRedoDescription(), Push(), Redo(), RedoStackSize(), and Undo().

◆ max_stack_size_

size_t yaze::editor::UndoManager::max_stack_size_ = 50
private

Definition at line 66 of file undo_manager.h.

Referenced by EnforceStackLimit(), GetMaxStackSize(), and SetMaxStackSize().


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