mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
TabBar: made a change to that declared ideal width (for auto-resize) won't lag by an extra frame.
Vaguely relate to underlying (uncommited) work for #3291
This commit is contained in:
parent
8074b49148
commit
b15b25bccd
@ -6657,9 +6657,9 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
||||
tab_bar->CurrFrameVisible = g.FrameCount;
|
||||
tab_bar->FramePadding = g.Style.FramePadding;
|
||||
|
||||
// Layout
|
||||
ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
|
||||
// Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap
|
||||
window->DC.CursorPos.x = tab_bar->BarRect.Min.x;
|
||||
window->DC.CursorPos.y = tab_bar->BarRect.Max.y + g.Style.ItemSpacing.y;
|
||||
|
||||
// Draw separator
|
||||
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
|
||||
@ -6685,7 +6685,7 @@ void ImGui::EndTabBar()
|
||||
IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!");
|
||||
return;
|
||||
}
|
||||
if (tab_bar->WantLayout)
|
||||
if (tab_bar->WantLayout) // Fallback in case no TabItem have been submitted
|
||||
TabBarLayout(tab_bar);
|
||||
|
||||
// Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed().
|
||||
@ -6871,6 +6871,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
// Clear name buffers
|
||||
if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0)
|
||||
tab_bar->TabsNames.Buf.resize(0);
|
||||
|
||||
// Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame)
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->DC.CursorPos = tab_bar->BarRect.Min;
|
||||
ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
|
||||
}
|
||||
|
||||
// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack.
|
||||
|
Loading…
Reference in New Issue
Block a user