From f42d7b89e2430e02905cdd284b20ae0fe7a558fd Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 12 Dec 2017 00:18:31 +0100 Subject: [PATCH] Internals: Removed misleading GetWindowParent() function. + renaming to clear confusing. --- imgui.cpp | 15 ++++----------- imgui_internal.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 61a1217c..cf83b2ea 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1910,13 +1910,6 @@ static void SetCurrentWindow(ImGuiWindow* window) g.FontSize = window->CalcFontSize(); } -ImGuiWindow* ImGui::GetParentWindow() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.CurrentWindowStack.Size >= 2); - return g.CurrentWindowStack[(unsigned int)g.CurrentWindowStack.Size - 2]; -} - void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; @@ -3686,9 +3679,9 @@ void ImGui::EndTooltip() void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) { ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow* parent_window = g.CurrentWindow; int current_stack_size = g.CurrentPopupStack.Size; - ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##Menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here) + ImGuiPopupRef popup_ref = ImGuiPopupRef(id, parent_window, parent_window->GetID("##Menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL. if (g.OpenPopupStack.Size < current_stack_size + 1) g.OpenPopupStack.push_back(popup_ref); else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) @@ -3699,7 +3692,7 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by CloseInactivePopups(). // This is equivalent to what ClosePopupToLevel() does. if (g.OpenPopupStack[current_stack_size].PopupId == id) - FocusWindow(window); + FocusWindow(parent_window); } } @@ -9426,7 +9419,7 @@ bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_item void ImGui::ListBoxFooter() { - ImGuiWindow* parent_window = GetParentWindow(); + ImGuiWindow* parent_window = GetCurrentWindow()->ParentWindow; const ImRect bb = parent_window->DC.LastItemRect; const ImGuiStyle& style = GetStyle(); diff --git a/imgui_internal.h b/imgui_internal.h index 5a84f2f6..b1dab53f 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -799,7 +799,6 @@ namespace ImGui // - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal. inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } - IMGUI_API ImGuiWindow* GetParentWindow(); IMGUI_API ImGuiWindow* FindWindowByName(const char* name); IMGUI_API void FocusWindow(ImGuiWindow* window); IMGUI_API void BringWindowToFront(ImGuiWindow* window);