mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Viewport: When resizing/moving a window using the host OS/WM we attempt to merge back into host viewport. (#1542)
This commit is contained in:
parent
1cafdb5b46
commit
7f960616e0
10
imgui.cpp
10
imgui.cpp
@ -3553,7 +3553,7 @@ static void ImGui::UpdateViewports()
|
|||||||
if (viewport->PlatformRequestResize)
|
if (viewport->PlatformRequestResize)
|
||||||
viewport->Size = g.PlatformIO.Platform_GetWindowSize(viewport);
|
viewport->Size = g.PlatformIO.Platform_GetWindowSize(viewport);
|
||||||
|
|
||||||
// Translate imgui windows when a host viewport has been moved
|
// Translate imgui windows when a Host Viewport has been moved
|
||||||
ImVec2 delta = viewport->Pos - viewport->LastPos;
|
ImVec2 delta = viewport->Pos - viewport->LastPos;
|
||||||
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (delta.x != 0.0f || delta.y != 0.0f))
|
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (delta.x != 0.0f || delta.y != 0.0f))
|
||||||
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
|
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
|
||||||
@ -6827,13 +6827,19 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronize viewport --> window
|
// Synchronize viewport --> window in case the platform window has been moved or resized from the OS/WM
|
||||||
if (window->ViewportOwned)
|
if (window->ViewportOwned)
|
||||||
{
|
{
|
||||||
if (window->Viewport->PlatformRequestMove)
|
if (window->Viewport->PlatformRequestMove)
|
||||||
|
{
|
||||||
window->Pos = window->Viewport->Pos;
|
window->Pos = window->Viewport->Pos;
|
||||||
|
window->ViewportTryMerge = true;
|
||||||
|
}
|
||||||
if (window->Viewport->PlatformRequestResize)
|
if (window->Viewport->PlatformRequestResize)
|
||||||
|
{
|
||||||
window->Size = window->SizeFull = window->Viewport->Size;
|
window->Size = window->SizeFull = window->Viewport->Size;
|
||||||
|
window->ViewportTryMerge = true;
|
||||||
|
}
|
||||||
|
|
||||||
// We also tell the back-end that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha
|
// We also tell the back-end that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha
|
||||||
window->Viewport->Flags |= ImGuiViewportFlags_NoRendererClear;
|
window->Viewport->Flags |= ImGuiViewportFlags_NoRendererClear;
|
||||||
|
4
imgui.h
4
imgui.h
@ -2004,8 +2004,8 @@ struct ImGuiViewport
|
|||||||
void* PlatformUserData; // void* to hold custom data structure for the platform (e.g. windowing info, render context)
|
void* PlatformUserData; // void* to hold custom data structure for the platform (e.g. windowing info, render context)
|
||||||
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GlfwWindow*, SDL_Window*)
|
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GlfwWindow*, SDL_Window*)
|
||||||
bool PlatformRequestClose; // Platform window requested closure
|
bool PlatformRequestClose; // Platform window requested closure
|
||||||
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved using OS windowing facility)
|
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager)
|
||||||
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resize using OS windowing facility)
|
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resize by the OS / host window manager)
|
||||||
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.)
|
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.)
|
||||||
|
|
||||||
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; PlatformUserData = PlatformHandle = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; RendererUserData = NULL; }
|
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; PlatformUserData = PlatformHandle = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; RendererUserData = NULL; }
|
||||||
|
Loading…
Reference in New Issue
Block a user