[nostalgia/core/studio] Cleanup TileSheetEditorModel update tracking

This commit is contained in:
2022-02-19 03:06:18 -06:00
parent db2a225855
commit b517cf6858
2 changed files with 14 additions and 9 deletions
@@ -16,6 +16,8 @@ TileSheetEditorModel::TileSheetEditorModel(Context *ctx, const ox::String &path)
oxRequireT(img, readObj<TileSheet>(ctx, path.c_str()));
m_img = *img;
oxThrowError(readObj<Palette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
m_undoStack.undoTriggered.connect(this, &TileSheetEditorModel::markUpdated);
m_undoStack.redoTriggered.connect(this, &TileSheetEditorModel::markUpdated);
}
void TileSheetEditorModel::cut() {
@@ -29,11 +31,11 @@ void TileSheetEditorModel::paste() {
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
if (m_ongoingDrawCommand) {
m_updated = m_ongoingDrawCommand->append(ptToIdx(pt, m_img.columns()));
m_updated = m_updated || m_ongoingDrawCommand->append(ptToIdx(pt, m_img.columns()));
} else {
const auto idx = ptToIdx(pt, m_img.columns());
if (m_img.getPixel(idx) != palIdx) {
pushCommand(new DrawCommand(&m_updated, &m_img, idx, palIdx));
pushCommand(new DrawCommand(&m_img, idx, palIdx));
}
}
}
@@ -46,6 +48,11 @@ bool TileSheetEditorModel::updated() const noexcept {
return m_updated;
}
ox::Error TileSheetEditorModel::markUpdated() noexcept {
m_updated = true;
return OxError(0);
}
void TileSheetEditorModel::ackUpdate() noexcept {
m_updated = false;
}