mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
Qt: Improve imgui hidpi scaling
This commit is contained in:
parent
168eb5fe2d
commit
686df4a203
|
@ -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 |
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -95,7 +101,7 @@ void QtDisplayWindow::keyReleaseEvent(QKeyEvent* event)
|
|||
void QtDisplayWindow::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QWindow::resizeEvent(event);
|
||||
|
||||
|
||||
const int width = static_cast<int>(static_cast<qreal>(event->size().width()) * devicePixelRatio());
|
||||
const int height = static_cast<int>(static_cast<qreal>(event->size().height()) * devicePixelRatio());
|
||||
emit windowResizedEvent(width, height);
|
||||
|
|
Loading…
Reference in a new issue