-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Multiselection + skipping column submission breaks table auto-fit #9341
Copy link
Copy link
Open
Description
Version/Branch of Dear ImGui:
latest docking
Back-ends:
NA
Compiler, OS:
NA
Full config/build information:
No response
Details:
Took me a while to pin this down, but it seems that adding multiselect to a table that has clipped rows (and thus non-submitted NextColumn statements) causes the auto-fit of the first column (at least) to see the entire row as that columns ideal max. (Or something like that) causing autofit to increase beyond normal.
Forcing addition of all NextColum() calls, even with not content fixes this.
Not having multiselect fixes this.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
void TestDebugCLippedTreeInTable()
{
ImGui::Begin("TestDebugCLippedTreeInTable");
static ImGuiTableFlags const tableFlags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH |
ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter |
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Hideable | ImGuiTableColumnFlags_NoHeaderWidth | ImGuiTableFlags_ContextMenuInBody;
if (ImGui::BeginTable("TestDebugCLippedTreeInTable", 2, tableFlags))
{
float rowHeight = ImGui::GetTextLineHeight() + ImGui::GetStyle().CellPadding.y * 2;
ImGui::TableSetupScrollFreeze(1, 1);
ImGui::TableSetupColumn("Tree Node Column", ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoHeaderLabel, 100.f);
ImGui::TableSetupColumn("Data Column 1", ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoHeaderLabel, 100.f);
ImGui::TableHeadersRow();
// Adding multi-select functionality breaks column auto-fit:
static std::vector<int> selectedItems;
ImGuiMultiSelectFlags const multiSelectFlags = ImGuiMultiSelectFlags_ClearOnClickVoid | ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_SelectOnClickRelease;
ImGuiMultiSelectIO* msIo = ImGui::BeginMultiSelect(multiSelectFlags, static_cast<int>(selectedItems.size()), static_cast<int>(selectedItems.size()));
for (int i = 0; i < 100; i++)
{
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
// bool isRowVisible = true; // this works
bool isRowVisible = i < 10; // simulate skipping data columns, causing column auto-fit to fail
ImGui::TableNextColumn();
std::string nodeName = std::format("Base Node {}", i);
bool isNodeOpen = ImGui::TreeNodeEx(nodeName.c_str(), ImGuiTreeNodeFlags_SpanAllColumns);
if (isRowVisible)
{
// render data lines only if row is visible
ImGui::TableNextColumn();
ImGui::TextUnformatted("Data Value 1");
}
// else ImGui::TableNextColumn(); // this would fix auto-fit again...
if (isNodeOpen)
{
// -- (possibly render sub-tree nodes with data columns recursively)
ImGui::TreePop();
}
}
msIo = ImGui::EndMultiSelect();
// Apply multi-select requests
ImGui::EndTable();
}
ImGui::End();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels