From f6235304a0101d6aeb8ad078b17afe5879efb4d6 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 26 May 2024 02:10:25 -0500 Subject: [PATCH] [jasper/world/studio] Make Ctrl-A select the entire map --- .../studio/worldeditor/worldeditor-imgui.cpp | 31 +++++++------------ .../studio/worldeditor/worldeditor-imgui.hpp | 2 ++ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp index 9e69bbd..650418f 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp @@ -71,22 +71,6 @@ constexpr ox::Point fbPtToTileAddr( }; } -[[nodiscard]] -constexpr ox::Point fbPtToTileAddr( - ox::Point const&fbPt, - ox::Vec2 const&mapSz) noexcept { - return fbPtToTileAddr(static_cast(fbPt), mapSz); -} - -[[nodiscard]] -constexpr studio::Selection fbPtToTileAddr( - studio::Selection sel, - ox::Vec2 const&mapSz) noexcept { - sel.a = fbPtToTileAddr(sel.a, mapSz); - sel.b = fbPtToTileAddr(sel.b, mapSz); - return sel; -} - [[nodiscard]] constexpr bool inside(auto const val, int const min, int const max) noexcept { auto const v = static_cast(val); @@ -263,9 +247,13 @@ void WorldEditorImGui::handleSelection(ox::Size const&paneSz, float fbPaneScale) m_selTracker.finishSelection(); m_selection.emplace(m_selTracker.selection()); } - if (io.KeyCtrl && io.KeysDown[ImGuiKey_G]) { - m_selection.reset(); - m_view.clearSelection(); + if (io.KeyCtrl) { + if (io.KeysDown[ImGuiKey_G]) { + clearSelection(); + } else if (io.KeysDown[ImGuiKey_A]) { + m_selection.emplace(ox::Point{0, 0}, ox::Point{m_doc.columns - 1, m_doc.rows - 1}); + m_view.setSelection(*m_selection); + } } } @@ -354,4 +342,9 @@ bool WorldEditorImGui::tileSelected(ox::Point const&pt) const noexcept { return inside(pt.x, sel.a.x, sel.b.x) && inside(pt.y, sel.a.y, sel.b.y); } +void WorldEditorImGui::clearSelection() noexcept { + m_selection.reset(); + m_view.clearSelection(); +} + } diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp index 6250652..bd76e55 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp @@ -89,6 +89,8 @@ class WorldEditorImGui: public studio::Editor { [[nodiscard]] bool tileSelected(ox::Point const&pt) const noexcept; + + void clearSelection() noexcept; }; }