[nostalgia/studio] Add redo and undo triggered signals to UndoStack
This commit is contained in:
parent
56ec063658
commit
db2a225855
@ -19,12 +19,14 @@ void UndoStack::redo() noexcept {
|
||||
if (m_stackIdx < m_stack.size()) {
|
||||
m_stack[m_stackIdx++]->redo();
|
||||
}
|
||||
redoTriggered.emit();
|
||||
}
|
||||
|
||||
void UndoStack::undo() noexcept {
|
||||
if (m_stackIdx) {
|
||||
m_stack[--m_stackIdx]->undo();
|
||||
}
|
||||
undoTriggered.emit();
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
@ -30,14 +31,17 @@ class UndoStack {
|
||||
void undo() noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool canRedo() noexcept {
|
||||
constexpr bool canRedo() const noexcept {
|
||||
return m_stackIdx < m_stack.size();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool canUndo() noexcept {
|
||||
constexpr bool canUndo() const noexcept {
|
||||
return m_stackIdx;
|
||||
}
|
||||
|
||||
ox::Signal<ox::Error()> redoTriggered;
|
||||
ox::Signal<ox::Error()> undoTriggered;
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user