mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-14 19:17:48 +01:00
Internals: NewFrame: move the window reset loop higher up, namely before UpdateHoveredWindowAndCaptureFlags() -> FindHoveredWindowEx().
This allows using FindHoveredWindowEx() from anywhere in the frame.
This commit is contained in:
parent
797101a882
commit
26785fd873
35
imgui.cpp
35
imgui.cpp
@ -5158,8 +5158,25 @@ void ImGui::NewFrame()
|
|||||||
// Update mouse input state
|
// Update mouse input state
|
||||||
UpdateMouseInputs();
|
UpdateMouseInputs();
|
||||||
|
|
||||||
|
// Mark all windows as not visible and compact unused memory.
|
||||||
|
IM_ASSERT(g.WindowsFocusOrder.Size <= g.Windows.Size);
|
||||||
|
const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer;
|
||||||
|
for (ImGuiWindow* window : g.Windows)
|
||||||
|
{
|
||||||
|
window->WasActive = window->Active;
|
||||||
|
window->Active = false;
|
||||||
|
window->WriteAccessed = false;
|
||||||
|
window->BeginCountPreviousFrame = window->BeginCount;
|
||||||
|
window->BeginCount = 0;
|
||||||
|
|
||||||
|
// Garbage collect transient buffers of recently unused windows
|
||||||
|
if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time)
|
||||||
|
GcCompactTransientWindowBuffers(window);
|
||||||
|
}
|
||||||
|
|
||||||
// Find hovered window
|
// Find hovered window
|
||||||
// (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame)
|
// (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame)
|
||||||
|
// (currently needs to be done after the WasActive=Active loop and FindHoveredWindowEx uses ->Active)
|
||||||
UpdateHoveredWindowAndCaptureFlags();
|
UpdateHoveredWindowAndCaptureFlags();
|
||||||
|
|
||||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
||||||
@ -5181,22 +5198,6 @@ void ImGui::NewFrame()
|
|||||||
// Mouse wheel scrolling, scale
|
// Mouse wheel scrolling, scale
|
||||||
UpdateMouseWheel();
|
UpdateMouseWheel();
|
||||||
|
|
||||||
// Mark all windows as not visible and compact unused memory.
|
|
||||||
IM_ASSERT(g.WindowsFocusOrder.Size <= g.Windows.Size);
|
|
||||||
const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer;
|
|
||||||
for (ImGuiWindow* window : g.Windows)
|
|
||||||
{
|
|
||||||
window->WasActive = window->Active;
|
|
||||||
window->Active = false;
|
|
||||||
window->WriteAccessed = false;
|
|
||||||
window->BeginCountPreviousFrame = window->BeginCount;
|
|
||||||
window->BeginCount = 0;
|
|
||||||
|
|
||||||
// Garbage collect transient buffers of recently unused windows
|
|
||||||
if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time)
|
|
||||||
GcCompactTransientWindowBuffers(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Garbage collect transient buffers of recently unused tables
|
// Garbage collect transient buffers of recently unused tables
|
||||||
for (int i = 0; i < g.TablesLastTimeActive.Size; i++)
|
for (int i = 0; i < g.TablesLastTimeActive.Size; i++)
|
||||||
if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time)
|
if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time)
|
||||||
@ -5660,7 +5661,7 @@ void ImGui::FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_vi
|
|||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[i];
|
ImGuiWindow* window = g.Windows[i];
|
||||||
IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer.
|
IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer.
|
||||||
if (!window->Active || window->Hidden)
|
if (!window->WasActive || window->Hidden)
|
||||||
continue;
|
continue;
|
||||||
if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
|
if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user