1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-15 19:43:28 +01:00

Viewport, Platform: Update the contents of GetPlatformData() in EndFrame() so back-end can access it even if UpdatePlatformWindows hasn't been called. (#1542)

This commit is contained in:
omar 2018-03-19 17:33:21 +01:00
parent 2fecd332fc
commit 9d5ec05150

View File

@ -3483,10 +3483,6 @@ void ImGui::UpdatePlatformWindows()
IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?");
IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount);
g.FrameCountPlatformEnded = g.FrameCount;
g.PlatformData.MainViewport = g.Viewports[0];
g.PlatformData.Viewports.resize(0);
g.PlatformData.Viewports.push_back(g.Viewports[0]);
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_EnableViewports))
return;
@ -3508,9 +3504,6 @@ void ImGui::UpdatePlatformWindows()
continue;
}
g.PlatformData.Viewports.push_back(viewport);
IM_ASSERT(viewport->Window != NULL);
bool is_new_window = (viewport->PlatformHandle == NULL && viewport->PlatformUserData == NULL && viewport->RendererUserData == NULL);
if (is_new_window && viewport->PlatformHandle == NULL && viewport->PlatformUserData == NULL)
g.PlatformIO.Platform_CreateWindow(viewport);
@ -4417,6 +4410,19 @@ void ImGui::EndFrame()
}
}
// Update user-side viewport list
g.PlatformData.MainViewport = g.Viewports[0];
g.PlatformData.Viewports.resize(0);
for (int i = 0; i < g.Viewports.Size; i++)
{
ImGuiViewportP* viewport = g.Viewports[i];
if (viewport->LastFrameActive < g.FrameCount)
continue;
if (i > 0)
IM_ASSERT(viewport->Window != NULL);
g.PlatformData.Viewports.push_back(viewport);
}
// Sort the window list so that all child windows are after their parent
// We cannot do that on FocusWindow() because childs may not exist yet
g.WindowsSortBuffer.resize(0);