From 338970b243db235f947feb0f68acb6470088af48 Mon Sep 17 00:00:00 2001 From: indigo Date: Sat, 4 Jul 2026 20:44:36 +0800 Subject: [PATCH] Mask viewport split dividers under floating windows The divider hit-zones are raw screen rects; gate them on IsWindowHovered(ChildWindows) so a window stacked over the viewport (e.g. the Material Editor) doesn't highlight or start a resize drag through it. In-progress drags still track until release. Co-Authored-By: Claude Fable 5 --- .gitignore | 1 + src/ui/ViewportPanel.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index cb5ac4b..ac37312 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,4 @@ imgui.ini # OCIO config LUT files — downloaded automatically at CMake configure time resources/OpenColorIO-Configs/ +resources/hdri/ diff --git a/src/ui/ViewportPanel.cpp b/src/ui/ViewportPanel.cpp index e1a9330..ebb7a3e 100644 --- a/src/ui/ViewportPanel.cpp +++ b/src/ui/ViewportPanel.cpp @@ -247,6 +247,12 @@ bool ViewportPanel::IsMouseOverDivider(ImVec2 origin, ImVec2 total) const if (m_maximizedTileIndex >= 0) return false; if (m_draggingDivH || m_draggingDivV) return true; + // The hit-zones below are raw screen rects; without this gate a floating + // window stacked over the viewport (e.g. the Material Editor) wouldn't + // mask them and the divider would still react underneath it. + if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) + return false; + const float kDivHalf = 3.0f; ImVec2 mouse = ImGui::GetMousePos(); @@ -283,6 +289,11 @@ void ViewportPanel::DrawDividers(ImVec2 origin, ImVec2 total) // accidentally triggered when the mouse drifts over the hit-zone. bool lmbClicked = ImGui::IsMouseClicked(ImGuiMouseButton_Left); bool lmbReleased = ImGui::IsMouseReleased(ImGuiMouseButton_Left); + // Raw screen-rect hit-testing below — require this window (or its tiles) + // to actually be the hovered window, so a floating window stacked on top + // (e.g. the Material Editor) masks the dividers. In-progress drags are + // exempt: they must keep tracking until LMB release wherever the mouse is. + bool windowHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows); // Vertical divider (HSplit / Quad) if (m_layout == LayoutMode::HSplit || m_layout == LayoutMode::Quad) { @@ -290,7 +301,7 @@ void ViewportPanel::DrawDividers(ImVec2 origin, ImVec2 total) ImVec2 hMin(divX - kDivThick * 0.5f, origin.y); ImVec2 hMax(divX + kDivThick * 0.5f, origin.y + total.y); - bool hovering = !m_draggingDivV && + bool hovering = windowHovered && !m_draggingDivV && mousePos.x >= hMin.x && mousePos.x <= hMax.x && mousePos.y >= hMin.y && mousePos.y <= hMax.y; @@ -315,7 +326,7 @@ void ViewportPanel::DrawDividers(ImVec2 origin, ImVec2 total) ImVec2 hMin(origin.x, divY - kDivThick * 0.5f); ImVec2 hMax(origin.x + total.x, divY + kDivThick * 0.5f); - bool hovering = !m_draggingDivH && + bool hovering = windowHovered && !m_draggingDivH && mousePos.x >= hMin.x && mousePos.x <= hMax.x && mousePos.y >= hMin.y && mousePos.y <= hMax.y;