MCPcopy Create free account
hub / github.com/cinder/Cinder / TabItemEx

Method TabItemEx

src/imgui/imgui_widgets.cpp:10356–10601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10354}
10355
10356bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window)
10357{
10358 // Layout whole tab bar if not already done
10359 ImGuiContext& g = *GImGui;
10360 if (tab_bar->WantLayout)
10361 {
10362 ImGuiNextItemData backup_next_item_data = g.NextItemData;
10363 TabBarLayout(tab_bar);
10364 g.NextItemData = backup_next_item_data;
10365 }
10366 ImGuiWindow* window = g.CurrentWindow;
10367 if (window->SkipItems)
10368 return false;
10369
10370 const ImGuiStyle& style = g.Style;
10371 const ImGuiID id = TabBarCalcTabID(tab_bar, label, docked_window);
10372
10373 // If the user called us with *p_open == false, we early out and don't render.
10374 // 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.
10375 IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags);
10376 if (p_open && !*p_open)
10377 {
10378 ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav);
10379 return false;
10380 }
10381
10382 IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button));
10383 IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing
10384
10385 // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
10386 if (flags & ImGuiTabItemFlags_NoCloseButton)
10387 p_open = NULL;
10388 else if (p_open == NULL)
10389 flags |= ImGuiTabItemFlags_NoCloseButton;
10390
10391 // Acquire tab data
10392 ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id);
10393 bool tab_is_new = false;
10394 if (tab == NULL)
10395 {
10396 tab_bar->Tabs.push_back(ImGuiTabItem());
10397 tab = &tab_bar->Tabs.back();
10398 tab->ID = id;
10399 tab_bar->TabsAddedNew = tab_is_new = true;
10400 }
10401 tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
10402
10403 // Calculate tab contents size
10404 ImVec2 size = TabItemCalcSize(label, (p_open != NULL) || (flags & ImGuiTabItemFlags_UnsavedDocument));
10405 tab->RequestedWidth = -1.0f;
10406 if (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasWidth)
10407 size.x = tab->RequestedWidth = g.NextItemData.Width;
10408 if (tab_is_new)
10409 tab->Width = ImMax(1.0f, size.x);
10410 tab->ContentWidth = size.x;
10411 tab->BeginOrder = tab_bar->TabsActiveCount++;
10412
10413 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
ImLerpFunction · 0.85
ImSaturateFunction · 0.85
GetForegroundDrawListFunction · 0.85
backMethod · 0.80
PathArcToFastMethod · 0.80
PathStrokeMethod · 0.80
AddLineMethod · 0.80
ImRectFunction · 0.50

Tested by

no test coverage detected