[jasper/world/studio] Fix world tile selection to properly release when out of bounds
All checks were successful
Build / build (push) Successful in 3m14s
All checks were successful
Build / build (push) Successful in 3m14s
This commit is contained in:
parent
d0073b2161
commit
7ac29585d6
@ -72,12 +72,6 @@ constexpr ox::Point fbPtToTileAddr(
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool inside(auto const val, int const min, int const max) noexcept {
|
||||
auto const v = static_cast<int>(val);
|
||||
return v <= max && v >= min;
|
||||
};
|
||||
|
||||
WorldEditorImGui::WorldEditorImGui(studio::StudioContext &sctx, ox::StringView path):
|
||||
Editor(path),
|
||||
m_sctx(sctx),
|
||||
@ -301,7 +295,7 @@ void WorldEditorImGui::drawWorldView() noexcept {
|
||||
std::ignore = ig::dragDropTarget([this, fbPaneScale] {
|
||||
return handleDrop(fbPaneScale);
|
||||
});
|
||||
handleMouseSelection(static_cast<ox::Size>(ox::Vec2(paneSize)), fbPaneScale);
|
||||
handleMouseSelection(fbPaneScale);
|
||||
auto const&io = ImGui::GetIO();
|
||||
if (io.KeyCtrl) {
|
||||
if (io.KeysDown[ImGuiKey_G]) {
|
||||
@ -316,13 +310,11 @@ void WorldEditorImGui::drawWorldView() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void WorldEditorImGui::handleMouseSelection(ox::Size const&paneSz, float fbPaneScale) noexcept {
|
||||
void WorldEditorImGui::handleMouseSelection(float fbPaneScale) noexcept {
|
||||
auto const&io = ImGui::GetIO();
|
||||
if (io.MouseDown[0]) {
|
||||
auto const fbPos = world::fbPos(ox::Vec2{io.MousePos});
|
||||
auto const startSel = io.MouseClicked[0]
|
||||
&& inside(fbPos.x, 0, paneSz.width)
|
||||
&& inside(fbPos.y, 0, paneSz.height);
|
||||
auto const startSel = io.MouseClicked[0] && ImGui::IsItemHovered();
|
||||
auto const scaledViewSz = static_cast<ox::Vec2>(m_view.drawSize()) * fbPaneScale;
|
||||
m_selTracker.updateCursorPoint(fbPtToTileAddr(fbPos, scaledViewSz), startSel);
|
||||
if (m_selTracker.selectionOngoing()) {
|
||||
@ -428,11 +420,7 @@ ox::Error WorldEditorImGui::undoStackChanged(studio::UndoCommand const*) {
|
||||
}
|
||||
|
||||
bool WorldEditorImGui::tileSelected(ox::Point const&pt) const noexcept {
|
||||
if (!m_selection) {
|
||||
return false;
|
||||
}
|
||||
auto const&sel = *m_selection;
|
||||
return sel.contains(pt);
|
||||
return m_selection && m_selection->contains(pt);
|
||||
}
|
||||
|
||||
void WorldEditorImGui::clearSelection() noexcept {
|
||||
|
@ -81,7 +81,7 @@ class WorldEditorImGui: public studio::Editor {
|
||||
|
||||
void drawWorldView() noexcept;
|
||||
|
||||
void handleMouseSelection(ox::Size const&paneSz, float fbPaneScale) noexcept;
|
||||
void handleMouseSelection(float fbPaneScale) noexcept;
|
||||
|
||||
ox::Error handleDrop(float fbPaneScale) noexcept;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user