MCPcopy Create free account
hub / github.com/XJTU-Graphics/dandelion / TabItemEx

Method TabItemEx

deps/imgui/imgui_widgets.cpp:10253–10558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10251}
10252
10253bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window)
10254{
10255 // Layout whole tab bar if not already done
10256 ImGuiContext& g = *GImGui;
10257 if (tab_bar->WantLayout)
10258 {
10259 ImGuiNextItemData backup_next_item_data = g.NextItemData;
10260 TabBarLayout(tab_bar);
10261 g.NextItemData = backup_next_item_data;
10262 }
10263 ImGuiWindow* window = g.CurrentWindow;
10264 if (window->SkipItems)
10265 return false;
10266
10267 const ImGuiStyle& style = g.Style;
10268 const ImGuiID id = TabBarCalcTabID(tab_bar, label, docked_window);
10269
10270 // If the user called us with *p_open == false, we early out and don't render.
10271 // 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.
10272 IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags);
10273 if (p_open && !*p_open)
10274 {
10275 ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav);
10276 return false;
10277 }
10278
10279 IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button));
10280 IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing
10281
10282 // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
10283 if (flags & ImGuiTabItemFlags_NoCloseButton)
10284 p_open = NULL;
10285 else if (p_open == NULL)
10286 flags |= ImGuiTabItemFlags_NoCloseButton;
10287
10288 // Acquire tab data
10289 ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id);
10290 bool tab_is_new = false;
10291 if (tab == NULL)
10292 {
10293 tab_bar->Tabs.push_back(ImGuiTabItem());
10294 tab = &tab_bar->Tabs.back();
10295 tab->ID = id;
10296 tab_bar->TabsAddedNew = tab_is_new = true;
10297 }
10298 tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
10299
10300 // Calculate tab contents size
10301 ImVec2 size = TabItemCalcSize(label, (p_open != NULL) || (flags & ImGuiTabItemFlags_UnsavedDocument));
10302 tab->RequestedWidth = -1.0f;
10303 if (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasWidth)
10304 size.x = tab->RequestedWidth = g.NextItemData.Width;
10305 if (tab_is_new)
10306 tab->Width = ImMax(1.0f, size.x);
10307 tab->ContentWidth = size.x;
10308 tab->BeginOrder = tab_bar->TabsActiveCount++;
10309
10310 const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);

Callers

nothing calls this directly

Calls 15

ImGuiTabItemClass · 0.85
ImMaxFunction · 0.85
ImVec2Function · 0.85
ItemSizeFunction · 0.85
ImClampFunction · 0.85
TabBarGetTabOrderFunction · 0.85
ImLerpFunction · 0.85
ImSaturateFunction · 0.85
GetForegroundDrawListFunction · 0.85
IsDataTypeMethod · 0.80
PathArcToFastMethod · 0.80
PathStrokeMethod · 0.80

Tested by

no test coverage detected