[nostalgia/studio] Fix TileSheetEditor to switch to appropriate subsheet on undo/redo
This commit is contained in:
@@ -93,7 +93,7 @@ Editor::Editor() noexcept {
|
||||
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);
|
||||
}
|
||||
|
||||
ox::Error Editor::markUnsavedChanges(int) noexcept {
|
||||
ox::Error Editor::markUnsavedChanges(const UndoCommand*) noexcept {
|
||||
setUnsavedChanges(true);
|
||||
return OxError(0);
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ class Editor: public studio::BaseEditor {
|
||||
}
|
||||
|
||||
private:
|
||||
ox::Error markUnsavedChanges(int) noexcept;
|
||||
ox::Error markUnsavedChanges(const UndoCommand*) noexcept;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -14,10 +14,9 @@ void UndoStack::push(UndoCommand *cmd) noexcept {
|
||||
for (const auto i = m_stackIdx; i < m_stack.size();) {
|
||||
oxIgnoreError(m_stack.erase(i));
|
||||
}
|
||||
auto cmdId = cmd->commandId();
|
||||
cmd->redo();
|
||||
redoTriggered.emit(cmdId);
|
||||
changeTriggered.emit(cmdId);
|
||||
redoTriggered.emit(cmd);
|
||||
changeTriggered.emit(cmd);
|
||||
if (!m_stack.size() || !m_stack.back().value->mergeWith(cmd)) {
|
||||
m_stack.emplace_back(cmd);
|
||||
++m_stackIdx;
|
||||
@@ -29,20 +28,18 @@ void UndoStack::push(UndoCommand *cmd) noexcept {
|
||||
void UndoStack::redo() noexcept {
|
||||
if (m_stackIdx < m_stack.size()) {
|
||||
auto &c = m_stack[m_stackIdx++];
|
||||
auto cmdId = c->commandId();
|
||||
c->redo();
|
||||
redoTriggered.emit(cmdId);
|
||||
changeTriggered.emit(cmdId);
|
||||
redoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
}
|
||||
}
|
||||
|
||||
void UndoStack::undo() noexcept {
|
||||
if (m_stackIdx) {
|
||||
auto &c = m_stack[--m_stackIdx];
|
||||
auto cmdId = c->commandId();
|
||||
c->undo();
|
||||
undoTriggered.emit(cmdId);
|
||||
changeTriggered.emit(cmdId);
|
||||
undoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,9 +43,9 @@ class UndoStack {
|
||||
return m_stackIdx;
|
||||
}
|
||||
|
||||
ox::Signal<ox::Error(int)> redoTriggered;
|
||||
ox::Signal<ox::Error(int)> undoTriggered;
|
||||
ox::Signal<ox::Error(int)> changeTriggered;
|
||||
ox::Signal<ox::Error(const studio::UndoCommand*)> redoTriggered;
|
||||
ox::Signal<ox::Error(const studio::UndoCommand*)> undoTriggered;
|
||||
ox::Signal<ox::Error(const studio::UndoCommand*)> changeTriggered;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user