From b630cb5b427081e724d2b452ba7d20bcddf6a686 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 10 May 2016 17:00:42 +0200 Subject: [PATCH] ImGuiWindow: Storing ParentWindow (#615, #646) --- imgui.cpp | 2 ++ imgui_internal.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index d9ea1d2e..a849ba5a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1641,6 +1641,7 @@ ImGuiWindow::ImGuiWindow(const char* name) DrawList->_OwnerName = Name; RootWindow = NULL; RootNonPopupWindow = NULL; + ParentWindow = NULL; FocusIdxAllCounter = FocusIdxTabCounter = -1; FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = IM_INT_MAX; @@ -3759,6 +3760,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us for (root_non_popup_idx = root_idx; root_non_popup_idx > 0; root_non_popup_idx--) if (!(g.CurrentWindowStack[root_non_popup_idx]->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) break; + window->ParentWindow = parent_window; window->RootWindow = g.CurrentWindowStack[root_idx]; window->RootNonPopupWindow = g.CurrentWindowStack[root_non_popup_idx]; // This is merely for displaying the TitleBgActive color. diff --git a/imgui_internal.h b/imgui_internal.h index bf4f73f1..6c90e53a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -636,7 +636,8 @@ struct IMGUI_API ImGuiWindow float FontWindowScale; // Scale multiplier per-window ImDrawList* DrawList; ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself. - ImGuiWindow* RootNonPopupWindow; // If we are a child widnow, this is pointing to the first non-child non-popup parent window. Else point to ourself. + ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself. + ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL. // Focus int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()