Log/Capture: fix capture to work on clipped child windows.

+ Tweak ErrorCheckEndFrameRecover() to use local window pointer.
This commit is contained in:
ocornut 2020-12-03 15:14:32 +01:00
parent 2afdfa602f
commit 998d7303b1
2 changed files with 14 additions and 10 deletions

View File

@ -78,6 +78,7 @@ Other Changes:
- Fonts: Updated GetGlyphRangesJapanese() to include a larger 2999 ideograms selection of Joyo/Jinmeiyo - Fonts: Updated GetGlyphRangesJapanese() to include a larger 2999 ideograms selection of Joyo/Jinmeiyo
kanjis, from the previous 1946 ideograms selection. This will consume a some more memory but be generally kanjis, from the previous 1946 ideograms selection. This will consume a some more memory but be generally
much more fitting for Japanese display, until we switch to a more dynamic atlas. (#3627) [@vaiorabbit] much more fitting for Japanese display, until we switch to a more dynamic atlas. (#3627) [@vaiorabbit]
- Log/Capture: fix capture to work on clipped child windows.
- Misc: Made the ItemFlags stack shared, so effectively the ButtonRepeat/AllowKeyboardFocus states - Misc: Made the ItemFlags stack shared, so effectively the ButtonRepeat/AllowKeyboardFocus states
(and others exposed in internals such as PushItemFlag) are inherited by stacked Begin/End pairs, (and others exposed in internals such as PushItemFlag) are inherited by stacked Begin/End pairs,
vs previously a non-child stacked Begin() would reset those flags back to zero for the stacked window. vs previously a non-child stacked Begin() would reset those flags back to zero for the stacked window.

View File

@ -6044,9 +6044,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Child window can be out of sight and have "negative" clip windows. // Child window can be out of sight and have "negative" clip windows.
// Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar). // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0);
if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) // FIXME: Doesn't make sense for ChildWindow??
if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y) if (!g.LogEnabled)
window->HiddenFramesCanSkipItems = 1; if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
window->HiddenFramesCanSkipItems = 1;
// Hide along with parent or if parent is collapsed // Hide along with parent or if parent is collapsed
if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0)) if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0))
@ -6930,37 +6931,38 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
} }
#endif #endif
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(window != NULL);
while (g.CurrentTabBar != NULL) //-V1044 while (g.CurrentTabBar != NULL) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name);
EndTabBar(); EndTabBar();
} }
while (g.CurrentWindow->DC.TreeDepth > 0) //-V1044 while (window->DC.TreeDepth > 0)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name);
TreePop(); TreePop();
} }
while (g.GroupStack.Size > g.CurrentWindow->DC.StackSizesOnBegin.SizeOfGroupStack) //-V1044 while (g.GroupStack.Size > window->DC.StackSizesOnBegin.SizeOfGroupStack)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name);
EndGroup(); EndGroup();
} }
while (g.CurrentWindow->IDStack.Size > 1) //-V1044 while (window->IDStack.Size > 1)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name);
PopID(); PopID();
} }
while (g.ColorStack.Size > g.CurrentWindow->DC.StackSizesOnBegin.SizeOfColorStack) //-V1044 while (g.ColorStack.Size > window->DC.StackSizesOnBegin.SizeOfColorStack)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col));
PopStyleColor(); PopStyleColor();
} }
while (g.StyleVarStack.Size > g.CurrentWindow->DC.StackSizesOnBegin.SizeOfStyleVarStack) //-V1044 while (g.StyleVarStack.Size > window->DC.StackSizesOnBegin.SizeOfStyleVarStack)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
PopStyleVar(); PopStyleVar();
} }
while (g.FocusScopeStack.Size > g.CurrentWindow->DC.StackSizesOnBegin.SizeOfFocusScopeStack) //-V1044 while (g.FocusScopeStack.Size > window->DC.StackSizesOnBegin.SizeOfFocusScopeStack)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
PopFocusScope(); PopFocusScope();
@ -6970,7 +6972,8 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
IM_ASSERT(g.CurrentWindow->IsFallbackWindow); IM_ASSERT(g.CurrentWindow->IsFallbackWindow);
break; break;
} }
if (g.CurrentWindow->Flags & ImGuiWindowFlags_ChildWindow) IM_ASSERT(window == g.CurrentWindow);
if (window->Flags & ImGuiWindowFlags_ChildWindow)
{ {
if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name);
EndChild(); EndChild();