Demonstrate old/legacy Columns API! [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!]
| 7613 | // Demonstrate old/legacy Columns API! |
| 7614 | // [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!] |
| 7615 | static void DemoWindowColumns() |
| 7616 | { |
| 7617 | bool open = ImGui::TreeNode("Legacy Columns API"); |
| 7618 | ImGui::SameLine(); |
| 7619 | HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!"); |
| 7620 | if (!open) |
| 7621 | return; |
| 7622 | |
| 7623 | // Basic columns |
| 7624 | if (ImGui::TreeNode("Basic")) |
| 7625 | { |
| 7626 | IMGUI_DEMO_MARKER("Columns (legacy API)/Basic"); |
| 7627 | ImGui::Text("Without border:"); |
| 7628 | ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border |
| 7629 | ImGui::Separator(); |
| 7630 | for (int n = 0; n < 14; n++) |
| 7631 | { |
| 7632 | char label[32]; |
| 7633 | sprintf(label, "Item %d", n); |
| 7634 | if (ImGui::Selectable(label)) {} |
| 7635 | //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {} |
| 7636 | ImGui::NextColumn(); |
| 7637 | } |
| 7638 | ImGui::Columns(1); |
| 7639 | ImGui::Separator(); |
| 7640 | |
| 7641 | ImGui::Text("With border:"); |
| 7642 | ImGui::Columns(4, "mycolumns"); // 4-ways, with border |
| 7643 | ImGui::Separator(); |
| 7644 | ImGui::Text("ID"); ImGui::NextColumn(); |
| 7645 | ImGui::Text("Name"); ImGui::NextColumn(); |
| 7646 | ImGui::Text("Path"); ImGui::NextColumn(); |
| 7647 | ImGui::Text("Hovered"); ImGui::NextColumn(); |
| 7648 | ImGui::Separator(); |
| 7649 | const char* names[3] = { "One", "Two", "Three" }; |
| 7650 | const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; |
| 7651 | static int selected = -1; |
| 7652 | for (int i = 0; i < 3; i++) |
| 7653 | { |
| 7654 | char label[32]; |
| 7655 | sprintf(label, "%04d", i); |
| 7656 | if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) |
| 7657 | selected = i; |
| 7658 | bool hovered = ImGui::IsItemHovered(); |
| 7659 | ImGui::NextColumn(); |
| 7660 | ImGui::Text(names[i]); ImGui::NextColumn(); |
| 7661 | ImGui::Text(paths[i]); ImGui::NextColumn(); |
| 7662 | ImGui::Text("%d", hovered); ImGui::NextColumn(); |
| 7663 | } |
| 7664 | ImGui::Columns(1); |
| 7665 | ImGui::Separator(); |
| 7666 | ImGui::TreePop(); |
| 7667 | } |
| 7668 | |
| 7669 | if (ImGui::TreeNode("Borders")) |
| 7670 | { |
| 7671 | IMGUI_DEMO_MARKER("Columns (legacy API)/Borders"); |
| 7672 | // NB: Future columns API should allow automatic horizontal borders. |
no test coverage detected