|
|
|
@ -6782,15 +6782,16 @@ ImGuiTabBar::ImGuiTabBar() |
|
|
|
|
Flags = ImGuiTabBarFlags_None; |
|
|
|
|
ReorderRequestTabId = 0; |
|
|
|
|
ReorderRequestDir = 0; |
|
|
|
|
TabsActiveCount = 0; |
|
|
|
|
WantLayout = VisibleTabWasSubmitted = false; |
|
|
|
|
LastTabItemIdx = -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const void* rhs) |
|
|
|
|
static int IMGUI_CDECL TabItemComparerByBeginOrder(const void* lhs, const void* rhs) |
|
|
|
|
{ |
|
|
|
|
const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; |
|
|
|
|
const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; |
|
|
|
|
return (int)(a->Offset - b->Offset); |
|
|
|
|
return (int)(a->BeginOrder - b->BeginOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref) |
|
|
|
@ -6842,10 +6843,9 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// When toggling back from ordered to manually-reorderable, shuffle tabs to enforce the last visible order.
|
|
|
|
|
// Otherwise, the most recently inserted tabs would move at the end of visible list which can be a little too confusing or magic for the user.
|
|
|
|
|
if ((flags & ImGuiTabBarFlags_Reorderable) && !(tab_bar->Flags & ImGuiTabBarFlags_Reorderable) && tab_bar->Tabs.Size > 1 && tab_bar->PrevFrameVisible != -1) |
|
|
|
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByVisibleOffset); |
|
|
|
|
// When toggling ImGuiTabBarFlags_Reorderable flag, ensure tabs are ordered based on their submission order.
|
|
|
|
|
if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) && tab_bar->Tabs.Size > 1) |
|
|
|
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder); |
|
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
|
if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) |
|
|
|
@ -6857,6 +6857,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG |
|
|
|
|
tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible; |
|
|
|
|
tab_bar->CurrFrameVisible = g.FrameCount; |
|
|
|
|
tab_bar->FramePadding = g.Style.FramePadding; |
|
|
|
|
tab_bar->TabsActiveCount = 0; |
|
|
|
|
|
|
|
|
|
// 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; |
|
|
|
@ -7362,6 +7363,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, |
|
|
|
|
} |
|
|
|
|
tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab); |
|
|
|
|
tab->ContentWidth = size.x; |
|
|
|
|
tab->BeginOrder = tab_bar->TabsActiveCount++; |
|
|
|
|
|
|
|
|
|
const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); |
|
|
|
|
const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0; |
|
|
|
|