1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Tables: clarify TableNextRow() row_height and adjust demo to make this clearer (demo height were arbitrary and therefore misleading).

This commit is contained in:
ocornut 2025-11-26 18:25:30 +01:00
parent c36162fc6c
commit 9c75ef5a61
3 changed files with 8 additions and 4 deletions

View file

@ -61,6 +61,9 @@ Other Changes:
selects `VkSwapchainCreateInfoKHR`'s `compositeAlpha` value based on selects `VkSwapchainCreateInfoKHR`'s `compositeAlpha` value based on
`cap.supportedCompositeAlpha`, which seems to be required on some Android `cap.supportedCompositeAlpha`, which seems to be required on some Android
devices. (#8784) [@FelixStach] devices. (#8784) [@FelixStach]
- Examples:
- Win32+DirectX12: ignore seemingly incorrect D3D12_MESSAGE_ID_FENCE_ZERO_WAIT
warning on startups on some setups. (#9084, #9093) [@RT2Code, @LeoGautheron]
----------------------------------------------------------------------- -----------------------------------------------------------------------

View file

@ -897,7 +897,7 @@ namespace ImGui
// - 5. Call EndTable() // - 5. Call EndTable()
IMGUI_API bool BeginTable(const char* str_id, int columns, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f); IMGUI_API bool BeginTable(const char* str_id, int columns, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true! IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. 'min_row_height' include the minimum top and bottom padding aka CellPadding.y * 2.0f.
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible. IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible. IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.

View file

@ -6509,7 +6509,7 @@ static void DemoWindowTables()
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("A0 Row 0"); ImGui::Text("A0 Row 0");
{ {
float rows_height = TEXT_BASE_HEIGHT * 2; float rows_height = (TEXT_BASE_HEIGHT * 2.0f) + (ImGui::GetStyle().CellPadding.y * 2.0f);
if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{ {
ImGui::TableSetupColumn("B0"); ImGui::TableSetupColumn("B0");
@ -6551,7 +6551,7 @@ static void DemoWindowTables()
{ {
for (int row = 0; row < 8; row++) for (int row = 0; row < 8; row++)
{ {
float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row); float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row + ImGui::GetStyle().CellPadding.y * 2.0f);
ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height); ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("min_row_height = %.2f", min_row_height); ImGui::Text("min_row_height = %.2f", min_row_height);
@ -6655,9 +6655,10 @@ static void DemoWindowTables()
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{ {
const float rows_height = TEXT_BASE_HEIGHT * 1.5f + ImGui::GetStyle().CellPadding.y * 2.0f;
for (int row = 0; row < 3; row++) for (int row = 0; row < 3; row++)
{ {
ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f); ImGui::TableNextRow(0, rows_height);
for (int column = 0; column < 3; column++) for (int column = 0; column < 3; column++)
{ {
ImGui::TableNextColumn(); ImGui::TableNextColumn();