Demonstrate old/legacy Columns API! [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!]
| 5430 | // Demonstrate old/legacy Columns API! |
| 5431 | // [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!] |
| 5432 | static void ShowDemoWindowColumns() |
| 5433 | { |
| 5434 | IMGUI_DEMO_MARKER("Columns (legacy API)"); |
| 5435 | bool open = ImGui::TreeNode("Legacy Columns API"); |
| 5436 | ImGui::SameLine(); |
| 5437 | HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!"); |
| 5438 | if (!open) |
| 5439 | return; |
| 5440 | |
| 5441 | // Basic columns |
| 5442 | IMGUI_DEMO_MARKER("Columns (legacy API)/Basic"); |
| 5443 | if (ImGui::TreeNode("Basic")) |
| 5444 | { |
| 5445 | ImGui::Text("Without border:"); |
| 5446 | ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border |
| 5447 | ImGui::Separator(); |
| 5448 | for (int n = 0; n < 14; n++) |
| 5449 | { |
| 5450 | char label[32]; |
| 5451 | sprintf(label, "Item %d", n); |
| 5452 | if (ImGui::Selectable(label)) {} |
| 5453 | //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {} |
| 5454 | ImGui::NextColumn(); |
| 5455 | } |
| 5456 | ImGui::Columns(1); |
| 5457 | ImGui::Separator(); |
| 5458 | |
| 5459 | ImGui::Text("With border:"); |
| 5460 | ImGui::Columns(4, "mycolumns"); // 4-ways, with border |
| 5461 | ImGui::Separator(); |
| 5462 | ImGui::Text("ID"); ImGui::NextColumn(); |
| 5463 | ImGui::Text("Name"); ImGui::NextColumn(); |
| 5464 | ImGui::Text("Path"); ImGui::NextColumn(); |
| 5465 | ImGui::Text("Hovered"); ImGui::NextColumn(); |
| 5466 | ImGui::Separator(); |
| 5467 | const char* names[3] = { "One", "Two", "Three" }; |
| 5468 | const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; |
| 5469 | static int selected = -1; |
| 5470 | for (int i = 0; i < 3; i++) |
| 5471 | { |
| 5472 | char label[32]; |
| 5473 | sprintf(label, "%04d", i); |
| 5474 | if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) |
| 5475 | selected = i; |
| 5476 | bool hovered = ImGui::IsItemHovered(); |
| 5477 | ImGui::NextColumn(); |
| 5478 | ImGui::Text(names[i]); ImGui::NextColumn(); |
| 5479 | ImGui::Text(paths[i]); ImGui::NextColumn(); |
| 5480 | ImGui::Text("%d", hovered); ImGui::NextColumn(); |
| 5481 | } |
| 5482 | ImGui::Columns(1); |
| 5483 | ImGui::Separator(); |
| 5484 | ImGui::TreePop(); |
| 5485 | } |
| 5486 | |
| 5487 | IMGUI_DEMO_MARKER("Columns (legacy API)/Borders"); |
| 5488 | if (ImGui::TreeNode("Borders")) |
| 5489 | { |
no test coverage detected