mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Viewport: Store current dpi scale in context.
This commit is contained in:
parent
664fb38e39
commit
32380a0112
@ -7391,8 +7391,7 @@ ImDrawList* ImGui::GetWindowDrawList()
|
||||
float ImGui::GetWindowDpiScale()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.CurrentViewport != NULL);
|
||||
return g.CurrentViewport->DpiScale;
|
||||
return g.CurrentDpiScale;
|
||||
}
|
||||
|
||||
ImGuiViewport* ImGui::GetWindowViewport()
|
||||
@ -10253,6 +10252,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view
|
||||
viewport->LastFrameActive = g.FrameCount;
|
||||
if (g.CurrentViewport == viewport)
|
||||
return;
|
||||
g.CurrentDpiScale = viewport->DpiScale;
|
||||
g.CurrentViewport = viewport;
|
||||
//IMGUI_DEBUG_LOG_VIEWPORT("SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);
|
||||
|
||||
@ -10408,6 +10408,7 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
main_viewport_platform_pos = (main_viewport->Flags & ImGuiViewportFlags_Minimized) ? 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.CurrentDpiScale = 0.0f;
|
||||
g.CurrentViewport = NULL;
|
||||
g.MouseViewport = NULL;
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
|
@ -1079,6 +1079,7 @@ struct ImGuiContext
|
||||
|
||||
// Viewports
|
||||
ImVector<ImGuiViewportP*> Viewports; // Active viewports (always 1+, and generally 1 unless multi-viewports are enabled). Each viewports hold their copy of ImDrawData.
|
||||
float CurrentDpiScale; // == CurrentViewport->DpiScale
|
||||
ImGuiViewportP* CurrentViewport; // We track changes of viewport (happening in Begin) so we can call Platform_OnChangedViewport()
|
||||
ImGuiViewportP* MouseViewport;
|
||||
ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
|
||||
@ -1271,6 +1272,7 @@ struct ImGuiContext
|
||||
LastActiveId = 0;
|
||||
LastActiveIdTimer = 0.0f;
|
||||
|
||||
CurrentDpiScale = 0.0f;
|
||||
CurrentViewport = NULL;
|
||||
MouseViewport = MouseLastHoveredViewport = NULL;
|
||||
PlatformLastFocusedViewport = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user