MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / TabItemEx

Method TabItemEx

core/src/imgui/imgui_widgets.cpp:7707–7918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7705}
7706
7707bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags)
7708{
7709 // Layout whole tab bar if not already done
7710 if (tab_bar->WantLayout)
7711 TabBarLayout(tab_bar);
7712
7713 ImGuiContext& g = *GImGui;
7714 ImGuiWindow* window = g.CurrentWindow;
7715 if (window->SkipItems)
7716 return false;
7717
7718 const ImGuiStyle& style = g.Style;
7719 const ImGuiID id = TabBarCalcTabID(tab_bar, label);
7720
7721 // If the user called us with *p_open == false, we early out and don't render.
7722 // We make a call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID.
7723 IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags);
7724 if (p_open && !*p_open)
7725 {
7726 PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true);
7727 ItemAdd(ImRect(), id);
7728 PopItemFlag();
7729 return false;
7730 }
7731
7732 IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button));
7733 IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing
7734
7735 // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
7736 if (flags & ImGuiTabItemFlags_NoCloseButton)
7737 p_open = NULL;
7738 else if (p_open == NULL)
7739 flags |= ImGuiTabItemFlags_NoCloseButton;
7740
7741 // Calculate tab contents size
7742 ImVec2 size = TabItemCalcSize(label, p_open != NULL);
7743
7744 // Acquire tab data
7745 ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id);
7746 bool tab_is_new = false;
7747 if (tab == NULL)
7748 {
7749 tab_bar->Tabs.push_back(ImGuiTabItem());
7750 tab = &tab_bar->Tabs.back();
7751 tab->ID = id;
7752 tab->Width = size.x;
7753 tab_bar->TabsAddedNew = true;
7754 tab_is_new = true;
7755 }
7756 tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
7757 tab->ContentWidth = size.x;
7758 tab->BeginOrder = tab_bar->TabsActiveCount++;
7759
7760 const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
7761 const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0;
7762 const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount);
7763 const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0;
7764 tab->LastFrameVisible = g.FrameCount;

Callers

nothing calls this directly

Calls 12

ImGuiTabItemClass · 0.85
ImVec2Function · 0.85
ImMaxFunction · 0.85
ImLerpFunction · 0.85
ImSaturateFunction · 0.85
GetForegroundDrawListFunction · 0.85
index_from_ptrMethod · 0.80
ImRectFunction · 0.70
push_backMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected