From 7a31030978feeb08f98f8269c43ca66f2b85529e Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 30 Aug 2015 18:30:54 +0100 Subject: [PATCH] Begin() windows flags are locked on the first begin of the frame, allowing using to not bother passing flags for append --- imgui.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 35195c2df..83847900c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3422,7 +3422,13 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ window = CreateNewWindow(name, size_on_first_use, flags); window_is_new = true; } - window->Flags = (ImGuiWindowFlags)flags; + + const int current_frame = ImGui::GetFrameCount(); + const bool first_begin_of_the_frame = (window->LastFrameDrawn != current_frame); + if (first_begin_of_the_frame) + window->Flags = (ImGuiWindowFlags)flags; + else + flags = window->Flags; // Add to stack ImGuiWindow* parent_window = !g.CurrentWindowStack.empty() ? g.CurrentWindowStack.back() : NULL; @@ -3431,8 +3437,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ CheckStacksSize(window, true); IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); - const int current_frame = ImGui::GetFrameCount(); - const bool first_begin_of_the_frame = (window->LastFrameDrawn != current_frame); bool window_was_visible = (window->LastFrameDrawn == current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on if (flags & ImGuiWindowFlags_Popup) {