| 6379 | } |
| 6380 | |
| 6381 | void ImGui::EndChild() |
| 6382 | { |
| 6383 | ImGuiContext& g = *GImGui; |
| 6384 | ImGuiWindow* child_window = g.CurrentWindow; |
| 6385 | |
| 6386 | const ImGuiID backup_within_end_child_id = g.WithinEndChildID; |
| 6387 | IM_ASSERT(child_window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls |
| 6388 | |
| 6389 | g.WithinEndChildID = child_window->ID; |
| 6390 | ImVec2 child_size = child_window->Size; |
| 6391 | End(); |
| 6392 | if (child_window->BeginCount == 1) |
| 6393 | { |
| 6394 | ImGuiWindow* parent_window = g.CurrentWindow; |
| 6395 | ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + child_size); |
| 6396 | ItemSize(child_size); |
| 6397 | const bool nav_flattened = (child_window->ChildFlags & ImGuiChildFlags_NavFlattened) != 0; |
| 6398 | if ((child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavWindowHasScrollY) && !nav_flattened) |
| 6399 | { |
| 6400 | ItemAdd(bb, child_window->ChildId); |
| 6401 | RenderNavCursor(bb, child_window->ChildId); |
| 6402 | |
| 6403 | // 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) |
| 6404 | if (child_window->DC.NavLayersActiveMask == 0 && child_window == g.NavWindow) |
| 6405 | RenderNavCursor(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavRenderCursorFlags_Compact); |
| 6406 | } |
| 6407 | else |
| 6408 | { |
| 6409 | // Not navigable into |
| 6410 | // - This is a bit of a fringe use case, mostly useful for undecorated, non-scrolling contents childs, or empty childs. |
| 6411 | // - We could later decide to not apply this path if ImGuiChildFlags_FrameStyle or ImGuiChildFlags_Borders is set. |
| 6412 | ItemAdd(bb, child_window->ChildId, NULL, ImGuiItemFlags_NoNav); |
| 6413 | |
| 6414 | // But when flattened we directly reach items, adjust active layer mask accordingly |
| 6415 | if (nav_flattened) |
| 6416 | parent_window->DC.NavLayersActiveMaskNext |= child_window->DC.NavLayersActiveMaskNext; |
| 6417 | } |
| 6418 | if (g.HoveredWindow == child_window) |
| 6419 | g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow; |
| 6420 | child_window->DC.ChildItemStatusFlags = g.LastItemData.StatusFlags; |
| 6421 | //SetLastItemDataForChildWindowItem(child_window, child_window->Rect()); // Not needed, effectively done by ItemAdd() |
| 6422 | } |
| 6423 | else |
| 6424 | { |
| 6425 | SetLastItemDataForChildWindowItem(child_window, child_window->Rect()); |
| 6426 | } |
| 6427 | |
| 6428 | g.WithinEndChildID = backup_within_end_child_id; |
| 6429 | g.LogLinePosY = -FLT_MAX; // To enforce a carriage return |
| 6430 | } |
| 6431 | |
| 6432 | static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) |
| 6433 | { |