MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / ShowExampleAppLayout

Function ShowExampleAppLayout

plugins/Cardinal/src/DearImGui/imgui_demo.cpp:6909–6969  ·  view source on GitHub ↗

Demonstrate create a window with multiple child windows.

Source from the content-addressed store, hash-verified

6907
6908// Demonstrate create a window with multiple child windows.
6909static void ShowExampleAppLayout(bool* p_open)
6910{
6911 ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
6912 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
6913 {
6914 IMGUI_DEMO_MARKER("Examples/Simple layout");
6915 if (ImGui::BeginMenuBar())
6916 {
6917 if (ImGui::BeginMenu("File"))
6918 {
6919 if (ImGui::MenuItem("Close")) *p_open = false;
6920 ImGui::EndMenu();
6921 }
6922 ImGui::EndMenuBar();
6923 }
6924
6925 // Left
6926 static int selected = 0;
6927 {
6928 ImGui::BeginChild("left pane", ImVec2(150, 0), true);
6929 for (int i = 0; i < 100; i++)
6930 {
6931 // FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav
6932 char label[128];
6933 sprintf(label, "MyObject %d", i);
6934 if (ImGui::Selectable(label, selected == i))
6935 selected = i;
6936 }
6937 ImGui::EndChild();
6938 }
6939 ImGui::SameLine();
6940
6941 // Right
6942 {
6943 ImGui::BeginGroup();
6944 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
6945 ImGui::Text("MyObject: %d", selected);
6946 ImGui::Separator();
6947 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
6948 {
6949 if (ImGui::BeginTabItem("Description"))
6950 {
6951 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
6952 ImGui::EndTabItem();
6953 }
6954 if (ImGui::BeginTabItem("Details"))
6955 {
6956 ImGui::Text("ID: 0123456789");
6957 ImGui::EndTabItem();
6958 }
6959 ImGui::EndTabBar();
6960 }
6961 ImGui::EndChild();
6962 if (ImGui::Button("Revert")) {}
6963 ImGui::SameLine();
6964 if (ImGui::Button("Save")) {}
6965 ImGui::EndGroup();
6966 }

Callers 1

ShowDemoWindowMethod · 0.85

Calls 3

ImVec2Function · 0.85
MenuItemClass · 0.85
ButtonClass · 0.85

Tested by

no test coverage detected