Demonstrate create a window with multiple child windows.
| 6797 | |
| 6798 | // Demonstrate create a window with multiple child windows. |
| 6799 | static void ShowExampleAppLayout(bool* p_open) |
| 6800 | { |
| 6801 | ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); |
| 6802 | if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar)) |
| 6803 | { |
| 6804 | if (ImGui::BeginMenuBar()) |
| 6805 | { |
| 6806 | if (ImGui::BeginMenu("File")) |
| 6807 | { |
| 6808 | if (ImGui::MenuItem("Close")) *p_open = false; |
| 6809 | ImGui::EndMenu(); |
| 6810 | } |
| 6811 | ImGui::EndMenuBar(); |
| 6812 | } |
| 6813 | |
| 6814 | // Left |
| 6815 | static int selected = 0; |
| 6816 | { |
| 6817 | ImGui::BeginChild("left pane", ImVec2(150, 0), true); |
| 6818 | for (int i = 0; i < 100; i++) |
| 6819 | { |
| 6820 | char label[128]; |
| 6821 | sprintf(label, "MyObject %d", i); |
| 6822 | if (ImGui::Selectable(label, selected == i)) |
| 6823 | selected = i; |
| 6824 | } |
| 6825 | ImGui::EndChild(); |
| 6826 | } |
| 6827 | ImGui::SameLine(); |
| 6828 | |
| 6829 | // Right |
| 6830 | { |
| 6831 | ImGui::BeginGroup(); |
| 6832 | ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us |
| 6833 | ImGui::Text("MyObject: %d", selected); |
| 6834 | ImGui::Separator(); |
| 6835 | if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) |
| 6836 | { |
| 6837 | if (ImGui::BeginTabItem("Description")) |
| 6838 | { |
| 6839 | ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); |
| 6840 | ImGui::EndTabItem(); |
| 6841 | } |
| 6842 | if (ImGui::BeginTabItem("Details")) |
| 6843 | { |
| 6844 | ImGui::Text("ID: 0123456789"); |
| 6845 | ImGui::EndTabItem(); |
| 6846 | } |
| 6847 | ImGui::EndTabBar(); |
| 6848 | } |
| 6849 | ImGui::EndChild(); |
| 6850 | if (ImGui::Button("Revert")) {} |
| 6851 | ImGui::SameLine(); |
| 6852 | if (ImGui::Button("Save")) {} |
| 6853 | ImGui::EndGroup(); |
| 6854 | } |
| 6855 | } |
| 6856 | ImGui::End(); |
no test coverage detected