mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Tabs: Enforcing minimum size of 1.0f, fixed asserting on zero-tab widths. (#5572)
Also fixed SetNextItemWidth(0.0f) not being consistent with tabs. (#5262)
This commit is contained in:
parent
b137f31b8c
commit
3e6f948851
@ -100,6 +100,7 @@ Other Changes:
|
|||||||
- Tabs: Fixed shrinking policy leading to infinite loops when fed unrounded tab widths. (#5652)
|
- 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
|
- Tabs: Fixed shrinking policy sometimes erroneously making right-most tabs stray a little out
|
||||||
bar boundaries (bug in 1.88). (#5652).
|
bar boundaries (bug in 1.88). (#5652).
|
||||||
|
- Tabs: Enforcing minimum size of 1.0f, fixed asserting on zero-tab widths. (#5572)
|
||||||
- Window: Fixed a potential crash when appending to a child window. (#5515, #3496, #4797) [@rokups]
|
- 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
|
- IO: Added ImGuiKey_MouseXXX aliases for mouse buttons/wheel so all operations done on ImGuiKey
|
||||||
can apply to mouse data as well. (#4921)
|
can apply to mouse data as well. (#4921)
|
||||||
|
@ -7552,7 +7552,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
// and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
|
// and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
|
||||||
const char* tab_name = tab_bar->GetTabName(tab);
|
const char* tab_name = tab_bar->GetTabName(tab);
|
||||||
const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true;
|
const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true;
|
||||||
tab->ContentWidth = (tab->RequestedWidth > 0.0f) ? tab->RequestedWidth : TabItemCalcSize(tab_name, has_close_button).x;
|
tab->ContentWidth = (tab->RequestedWidth >= 0.0f) ? tab->RequestedWidth : TabItemCalcSize(tab_name, has_close_button).x;
|
||||||
|
|
||||||
int section_n = TabItemGetSectionIdx(tab);
|
int section_n = TabItemGetSectionIdx(tab);
|
||||||
ImGuiTabBarSection* section = §ions[section_n];
|
ImGuiTabBarSection* section = §ions[section_n];
|
||||||
@ -7564,9 +7564,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
ImGuiShrinkWidthItem* shrink_width_item = &g.ShrinkWidthBuffer[shrink_buffer_indexes[section_n]++];
|
ImGuiShrinkWidthItem* shrink_width_item = &g.ShrinkWidthBuffer[shrink_buffer_indexes[section_n]++];
|
||||||
shrink_width_item->Index = tab_n;
|
shrink_width_item->Index = tab_n;
|
||||||
shrink_width_item->Width = shrink_width_item->InitialWidth = tab->ContentWidth;
|
shrink_width_item->Width = shrink_width_item->InitialWidth = tab->ContentWidth;
|
||||||
|
tab->Width = ImMax(tab->ContentWidth, 1.0f);
|
||||||
IM_ASSERT(tab->ContentWidth > 0.0f);
|
|
||||||
tab->Width = tab->ContentWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute total ideal width (used for e.g. auto-resizing a window)
|
// Compute total ideal width (used for e.g. auto-resizing a window)
|
||||||
@ -7610,6 +7608,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
if (shrinked_width < 0.0f)
|
if (shrinked_width < 0.0f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
shrinked_width = ImMax(1.0f, shrinked_width);
|
||||||
int section_n = TabItemGetSectionIdx(tab);
|
int section_n = TabItemGetSectionIdx(tab);
|
||||||
sections[section_n].Width -= (tab->Width - shrinked_width);
|
sections[section_n].Width -= (tab->Width - shrinked_width);
|
||||||
tab->Width = shrinked_width;
|
tab->Width = shrinked_width;
|
||||||
@ -8085,7 +8084,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
|
if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
|
||||||
size.x = tab->RequestedWidth = g.NextItemData.Width;
|
size.x = tab->RequestedWidth = g.NextItemData.Width;
|
||||||
if (tab_is_new)
|
if (tab_is_new)
|
||||||
tab->Width = size.x;
|
tab->Width = ImMax(1.0f, size.x);
|
||||||
tab->ContentWidth = size.x;
|
tab->ContentWidth = size.x;
|
||||||
tab->BeginOrder = tab_bar->TabsActiveCount++;
|
tab->BeginOrder = tab_bar->TabsActiveCount++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user