MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / DemoWindowColumns

Function DemoWindowColumns

imgui_tiny_app/imgui/imgui_demo.cpp:7701–7904  ·  view source on GitHub ↗

Demonstrate old/legacy Columns API! [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!]

Source from the content-addressed store, hash-verified

7699// Demonstrate old/legacy Columns API!
7700// [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!]
7701static void DemoWindowColumns()
7702{
7703 bool open = ImGui::TreeNode("Legacy Columns API");
7704 ImGui::SameLine();
7705 HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!");
7706 if (!open)
7707 return;
7708
7709 // Basic columns
7710 if (ImGui::TreeNode("Basic"))
7711 {
7712 IMGUI_DEMO_MARKER("Columns (legacy API)/Basic");
7713 ImGui::Text("Without border:");
7714 ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
7715 ImGui::Separator();
7716 for (int n = 0; n < 14; n++)
7717 {
7718 char label[32];
7719 sprintf(label, "Item %d", n);
7720 if (ImGui::Selectable(label)) {}
7721 //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {}
7722 ImGui::NextColumn();
7723 }
7724 ImGui::Columns(1);
7725 ImGui::Separator();
7726
7727 ImGui::Text("With border:");
7728 ImGui::Columns(4, "mycolumns"); // 4-ways, with border
7729 ImGui::Separator();
7730 ImGui::Text("ID"); ImGui::NextColumn();
7731 ImGui::Text("Name"); ImGui::NextColumn();
7732 ImGui::Text("Path"); ImGui::NextColumn();
7733 ImGui::Text("Hovered"); ImGui::NextColumn();
7734 ImGui::Separator();
7735 const char* names[3] = { "One", "Two", "Three" };
7736 const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
7737 static int selected = -1;
7738 for (int i = 0; i < 3; i++)
7739 {
7740 char label[32];
7741 sprintf(label, "%04d", i);
7742 if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
7743 selected = i;
7744 bool hovered = ImGui::IsItemHovered();
7745 ImGui::NextColumn();
7746 ImGui::Text(names[i]); ImGui::NextColumn();
7747 ImGui::Text(paths[i]); ImGui::NextColumn();
7748 ImGui::Text("%d", hovered); ImGui::NextColumn();
7749 }
7750 ImGui::Columns(1);
7751 ImGui::Separator();
7752 ImGui::TreePop();
7753 }
7754
7755 if (ImGui::TreeNode("Borders"))
7756 {
7757 IMGUI_DEMO_MARKER("Columns (legacy API)/Borders");
7758 // NB: Future columns API should allow automatic horizontal borders.

Callers 1

DemoWindowTablesFunction · 0.85

Calls 4

HelpMarkerFunction · 0.85
ImVec2Function · 0.85
BeginMethod · 0.80
StepMethod · 0.45

Tested by

no test coverage detected