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 <noreply@anthropic.com>
This commit is contained in:
@@ -78,3 +78,4 @@ imgui.ini
|
||||
|
||||
# OCIO config LUT files — downloaded automatically at CMake configure time
|
||||
resources/OpenColorIO-Configs/
|
||||
resources/hdri/
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user