diff --git a/release-notes.md b/release-notes.md index 45dd61cf8..f3888fb1d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -5,6 +5,7 @@ * Fix file deletion to close file even if not active * Fix file copy to work when creating a copy with the name of a previously deleted file +* Fix copy/cut/paste enablement when there is no selection * Make file picker popup accept on double click of a file * PaletteEditor: Add RGB key shortcuts for focusing color channels * PaletteEditor: Add color preview to color editor diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index fff75c917..ba53777c9 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -192,6 +192,8 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do } void TileSheetEditorImGui::draw(studio::Context&) noexcept { + setCopyEnabled(m_model.hasSelection()); + setCutEnabled(m_model.hasSelection()); if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) { if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) { if (ImGui::IsKeyPressed(ImGuiKey_A)) { diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp index b8c7a5210..5c68a828f 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp @@ -315,6 +315,10 @@ void TileSheetEditorModel::clearSelection() noexcept { m_selection.reset(); } +bool TileSheetEditorModel::hasSelection() const noexcept { + return m_selection.has_value(); +} + bool TileSheetEditorModel::updated() const noexcept { return m_updated; } diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.hpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.hpp index eaa178712..3a2663b3a 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.hpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.hpp @@ -118,6 +118,9 @@ class TileSheetEditorModel final: public ox::SignalHandler { void clearSelection() noexcept; + [[nodiscard]] + bool hasSelection() const noexcept; + [[nodiscard]] bool updated() const noexcept; diff --git a/src/olympic/studio/modlib/src/editor.cpp b/src/olympic/studio/modlib/src/editor.cpp index 442a586c2..d05e05beb 100644 --- a/src/olympic/studio/modlib/src/editor.cpp +++ b/src/olympic/studio/modlib/src/editor.cpp @@ -72,8 +72,10 @@ bool BaseEditor::exportable() const noexcept { } void BaseEditor::setCutEnabled(bool v) { - m_cutEnabled = v; - cutEnabledChanged.emit(v); + if (m_cutEnabled != v) { + m_cutEnabled = v; + cutEnabledChanged.emit(v); + } } bool BaseEditor::cutEnabled() const noexcept { @@ -81,8 +83,10 @@ bool BaseEditor::cutEnabled() const noexcept { } void BaseEditor::setCopyEnabled(bool v) { - m_copyEnabled = v; - copyEnabledChanged.emit(v); + if (m_copyEnabled != v) { + m_copyEnabled = v; + copyEnabledChanged.emit(v); + } } bool BaseEditor::copyEnabled() const noexcept { @@ -90,8 +94,10 @@ bool BaseEditor::copyEnabled() const noexcept { } void BaseEditor::setPasteEnabled(bool v) { - m_pasteEnabled = v; - pasteEnabledChanged.emit(v); + if (m_pasteEnabled != v) { + m_pasteEnabled = v; + pasteEnabledChanged.emit(v); + } } bool BaseEditor::pasteEnabled() const noexcept {