Fixed incorrect assignment of IsFallbackWindow which would tag dock node host windows created in NewFrame() as such, messing with popup viewport inheritance.

This commit is contained in:
omar 2019-08-22 11:34:17 +02:00
parent aedcd2fb1a
commit 72090b646f
2 changed files with 7 additions and 7 deletions

View File

@ -2733,7 +2733,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
SkipItems = false; SkipItems = false;
Appearing = false; Appearing = false;
Hidden = false; Hidden = false;
FallbackWindow = false; IsFallbackWindow = false;
HasCloseButton = false; HasCloseButton = false;
ResizeBorderHeld = -1; ResizeBorderHeld = -1;
BeginCount = 0; BeginCount = 0;
@ -4062,10 +4062,10 @@ void ImGui::NewFrame()
// Create implicit/fallback window - which we will only render it if the user has added something to it. // Create implicit/fallback window - which we will only render it if the user has added something to it.
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
// This fallback is particularly important as it avoid ImGui:: calls from crashing. // This fallback is particularly important as it avoid ImGui:: calls from crashing.
g.FrameScopePushedFallbackWindow = true;
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver); SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
Begin("Debug##Default"); Begin("Debug##Default");
IM_ASSERT(g.CurrentWindow->FallbackWindow == true); IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
g.FrameScopePushedFallbackWindow = true;
#ifdef IMGUI_ENABLE_TEST_ENGINE #ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PostNewFrame(&g); ImGuiTestEngineHook_PostNewFrame(&g);
@ -5796,7 +5796,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const int current_frame = g.FrameCount; const int current_frame = g.FrameCount;
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame); const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
window->FallbackWindow = (g.CurrentWindowStack.Size == 0); window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.FrameScopePushedFallbackWindow);
// Update the Appearing flag // Update the Appearing flag
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
@ -10731,7 +10731,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport) == 0) if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport) == 0)
{ {
// By default inherit from parent window // By default inherit from parent window
if (window->Viewport == NULL && window->ParentWindow && !window->ParentWindow->FallbackWindow) if (window->Viewport == NULL && window->ParentWindow && !window->ParentWindow->IsFallbackWindow)
window->Viewport = window->ParentWindow->Viewport; window->Viewport = window->ParentWindow->Viewport;
// Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file // Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file
@ -14024,7 +14024,7 @@ bool ImGui::GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.IO.ConfigDockingAlwaysTabBar || window->WindowClass.DockingAlwaysTabBar) if (g.IO.ConfigDockingAlwaysTabBar || window->WindowClass.DockingAlwaysTabBar)
if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking)) == 0) if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking)) == 0)
if (!window->FallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise if (!window->IsFallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise
return true; return true;
return false; return false;
} }

View File

@ -1465,7 +1465,7 @@ struct IMGUI_API ImGuiWindow
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed) bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
bool Appearing; // Set during the frame where the window is appearing (or re-appearing) bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
bool Hidden; // Do not display (== (HiddenFrames*** > 0)) bool Hidden; // Do not display (== (HiddenFrames*** > 0))
bool FallbackWindow; bool IsFallbackWindow;
bool HasCloseButton; // Set when the window has a close button (p_open != NULL) bool HasCloseButton; // Set when the window has a close button (p_open != NULL)
signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3) signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3)
short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs) short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)