mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-12 01:38:29 +12:00
Automatically scale imgui text based on display pixel density (#545)
This commit is contained in:
parent
503e99d069
commit
2cfb7f3737
7 changed files with 52 additions and 19 deletions
|
@ -1523,6 +1523,7 @@ void MainWindow::OnSizeEvent(wxSizeEvent& event)
|
|||
g_window_info.height = client_size.GetHeight();
|
||||
g_window_info.phys_width = ToPhys(client_size.GetWidth());
|
||||
g_window_info.phys_height = ToPhys(client_size.GetHeight());
|
||||
g_window_info.dpi_scale = GetDPIScaleFactor();
|
||||
|
||||
if (m_debugger_window && m_debugger_window->IsShown())
|
||||
m_debugger_window->OnParentMove(GetPosition(), event.GetSize());
|
||||
|
@ -1540,6 +1541,7 @@ void MainWindow::OnDPIChangedEvent(wxDPIChangedEvent& event)
|
|||
g_window_info.height = client_size.GetHeight();
|
||||
g_window_info.phys_width = ToPhys(client_size.GetWidth());
|
||||
g_window_info.phys_height = ToPhys(client_size.GetHeight());
|
||||
g_window_info.dpi_scale = GetDPIScaleFactor();
|
||||
}
|
||||
|
||||
void MainWindow::OnMove(wxMoveEvent& event)
|
||||
|
|
|
@ -103,6 +103,7 @@ void PadViewFrame::OnSizeEvent(wxSizeEvent& event)
|
|||
g_window_info.pad_height = client_size.GetHeight();
|
||||
g_window_info.phys_pad_width = ToPhys(client_size.GetWidth());
|
||||
g_window_info.phys_pad_height = ToPhys(client_size.GetHeight());
|
||||
g_window_info.pad_dpi_scale = GetDPIScaleFactor();
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
@ -115,6 +116,7 @@ void PadViewFrame::OnDPIChangedEvent(wxDPIChangedEvent& event)
|
|||
g_window_info.pad_height = client_size.GetHeight();
|
||||
g_window_info.phys_pad_width = ToPhys(client_size.GetWidth());
|
||||
g_window_info.phys_pad_height = ToPhys(client_size.GetHeight());
|
||||
g_window_info.pad_dpi_scale = GetDPIScaleFactor();
|
||||
}
|
||||
|
||||
void PadViewFrame::OnMoveEvent(wxMoveEvent& event)
|
||||
|
|
|
@ -143,7 +143,6 @@ void gui_getWindowSize(int& w, int& h)
|
|||
h = g_window_info.height;
|
||||
}
|
||||
|
||||
|
||||
void gui_getPadWindowSize(int& w, int& h)
|
||||
{
|
||||
if (g_window_info.pad_open)
|
||||
|
@ -178,6 +177,16 @@ void gui_getPadWindowPhysSize(int& w, int& h)
|
|||
}
|
||||
}
|
||||
|
||||
double gui_getWindowDPIScale()
|
||||
{
|
||||
return g_window_info.dpi_scale;
|
||||
}
|
||||
|
||||
double gui_getPadDPIScale()
|
||||
{
|
||||
return g_window_info.pad_open ? g_window_info.pad_dpi_scale.load() : 1.0;
|
||||
}
|
||||
|
||||
bool gui_isPadWindowOpen()
|
||||
{
|
||||
return g_window_info.pad_open;
|
||||
|
|
|
@ -57,10 +57,12 @@ struct WindowInfo
|
|||
|
||||
std::atomic_int32_t width, height; // client size of main window
|
||||
std::atomic_int32_t phys_width, phys_height; // client size of main window in physical pixels
|
||||
std::atomic<double> dpi_scale;
|
||||
|
||||
std::atomic_bool pad_open; // if separate pad view is open
|
||||
std::atomic_int32_t pad_width, pad_height; // client size of pad window
|
||||
std::atomic_int32_t phys_pad_width, phys_pad_height; // client size of pad window in physical pixels
|
||||
std::atomic<double> pad_dpi_scale;
|
||||
|
||||
std::atomic_bool pad_maximized = false;
|
||||
std::atomic_int32_t restored_pad_x = -1, restored_pad_y = -1;
|
||||
|
@ -118,6 +120,8 @@ void gui_getWindowSize(int& w, int& h);
|
|||
void gui_getPadWindowSize(int& w, int& h);
|
||||
void gui_getWindowPhysSize(int& w, int& h);
|
||||
void gui_getPadWindowPhysSize(int& w, int& h);
|
||||
double gui_getWindowDPIScale();
|
||||
double gui_getPadDPIScale();
|
||||
bool gui_isPadWindowOpen();
|
||||
bool gui_isKeyDown(uint32 key);
|
||||
bool gui_isKeyDown(PlatformKeyCodes key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue