mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-22 01:54:21 +00:00
Viewports: added per-viewport FramebufferScale, Platform_GetWindowFramebufferScale() + Backends: GLFW, SDL2, SDL3, Apple: added support. (#1065, #1542, #1676, #1786, #2826, #3757, #5081, #5580, #5592, #6465, #7273, #7779 etc.)
) Metal backend is not in charge of writing to DpiScale/FramebufferScale (tho it was a neat workaround).
This commit is contained in:
parent
63554bcee5
commit
c90ea1315a
9 changed files with 119 additions and 46 deletions
|
|
@ -5719,7 +5719,7 @@ static void InitViewportDrawData(ImGuiViewportP* viewport)
|
|||
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
||||
draw_data->DisplayPos = viewport->Pos;
|
||||
draw_data->DisplaySize = is_minimized ? ImVec2(0.0f, 0.0f) : viewport->Size;
|
||||
draw_data->FramebufferScale = io.DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
|
||||
draw_data->FramebufferScale = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale : io.DisplayFramebufferScale;
|
||||
draw_data->OwnerViewport = viewport;
|
||||
}
|
||||
|
||||
|
|
@ -16015,6 +16015,8 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||
viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport);
|
||||
if (viewport->PlatformRequestResize)
|
||||
viewport->Size = viewport->LastPlatformSize = g.PlatformIO.Platform_GetWindowSize(viewport);
|
||||
if (g.PlatformIO.Platform_GetWindowFramebufferScale != NULL)
|
||||
viewport->FramebufferScale = g.PlatformIO.Platform_GetWindowFramebufferScale(viewport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -22313,8 +22315,9 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
|||
if (open)
|
||||
{
|
||||
ImGuiWindowFlags flags = viewport->Flags;
|
||||
BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nWorkArea Inset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%",
|
||||
BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nFrameBufferScale: (%.2f,%.2f)\nWorkArea Inset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%",
|
||||
viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y,
|
||||
viewport->FramebufferScale.x, viewport->FramebufferScale.y,
|
||||
viewport->WorkInsetMin.x, viewport->WorkInsetMin.y, viewport->WorkInsetMax.x, viewport->WorkInsetMax.y,
|
||||
viewport->PlatformMonitor, viewport->DpiScale * 100.0f);
|
||||
if (viewport->Idx > 0) { SameLine(); if (SmallButton("Reset Pos")) { viewport->Pos = ImVec2(200, 200); viewport->UpdateWorkRect(); if (viewport->Window) viewport->Window->Pos = viewport->Pos; } }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue