mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Viewport: Fix for minimization of individual viewports (the current back-end forcing a parent/child relationship between secondary viewports and the main viewport have hidden this issue). Follows d8ab2c1ac
.
This commit is contained in:
parent
05bc323be0
commit
606175b98f
20
imgui.cpp
20
imgui.cpp
@ -5169,7 +5169,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||||
window->Pos = FindBestWindowPosForPopup(window);
|
window->Pos = FindBestWindowPosForPopup(window);
|
||||||
|
|
||||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned)
|
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !window->Viewport->PlatformWindowMinimized)
|
||||||
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
||||||
{
|
{
|
||||||
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||||
@ -7419,13 +7419,25 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
|
IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
|
||||||
|
|
||||||
|
// Update Minimized status (we need it first in order to decide if we'll apply Pos/Size of the main viewport)
|
||||||
|
for (int n = 0; n < g.Viewports.Size; n++)
|
||||||
|
{
|
||||||
|
ImGuiViewportP* viewport = g.Viewports[n];
|
||||||
|
const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated);
|
||||||
|
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||||
|
if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
|
||||||
|
viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create/update main viewport with current platform position and size
|
||||||
ImGuiViewportP* main_viewport = g.Viewports[0];
|
ImGuiViewportP* main_viewport = g.Viewports[0];
|
||||||
IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
|
IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
|
||||||
IM_ASSERT(main_viewport->Window == NULL);
|
IM_ASSERT(main_viewport->Window == NULL);
|
||||||
ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
|
ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
|
||||||
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
ImVec2 main_viewport_platform_size = g.IO.DisplaySize;
|
||||||
main_viewport_platform_pos = g.PlatformIO.Platform_GetWindowPos(main_viewport);
|
if (g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable)
|
||||||
AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, g.IO.DisplaySize, ImGuiViewportFlags_CanHostOtherWindows);
|
main_viewport_platform_pos = main_viewport->PlatformWindowMinimized ? main_viewport->Pos : g.PlatformIO.Platform_GetWindowPos(main_viewport);
|
||||||
|
AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, main_viewport_platform_size, ImGuiViewportFlags_CanHostOtherWindows);
|
||||||
|
|
||||||
g.CurrentViewport = NULL;
|
g.CurrentViewport = NULL;
|
||||||
g.MouseViewport = NULL;
|
g.MouseViewport = NULL;
|
||||||
|
@ -664,7 +664,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
float LastAlpha;
|
float LastAlpha;
|
||||||
short PlatformMonitor;
|
short PlatformMonitor;
|
||||||
bool PlatformWindowCreated;
|
bool PlatformWindowCreated;
|
||||||
bool PlatformWindowMinimized;
|
bool PlatformWindowMinimized; // When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport
|
||||||
ImGuiWindow* Window; // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
|
ImGuiWindow* Window; // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
|
||||||
ImDrawList* OverlayDrawList; // For convenience, a draw list we can render to that's always rendered last (we use it to draw software mouse cursor when io.MouseDrawCursor is set)
|
ImDrawList* OverlayDrawList; // For convenience, a draw list we can render to that's always rendered last (we use it to draw software mouse cursor when io.MouseDrawCursor is set)
|
||||||
ImDrawData DrawDataP;
|
ImDrawData DrawDataP;
|
||||||
|
Loading…
Reference in New Issue
Block a user