Преглед на файлове

Tabs: Fixed ShrinkWidths() redistribution of remainder leading to infinite bug + over redistribution. (#5652)

Amend c4b91017
ocornut преди 3 години
родител
ревизия
b137f31b8c
променени са 3 файла, в които са добавени 7 реда и са изтрити 4 реда
  1. 3 0
      docs/CHANGELOG.txt
  2. 1 1
      imgui.h
  3. 3 3
      imgui_widgets.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -97,6 +97,9 @@ Other Changes:
   next row in such state where subsequent SameLine() would move back to previous row.
 - Tabs: Fixed a crash when closing multiple windows (possible with docking only) with an
   appended TabItemButton(). (#5515, #3291) [@rokups]
+- Tabs: Fixed shrinking policy leading to infinite loops when fed unrounded tab widths. (#5652)
+- Tabs: Fixed shrinking policy sometimes erroneously making right-most tabs stray a little out
+  bar boundaries (bug in 1.88). (#5652).
 - Window: Fixed a potential crash when appending to a child window. (#5515, #3496, #4797) [@rokups]
 - IO: Added ImGuiKey_MouseXXX aliases for mouse buttons/wheel so all operations done on ImGuiKey
   can apply to mouse data as well. (#4921)

+ 1 - 1
imgui.h

@@ -65,7 +65,7 @@ Index of this file:
 // Version
 // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
 #define IMGUI_VERSION               "1.89 WIP"
-#define IMGUI_VERSION_NUM           18816
+#define IMGUI_VERSION_NUM           18817
 #define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
 #define IMGUI_HAS_TABLE
 

+ 3 - 3
imgui_widgets.cpp

@@ -1575,8 +1575,8 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc
         width_excess += items[n].Width - width_rounded;
         items[n].Width = width_rounded;
     }
-    while (width_excess > 0.0f)
-        for (int n = 0; n < count; n++)
+    while (width_excess >= 1.0f)
+        for (int n = 0; n < count && width_excess >= 1.0f; n++)
             if (items[n].Width + 1.0f <= items[n].InitialWidth)
             {
                 items[n].Width += 1.0f;
@@ -7596,7 +7596,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
         width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section
 
     // With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore
-    if (width_excess > 0.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible))
+    if (width_excess >= 1.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible))
     {
         int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount);
         int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0);