MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / BeginTabBarEx

Method BeginTabBarEx

KBotExt/imgui/imgui_widgets.cpp:7552–7609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7550}
7551
7552bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags)
7553{
7554 ImGuiContext& g = *GImGui;
7555 ImGuiWindow* window = g.CurrentWindow;
7556 if (window->SkipItems)
7557 return false;
7558
7559 if ((flags & ImGuiTabBarFlags_DockNode) == 0)
7560 PushOverrideID(tab_bar->ID);
7561
7562 // Add to stack
7563 g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar));
7564 g.CurrentTabBar = tab_bar;
7565
7566 // Append with multiple BeginTabBar()/EndTabBar() pairs.
7567 tab_bar->BackupCursorPos = window->DC.CursorPos;
7568 if (tab_bar->CurrFrameVisible == g.FrameCount)
7569 {
7570 window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
7571 tab_bar->BeginCount++;
7572 return true;
7573 }
7574
7575 // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable
7576 if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable)))
7577 ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder);
7578 tab_bar->TabsAddedNew = false;
7579
7580 // Flags
7581 if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
7582 flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
7583
7584 tab_bar->Flags = flags;
7585 tab_bar->BarRect = tab_bar_bb;
7586 tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab()
7587 tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible;
7588 tab_bar->CurrFrameVisible = g.FrameCount;
7589 tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight;
7590 tab_bar->CurrTabsContentsHeight = 0.0f;
7591 tab_bar->ItemSpacingY = g.Style.ItemSpacing.y;
7592 tab_bar->FramePadding = g.Style.FramePadding;
7593 tab_bar->TabsActiveCount = 0;
7594 tab_bar->LastTabItemIdx = -1;
7595 tab_bar->BeginCount = 1;
7596
7597 // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap
7598 window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
7599
7600 // Draw separator
7601 const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
7602 const float y = tab_bar->BarRect.Max.y - 1.0f;
7603 {
7604 const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f);
7605 const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f);
7606 window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f);
7607 }
7608 return true;
7609}

Callers

nothing calls this directly

Calls 4

GetTabBarRefFromTabBarFunction · 0.85
ImVec2Function · 0.85
ImQsortFunction · 0.85
AddLineMethod · 0.80

Tested by

no test coverage detected