MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / ShowExampleAppLayout

Function ShowExampleAppLayout

external/imgui/imgui_demo.cpp:9524–9583  ·  view source on GitHub ↗

Demonstrate create a window with multiple child windows.

Source from the content-addressed store, hash-verified

9522
9523// Demonstrate create a window with multiple child windows.
9524static void ShowExampleAppLayout(bool* p_open)
9525{
9526 ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
9527 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
9528 {
9529 IMGUI_DEMO_MARKER("Examples/Simple layout");
9530 if (ImGui::BeginMenuBar())
9531 {
9532 if (ImGui::BeginMenu("File"))
9533 {
9534 if (ImGui::MenuItem("Close", "Ctrl+W")) { *p_open = false; }
9535 ImGui::EndMenu();
9536 }
9537 ImGui::EndMenuBar();
9538 }
9539
9540 // Left
9541 static int selected = 0;
9542 {
9543 ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeX);
9544 for (int i = 0; i < 100; i++)
9545 {
9546 char label[128];
9547 sprintf(label, "MyObject %d", i);
9548 if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SelectOnNav))
9549 selected = i;
9550 }
9551 ImGui::EndChild();
9552 }
9553 ImGui::SameLine();
9554
9555 // Right
9556 {
9557 ImGui::BeginGroup();
9558 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
9559 ImGui::Text("MyObject: %d", selected);
9560 ImGui::Separator();
9561 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
9562 {
9563 if (ImGui::BeginTabItem("Description"))
9564 {
9565 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
9566 ImGui::EndTabItem();
9567 }
9568 if (ImGui::BeginTabItem("Details"))
9569 {
9570 ImGui::Text("ID: 0123456789");
9571 ImGui::EndTabItem();
9572 }
9573 ImGui::EndTabBar();
9574 }
9575 ImGui::EndChild();
9576 if (ImGui::Button("Revert")) {}
9577 ImGui::SameLine();
9578 if (ImGui::Button("Save")) {}
9579 ImGui::EndGroup();
9580 }
9581 }

Callers 1

ShowDemoWindowMethod · 0.85

Calls 1

ImVec2Function · 0.85

Tested by

no test coverage detected