[jasper/world/studio] Make Ctrl-A select the entire map
All checks were successful
Build / build (push) Successful in 3m18s

This commit is contained in:
Gary Talent 2024-05-26 02:10:25 -05:00
parent 4a73a7c35a
commit f6235304a0
2 changed files with 14 additions and 19 deletions

View File

@ -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<ox::Vec2>(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<int>(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();
}
}

View File

@ -89,6 +89,8 @@ class WorldEditorImGui: public studio::Editor {
[[nodiscard]]
bool tileSelected(ox::Point const&pt) const noexcept;
void clearSelection() noexcept;
};
}