|
@@ -4488,7 +4488,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
|
|
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
|
|
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
|
|
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
|
|
bool clear_hovered_windows = false;
|
|
bool clear_hovered_windows = false;
|
|
- FindHoveredWindow();
|
|
|
|
|
|
+ FindHoveredWindowEx(g.IO.MousePos, false, &g.HoveredWindow, &g.HoveredWindowUnderMovingWindow);
|
|
|
|
|
|
// Modal windows prevents mouse from hovering behind them.
|
|
// Modal windows prevents mouse from hovering behind them.
|
|
ImGuiWindow* modal_window = GetTopMostPopupModal();
|
|
ImGuiWindow* modal_window = GetTopMostPopupModal();
|
|
@@ -5215,15 +5215,17 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
|
}
|
|
}
|
|
|
|
|
|
// Find window given position, search front-to-back
|
|
// Find window given position, search front-to-back
|
|
-// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically
|
|
|
|
-// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
|
|
|
|
-// called, aka before the next Begin(). Moving window isn't affected.
|
|
|
|
-static void FindHoveredWindow()
|
|
|
|
|
|
+// - Typically write output back to g.HoveredWindow and g.HoveredWindowUnderMovingWindow.
|
|
|
|
+// - FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically
|
|
|
|
+// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
|
|
|
|
+// called, aka before the next Begin(). Moving window isn't affected.
|
|
|
|
+// - The 'find_first_and_in_any_viewport = true' mode is only used by TestEngine. It is simpler to maintain here.
|
|
|
|
+void ImGui::FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
ImGuiWindow* hovered_window = NULL;
|
|
ImGuiWindow* hovered_window = NULL;
|
|
- ImGuiWindow* hovered_window_ignoring_moving_window = NULL;
|
|
|
|
|
|
+ ImGuiWindow* hovered_window_under_moving_window = NULL;
|
|
if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
hovered_window = g.MovingWindow;
|
|
hovered_window = g.MovingWindow;
|
|
|
|
|
|
@@ -5240,7 +5242,7 @@ static void FindHoveredWindow()
|
|
|
|
|
|
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
|
|
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
|
|
ImVec2 hit_padding = (window->Flags & (ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) ? padding_regular : padding_for_resize;
|
|
ImVec2 hit_padding = (window->Flags & (ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) ? padding_regular : padding_for_resize;
|
|
- if (!window->OuterRectClipped.ContainsWithPad(g.IO.MousePos, hit_padding))
|
|
|
|
|
|
+ if (!window->OuterRectClipped.ContainsWithPad(pos, hit_padding))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
// Support for one rectangular hole in any given window
|
|
// Support for one rectangular hole in any given window
|
|
@@ -5249,21 +5251,30 @@ static void FindHoveredWindow()
|
|
{
|
|
{
|
|
ImVec2 hole_pos(window->Pos.x + (float)window->HitTestHoleOffset.x, window->Pos.y + (float)window->HitTestHoleOffset.y);
|
|
ImVec2 hole_pos(window->Pos.x + (float)window->HitTestHoleOffset.x, window->Pos.y + (float)window->HitTestHoleOffset.y);
|
|
ImVec2 hole_size((float)window->HitTestHoleSize.x, (float)window->HitTestHoleSize.y);
|
|
ImVec2 hole_size((float)window->HitTestHoleSize.x, (float)window->HitTestHoleSize.y);
|
|
- if (ImRect(hole_pos, hole_pos + hole_size).Contains(g.IO.MousePos))
|
|
|
|
|
|
+ if (ImRect(hole_pos, hole_pos + hole_size).Contains(pos))
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if (hovered_window == NULL)
|
|
|
|
|
|
+ if (find_first_and_in_any_viewport)
|
|
|
|
+ {
|
|
hovered_window = window;
|
|
hovered_window = window;
|
|
- IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer.
|
|
|
|
- if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow))
|
|
|
|
- hovered_window_ignoring_moving_window = window;
|
|
|
|
- if (hovered_window && hovered_window_ignoring_moving_window)
|
|
|
|
break;
|
|
break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (hovered_window == NULL)
|
|
|
|
+ hovered_window = window;
|
|
|
|
+ IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer.
|
|
|
|
+ if (hovered_window_under_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow))
|
|
|
|
+ hovered_window_under_moving_window = window;
|
|
|
|
+ if (hovered_window && hovered_window_under_moving_window)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- g.HoveredWindow = hovered_window;
|
|
|
|
- g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window;
|
|
|
|
|
|
+ *out_hovered_window = hovered_window;
|
|
|
|
+ if (out_hovered_window_under_moving_window != NULL)
|
|
|
|
+ *out_hovered_window_under_moving_window = hovered_window_under_moving_window;
|
|
}
|
|
}
|
|
|
|
|
|
bool ImGui::IsItemActive()
|
|
bool ImGui::IsItemActive()
|