| 5423 | } |
| 5424 | |
| 5425 | void ImGui::EndChild() |
| 5426 | { |
| 5427 | ImGuiContext& g = *GImGui; |
| 5428 | ImGuiWindow* window = g.CurrentWindow; |
| 5429 | |
| 5430 | IM_ASSERT(g.WithinEndChild == false); |
| 5431 | IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls |
| 5432 | |
| 5433 | g.WithinEndChild = true; |
| 5434 | if (window->BeginCount > 1) |
| 5435 | { |
| 5436 | End(); |
| 5437 | } |
| 5438 | else |
| 5439 | { |
| 5440 | ImVec2 sz = window->Size; |
| 5441 | if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f |
| 5442 | sz.x = ImMax(4.0f, sz.x); |
| 5443 | if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) |
| 5444 | sz.y = ImMax(4.0f, sz.y); |
| 5445 | End(); |
| 5446 | |
| 5447 | ImGuiWindow* parent_window = g.CurrentWindow; |
| 5448 | ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); |
| 5449 | ItemSize(sz); |
| 5450 | if ((window->DC.NavLayersActiveMask != 0 || window->DC.NavWindowHasScrollY) && !(window->Flags & ImGuiWindowFlags_NavFlattened)) |
| 5451 | { |
| 5452 | ItemAdd(bb, window->ChildId); |
| 5453 | RenderNavHighlight(bb, window->ChildId); |
| 5454 | |
| 5455 | // When browsing a window that has no activable items (scroll only) we keep a highlight on the child (pass g.NavId to trick into always displaying) |
| 5456 | if (window->DC.NavLayersActiveMask == 0 && window == g.NavWindow) |
| 5457 | RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_TypeThin); |
| 5458 | } |
| 5459 | else |
| 5460 | { |
| 5461 | // Not navigable into |
| 5462 | ItemAdd(bb, 0); |
| 5463 | |
| 5464 | // But when flattened we directly reach items, adjust active layer mask accordingly |
| 5465 | if (window->Flags & ImGuiWindowFlags_NavFlattened) |
| 5466 | parent_window->DC.NavLayersActiveMaskNext |= window->DC.NavLayersActiveMaskNext; |
| 5467 | } |
| 5468 | if (g.HoveredWindow == window) |
| 5469 | g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow; |
| 5470 | } |
| 5471 | g.WithinEndChild = false; |
| 5472 | g.LogLinePosY = -FLT_MAX; // To enforce a carriage return |
| 5473 | } |
| 5474 | |
| 5475 | // Helper to create a child window / scrolling region that looks like a normal widget frame. |
| 5476 | bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) |