Viewports: Minor tweaks. (#2471)

This commit is contained in:
omar 2019-05-08 18:22:56 +02:00
parent 9bf3f910c8
commit 239c8732d7
3 changed files with 11 additions and 8 deletions

View File

@ -1099,6 +1099,7 @@ static void UpdateViewportsNewFrame();
static void UpdateViewportsEndFrame(); static void UpdateViewportsEndFrame();
static void UpdateSelectWindowViewport(ImGuiWindow* window); static void UpdateSelectWindowViewport(ImGuiWindow* window);
static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport); static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport);
static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window);
static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport); static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window); static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window);
static int FindPlatformMonitorForPos(const ImVec2& pos); static int FindPlatformMonitorForPos(const ImVec2& pos);
@ -10233,6 +10234,12 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
return true; 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!) // Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!)
void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) 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. // 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); bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && g.ActiveId == 0);
if (try_to_merge_into_host_viewport) if (try_to_merge_into_host_viewport)
UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); UpdateTryMergeWindowIntoHostViewports(window);
} }
// Fallback to default viewport // Fallback to default viewport
@ -10618,7 +10625,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
window->Viewport->ID = window->ID; window->Viewport->ID = window->ID;
window->Viewport->LastNameHash = 0; window->Viewport->LastNameHash = 0;
} }
else if (!UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0])) // Merge? else if (!UpdateTryMergeWindowIntoHostViewports(window)) // Merge?
{ {
// New viewport // New viewport
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing); window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);

View File

@ -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_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_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_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. // 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.

View File

@ -748,11 +748,6 @@ struct ImDrawDataBuilder
IMGUI_API void FlattenIntoSingleLayer(); 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!) // ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
// Note that every instance of ImGuiViewport is in fact a ImGuiViewportP. // Note that every instance of ImGuiViewport is in fact a ImGuiViewportP.
struct ImGuiViewportP : public ImGuiViewport struct ImGuiViewportP : public ImGuiViewport