[studio,nostalgia/gfx/studio/tilesheet] Fix copy/cut/paste enablement when there is no selection
All checks were successful
Build / build (push) Successful in 2m2s

This commit is contained in:
2025-06-21 00:18:34 -05:00
parent 58e0ecb469
commit 5f2397903a
5 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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)) {

View File

@ -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;
}

View File

@ -118,6 +118,9 @@ class TileSheetEditorModel final: public ox::SignalHandler {
void clearSelection() noexcept;
[[nodiscard]]
bool hasSelection() const noexcept;
[[nodiscard]]
bool updated() const noexcept;

View File

@ -72,27 +72,33 @@ bool BaseEditor::exportable() const noexcept {
}
void BaseEditor::setCutEnabled(bool v) {
if (m_cutEnabled != v) {
m_cutEnabled = v;
cutEnabledChanged.emit(v);
}
}
bool BaseEditor::cutEnabled() const noexcept {
return m_cutEnabled;
}
void BaseEditor::setCopyEnabled(bool v) {
if (m_copyEnabled != v) {
m_copyEnabled = v;
copyEnabledChanged.emit(v);
}
}
bool BaseEditor::copyEnabled() const noexcept {
return m_copyEnabled;
}
void BaseEditor::setPasteEnabled(bool v) {
if (m_pasteEnabled != v) {
m_pasteEnabled = v;
pasteEnabledChanged.emit(v);
}
}
bool BaseEditor::pasteEnabled() const noexcept {
return m_pasteEnabled && acceptsClipboardPayload();