Demonstrate create a window with multiple child windows.
| 7433 | |
| 7434 | // Demonstrate create a window with multiple child windows. |
| 7435 | static void ShowExampleAppLayout(bool* p_open) |
| 7436 | { |
| 7437 | ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); |
| 7438 | if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar)) |
| 7439 | { |
| 7440 | IMGUI_DEMO_MARKER("Examples/Simple layout"); |
| 7441 | if (ImGui::BeginMenuBar()) |
| 7442 | { |
| 7443 | if (ImGui::BeginMenu("File")) |
| 7444 | { |
| 7445 | if (ImGui::MenuItem("Close", "Ctrl+W")) { *p_open = false; } |
| 7446 | ImGui::EndMenu(); |
| 7447 | } |
| 7448 | ImGui::EndMenuBar(); |
| 7449 | } |
| 7450 | |
| 7451 | // Left |
| 7452 | static int selected = 0; |
| 7453 | { |
| 7454 | ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Border | ImGuiChildFlags_ResizeX); |
| 7455 | for (int i = 0; i < 100; i++) |
| 7456 | { |
| 7457 | // FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav |
| 7458 | char label[128]; |
| 7459 | sprintf(label, "MyObject %d", i); |
| 7460 | if (ImGui::Selectable(label, selected == i)) |
| 7461 | selected = i; |
| 7462 | } |
| 7463 | ImGui::EndChild(); |
| 7464 | } |
| 7465 | ImGui::SameLine(); |
| 7466 | |
| 7467 | // Right |
| 7468 | { |
| 7469 | ImGui::BeginGroup(); |
| 7470 | ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us |
| 7471 | ImGui::Text("MyObject: %d", selected); |
| 7472 | ImGui::Separator(); |
| 7473 | if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) |
| 7474 | { |
| 7475 | if (ImGui::BeginTabItem("Description")) |
| 7476 | { |
| 7477 | ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); |
| 7478 | ImGui::EndTabItem(); |
| 7479 | } |
| 7480 | if (ImGui::BeginTabItem("Details")) |
| 7481 | { |
| 7482 | ImGui::Text("ID: 0123456789"); |
| 7483 | ImGui::EndTabItem(); |
| 7484 | } |
| 7485 | ImGui::EndTabBar(); |
| 7486 | } |
| 7487 | ImGui::EndChild(); |
| 7488 | if (ImGui::Button("Revert")) {} |
| 7489 | ImGui::SameLine(); |
| 7490 | if (ImGui::Button("Save")) {} |
| 7491 | ImGui::EndGroup(); |
| 7492 | } |
no test coverage detected