mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
TabBar: Internals: add tab_bar->VisibleTabContentsJustAppeared. (#9581)
This commit is contained in:
parent
86b853ae8a
commit
50ae760fce
@ -2946,6 +2946,7 @@ struct ImGuiTabItem
|
|||||||
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
||||||
ImS16 IndexDuringLayout; // Index only used during TabBarLayout(). Tabs gets reordered so 'Tabs[n].IndexDuringLayout == n' but may mismatch during additions.
|
ImS16 IndexDuringLayout; // Index only used during TabBarLayout(). Tabs gets reordered so 'Tabs[n].IndexDuringLayout == n' but may mismatch during additions.
|
||||||
bool WantClose; // Marked as closed by SetTabItemClosed()
|
bool WantClose; // Marked as closed by SetTabItemClosed()
|
||||||
|
bool ContentsIsVisible;
|
||||||
|
|
||||||
ImGuiTabItem() { memset((void*)this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; RequestedWidth = -1.0f; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
|
ImGuiTabItem() { memset((void*)this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; RequestedWidth = -1.0f; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
|
||||||
};
|
};
|
||||||
@ -2982,6 +2983,7 @@ struct IMGUI_API ImGuiTabBar
|
|||||||
ImS8 BeginCount;
|
ImS8 BeginCount;
|
||||||
bool WantLayout;
|
bool WantLayout;
|
||||||
bool VisibleTabWasSubmitted;
|
bool VisibleTabWasSubmitted;
|
||||||
|
bool VisibleTabContentsJustAppeared;
|
||||||
bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
|
bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
|
||||||
bool ScrollButtonEnabled;
|
bool ScrollButtonEnabled;
|
||||||
ImS16 TabsActiveCount; // Number of tabs submitted this frame.
|
ImS16 TabsActiveCount; // Number of tabs submitted this frame.
|
||||||
|
|||||||
@ -10323,7 +10323,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
|
|
||||||
// Lock in visible tab
|
// Lock in visible tab
|
||||||
tab_bar->VisibleTabContentsId = tab_bar->SelectedTabId;
|
tab_bar->VisibleTabContentsId = tab_bar->SelectedTabId;
|
||||||
tab_bar->VisibleTabWasSubmitted = false;
|
tab_bar->VisibleTabWasSubmitted = tab_bar->VisibleTabContentsJustAppeared = false;
|
||||||
|
|
||||||
// Apply request requests
|
// Apply request requests
|
||||||
if (scroll_to_tab_id != 0)
|
if (scroll_to_tab_id != 0)
|
||||||
@ -10866,14 +10866,19 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
// Lock visibility
|
// Lock visibility
|
||||||
// (Note: tab_contents_visible != tab_selected... because Ctrl+Tab operations may preview some tabs without selecting them!)
|
// (Note: tab_contents_visible != tab_selected... because Ctrl+Tab operations may preview some tabs without selecting them!)
|
||||||
bool tab_contents_visible = (tab_bar->VisibleTabContentsId == id);
|
bool tab_contents_visible = (tab_bar->VisibleTabContentsId == id);
|
||||||
if (tab_contents_visible)
|
|
||||||
tab_bar->VisibleTabWasSubmitted = true;
|
|
||||||
|
|
||||||
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
|
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
|
||||||
if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
|
if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
|
||||||
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
||||||
tab_contents_visible = true;
|
tab_contents_visible = true;
|
||||||
|
|
||||||
|
if (tab_contents_visible)
|
||||||
|
{
|
||||||
|
tab_bar->VisibleTabWasSubmitted = true;
|
||||||
|
tab_bar->VisibleTabContentsJustAppeared = tab_contents_visible && !tab->ContentsIsVisible;
|
||||||
|
}
|
||||||
|
tab->ContentsIsVisible = tab_contents_visible;
|
||||||
|
|
||||||
// Note that tab_is_new is not necessarily the same as tab_appearing! When a tab bar stops being submitted
|
// Note that tab_is_new is not necessarily the same as tab_appearing! When a tab bar stops being submitted
|
||||||
// and then gets submitted again, the tabs will have 'tab_appearing=true' but 'tab_is_new=false'.
|
// and then gets submitted again, the tabs will have 'tab_appearing=true' but 'tab_is_new=false'.
|
||||||
if (tab_appearing && (!tab_bar_appearing || tab_is_new))
|
if (tab_appearing && (!tab_bar_appearing || tab_is_new))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user