Manages undo/redo stacks for a single editor. More...
#include <undo_manager.h>
Public Member Functions | |
| UndoManager ()=default | |
| ~UndoManager ()=default | |
| UndoManager (const UndoManager &)=delete | |
| UndoManager & | operator= (const UndoManager &)=delete |
| UndoManager (UndoManager &&)=default | |
| UndoManager & | operator= (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 |
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.
|
default |
|
default |
|
delete |
|
default |
|
delete |
|
default |
| 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().

| absl::Status yaze::editor::UndoManager::Undo | ( | ) |
Undo the top action. Returns error if stack is empty.
Definition at line 26 of file undo_manager.cc.
References redo_stack_, and undo_stack_.
Referenced by yaze::editor::PixelEditorPanel::DrawToolbar(), yaze::editor::Tile16Editor::Undo(), yaze::editor::GraphicsEditor::Undo(), yaze::editor::MessageEditor::Undo(), yaze::editor::MusicEditor::Undo(), and yaze::editor::OverworldEditor::Undo().
| absl::Status yaze::editor::UndoManager::Redo | ( | ) |
Redo the top action. Returns error if stack is empty.
Definition at line 42 of file undo_manager.cc.
References redo_stack_, and undo_stack_.
Referenced by yaze::editor::PixelEditorPanel::DrawToolbar(), yaze::editor::Tile16Editor::Redo(), yaze::editor::GraphicsEditor::Redo(), yaze::editor::MessageEditor::Redo(), yaze::editor::MusicEditor::Redo(), and yaze::editor::OverworldEditor::Redo().
|
inline |
Definition at line 44 of file undo_manager.h.
References undo_stack_.
Referenced by yaze::editor::PixelEditorPanel::DrawToolbar(), yaze::editor::DungeonEditorV2::Initialize(), and yaze::editor::Tile16Editor::UpdateTile16Edit().
|
inline |
Definition at line 45 of file undo_manager.h.
References redo_stack_.
Referenced by yaze::editor::PixelEditorPanel::DrawToolbar(), and yaze::editor::DungeonEditorV2::Initialize().
| 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().
| 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().
|
inline |
Definition at line 53 of file undo_manager.h.
References max_stack_size_.
|
inline |
Definition at line 54 of file undo_manager.h.
References max_stack_size_.
|
inline |
Definition at line 56 of file undo_manager.h.
References undo_stack_.
Referenced by yaze::editor::DungeonEditorV2::Initialize().
|
inline |
Definition at line 57 of file undo_manager.h.
References redo_stack_.
| 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().
|
private |
Definition at line 73 of file undo_manager.cc.
References max_stack_size_, and undo_stack_.
Referenced by Push().
|
private |
Definition at line 64 of file undo_manager.h.
Referenced by CanUndo(), Clear(), EnforceStackLimit(), GetUndoDescription(), Push(), Redo(), Undo(), and UndoStackSize().
|
private |
Definition at line 65 of file undo_manager.h.
Referenced by CanRedo(), Clear(), GetRedoDescription(), Push(), Redo(), RedoStackSize(), and Undo().
|
private |
Definition at line 66 of file undo_manager.h.
Referenced by EnforceStackLimit(), GetMaxStackSize(), and SetMaxStackSize().