Tables: rework keep-visible/max-width code to be less incorrect, but right-most column may effectively has few pixels less of visible cliprect width.

See table_width_distrib and table_width_keep_visible tests.
+ fix minor left-side clipping on post-frozen column
+ made TableHeader() use reliable column->MaxX
This commit is contained in:
ocornut
2020-11-16 12:30:17 +01:00
parent 197e9c085b
commit c5dcf2fde1
2 changed files with 42 additions and 18 deletions

View File

@ -3690,10 +3690,20 @@ static void ShowDemoWindowTables()
ImGui::SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)");
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV);
static bool show_headers = false;
ImGui::Checkbox("show_headers", &show_headers);
PopStyleCompact();
if (ImGui::BeginTable("##table1", 3, flags))
{
if (show_headers)
{
ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two");
ImGui::TableSetupColumn("Three");
ImGui::TableHeadersRow();
}
for (int row = 0; row < 5; row++)
{
ImGui::TableNextRow();
@ -3710,8 +3720,8 @@ static void ShowDemoWindowTables()
sprintf(buf, "Hello %d,%d", row, column);
ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f));
}
if (ImGui::TableGetHoveredColumn() == column)
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 100, 0, 255));
//if (ImGui::TableGetHoveredColumn() == column)
// ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 100, 0, 255));
}
}
ImGui::EndTable();