From 8035405481b734df635c19fcd03c430078fa4189 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 20 Jul 2020 23:12:21 +0200 Subject: [PATCH] Begin: Move code from BeginChild() to EndChild() to allow End() calling EndChild() in new-begin experiments. --- imgui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 34b7634a..8531fbbb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5124,11 +5124,6 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b child_window->ChildId = id; child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; - // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. - // While this is not really documented/defined, it seems that the expected thing to do. - if (child_window->BeginCount == 1) - parent_window->DC.CursorPos = child_window->Pos; - // Process navigation-in immediately so NavInit can run on first frame if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) { @@ -5160,6 +5155,11 @@ void ImGui::EndChild() IM_ASSERT(g.WithinEndChild == false); IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls + // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. + // While this is not really documented/defined, it seems that the expected thing to do. + if (window->BeginCount == 1) + window->ParentWindow->DC.CursorPos = window->Pos; + g.WithinEndChild = true; if (window->BeginCount > 1) {