From 239c8732d72f147f9dc4124c73cca472f3cd6f0b Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 8 May 2019 18:22:56 +0200 Subject: [PATCH] Viewports: Minor tweaks. (#2471) --- imgui.cpp | 11 +++++++++-- imgui.h | 3 ++- imgui_internal.h | 5 ----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index b5565e0b..8cde9de9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1099,6 +1099,7 @@ static void UpdateViewportsNewFrame(); static void UpdateViewportsEndFrame(); static void UpdateSelectWindowViewport(ImGuiWindow* window); static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport); +static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window); static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport); static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window); static int FindPlatformMonitorForPos(const ImVec2& pos); @@ -10233,6 +10234,12 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG return true; } +static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + return UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); +} + // Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!) void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) { @@ -10584,7 +10591,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) // We cannot test window->ViewportOwned as it set lower in the function. bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && g.ActiveId == 0); if (try_to_merge_into_host_viewport) - UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); + UpdateTryMergeWindowIntoHostViewports(window); } // Fallback to default viewport @@ -10618,7 +10625,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) window->Viewport->ID = window->ID; window->Viewport->LastNameHash = 0; } - else if (!UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0])) // Merge? + else if (!UpdateTryMergeWindowIntoHostViewports(window)) // Merge? { // New viewport window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing); diff --git a/imgui.h b/imgui.h index ae549e5d..895c6acd 100644 --- a/imgui.h +++ b/imgui.h @@ -2358,7 +2358,8 @@ enum ImGuiViewportFlags_ ImGuiViewportFlags_NoInputs = 1 << 4, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it. ImGuiViewportFlags_NoRendererClear = 1 << 5, // Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely). ImGuiViewportFlags_TopMost = 1 << 6, // Platform Window: Display on top (for tooltips only) - ImGuiViewportFlags_Minimized = 1 << 7 // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport. + ImGuiViewportFlags_Minimized = 1 << 7, // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport. + ImGuiViewportFlags_CanHostOtherWindows = 1 << 8 // Main viewport: can host multiple imgui windows (secondary viewports are associated to a single window) }; // The viewports created and managed by imgui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport. diff --git a/imgui_internal.h b/imgui_internal.h index 2ec59755..743ede20 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -748,11 +748,6 @@ struct ImDrawDataBuilder IMGUI_API void FlattenIntoSingleLayer(); }; -enum ImGuiViewportFlagsPrivate_ -{ - ImGuiViewportFlags_CanHostOtherWindows = 1 << 10 // Normal viewports are associated to a single window. The main viewport can host multiple windows. -}; - // ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!) // Note that every instance of ImGuiViewport is in fact a ImGuiViewportP. struct ImGuiViewportP : public ImGuiViewport