Qt: Improve imgui hidpi scaling

This commit is contained in:
Connor McLaughlin 2020-01-07 18:52:33 +10:00
parent 168eb5fe2d
commit 686df4a203
2 changed files with 12 additions and 4 deletions

View file

@ -12,8 +12,8 @@
#include "spu.h"
#include "system.h"
#include "timers.h"
#include <cstring>
#include <cmath>
#include <cstring>
#include <imgui.h>
Log_SetChannel(HostInterface);
@ -113,8 +113,10 @@ void HostInterface::DrawFPSWindow()
if (!(show_fps | show_vps | show_speed))
return;
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - 175.0f, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(175.0f, 16.0f));
const ImVec2 window_size =
ImVec2(175.0f * ImGui::GetIO().DisplayFramebufferScale.x, 16.0f * ImGui::GetIO().DisplayFramebufferScale.y);
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - window_size.x, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(window_size);
if (!ImGui::Begin("FPSWindow", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse |

View file

@ -45,6 +45,12 @@ bool QtDisplayWindow::createImGuiContext()
io.DisplaySize.x = static_cast<float>(m_window_width);
io.DisplaySize.y = static_cast<float>(m_window_height);
const float framebuffer_scale = static_cast<float>(devicePixelRatio());
io.DisplayFramebufferScale.x = framebuffer_scale;
io.DisplayFramebufferScale.y = framebuffer_scale;
io.FontGlobalScale = framebuffer_scale;
ImGui::GetStyle().ScaleAllSizes(framebuffer_scale);
return true;
}