Docking: Fixed floating->docking transition on a platform window mistakenly destroying the platform window because the upcoming tab isn't visible and triggers viewport GC. Fixed missing title bar data on recreate window.

This commit is contained in:
omar 2018-09-13 15:06:27 +02:00
parent 136fc56af0
commit 6d91055462

View File

@ -7274,9 +7274,18 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view
if (viewport && current_window && viewport->Window && (current_window->DockNode || (current_window->Flags & ImGuiWindowFlags_DockNodeHost))) if (viewport && current_window && viewport->Window && (current_window->DockNode || (current_window->Flags & ImGuiWindowFlags_DockNodeHost)))
if (viewport->LastFrameActive < g.FrameCount && viewport->Window != current_window) if (viewport->LastFrameActive < g.FrameCount && viewport->Window != current_window)
{ {
//printf("[%05d] Window '%s' steal Viewport %08X from Window '%s'\n", g.FrameCount, current_window->Name, viewport->ID, viewport->Window->Name); // When called from Begin() we don't have access to a proper version of the Hidden flag yet.
viewport->Window = current_window; bool will_be_visible = true;
viewport->ID = current_window->ID; if (current_window->DockIsActive && !current_window->DockTabIsVisible)
will_be_visible = false;
if (will_be_visible)
{
//printf("[%05d] Window '%s' steal Viewport %08X from Window '%s'\n", g.FrameCount, current_window->Name, viewport->ID, viewport->Window->Name);
viewport->Window = current_window;
viewport->ID = current_window->ID;
viewport->LastNameHash = 0;
}
} }
if (viewport) if (viewport)
@ -7710,6 +7719,7 @@ void ImGui::UpdatePlatformWindows()
g.PlatformIO.Platform_CreateWindow(viewport); g.PlatformIO.Platform_CreateWindow(viewport);
if (g.PlatformIO.Renderer_CreateWindow != NULL) if (g.PlatformIO.Renderer_CreateWindow != NULL)
g.PlatformIO.Renderer_CreateWindow(viewport); g.PlatformIO.Renderer_CreateWindow(viewport);
viewport->LastNameHash = 0;
viewport->RendererLastSize = viewport->Size; viewport->RendererLastSize = viewport->Size;
viewport->CreatedPlatformWindow = true; viewport->CreatedPlatformWindow = true;
} }
@ -10107,7 +10117,6 @@ static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window)
// then we need to hide the first one after the fact otherwise it would be visible as a standalone window for one frame. // then we need to hide the first one after the fact otherwise it would be visible as a standalone window for one frame.
if (node->Windows.Size == 2 && node->HostWindow == NULL && node->Windows[0]->WasActive == false) if (node->Windows.Size == 2 && node->HostWindow == NULL && node->Windows[0]->WasActive == false)
{ {
IM_ASSERT(node->Windows[0]->DockIsActive == false);
node->Windows[0]->Hidden = true; node->Windows[0]->Hidden = true;
node->Windows[0]->HiddenFramesRegular = 1; node->Windows[0]->HiddenFramesRegular = 1;
} }