From 7d2a068dea877efb6007a183494d20c813971f0f Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 11 Jan 2018 17:33:37 +0100 Subject: [PATCH] Begin: Shuffling bits of code around. --- imgui.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 23cded81..9135add8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4565,14 +4565,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f) window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f); - if (window_just_activated_by_user) - { - // Popup first latch mouse position, will position itself when it appears next frame - window->AutoPosLastDirection = ImGuiDir_None; - if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api) - window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos; - } - // Collapse window by double-clicking on title bar // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) @@ -4660,14 +4652,23 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // POSITION + // Popup latch its initial position, will position itself when it appears next frame + if (window_just_activated_by_user) + { + window->AutoPosLastDirection = ImGuiDir_None; + if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api) + window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos; + } + // Position child window if (flags & ImGuiWindowFlags_ChildWindow) { window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size; parent_window->DC.ChildWindows.push_back(window); + + if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api) + window->Pos = window->PosFloat = parent_window->DC.CursorPos; } - if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api) - window->Pos = window->PosFloat = parent_window->DC.CursorPos; const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0); if (window_pos_with_pivot)