MCPcopy Create free account
hub / github.com/cinder/Cinder / ShowExampleAppLayout

Function ShowExampleAppLayout

src/imgui/imgui_demo.cpp:9286–9345  ·  view source on GitHub ↗

Demonstrate create a window with multiple child windows.

Source from the content-addressed store, hash-verified

9284
9285// Demonstrate create a window with multiple child windows.
9286static void ShowExampleAppLayout(bool* p_open)
9287{
9288 ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
9289 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
9290 {
9291 IMGUI_DEMO_MARKER("Examples/Simple layout");
9292 if (ImGui::BeginMenuBar())
9293 {
9294 if (ImGui::BeginMenu("File"))
9295 {
9296 if (ImGui::MenuItem("Close", "Ctrl+W")) { *p_open = false; }
9297 ImGui::EndMenu();
9298 }
9299 ImGui::EndMenuBar();
9300 }
9301
9302 // Left
9303 static int selected = 0;
9304 {
9305 ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeX);
9306 for (int i = 0; i < 100; i++)
9307 {
9308 char label[128];
9309 sprintf(label, "MyObject %d", i);
9310 if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SelectOnNav))
9311 selected = i;
9312 }
9313 ImGui::EndChild();
9314 }
9315 ImGui::SameLine();
9316
9317 // Right
9318 {
9319 ImGui::BeginGroup();
9320 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
9321 ImGui::Text("MyObject: %d", selected);
9322 ImGui::Separator();
9323 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
9324 {
9325 if (ImGui::BeginTabItem("Description"))
9326 {
9327 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
9328 ImGui::EndTabItem();
9329 }
9330 if (ImGui::BeginTabItem("Details"))
9331 {
9332 ImGui::Text("ID: 0123456789");
9333 ImGui::EndTabItem();
9334 }
9335 ImGui::EndTabBar();
9336 }
9337 ImGui::EndChild();
9338 if (ImGui::Button("Revert")) {}
9339 ImGui::SameLine();
9340 if (ImGui::Button("Save")) {}
9341 ImGui::EndGroup();
9342 }
9343 }

Callers 1

ShowDemoWindowMethod · 0.85

Calls 1

ImVec2Function · 0.85

Tested by

no test coverage detected