Tables: Made it possible to use SameLine(0,0) after TableNextColumn() or TableSetColumnIndex() in order to reuse line height from previous cell.

This commit is contained in:
ocornut
2023-08-14 13:02:44 +02:00
parent 1362fc0c56
commit 8f5ce73140
4 changed files with 28 additions and 3 deletions

View File

@ -4766,7 +4766,7 @@ static void ShowDemoWindowTables()
if (ImGui::TreeNode("Row height"))
{
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_BordersOuter | ImGuiTableFlags_BordersInnerV))
if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_Borders))
{
for (int row = 0; row < 10; row++)
{
@ -4777,6 +4777,28 @@ static void ShowDemoWindowTables()
}
ImGui::EndTable();
}
HelpMarker("Showcase using SameLine(0,0) to share Current Line Height between cells.\n\nPlease note that Tables Row Height is not the same thing as Current Line Height, as a table cell may contains multiple lines.");
if (ImGui::BeginTable("table_share_lineheight", 2, ImGuiTableFlags_Borders))
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::ColorButton("##1", ImVec4(0.13f, 0.26f, 0.40f, 1.0f), ImGuiColorEditFlags_None, ImVec2(40, 40));
ImGui::TableNextColumn();
ImGui::Text("Line 1");
ImGui::Text("Line 2");
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::ColorButton("##2", ImVec4(0.13f, 0.26f, 0.40f, 1.0f), ImGuiColorEditFlags_None, ImVec2(40, 40));
ImGui::TableNextColumn();
ImGui::SameLine(0.0f, 0.0f); // Reuse line height from previous column
ImGui::Text("Line 1, with SameLine(0,0)");
ImGui::Text("Line 2");
ImGui::EndTable();
}
ImGui::TreePop();
}