TabBar: expose NextScrollToTabId to internal API.

This commit is contained in:
ocornut
2026-01-30 18:41:40 +01:00
parent a9ca61a7ce
commit 4b8e41cffb
2 changed files with 7 additions and 1 deletions

View File

@@ -2792,7 +2792,7 @@ struct ImGuiTabItem
ImGuiTabItemFlags Flags;
int LastFrameVisible;
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
float Offset; // Position relative to beginning of tab
float Offset; // Position relative to beginning of tab bar
float Width; // Width currently displayed
float ContentWidth; // Width of label + padding, stored during BeginTabItem() call (misnamed as "Content" would normally imply width of label only)
float RequestedWidth; // Width optionally requested by caller, -1.0f is unused
@@ -2813,6 +2813,7 @@ struct IMGUI_API ImGuiTabBar
ImGuiID ID; // Zero for tab-bars used by docking
ImGuiID SelectedTabId; // Selected tab/window
ImGuiID NextSelectedTabId; // Next selected tab/window. Will also trigger a scrolling animation
ImGuiID NextScrollToTabId;
ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for Ctrl+Tab preview)
int CurrFrameVisible;
int PrevFrameVisible;

View File

@@ -9801,6 +9801,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
// Setup next selected tab
ImGuiID scroll_to_tab_id = 0;
if (tab_bar->NextScrollToTabId)
{
scroll_to_tab_id = tab_bar->NextScrollToTabId;
tab_bar->NextScrollToTabId = 0;
}
if (tab_bar->NextSelectedTabId)
{
tab_bar->SelectedTabId = tab_bar->NextSelectedTabId;