|
|
@ -6782,15 +6782,16 @@ ImGuiTabBar::ImGuiTabBar()
|
|
|
|
Flags = ImGuiTabBarFlags_None;
|
|
|
|
Flags = ImGuiTabBarFlags_None;
|
|
|
|
ReorderRequestTabId = 0;
|
|
|
|
ReorderRequestTabId = 0;
|
|
|
|
ReorderRequestDir = 0;
|
|
|
|
ReorderRequestDir = 0;
|
|
|
|
|
|
|
|
TabsActiveCount = 0;
|
|
|
|
WantLayout = VisibleTabWasSubmitted = false;
|
|
|
|
WantLayout = VisibleTabWasSubmitted = false;
|
|
|
|
LastTabItemIdx = -1;
|
|
|
|
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* a = (const ImGuiTabItem*)lhs;
|
|
|
|
const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
|
|
|
|
const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
|
|
|
|
return (int)(a->Offset - b->Offset);
|
|
|
|
return (int)(a->BeginOrder - b->BeginOrder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref)
|
|
|
|
static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref)
|
|
|
@ -6842,10 +6843,9 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// When toggling back from ordered to manually-reorderable, shuffle tabs to enforce the last visible order.
|
|
|
|
// When toggling ImGuiTabBarFlags_Reorderable flag, ensure tabs are ordered based on their submission 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)
|
|
|
|
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), TabItemComparerByBeginOrder);
|
|
|
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByVisibleOffset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
// Flags
|
|
|
|
if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
|
|
|
|
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->PrevFrameVisible = tab_bar->CurrFrameVisible;
|
|
|
|
tab_bar->CurrFrameVisible = g.FrameCount;
|
|
|
|
tab_bar->CurrFrameVisible = g.FrameCount;
|
|
|
|
tab_bar->FramePadding = g.Style.FramePadding;
|
|
|
|
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
|
|
|
|
// 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.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_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
|
|
|
|
tab->ContentWidth = size.x;
|
|
|
|
tab->ContentWidth = size.x;
|
|
|
|
|
|
|
|
tab->BeginOrder = tab_bar->TabsActiveCount++;
|
|
|
|
|
|
|
|
|
|
|
|
const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
|
|
|
|
const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
|
|
|
|
const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0;
|
|
|
|
const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0;
|
|
|
|