From 8926d12c7dfe8ef7131936b5c8ce5ed2ed1adfb1 Mon Sep 17 00:00:00 2001 From: David Kehoe Date: Tue, 4 Nov 2025 17:07:55 +1000 Subject: [PATCH] Update UI.h --- src/Utils/UI.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Utils/UI.h b/src/Utils/UI.h index 017a47e992..cd3f8f7e3c 100644 --- a/src/Utils/UI.h +++ b/src/Utils/UI.h @@ -375,6 +375,7 @@ namespace Util * Each function should compare two rows and return true if the first should come before the second. * @param cellRender Function to render a cell: (rowIdx, colIdx, const T& row). * @param footerRows Optional static footer rows (not sorted, rendered after main rows). + * @param outerSize Optional outer size for the table (0,0 = auto-size). */ template void ShowSortedStringTableCustom( @@ -385,10 +386,16 @@ namespace Util bool ascending, const std::vector>& customSorts, std::function cellRender, - const std::vector& footerRows = {}) + const std::vector& footerRows = {}, + const ImVec2& outerSize = ImVec2(0, 0)) { ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Sortable | ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_SizingStretchProp; - if (ImGui::BeginTable(table_id, static_cast(headers.size()), flags)) { + ImVec2 tableSize = outerSize; + if (outerSize.y == 0.0f) { + size_t totalRows = rows.size() + footerRows.size(); + tableSize.y = ImGui::GetTextLineHeightWithSpacing() * (static_cast((totalRows < 15) ? totalRows : 15) + 1.2f); + } + if (ImGui::BeginTable(table_id, static_cast(headers.size()), flags, tableSize)) { // Set up columns with content-based sizing for (size_t i = 0; i < headers.size(); ++i) { ImGui::TableSetupColumn(headers[i].c_str());