[DEBUG] Display contents of ImGuiTabBar
| 13713 | |
| 13714 | // [DEBUG] Display contents of ImGuiTabBar |
| 13715 | void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) |
| 13716 | { |
| 13717 | // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. |
| 13718 | char buf[256]; |
| 13719 | char* p = buf; |
| 13720 | const char* buf_end = buf + IM_ARRAYSIZE(buf); |
| 13721 | const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2); |
| 13722 | p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*"); |
| 13723 | p += ImFormatString(p, buf_end - p, " { "); |
| 13724 | for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++) |
| 13725 | { |
| 13726 | ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; |
| 13727 | p += ImFormatString(p, buf_end - p, "%s'%s'", |
| 13728 | tab_n > 0 ? ", " : "", (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???"); |
| 13729 | } |
| 13730 | p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } "); |
| 13731 | if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } |
| 13732 | bool open = TreeNode(label, "%s", buf); |
| 13733 | if (!is_active) { PopStyleColor(); } |
| 13734 | if (is_active && IsItemHovered()) |
| 13735 | { |
| 13736 | ImDrawList* draw_list = GetForegroundDrawList(); |
| 13737 | draw_list->AddRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, IM_COL32(255, 255, 0, 255)); |
| 13738 | draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); |
| 13739 | draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); |
| 13740 | } |
| 13741 | if (open) |
| 13742 | { |
| 13743 | for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) |
| 13744 | { |
| 13745 | const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; |
| 13746 | PushID(tab); |
| 13747 | if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2); |
| 13748 | if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine(); |
| 13749 | Text("%02d%c Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f", |
| 13750 | tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); |
| 13751 | PopID(); |
| 13752 | } |
| 13753 | TreePop(); |
| 13754 | } |
| 13755 | } |
| 13756 | |
| 13757 | void ImGui::DebugNodeViewport(ImGuiViewportP* viewport) |
| 13758 | { |
nothing calls this directly
no test coverage detected