mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 16:46:36 +00:00
NewFrame: Removed unnecessary call to FindHoveredWindow() and simplified code (went through this multiple times, hopefully haven't broken anything)
This commit is contained in:
parent
6243252d5a
commit
a6edd10ee6
15
imgui.cpp
15
imgui.cpp
@ -629,7 +629,7 @@ static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y
|
|||||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
|
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
|
||||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
|
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
|
||||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
|
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
|
||||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
|
static ImGuiWindow* FindHoveredWindow(ImVec2 pos);
|
||||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
||||||
static void ClearSetNextWindowData();
|
static void ClearSetNextWindowData();
|
||||||
static void CheckStacksSize(ImGuiWindow* window, bool write);
|
static void CheckStacksSize(ImGuiWindow* window, bool write);
|
||||||
@ -2362,11 +2362,8 @@ void ImGui::NewFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
||||||
g.HoveredWindow = g.MovingWindow ? g.MovingWindow : FindHoveredWindow(g.IO.MousePos, false);
|
g.HoveredWindow = g.MovingWindow ? g.MovingWindow : FindHoveredWindow(g.IO.MousePos);
|
||||||
if (g.HoveredWindow && (g.HoveredWindow->Flags & ImGuiWindowFlags_ChildWindow))
|
g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
|
||||||
g.HoveredRootWindow = g.HoveredWindow->RootWindow;
|
|
||||||
else
|
|
||||||
g.HoveredRootWindow = g.MovingWindow ? g.MovingWindow->RootWindow : FindHoveredWindow(g.IO.MousePos, true);
|
|
||||||
|
|
||||||
if (ImGuiWindow* modal_window = GetFrontMostModalRootWindow())
|
if (ImGuiWindow* modal_window = GetFrontMostModalRootWindow())
|
||||||
{
|
{
|
||||||
@ -3239,7 +3236,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
|||||||
|
|
||||||
// Find window given position, search front-to-back
|
// Find window given position, search front-to-back
|
||||||
// FIXME: Note that we have a lag here because WindowRectClipped is updated in Begin() so windows moved by user via 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 thankfully isn't affected.
|
// FIXME: Note that we have a lag here because WindowRectClipped is updated in Begin() so windows moved by user via 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 thankfully isn't affected.
|
||||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
static ImGuiWindow* FindHoveredWindow(ImVec2 pos)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
for (int i = g.Windows.Size-1; i >= 0; i--)
|
for (int i = g.Windows.Size-1; i >= 0; i--)
|
||||||
@ -3249,10 +3246,8 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
|||||||
continue;
|
continue;
|
||||||
if (window->Flags & ImGuiWindowFlags_NoInputs)
|
if (window->Flags & ImGuiWindowFlags_NoInputs)
|
||||||
continue;
|
continue;
|
||||||
if (excluding_childs && (window->Flags & ImGuiWindowFlags_ChildWindow) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Using the clipped AABB so a child window will typically be clipped by its parent.
|
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
|
||||||
ImRect bb(window->WindowRectClipped.Min - g.Style.TouchExtraPadding, window->WindowRectClipped.Max + g.Style.TouchExtraPadding);
|
ImRect bb(window->WindowRectClipped.Min - g.Style.TouchExtraPadding, window->WindowRectClipped.Max + g.Style.TouchExtraPadding);
|
||||||
if (bb.Contains(pos))
|
if (bb.Contains(pos))
|
||||||
return window;
|
return window;
|
||||||
|
Loading…
Reference in New Issue
Block a user