MCPcopy Create free account
hub / github.com/RenderKit/embree / TabItemEx

Method TabItemEx

tutorials/common/imgui/imgui_widgets.cpp:8053–8271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8051}
8052
8053bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags)
8054{
8055 // Layout whole tab bar if not already done
8056 ImGuiContext& g = *GImGui;
8057 if (tab_bar->WantLayout)
8058 {
8059 ImGuiNextItemData backup_next_item_data = g.NextItemData;
8060 TabBarLayout(tab_bar);
8061 g.NextItemData = backup_next_item_data;
8062 }
8063 ImGuiWindow* window = g.CurrentWindow;
8064 if (window->SkipItems)
8065 return false;
8066
8067 const ImGuiStyle& style = g.Style;
8068 const ImGuiID id = TabBarCalcTabID(tab_bar, label);
8069
8070 // If the user called us with *p_open == false, we early out and don't render.
8071 // 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.
8072 IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags);
8073 if (p_open && !*p_open)
8074 {
8075 ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav);
8076 return false;
8077 }
8078
8079 IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button));
8080 IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing
8081
8082 // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
8083 if (flags & ImGuiTabItemFlags_NoCloseButton)
8084 p_open = NULL;
8085 else if (p_open == NULL)
8086 flags |= ImGuiTabItemFlags_NoCloseButton;
8087
8088 // Acquire tab data
8089 ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id);
8090 bool tab_is_new = false;
8091 if (tab == NULL)
8092 {
8093 tab_bar->Tabs.push_back(ImGuiTabItem());
8094 tab = &tab_bar->Tabs.back();
8095 tab->ID = id;
8096 tab_bar->TabsAddedNew = tab_is_new = true;
8097 }
8098 tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
8099
8100 // Calculate tab contents size
8101 ImVec2 size = TabItemCalcSize(label, (p_open != NULL) || (flags & ImGuiTabItemFlags_UnsavedDocument));
8102 tab->RequestedWidth = -1.0f;
8103 if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
8104 size.x = tab->RequestedWidth = g.NextItemData.Width;
8105 if (tab_is_new)
8106 tab->Width = ImMax(1.0f, size.x);
8107 tab->ContentWidth = size.x;
8108 tab->BeginOrder = tab_bar->TabsActiveCount++;
8109
8110 const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected