mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
TabBar: Internals: added TabItemIsContentsAppearing() and reworked 50ae760. (#9581)
This commit is contained in:
parent
50ae760fce
commit
1069a952e0
@ -2983,7 +2983,7 @@ struct IMGUI_API ImGuiTabBar
|
|||||||
ImS8 BeginCount;
|
ImS8 BeginCount;
|
||||||
bool WantLayout;
|
bool WantLayout;
|
||||||
bool VisibleTabWasSubmitted;
|
bool VisibleTabWasSubmitted;
|
||||||
bool VisibleTabContentsJustAppeared;
|
bool LastTabItemContentsAppearing;
|
||||||
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.
|
||||||
@ -3778,6 +3778,7 @@ namespace ImGui
|
|||||||
IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImVec2 mouse_pos);
|
IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImVec2 mouse_pos);
|
||||||
IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar);
|
IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar);
|
||||||
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window);
|
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window);
|
||||||
|
IMGUI_API bool TabItemIsContentsAppearing();
|
||||||
IMGUI_API void TabItemSpacing(const char* str_id, ImGuiTabItemFlags flags, float width);
|
IMGUI_API void TabItemSpacing(const char* str_id, ImGuiTabItemFlags flags, float width);
|
||||||
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker);
|
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker);
|
||||||
IMGUI_API ImVec2 TabItemCalcSize(ImGuiWindow* window);
|
IMGUI_API ImVec2 TabItemCalcSize(ImGuiWindow* window);
|
||||||
|
|||||||
@ -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 = tab_bar->VisibleTabContentsJustAppeared = false;
|
tab_bar->VisibleTabWasSubmitted = tab_bar->LastTabItemContentsAppearing = false;
|
||||||
|
|
||||||
// Apply request requests
|
// Apply request requests
|
||||||
if (scroll_to_tab_id != 0)
|
if (scroll_to_tab_id != 0)
|
||||||
@ -10752,6 +10752,12 @@ void ImGui::EndTabItem()
|
|||||||
PopID();
|
PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImGui::TabItemIsContentsAppearing()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
return g.CurrentTabBar->LastTabItemContentsAppearing;
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGui::TabItemButton(const char* label, ImGuiTabItemFlags flags)
|
bool ImGui::TabItemButton(const char* label, ImGuiTabItemFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -10863,20 +10869,17 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
TabBarQueueFocus(tab_bar, tab);
|
TabBarQueueFocus(tab_bar, tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
|
||||||
|
if (tab_bar->VisibleTabContentsId == 0 && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
|
||||||
|
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
||||||
|
tab_bar->VisibleTabContentsId = id;
|
||||||
|
|
||||||
// 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);
|
const bool tab_contents_visible = (tab_bar->VisibleTabContentsId == id);
|
||||||
|
|
||||||
// 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_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
|
||||||
tab_contents_visible = true;
|
|
||||||
|
|
||||||
if (tab_contents_visible)
|
if (tab_contents_visible)
|
||||||
{
|
|
||||||
tab_bar->VisibleTabWasSubmitted = true;
|
tab_bar->VisibleTabWasSubmitted = true;
|
||||||
tab_bar->VisibleTabContentsJustAppeared = tab_contents_visible && !tab->ContentsIsVisible;
|
tab_bar->LastTabItemContentsAppearing = tab_contents_visible && !tab->ContentsIsVisible;
|
||||||
}
|
|
||||||
tab->ContentsIsVisible = tab_contents_visible;
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user