From 4e292bf67d445180f5136a30ee822ea8031e2ba2 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 2 May 2015 12:20:06 +0100 Subject: [PATCH] Tidying up Begin(): separated blocks needed for auto-resize so it can be moved above position calculation later --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c0663f80..290c0e6b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3293,13 +3293,14 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ size_auto_fit.x += style.ScrollbarWidth; } - // Update window size + // Handle automatic resize if (window->Collapsed) { // We still process initial auto-fit on collapsed windows to get a window width // But otherwise we don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. if (window->AutoFitFrames > 0) window->SizeFull = window->AutoFitOnlyGrows ? ImMax(window->SizeFull, size_auto_fit) : size_auto_fit; + window->Size = title_bar_rect.GetSize(); } else { @@ -3323,7 +3324,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ if (window->Collapsed) { // Draw title bar only - window->Size = title_bar_rect.GetSize(); window->DrawList->AddRectFilled(title_bar_rect.GetTL(), title_bar_rect.GetBR(), window->Color(ImGuiCol_TitleBgCollapsed), window_rounding); if (window->Flags & ImGuiWindowFlags_ShowBorders) {