From 02a6c060804eed00b87604953a1f936a3e7f8609 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 18 Feb 2020 14:25:50 +0100 Subject: [PATCH] Window: Fixed a bug with child window inheriting ItemFlags from their parent when the child window also manipulate the ItemFlags stack. (#3024) [@Stanbroek] Amend f843facba4d012e225fb55b198001dbfcd0cc099 and 8828889d5ec1d8fb9ddb72bab16d5e21ba8425c6 --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4b2c1b26a..1c3edae52 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -44,6 +44,8 @@ Other Changes: when the menu is not open. (#3030) - InputText: Fixed password fields displaying ASCII spaces as blanks instead of using the '*' glyph. (#2149, #515) +- Window: Fixed a bug with child window inheriting ItemFlags from their parent when the child + window also manipulate the ItemFlags stack. (#3024) [@Stanbroek] - Font: Fixed non-ASCII space occasionally creating unnecessary empty polygons. - Demo: Added a black and white gradient to Demo>Examples>Custom Rendering. - Backends: Win32: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), diff --git a/imgui.cpp b/imgui.cpp index 85ecc45cb..0b67534d1 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5844,19 +5844,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; window->DC.FocusCounterRegular = window->DC.FocusCounterTabStop = -1; - window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_; window->DC.ItemWidth = window->ItemWidthDefault; window->DC.TextWrapPos = -1.0f; // disabled window->DC.ItemFlagsStack.resize(0); window->DC.ItemWidthStack.resize(0); window->DC.TextWrapPosStack.resize(0); window->DC.GroupStack.resize(0); - - if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags)) - { - window->DC.ItemFlags = parent_window->DC.ItemFlags; + window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_; + if (parent_window) window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags); - } if (window->AutoFitFramesX > 0) window->AutoFitFramesX--;