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