mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Fixes of DPI scaling on Windows.
This commit is contained in:
parent
dad8a47741
commit
e8325a8e2d
5 changed files with 17 additions and 21 deletions
|
@ -53,8 +53,9 @@ void on_window_geometry(wxTopLevelWindow *tlw, std::function<void()> callback);
|
|||
|
||||
enum { DPI_DEFAULT = 96 };
|
||||
|
||||
int get_dpi_for_window(wxWindow *window);
|
||||
wxFont get_default_font_for_dpi(int dpi);
|
||||
int get_dpi_for_window(const wxWindow *window);
|
||||
wxFont get_default_font_for_dpi(const wxWindow* window, int dpi);
|
||||
inline wxFont get_default_font(const wxWindow* window) { return get_default_font_for_dpi(window, get_dpi_for_window(window)); }
|
||||
|
||||
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
|
||||
struct DpiChangedEvent : public wxEvent {
|
||||
|
@ -84,7 +85,7 @@ public:
|
|||
int dpi = get_dpi_for_window(this);
|
||||
m_scale_factor = (float)dpi / (float)DPI_DEFAULT;
|
||||
m_prev_scale_factor = m_scale_factor;
|
||||
m_normal_font = get_default_font_for_dpi(dpi);
|
||||
m_normal_font = get_default_font_for_dpi(this, dpi);
|
||||
|
||||
/* Because of default window font is a primary display font,
|
||||
* We should set correct font for window before getting em_unit value.
|
||||
|
@ -106,15 +107,10 @@ public:
|
|||
|
||||
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
|
||||
this->Bind(wxEVT_DPI_CHANGED, [this](wxDPIChangedEvent& evt) {
|
||||
m_scale_factor = (float)evt.GetNewDPI().x / (float)DPI_DEFAULT;
|
||||
|
||||
m_new_font_point_size = get_default_font_for_dpi(evt.GetNewDPI().x).GetPointSize();
|
||||
|
||||
if (!m_can_rescale)
|
||||
return;
|
||||
|
||||
if (m_force_rescale || is_new_scale_factor())
|
||||
rescale(wxRect());
|
||||
m_scale_factor = (float)evt.GetNewDPI().x / (float)DPI_DEFAULT;
|
||||
m_new_font_point_size = get_default_font_for_dpi(this, evt.GetNewDPI().x).GetPointSize();
|
||||
if (m_can_rescale && (m_force_rescale || is_new_scale_factor()))
|
||||
rescale(wxRect());
|
||||
});
|
||||
#else
|
||||
this->Bind(EVT_DPI_CHANGED_SLICER, [this](const DpiChangedEvent& evt) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue