| 7371 | } |
| 7372 | |
| 7373 | bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags) |
| 7374 | { |
| 7375 | ImGuiContext& g = *GImGui; |
| 7376 | ImGuiWindow* window = g.CurrentWindow; |
| 7377 | if (window->SkipItems) |
| 7378 | return false; |
| 7379 | |
| 7380 | if ((flags & ImGuiTabBarFlags_DockNode) == 0) |
| 7381 | PushOverrideID(tab_bar->ID); |
| 7382 | |
| 7383 | // Add to stack |
| 7384 | g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar)); |
| 7385 | g.CurrentTabBar = tab_bar; |
| 7386 | |
| 7387 | // Append with multiple BeginTabBar()/EndTabBar() pairs. |
| 7388 | tab_bar->BackupCursorPos = window->DC.CursorPos; |
| 7389 | if (tab_bar->CurrFrameVisible == g.FrameCount) |
| 7390 | { |
| 7391 | window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); |
| 7392 | tab_bar->BeginCount++; |
| 7393 | return true; |
| 7394 | } |
| 7395 | |
| 7396 | // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable |
| 7397 | if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable))) |
| 7398 | ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder); |
| 7399 | tab_bar->TabsAddedNew = false; |
| 7400 | |
| 7401 | // Flags |
| 7402 | if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) |
| 7403 | flags |= ImGuiTabBarFlags_FittingPolicyDefault_; |
| 7404 | |
| 7405 | tab_bar->Flags = flags; |
| 7406 | tab_bar->BarRect = tab_bar_bb; |
| 7407 | tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab() |
| 7408 | tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible; |
| 7409 | tab_bar->CurrFrameVisible = g.FrameCount; |
| 7410 | tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight; |
| 7411 | tab_bar->CurrTabsContentsHeight = 0.0f; |
| 7412 | tab_bar->ItemSpacingY = g.Style.ItemSpacing.y; |
| 7413 | tab_bar->FramePadding = g.Style.FramePadding; |
| 7414 | tab_bar->TabsActiveCount = 0; |
| 7415 | tab_bar->BeginCount = 1; |
| 7416 | |
| 7417 | // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap |
| 7418 | window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); |
| 7419 | |
| 7420 | // Draw separator |
| 7421 | const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); |
| 7422 | const float y = tab_bar->BarRect.Max.y - 1.0f; |
| 7423 | { |
| 7424 | const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f); |
| 7425 | const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f); |
| 7426 | window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f); |
| 7427 | } |
| 7428 | return true; |
| 7429 | } |
| 7430 |
nothing calls this directly
no test coverage detected