Tables: Made it possible to change style.CellPadding.y between rows. Added demo.

This commit is contained in:
ocornut
2023-09-04 11:20:20 +02:00
parent 3816d478df
commit e8a5c9e1b8
6 changed files with 28 additions and 7 deletions

View File

@ -4790,7 +4790,7 @@ static void ShowDemoWindowTables()
HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would require a unique clipping rectangle per row.");
if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_Borders))
{
for (int row = 0; row < 10; row++)
for (int row = 0; row < 8; row++)
{
float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row);
ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height);
@ -4821,6 +4821,23 @@ static void ShowDemoWindowTables()
ImGui::EndTable();
}
HelpMarker("Showcase altering CellPadding.y between rows. Note that CellPadding.x is locked for the entire table.");
if (ImGui::BeginTable("table_changing_cellpadding_y", 1, ImGuiTableFlags_Borders))
{
ImGuiStyle& style = ImGui::GetStyle();
for (int row = 0; row < 8; row++)
{
if ((row % 3) == 2)
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(style.CellPadding.x, 20.0f));
ImGui::TableNextRow(ImGuiTableRowFlags_None);
ImGui::TableNextColumn();
ImGui::Text("CellPadding.y = %.2f", style.CellPadding.y);
if ((row % 3) == 2)
ImGui::PopStyleVar();;
}
ImGui::EndTable();
}
ImGui::TreePop();
}