MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ShowExampleAppLayout

Function ShowExampleAppLayout

lib/imgui/imgui_demo.cpp:4108–4162  ·  view source on GitHub ↗

Demonstrate create a window with multiple child windows.

Source from the content-addressed store, hash-verified

4106
4107// Demonstrate create a window with multiple child windows.
4108static void ShowExampleAppLayout(bool* p_open)
4109{
4110 ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
4111 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
4112 {
4113 if (ImGui::BeginMenuBar())
4114 {
4115 if (ImGui::BeginMenu("File"))
4116 {
4117 if (ImGui::MenuItem("Close")) *p_open = false;
4118 ImGui::EndMenu();
4119 }
4120 ImGui::EndMenuBar();
4121 }
4122
4123 // left
4124 static int selected = 0;
4125 ImGui::BeginChild("left pane", ImVec2(150, 0), true);
4126 for (int i = 0; i < 100; i++)
4127 {
4128 char label[128];
4129 sprintf(label, "MyObject %d", i);
4130 if (ImGui::Selectable(label, selected == i))
4131 selected = i;
4132 }
4133 ImGui::EndChild();
4134 ImGui::SameLine();
4135
4136 // right
4137 ImGui::BeginGroup();
4138 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
4139 ImGui::Text("MyObject: %d", selected);
4140 ImGui::Separator();
4141 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
4142 {
4143 if (ImGui::BeginTabItem("Description"))
4144 {
4145 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
4146 ImGui::EndTabItem();
4147 }
4148 if (ImGui::BeginTabItem("Details"))
4149 {
4150 ImGui::Text("ID: 0123456789");
4151 ImGui::EndTabItem();
4152 }
4153 ImGui::EndTabBar();
4154 }
4155 ImGui::EndChild();
4156 if (ImGui::Button("Revert")) {}
4157 ImGui::SameLine();
4158 if (ImGui::Button("Save")) {}
4159 ImGui::EndGroup();
4160 }
4161 ImGui::End();
4162}
4163
4164//-----------------------------------------------------------------------------
4165// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 1

ImVec2Class · 0.85

Tested by

no test coverage detected