Demonstrate create a window with multiple child windows.
| 6974 | |
| 6975 | // Demonstrate create a window with multiple child windows. |
| 6976 | static void ShowExampleAppLayout(bool* p_open) |
| 6977 | { |
| 6978 | ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); |
| 6979 | if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar)) |
| 6980 | { |
| 6981 | IMGUI_DEMO_MARKER("Examples/Simple layout"); |
| 6982 | if (ImGui::BeginMenuBar()) |
| 6983 | { |
| 6984 | if (ImGui::BeginMenu("File")) |
| 6985 | { |
| 6986 | if (ImGui::MenuItem("Close")) *p_open = false; |
| 6987 | ImGui::EndMenu(); |
| 6988 | } |
| 6989 | ImGui::EndMenuBar(); |
| 6990 | } |
| 6991 | |
| 6992 | // Left |
| 6993 | static int selected = 0; |
| 6994 | { |
| 6995 | ImGui::BeginChild("left pane", ImVec2(150, 0), true); |
| 6996 | for (int i = 0; i < 100; i++) |
| 6997 | { |
| 6998 | // FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav |
| 6999 | char label[128]; |
| 7000 | sprintf(label, "MyObject %d", i); |
| 7001 | if (ImGui::Selectable(label, selected == i)) |
| 7002 | selected = i; |
| 7003 | } |
| 7004 | ImGui::EndChild(); |
| 7005 | } |
| 7006 | ImGui::SameLine(); |
| 7007 | |
| 7008 | // Right |
| 7009 | { |
| 7010 | ImGui::BeginGroup(); |
| 7011 | ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us |
| 7012 | ImGui::Text("MyObject: %d", selected); |
| 7013 | ImGui::Separator(); |
| 7014 | if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) |
| 7015 | { |
| 7016 | if (ImGui::BeginTabItem("Description")) |
| 7017 | { |
| 7018 | ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); |
| 7019 | ImGui::EndTabItem(); |
| 7020 | } |
| 7021 | if (ImGui::BeginTabItem("Details")) |
| 7022 | { |
| 7023 | ImGui::Text("ID: 0123456789"); |
| 7024 | ImGui::EndTabItem(); |
| 7025 | } |
| 7026 | ImGui::EndTabBar(); |
| 7027 | } |
| 7028 | ImGui::EndChild(); |
| 7029 | if (ImGui::Button("Revert")) {} |
| 7030 | ImGui::SameLine(); |
| 7031 | if (ImGui::Button("Save")) {} |
| 7032 | ImGui::EndGroup(); |
| 7033 | } |
no test coverage detected