Tab Bar: Fixed using more than 128 tabs in a tab bar.

Using ImS16 consistently + some better packing to avoid struct growing size.
This commit is contained in:
ocornut
2020-10-19 11:51:38 +02:00
parent 748bd1ba9c
commit 8c9b3c9013
3 changed files with 11 additions and 11 deletions

View File

@ -6882,7 +6882,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
tab_bar->BackupCursorPos = window->DC.CursorPos;
if (tab_bar->CurrFrameVisible == g.FrameCount)
{
window->DC.CursorPos = tab_bar->TabsContentsMin;
window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
tab_bar->BeginCount++;
return true;
}
@ -6904,14 +6904,13 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
tab_bar->CurrFrameVisible = g.FrameCount;
tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight;
tab_bar->CurrTabsContentsHeight = 0.0f;
tab_bar->ItemSpacingY = g.Style.ItemSpacing.y;
tab_bar->FramePadding = g.Style.FramePadding;
tab_bar->TabsActiveCount = 0;
tab_bar->BeginCount = 1;
// Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap
tab_bar->TabsContentsMin.x = tab_bar->BarRect.Min.x;
tab_bar->TabsContentsMin.y = tab_bar->BarRect.Max.y + g.Style.ItemSpacing.y;
window->DC.CursorPos = tab_bar->TabsContentsMin;
window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
// Draw separator
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
@ -6990,7 +6989,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n];
tab = &tab_bar->Tabs[tab_dst_n];
tab->IndexDuringLayout = (ImS8)tab_dst_n;
tab->IndexDuringLayout = (ImS16)tab_dst_n;
// We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
@ -7549,7 +7548,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
tab_bar->TabsAddedNew = true;
tab_is_new = true;
}
tab_bar->LastTabItemIdx = (ImS8)tab_bar->Tabs.index_from_ptr(tab);
tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
tab->ContentWidth = size.x;
tab->BeginOrder = tab_bar->TabsActiveCount++;