MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DemoWindowColumns

Function DemoWindowColumns

3rdparty/imgui/src/imgui_demo.cpp:7691–7894  ·  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

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

Callers 1

DemoWindowTablesFunction · 0.85

Calls 5

HelpMarkerFunction · 0.85
sprintfFunction · 0.85
ImVec2Function · 0.50
BeginMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected