| 4291 | //----------------------------------------------------------------------------- |
| 4292 | |
| 4293 | static void DemoWindowLayout() |
| 4294 | { |
| 4295 | IMGUI_DEMO_MARKER("Layout"); |
| 4296 | if (!ImGui::CollapsingHeader("Layout & Scrolling")) |
| 4297 | return; |
| 4298 | |
| 4299 | IMGUI_DEMO_MARKER("Layout/Child windows"); |
| 4300 | if (ImGui::TreeNode("Child windows")) |
| 4301 | { |
| 4302 | ImGui::SeparatorText("Child windows"); |
| 4303 | |
| 4304 | HelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window."); |
| 4305 | static bool disable_mouse_wheel = false; |
| 4306 | static bool disable_menu = false; |
| 4307 | ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel); |
| 4308 | ImGui::Checkbox("Disable Menu", &disable_menu); |
| 4309 | |
| 4310 | // Child 1: no border, enable horizontal scrollbar |
| 4311 | { |
| 4312 | ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar; |
| 4313 | if (disable_mouse_wheel) |
| 4314 | window_flags |= ImGuiWindowFlags_NoScrollWithMouse; |
| 4315 | ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 260), ImGuiChildFlags_None, window_flags); |
| 4316 | for (int i = 0; i < 100; i++) |
| 4317 | ImGui::Text("%04d: scrollable region", i); |
| 4318 | ImGui::EndChild(); |
| 4319 | } |
| 4320 | |
| 4321 | ImGui::SameLine(); |
| 4322 | |
| 4323 | // Child 2: rounded border |
| 4324 | { |
| 4325 | ImGuiWindowFlags window_flags = ImGuiWindowFlags_None; |
| 4326 | if (disable_mouse_wheel) |
| 4327 | window_flags |= ImGuiWindowFlags_NoScrollWithMouse; |
| 4328 | if (!disable_menu) |
| 4329 | window_flags |= ImGuiWindowFlags_MenuBar; |
| 4330 | ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); |
| 4331 | ImGui::BeginChild("ChildR", ImVec2(0, 260), ImGuiChildFlags_Borders, window_flags); |
| 4332 | if (!disable_menu && ImGui::BeginMenuBar()) |
| 4333 | { |
| 4334 | if (ImGui::BeginMenu("Menu")) |
| 4335 | { |
| 4336 | ShowExampleMenuFile(); |
| 4337 | ImGui::EndMenu(); |
| 4338 | } |
| 4339 | ImGui::EndMenuBar(); |
| 4340 | } |
| 4341 | if (ImGui::BeginTable("split", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings)) |
| 4342 | { |
| 4343 | for (int i = 0; i < 100; i++) |
| 4344 | { |
| 4345 | char buf[32]; |
| 4346 | sprintf(buf, "%03d", i); |
| 4347 | ImGui::TableNextColumn(); |
| 4348 | ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); |
| 4349 | } |
| 4350 | ImGui::EndTable(); |
no test coverage detected