Selaa lähdekoodia

Tidying up Begin(): separated blocks needed for auto-resize so it can be moved above position calculation later

ocornut 10 vuotta sitten
vanhempi
commit
4e292bf67d
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      imgui.cpp

+ 2 - 2
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;
                 size_auto_fit.x += style.ScrollbarWidth;
         }
         }
 
 
-        // Update window size
+        // Handle automatic resize
         if (window->Collapsed)
         if (window->Collapsed)
         {
         {
             // We still process initial auto-fit on collapsed windows to get a window width
             // We still process initial auto-fit on collapsed windows to get a window width
             // But otherwise we don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed.
             // But otherwise we don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed.
             if (window->AutoFitFrames > 0)
             if (window->AutoFitFrames > 0)
                 window->SizeFull = window->AutoFitOnlyGrows ? ImMax(window->SizeFull, size_auto_fit) : size_auto_fit;
                 window->SizeFull = window->AutoFitOnlyGrows ? ImMax(window->SizeFull, size_auto_fit) : size_auto_fit;
+            window->Size = title_bar_rect.GetSize();
         }
         }
         else
         else
         {
         {
@@ -3323,7 +3324,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
         if (window->Collapsed)
         if (window->Collapsed)
         {
         {
             // Draw title bar only
             // 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);
             window->DrawList->AddRectFilled(title_bar_rect.GetTL(), title_bar_rect.GetBR(), window->Color(ImGuiCol_TitleBgCollapsed), window_rounding);
             if (window->Flags & ImGuiWindowFlags_ShowBorders)
             if (window->Flags & ImGuiWindowFlags_ShowBorders)
             {
             {