[nostalgia/studio] Add redo and undo triggered signals to UndoStack

This commit is contained in:
Gary Talent 2022-02-19 03:05:45 -06:00
parent 56ec063658
commit db2a225855
2 changed files with 8 additions and 2 deletions

View File

@ -19,12 +19,14 @@ void UndoStack::redo() noexcept {
if (m_stackIdx < m_stack.size()) { if (m_stackIdx < m_stack.size()) {
m_stack[m_stackIdx++]->redo(); m_stack[m_stackIdx++]->redo();
} }
redoTriggered.emit();
} }
void UndoStack::undo() noexcept { void UndoStack::undo() noexcept {
if (m_stackIdx) { if (m_stackIdx) {
m_stack[--m_stackIdx]->undo(); m_stack[--m_stackIdx]->undo();
} }
undoTriggered.emit();
} }
} }

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <ox/event/signal.hpp>
#include <ox/std/error.hpp> #include <ox/std/error.hpp>
#include <ox/std/memory.hpp> #include <ox/std/memory.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
@ -30,14 +31,17 @@ class UndoStack {
void undo() noexcept; void undo() noexcept;
[[nodiscard]] [[nodiscard]]
constexpr bool canRedo() noexcept { constexpr bool canRedo() const noexcept {
return m_stackIdx < m_stack.size(); return m_stackIdx < m_stack.size();
} }
[[nodiscard]] [[nodiscard]]
constexpr bool canUndo() noexcept { constexpr bool canUndo() const noexcept {
return m_stackIdx; return m_stackIdx;
} }
ox::Signal<ox::Error()> redoTriggered;
ox::Signal<ox::Error()> undoTriggered;
}; };
} }