[nostalgia/studio] Make UndoCommand undo/redo return ox::Error
All checks were successful
Build / build (push) Successful in 2m29s
All checks were successful
Build / build (push) Successful in 2m29s
This commit is contained in:
parent
7fb0549c25
commit
a1c89906bd
@ -14,12 +14,13 @@ int AddPageCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::AddPage);
|
||||
}
|
||||
|
||||
void AddPageCommand::redo() noexcept {
|
||||
ox::Error AddPageCommand::redo() noexcept {
|
||||
m_pal.pages.emplace_back();
|
||||
return {};
|
||||
}
|
||||
|
||||
void AddPageCommand::undo() noexcept {
|
||||
std::ignore = m_pal.pages.erase(static_cast<std::size_t>(m_pal.pages.size() - 1));
|
||||
ox::Error AddPageCommand::undo() noexcept {
|
||||
return m_pal.pages.erase(static_cast<std::size_t>(m_pal.pages.size() - 1)).error;
|
||||
}
|
||||
|
||||
|
||||
@ -37,13 +38,14 @@ int DuplicatePageCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::DuplicatePage);
|
||||
}
|
||||
|
||||
void DuplicatePageCommand::redo() noexcept {
|
||||
ox::Error DuplicatePageCommand::redo() noexcept {
|
||||
m_pal.pages.emplace(m_dstIdx, std::move(m_page));
|
||||
return {};
|
||||
}
|
||||
|
||||
void DuplicatePageCommand::undo() noexcept {
|
||||
ox::Error DuplicatePageCommand::undo() noexcept {
|
||||
m_page = std::move(m_pal.pages[m_dstIdx]);
|
||||
std::ignore = m_pal.pages.erase(static_cast<std::size_t>(m_dstIdx));
|
||||
return m_pal.pages.erase(static_cast<std::size_t>(m_dstIdx)).error;
|
||||
}
|
||||
|
||||
size_t DuplicatePageCommand::insertIdx() const noexcept {
|
||||
@ -60,13 +62,14 @@ int RemovePageCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::RemovePage);
|
||||
}
|
||||
|
||||
void RemovePageCommand::redo() noexcept {
|
||||
ox::Error RemovePageCommand::redo() noexcept {
|
||||
m_page = std::move(m_pal.pages[m_idx]);
|
||||
std::ignore = m_pal.pages.erase(static_cast<std::size_t>(m_idx));
|
||||
return m_pal.pages.erase(static_cast<std::size_t>(m_idx)).error;
|
||||
}
|
||||
|
||||
void RemovePageCommand::undo() noexcept {
|
||||
ox::Error RemovePageCommand::undo() noexcept {
|
||||
m_pal.pages.insert(m_idx, std::move(m_page));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -81,12 +84,13 @@ int AddColorCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::AddColor);
|
||||
}
|
||||
|
||||
void AddColorCommand::redo() noexcept {
|
||||
ox::Error AddColorCommand::redo() noexcept {
|
||||
m_pal->pages[m_page].insert(static_cast<std::size_t>(m_idx), m_color);
|
||||
return {};
|
||||
}
|
||||
|
||||
void AddColorCommand::undo() noexcept {
|
||||
std::ignore = m_pal->pages[m_page].erase(static_cast<std::size_t>(m_idx));
|
||||
ox::Error AddColorCommand::undo() noexcept {
|
||||
return m_pal->pages[m_page].erase(static_cast<std::size_t>(m_idx)).error;
|
||||
}
|
||||
|
||||
|
||||
@ -101,12 +105,13 @@ int RemoveColorCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::RemoveColor);
|
||||
}
|
||||
|
||||
void RemoveColorCommand::redo() noexcept {
|
||||
std::ignore = m_pal->pages[m_page].erase(static_cast<std::size_t>(m_idx));
|
||||
ox::Error RemoveColorCommand::redo() noexcept {
|
||||
return m_pal->pages[m_page].erase(static_cast<std::size_t>(m_idx)).error;
|
||||
}
|
||||
|
||||
void RemoveColorCommand::undo() noexcept {
|
||||
m_pal->pages[m_page].insert(static_cast<std::size_t>(m_idx), m_color);
|
||||
ox::Error RemoveColorCommand::undo() noexcept {
|
||||
m_pal->pages[m_page].insert(static_cast<std::size_t>(m_idx), m_color);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -141,12 +146,14 @@ int UpdateColorCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::UpdateColor);
|
||||
}
|
||||
|
||||
void UpdateColorCommand::redo() noexcept {
|
||||
ox::Error UpdateColorCommand::redo() noexcept {
|
||||
m_pal->pages[m_page][static_cast<std::size_t>(m_idx)] = m_newColor;
|
||||
return {};
|
||||
}
|
||||
|
||||
void UpdateColorCommand::undo() noexcept {
|
||||
ox::Error UpdateColorCommand::undo() noexcept {
|
||||
m_pal->pages[m_page][static_cast<std::size_t>(m_idx)] = m_oldColor;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -161,12 +168,14 @@ int MoveColorCommand::commandId() const noexcept {
|
||||
return static_cast<int>(PaletteEditorCommandId::MoveColor);
|
||||
}
|
||||
|
||||
void MoveColorCommand::redo() noexcept {
|
||||
ox::Error MoveColorCommand::redo() noexcept {
|
||||
moveColor(static_cast<int>(m_idx), m_offset);
|
||||
return {};
|
||||
}
|
||||
|
||||
void MoveColorCommand::undo() noexcept {
|
||||
ox::Error MoveColorCommand::undo() noexcept {
|
||||
moveColor(static_cast<int>(m_idx) + m_offset, -m_offset);
|
||||
return {};
|
||||
}
|
||||
|
||||
void MoveColorCommand::moveColor(int idx, int offset) noexcept {
|
||||
|
@ -35,9 +35,9 @@ class AddPageCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
};
|
||||
|
||||
@ -55,9 +55,9 @@ class DuplicatePageCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
size_t insertIdx() const noexcept;
|
||||
@ -78,9 +78,9 @@ class RemovePageCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
};
|
||||
|
||||
@ -99,9 +99,9 @@ class AddColorCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept override;
|
||||
|
||||
void redo() noexcept override;
|
||||
ox::Error redo() noexcept override;
|
||||
|
||||
void undo() noexcept override;
|
||||
ox::Error undo() noexcept override;
|
||||
|
||||
};
|
||||
|
||||
@ -120,9 +120,9 @@ class RemoveColorCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept override;
|
||||
|
||||
void redo() noexcept override;
|
||||
ox::Error redo() noexcept override;
|
||||
|
||||
void undo() noexcept override;
|
||||
ox::Error undo() noexcept override;
|
||||
|
||||
};
|
||||
|
||||
@ -145,9 +145,9 @@ class UpdateColorCommand: public studio::UndoCommand {
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
};
|
||||
|
||||
@ -167,9 +167,9 @@ class MoveColorCommand: public studio::UndoCommand {
|
||||
int commandId() const noexcept override;
|
||||
|
||||
public:
|
||||
void redo() noexcept override;
|
||||
ox::Error redo() noexcept override;
|
||||
|
||||
void undo() noexcept override;
|
||||
ox::Error undo() noexcept override;
|
||||
|
||||
private:
|
||||
void moveColor(int idx, int offset) noexcept;
|
||||
|
@ -24,7 +24,7 @@ AddSubSheetCommand::AddSubSheetCommand(
|
||||
}
|
||||
}
|
||||
|
||||
void AddSubSheetCommand::redo() noexcept {
|
||||
ox::Error AddSubSheetCommand::redo() noexcept {
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
if (m_addedSheets.size() < 2) {
|
||||
auto i = parent.subsheets.size();
|
||||
@ -35,9 +35,10 @@ void AddSubSheetCommand::redo() noexcept {
|
||||
parent.columns = 0;
|
||||
parent.subsheets.emplace_back(m_img.idIt++, "Subsheet 1", 1, 1, m_img.bpp);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void AddSubSheetCommand::undo() noexcept {
|
||||
ox::Error AddSubSheetCommand::undo() noexcept {
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
if (parent.subsheets.size() == 2) {
|
||||
auto s = parent.subsheets[0];
|
||||
@ -47,9 +48,10 @@ void AddSubSheetCommand::undo() noexcept {
|
||||
parent.subsheets.clear();
|
||||
} else {
|
||||
for (auto idx = m_addedSheets.rbegin(); idx != m_addedSheets.rend(); ++idx) {
|
||||
oxLogError(rmSubSheet(m_img, *idx));
|
||||
oxReturnError(rmSubSheet(m_img, *idx));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int AddSubSheetCommand::commandId() const noexcept {
|
||||
|
@ -17,9 +17,9 @@ class AddSubSheetCommand: public TileSheetCommand {
|
||||
public:
|
||||
AddSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx parentIdx) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -41,18 +41,20 @@ CutPasteCommand::CutPasteCommand(
|
||||
}
|
||||
}
|
||||
|
||||
void CutPasteCommand::redo() noexcept {
|
||||
ox::Error CutPasteCommand::redo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (const auto &c : m_changes) {
|
||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.newPalIdx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void CutPasteCommand::undo() noexcept {
|
||||
ox::Error CutPasteCommand::undo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (const auto &c : m_changes) {
|
||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.oldPalIdx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int CutPasteCommand::commandId() const noexcept {
|
||||
|
@ -69,9 +69,9 @@ class CutPasteCommand: public TileSheetCommand {
|
||||
ox::Point const&dstEnd,
|
||||
TileSheetClipboard const&cb) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -28,7 +28,7 @@ core::DeleteTilesCommand::DeleteTilesCommand(
|
||||
}
|
||||
}
|
||||
|
||||
void core::DeleteTilesCommand::redo() noexcept {
|
||||
ox::Error core::DeleteTilesCommand::redo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
auto srcPos = m_deletePos + m_deleteSz;
|
||||
@ -37,9 +37,10 @@ void core::DeleteTilesCommand::redo() noexcept {
|
||||
const auto dst2 = p.data() + (p.size() - m_deleteSz);
|
||||
ox::memmove(dst1, src, p.size() - srcPos);
|
||||
ox::memset(dst2, 0, m_deleteSz * sizeof(decltype(p[0])));
|
||||
return {};
|
||||
}
|
||||
|
||||
void DeleteTilesCommand::undo() noexcept {
|
||||
ox::Error DeleteTilesCommand::undo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
const auto src = p.data() + m_deletePos;
|
||||
@ -48,6 +49,7 @@ void DeleteTilesCommand::undo() noexcept {
|
||||
const auto sz = p.size() - m_deletePos - m_deleteSz;
|
||||
ox::memmove(dst1, src, sz);
|
||||
ox::memcpy(dst2, m_deletedPixels.data(), m_deletedPixels.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
int DeleteTilesCommand::commandId() const noexcept {
|
||||
|
@ -23,9 +23,9 @@ class DeleteTilesCommand: public TileSheetCommand {
|
||||
std::size_t tileIdx,
|
||||
std::size_t tileCnt) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -56,18 +56,20 @@ bool DrawCommand::append(const ox::Vector<std::size_t> &idxList) noexcept {
|
||||
return out;
|
||||
}
|
||||
|
||||
void DrawCommand::redo() noexcept {
|
||||
ox::Error DrawCommand::redo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (const auto &c : m_changes) {
|
||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(m_palIdx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void DrawCommand::undo() noexcept {
|
||||
ox::Error DrawCommand::undo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (const auto &c : m_changes) {
|
||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.oldPalIdx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int DrawCommand::commandId() const noexcept {
|
||||
|
@ -40,9 +40,9 @@ class DrawCommand: public TileSheetCommand {
|
||||
|
||||
bool append(const ox::Vector<std::size_t> &idxList) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -28,7 +28,7 @@ core::InsertTilesCommand::InsertTilesCommand(
|
||||
}
|
||||
}
|
||||
|
||||
void InsertTilesCommand::redo() noexcept {
|
||||
ox::Error InsertTilesCommand::redo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
auto dstPos = m_insertPos + m_insertCnt;
|
||||
@ -36,9 +36,10 @@ void InsertTilesCommand::redo() noexcept {
|
||||
const auto src = p.data() + m_insertPos;
|
||||
ox::memmove(dst, src, p.size() - dstPos);
|
||||
ox::memset(src, 0, m_insertCnt * sizeof(decltype(p[0])));
|
||||
return {};
|
||||
}
|
||||
|
||||
void InsertTilesCommand::undo() noexcept {
|
||||
ox::Error InsertTilesCommand::undo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
const auto srcIdx = m_insertPos + m_insertCnt;
|
||||
@ -48,6 +49,7 @@ void InsertTilesCommand::undo() noexcept {
|
||||
const auto sz = p.size() - srcIdx;
|
||||
ox::memmove(dst1, src, sz);
|
||||
ox::memcpy(dst2, m_deletedPixels.data(), m_deletedPixels.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
int InsertTilesCommand::commandId() const noexcept {
|
||||
|
@ -23,9 +23,9 @@ class InsertTilesCommand: public TileSheetCommand {
|
||||
std::size_t tileIdx,
|
||||
std::size_t tileCnt) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -16,12 +16,14 @@ core::PaletteChangeCommand::PaletteChangeCommand(
|
||||
m_newPalette(ox::FileAddress(ox::sfmt<ox::IString<43>>("uuid://{}", newPalette))) {
|
||||
}
|
||||
|
||||
void PaletteChangeCommand::redo() noexcept {
|
||||
ox::Error PaletteChangeCommand::redo() noexcept {
|
||||
m_img.defaultPalette = m_newPalette;
|
||||
return {};
|
||||
}
|
||||
|
||||
void PaletteChangeCommand::undo() noexcept {
|
||||
ox::Error PaletteChangeCommand::undo() noexcept {
|
||||
m_img.defaultPalette = m_oldPalette;
|
||||
return {};
|
||||
}
|
||||
|
||||
int PaletteChangeCommand::commandId() const noexcept {
|
||||
|
@ -21,9 +21,9 @@ class PaletteChangeCommand: public TileSheetCommand {
|
||||
TileSheet &img,
|
||||
ox::CRStringView newPalette) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -13,16 +13,18 @@ core::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetId
|
||||
m_parentIdx.pop_back();
|
||||
}
|
||||
|
||||
void RmSubSheetCommand::redo() noexcept {
|
||||
ox::Error RmSubSheetCommand::redo() noexcept {
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
m_sheet = std::move(parent.subsheets[*m_idx.back().value]);
|
||||
oxLogError(parent.subsheets.erase(*m_idx.back().value).error);
|
||||
oxReturnError(parent.subsheets.erase(*m_idx.back().value).error);
|
||||
return {};
|
||||
}
|
||||
|
||||
void RmSubSheetCommand::undo() noexcept {
|
||||
ox::Error RmSubSheetCommand::undo() noexcept {
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
auto const i = *m_idx.back().value;
|
||||
parent.subsheets.insert(i, std::move(m_sheet));
|
||||
return {};
|
||||
}
|
||||
|
||||
int RmSubSheetCommand::commandId() const noexcept {
|
||||
|
@ -18,9 +18,9 @@ class RmSubSheetCommand: public TileSheetCommand {
|
||||
public:
|
||||
RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -20,15 +20,17 @@ core::UpdateSubSheetCommand::UpdateSubSheetCommand(
|
||||
m_newRows(rows) {
|
||||
}
|
||||
|
||||
void UpdateSubSheetCommand::redo() noexcept {
|
||||
ox::Error UpdateSubSheetCommand::redo() noexcept {
|
||||
auto &sheet = getSubSheet(m_img, m_idx);
|
||||
sheet.name = m_newName;
|
||||
oxLogError(resizeSubsheet(sheet, m_img.bpp, {m_newCols, m_newRows}));
|
||||
return {};
|
||||
}
|
||||
|
||||
void UpdateSubSheetCommand::undo() noexcept {
|
||||
ox::Error UpdateSubSheetCommand::undo() noexcept {
|
||||
auto &sheet = getSubSheet(m_img, m_idx);
|
||||
sheet = m_sheet;
|
||||
return {};
|
||||
}
|
||||
|
||||
int UpdateSubSheetCommand::commandId() const noexcept {
|
||||
|
@ -25,9 +25,9 @@ class UpdateSubSheetCommand: public TileSheetCommand {
|
||||
int cols,
|
||||
int rows) noexcept;
|
||||
|
||||
void redo() noexcept final;
|
||||
ox::Error redo() noexcept final;
|
||||
|
||||
void undo() noexcept final;
|
||||
ox::Error undo() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
int commandId() const noexcept final;
|
||||
|
@ -19,8 +19,8 @@ class NoChangesException: public ox::Exception {
|
||||
class UndoCommand {
|
||||
public:
|
||||
virtual ~UndoCommand() noexcept = default;
|
||||
virtual void redo() noexcept = 0;
|
||||
virtual void undo() noexcept = 0;
|
||||
virtual ox::Error redo() noexcept = 0;
|
||||
virtual ox::Error undo() noexcept = 0;
|
||||
[[nodiscard]]
|
||||
virtual int commandId() const noexcept = 0;
|
||||
virtual bool mergeWith(UndoCommand const&cmd) noexcept;
|
||||
|
@ -10,7 +10,9 @@ void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
for (auto const i = m_stackIdx; i < m_stack.size();) {
|
||||
std::ignore = m_stack.erase(i);
|
||||
}
|
||||
cmd->redo();
|
||||
if (cmd->redo()) {
|
||||
return;
|
||||
}
|
||||
redoTriggered.emit(cmd.get());
|
||||
changeTriggered.emit(cmd.get());
|
||||
if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(*cmd)) {
|
||||
@ -21,8 +23,11 @@ void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
|
||||
void UndoStack::redo() noexcept {
|
||||
if (m_stackIdx < m_stack.size()) {
|
||||
auto &c = m_stack[m_stackIdx++];
|
||||
c->redo();
|
||||
auto &c = m_stack[m_stackIdx];
|
||||
if (c->redo()) {
|
||||
return;
|
||||
}
|
||||
++m_stackIdx;
|
||||
redoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
}
|
||||
@ -31,7 +36,9 @@ void UndoStack::redo() noexcept {
|
||||
void UndoStack::undo() noexcept {
|
||||
if (m_stackIdx) {
|
||||
auto &c = m_stack[--m_stackIdx];
|
||||
c->undo();
|
||||
if (c->undo()) {
|
||||
return;
|
||||
}
|
||||
undoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user