diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index c7f69947ac..0564c9715d 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -131,6 +131,7 @@ static const wxChar ConfigurableToolbars[] = wxT( "ConfigurableToolbars" ); static const wxChar MaxPastedTextLength[] = wxT( "MaxPastedTextLength" ); static const wxChar PNSProcessClusterTimeout[] = wxT( "PNSProcessClusterTimeout" ); static const wxChar ImportSkipComponentBodies[] = wxT( "ImportSkipComponentBodies" ); +static const wxChar ScreenDPI[] = wxT( "ScreenDPI" ); } // namespace KEYS @@ -320,6 +321,8 @@ ADVANCED_CFG::ADVANCED_CFG() m_ImportSkipComponentBodies = false; + m_ScreenDPI = 91; + loadFromConfigFile(); } @@ -634,6 +637,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) &m_ImportSkipComponentBodies, m_ImportSkipComponentBodies ) ); + m_entries.push_back( std::make_unique( true, AC_KEYS::ScreenDPI, + &m_ScreenDPI, m_ScreenDPI, + 50, 500 ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config m_entries.push_back( std::make_unique( true, AC_KEYS::TraceMasks, &m_traceMasks, diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index e912676315..bc34a4ee32 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index cfd8669409..aac2870081 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -25,7 +25,7 @@ */ #include - +#include #include #include #include @@ -62,7 +62,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : // wxDC::GetPPI() reports 96 DPI, but somehow this value // is the closest match to the legacy renderer - SetScreenDPI( 91 ); + SetScreenDPI( ADVANCED_CFG::GetCfg().m_ScreenDPI ); SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); SetLayerDepth( 0.0 ); SetFlip( false, false ); diff --git a/common/widgets/zoom_correction_ctrl.cpp b/common/widgets/zoom_correction_ctrl.cpp index e8ea9594c5..9f6f6a3443 100644 --- a/common/widgets/zoom_correction_ctrl.cpp +++ b/common/widgets/zoom_correction_ctrl.cpp @@ -23,6 +23,7 @@ * Released under GNU GPL v2+ */ +#include #include #include @@ -55,7 +56,7 @@ private: double value = parent->GetValue(); ZOOM_CORRECTION_UNITS units = static_cast( parent->GetUnitsSelection() ); - double dpi = GetDPI().x; + double dpi = ADVANCED_CFG::GetCfg().m_ScreenDPI; double unitsPerInch = 25.4; if( units == ZOOM_CORRECTION_UNITS::CM ) @@ -222,6 +223,7 @@ int ZOOM_CORRECTION_CTRL::GetUnitsSelection() const return m_unitsChoice->GetSelection(); } + bool ZOOM_CORRECTION_CTRL::TransferDataToWindow() { m_slider->SetValue( (int)( *m_value * 100 ) ); diff --git a/include/advanced_config.h b/include/advanced_config.h index 5e153b40a3..2beee5044f 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -803,6 +803,18 @@ public: */ bool m_ImportSkipComponentBodies; + /** + * Screen DPI setting for display calculations. + * + * This setting controls the assumed screen DPI for various display calculations. + * Can be used to adjust sizing for high-DPI displays or unusual screen configurations. + * + * Setting name: "ScreenDPI" + * Valid values: 50 to 500 + * Default value: 91 + */ + int m_ScreenDPI; + wxString m_traceMasks; ///< Trace masks for wxLogTrace, loaded from the config file. ///@} diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index ddc0b62dbd..af5be9d83a 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -644,6 +644,7 @@ public: * For instance a typical notebook with HD+ resolution (1600x900) has 106 DPI. */ void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; } + double GetScreenDPI() const { return m_screenDPI; } /** * Get/set the Point in world space to look at. diff --git a/include/widgets/zoom_correction_ctrl.h b/include/widgets/zoom_correction_ctrl.h index 5119bc11ef..ab8b29e9f1 100644 --- a/include/widgets/zoom_correction_ctrl.h +++ b/include/widgets/zoom_correction_ctrl.h @@ -49,11 +49,11 @@ class ZOOM_CORRECTION_CTRL : public wxPanel public: ZOOM_CORRECTION_CTRL( wxWindow* aParent, double& aValue ); - void SetDisplayedValue( double aValue ); + void SetDisplayedValue( double aValue ); double GetValue() const; - int GetUnitsSelection() const; - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; + int GetUnitsSelection() const; + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; private: void sliderChanged( wxCommandEvent& aEvent );