diff --git a/imgui.cpp b/imgui.cpp index e3b41300..34cc1851 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -700,7 +700,6 @@ static void MarkIniSettingsDirty(ImGuiWindow* window); static ImRect GetViewportRect(); -static void CloseInactivePopups(ImGuiWindow* ref_window); static void ClosePopupToLevel(int remaining); static ImGuiWindow* GetFrontMostModalRootWindow(); @@ -2832,7 +2831,7 @@ static void ImGui::NavUpdateWindowing() g.NavDisableHighlight = false; g.NavDisableMouseHover = true; apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window); - CloseInactivePopups(apply_focus_window); + ClosePopupsOverWindow(apply_focus_window); FocusWindow(apply_focus_window); if (apply_focus_window->NavLastIds[0] == 0) NavInitWindow(apply_focus_window, false); @@ -3425,7 +3424,7 @@ void ImGui::NewFrame() // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. g.CurrentWindowStack.resize(0); g.CurrentPopupStack.resize(0); - CloseInactivePopups(g.NavWindow); + ClosePopupsOverWindow(g.NavWindow); // Create implicit window - we will only render it if the user has added something to it. // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. @@ -3877,7 +3876,7 @@ void ImGui::EndFrame() } // With right mouse button we close popups without changing focus - // (The left mouse button path calls FocusWindow which will lead NewFrame->CloseInactivePopups to trigger) + // (The left mouse button path calls FocusWindow which will lead NewFrame->ClosePopupsOverWindow to trigger) if (g.IO.MouseClicked[1]) { // Find the top-most window between HoveredWindow and the front most Modal Window. @@ -3894,7 +3893,7 @@ void ImGui::EndFrame() if (window == g.HoveredWindow) hovered_window_above_modal = true; } - CloseInactivePopups(hovered_window_above_modal ? g.HoveredWindow : modal); + ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal); } } } @@ -4699,7 +4698,7 @@ void ImGui::OpenPopupEx(ImGuiID id) else g.OpenPopupStack[current_stack_size] = popup_ref; - // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by CloseInactivePopups(). + // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow(). // This is equivalent to what ClosePopupToLevel() does. //if (g.OpenPopupStack[current_stack_size].PopupId == id) // FocusWindow(parent_window); @@ -4712,7 +4711,7 @@ void ImGui::OpenPopup(const char* str_id) OpenPopupEx(g.CurrentWindow->GetID(str_id)); } -static void CloseInactivePopups(ImGuiWindow* ref_window) +void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window) { ImGuiContext& g = *GImGui; if (g.OpenPopupStack.empty()) diff --git a/imgui_internal.h b/imgui_internal.h index 0c93de71..4531f732 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1034,6 +1034,7 @@ namespace ImGui IMGUI_API void OpenPopupEx(ImGuiID id); IMGUI_API void ClosePopup(ImGuiID id); + IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window); IMGUI_API bool IsPopupOpen(ImGuiID id); IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags); IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);