Called by user at the end of the main loop, after EndFrame() This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api.
| 14091 | // Called by user at the end of the main loop, after EndFrame() |
| 14092 | // This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api. |
| 14093 | void ImGui::UpdatePlatformWindows() |
| 14094 | { |
| 14095 | ImGuiContext& g = *GImGui; |
| 14096 | IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?"); |
| 14097 | IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount); |
| 14098 | g.FrameCountPlatformEnded = g.FrameCount; |
| 14099 | if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)) |
| 14100 | return; |
| 14101 | |
| 14102 | // Create/resize/destroy platform windows to match each active viewport. |
| 14103 | // Skip the main viewport (index 0), which is always fully handled by the application! |
| 14104 | for (int i = 1; i < g.Viewports.Size; i++) |
| 14105 | { |
| 14106 | ImGuiViewportP* viewport = g.Viewports[i]; |
| 14107 | |
| 14108 | // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window |
| 14109 | // (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame) |
| 14110 | bool destroy_platform_window = false; |
| 14111 | destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1); |
| 14112 | destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window)); |
| 14113 | if (destroy_platform_window) |
| 14114 | { |
| 14115 | DestroyPlatformWindow(viewport); |
| 14116 | continue; |
| 14117 | } |
| 14118 | |
| 14119 | // New windows that appears directly in a new viewport won't always have a size on their first frame |
| 14120 | if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0 || viewport->Size.y <= 0) |
| 14121 | continue; |
| 14122 | |
| 14123 | // Create window |
| 14124 | const bool is_new_platform_window = (viewport->PlatformWindowCreated == false); |
| 14125 | if (is_new_platform_window) |
| 14126 | { |
| 14127 | IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Create Platform Window %08X '%s'\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a"); |
| 14128 | g.PlatformIO.Platform_CreateWindow(viewport); |
| 14129 | if (g.PlatformIO.Renderer_CreateWindow != NULL) |
| 14130 | g.PlatformIO.Renderer_CreateWindow(viewport); |
| 14131 | viewport->LastNameHash = 0; |
| 14132 | viewport->LastPlatformPos = viewport->LastPlatformSize = ImVec2(FLT_MAX, FLT_MAX); // By clearing those we'll enforce a call to Platform_SetWindowPos/Size below, before Platform_ShowWindow (FIXME: Is that necessary?) |
| 14133 | viewport->LastRendererSize = viewport->Size; // We don't need to call Renderer_SetWindowSize() as it is expected Renderer_CreateWindow() already did it. |
| 14134 | viewport->PlatformWindowCreated = true; |
| 14135 | } |
| 14136 | |
| 14137 | // Apply Position and Size (from ImGui to Platform/Renderer backends) |
| 14138 | if ((viewport->LastPlatformPos.x != viewport->Pos.x || viewport->LastPlatformPos.y != viewport->Pos.y) && !viewport->PlatformRequestMove) |
| 14139 | g.PlatformIO.Platform_SetWindowPos(viewport, viewport->Pos); |
| 14140 | if ((viewport->LastPlatformSize.x != viewport->Size.x || viewport->LastPlatformSize.y != viewport->Size.y) && !viewport->PlatformRequestResize) |
| 14141 | g.PlatformIO.Platform_SetWindowSize(viewport, viewport->Size); |
| 14142 | if ((viewport->LastRendererSize.x != viewport->Size.x || viewport->LastRendererSize.y != viewport->Size.y) && g.PlatformIO.Renderer_SetWindowSize) |
| 14143 | g.PlatformIO.Renderer_SetWindowSize(viewport, viewport->Size); |
| 14144 | viewport->LastPlatformPos = viewport->Pos; |
| 14145 | viewport->LastPlatformSize = viewport->LastRendererSize = viewport->Size; |
| 14146 | |
| 14147 | // Update title bar (if it changed) |
| 14148 | if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(viewport->Window)) |
| 14149 | { |
| 14150 | const char* title_begin = window_for_title->Name; |
nothing calls this directly
no test coverage detected