Docking: Remove code in BeginDocked() to set HiddenFramesCannotSkipItems based on upcoming tab bar selection, solely based on focus (might break something subtle?). Follow-up to c355ed1267. (#2453, #2109)

This commit is contained in:
omar 2019-03-28 16:13:06 +01:00
parent b6ae8a0dca
commit 47219dd5c6

View File

@ -6070,9 +6070,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->BeginCount++;
g.NextWindowData.Clear();
// When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems.
// This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.
// This is analogous to regular windows being hidden from one frame.
// It is especially important as e.g. nested TabBars would otherwise generate flicker in the form of one empty frame, or focus requests won't be processed.
if (window->DockIsActive && !window->DockTabIsVisible)
{
if (window->LastFrameJustFocused == g.FrameCount) // This may be a better a generalization for the code in BeginDocked() setting the same field.
if (window->LastFrameJustFocused == g.FrameCount)
window->HiddenFramesCannotSkipItems = 1;
else
window->HiddenFramesCanSkipItems = 1;
@ -13527,14 +13531,6 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
if (node->VisibleWindow == window)
window->DockTabIsVisible = true;
// When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems.
// This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.
// This is analogous to regular windows being hidden from one frame. It is especially important as nested TabBars would otherwise generate flicker in the form
// of one empty frame.
// Note that we set HiddenFramesCannotSkipItems=2 because BeginDocked() is called just before Begin() has a chance to decrement the value. Effectively it'll be a 1 frame thing.
if (!window->DockTabIsVisible && node->TabBar && node->TabBar->NextSelectedTabId == window->ID)
window->HiddenFramesCannotSkipItems = 2;
// Update window flag
IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0);
window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize;