mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 01:20:55 +01:00
Tabs: Fixed ShrinkWidths() redistribution of remainder leading to infinite bug (second fix). (#5652, #5262)
Amend b137f31
This commit is contained in:
parent
3e6f948851
commit
52d9ee0dc2
@ -13236,7 +13236,7 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
|
|||||||
PushID(tab);
|
PushID(tab);
|
||||||
if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2);
|
if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2);
|
||||||
if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine();
|
if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine();
|
||||||
Text("%02d%c Tab 0x%08X '%s' Offset: %.1f, Width: %.1f/%.1f",
|
Text("%02d%c Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f",
|
||||||
tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth);
|
tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth);
|
||||||
PopID();
|
PopID();
|
||||||
}
|
}
|
||||||
|
2
imgui.h
2
imgui.h
@ -65,7 +65,7 @@ Index of this file:
|
|||||||
// Version
|
// 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)
|
// (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 "1.89 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18817
|
#define IMGUI_VERSION_NUM 18818
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
|
@ -1575,13 +1575,13 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc
|
|||||||
width_excess += items[n].Width - width_rounded;
|
width_excess += items[n].Width - width_rounded;
|
||||||
items[n].Width = width_rounded;
|
items[n].Width = width_rounded;
|
||||||
}
|
}
|
||||||
while (width_excess >= 1.0f)
|
while (width_excess > 0.0f)
|
||||||
for (int n = 0; n < count && width_excess >= 1.0f; n++)
|
for (int n = 0; n < count && width_excess > 0.0f; n++)
|
||||||
if (items[n].Width + 1.0f <= items[n].InitialWidth)
|
{
|
||||||
{
|
float width_to_add = ImMin(items[n].InitialWidth - items[n].Width, 1.0f);
|
||||||
items[n].Width += 1.0f;
|
items[n].Width += width_to_add;
|
||||||
width_excess -= 1.0f;
|
width_excess -= width_to_add;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user