[jasper/world/studio] Add input filtering for when popup is open
All checks were successful
Build / build (push) Successful in 3m57s
All checks were successful
Build / build (push) Successful in 3m57s
This commit is contained in:
parent
765d6d95f5
commit
20722ed0fd
@ -91,8 +91,8 @@ WorldEditorImGui::WorldEditorImGui(studio::StudioContext &sctx, ox::StringParam
|
||||
|
||||
void WorldEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
||||
constexpr auto resourcesWidth = 300.f;
|
||||
{
|
||||
constexpr auto resourcesWidth = 300.f;
|
||||
ig::ChildStackItem const worldView{"WorldView", {paneSize.x - resourcesWidth, 0}};
|
||||
drawWorldView();
|
||||
}
|
||||
@ -315,12 +315,11 @@ void WorldEditorImGui::drawWorldView() noexcept {
|
||||
return handleDrop(fbPaneScale);
|
||||
});
|
||||
handleMouseSelection(fbPaneScale);
|
||||
if (!popupOpen()) {
|
||||
auto const&io = ImGui::GetIO();
|
||||
if (io.KeyCtrl) {
|
||||
if (io.KeysDown[ImGuiKey_G]) {
|
||||
if (ig::mainWinHasFocus()) {
|
||||
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl)) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_G)) {
|
||||
clearSelection();
|
||||
} else if (io.KeysDown[ImGuiKey_A]) {
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_A)) {
|
||||
m_selection.emplace(ox::Point{0, 0}, ox::Point{m_doc.columns - 1, m_doc.rows - 1});
|
||||
m_view.setSelection(*m_selection);
|
||||
setCopyEnabled(true);
|
||||
@ -332,16 +331,15 @@ void WorldEditorImGui::drawWorldView() noexcept {
|
||||
}
|
||||
|
||||
void WorldEditorImGui::handleMouseSelection(float const 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] && ImGui::IsItemHovered();
|
||||
if (ImGui::IsMouseDown(0)) {
|
||||
auto const fbPos = world::fbPos(ox::Vec2{ImGui::GetMousePos()});
|
||||
auto const startSel = ImGui::IsMouseClicked(0) && ImGui::IsItemHovered();
|
||||
auto const scaledViewSz = ox::Vec2{m_view.drawSize()} * fbPaneScale;
|
||||
m_selTracker.updateCursorPoint(fbPtToTileAddr(fbPos, scaledViewSz), startSel);
|
||||
if (m_selTracker.selectionOngoing()) {
|
||||
m_view.setSelection(m_selTracker.selection());
|
||||
}
|
||||
} else if (io.MouseReleased[0] && m_selTracker.selectionOngoing()) {
|
||||
} else if (ImGui::IsMouseReleased(0) && m_selTracker.selectionOngoing()) {
|
||||
m_selTracker.finishSelection();
|
||||
m_selection.emplace(m_selTracker.selection());
|
||||
setCopyEnabled(true);
|
||||
@ -352,8 +350,7 @@ void WorldEditorImGui::handleMouseSelection(float const fbPaneScale) noexcept {
|
||||
|
||||
ox::Error WorldEditorImGui::handleDrop(float const fbPaneScale) noexcept {
|
||||
OX_REQUIRE(objId, ig::getDragDropPayload<WorldTileDragDrop>("WorldTile"));
|
||||
auto const&io = ImGui::GetIO();
|
||||
auto const fbPos = world::fbPos(ox::Vec2{io.MousePos});
|
||||
auto const fbPos = world::fbPos(ox::Vec2{ImGui::GetMousePos()});
|
||||
auto const viewSz = m_view.drawSize();
|
||||
auto const tileAddr = fbPtToTileAddr(
|
||||
fbPos,
|
||||
|
@ -100,6 +100,7 @@ class WorldEditorImGui: public studio::Editor {
|
||||
|
||||
ox::Error addDependency(ox::FileAddress const&fileAddr) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool popupOpen() const noexcept {
|
||||
return m_sizeEditor.show;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user