| 3526 | } |
| 3527 | |
| 3528 | static void ShowDemoWindowTables() |
| 3529 | { |
| 3530 | //ImGui::SetNextItemOpen(true, ImGuiCond_Once); |
| 3531 | if (!ImGui::CollapsingHeader("Tables & Columns")) |
| 3532 | return; |
| 3533 | |
| 3534 | // Using those as a base value to create width/height that are factor of the size of our font |
| 3535 | const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; |
| 3536 | const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); |
| 3537 | |
| 3538 | ImGui::PushID("Tables"); |
| 3539 | |
| 3540 | int open_action = -1; |
| 3541 | if (ImGui::Button("Open all")) |
| 3542 | open_action = 1; |
| 3543 | ImGui::SameLine(); |
| 3544 | if (ImGui::Button("Close all")) |
| 3545 | open_action = 0; |
| 3546 | ImGui::SameLine(); |
| 3547 | |
| 3548 | // Options |
| 3549 | static bool disable_indent = false; |
| 3550 | ImGui::Checkbox("Disable tree indentation", &disable_indent); |
| 3551 | ImGui::SameLine(); |
| 3552 | HelpMarker("Disable the indenting of tree nodes so demo tables can use the full window width."); |
| 3553 | ImGui::Separator(); |
| 3554 | if (disable_indent) |
| 3555 | ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 0.0f); |
| 3556 | |
| 3557 | // About Styling of tables |
| 3558 | // Most settings are configured on a per-table basis via the flags passed to BeginTable() and TableSetupColumns APIs. |
| 3559 | // There are however a few settings that a shared and part of the ImGuiStyle structure: |
| 3560 | // style.CellPadding // Padding within each cell |
| 3561 | // style.Colors[ImGuiCol_TableHeaderBg] // Table header background |
| 3562 | // style.Colors[ImGuiCol_TableBorderStrong] // Table outer and header borders |
| 3563 | // style.Colors[ImGuiCol_TableBorderLight] // Table inner borders |
| 3564 | // style.Colors[ImGuiCol_TableRowBg] // Table row background when ImGuiTableFlags_RowBg is enabled (even rows) |
| 3565 | // style.Colors[ImGuiCol_TableRowBgAlt] // Table row background when ImGuiTableFlags_RowBg is enabled (odds rows) |
| 3566 | |
| 3567 | // Demos |
| 3568 | if (open_action != -1) |
| 3569 | ImGui::SetNextItemOpen(open_action != 0); |
| 3570 | if (ImGui::TreeNode("Basic")) |
| 3571 | { |
| 3572 | // Here we will showcase three different ways to output a table. |
| 3573 | // They are very simple variations of a same thing! |
| 3574 | |
| 3575 | // [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column. |
| 3576 | // In many situations, this is the most flexible and easy to use pattern. |
| 3577 | HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop."); |
| 3578 | if (ImGui::BeginTable("table1", 3)) |
| 3579 | { |
| 3580 | for (int row = 0; row < 4; row++) |
| 3581 | { |
| 3582 | ImGui::TableNextRow(); |
| 3583 | for (int column = 0; column < 3; column++) |
| 3584 | { |
| 3585 | ImGui::TableSetColumnIndex(column); |
no test coverage detected