Fix screen scaling

We don't use wxWidget DPI (which is the screen DPI) for our on-screen
display.  Instead, we use 91 (?!?).  Make this configurable in advanced
config and use the set value in our scaling widget
This commit is contained in:
Seth Hillbrand 2025-08-25 18:02:39 -07:00
parent 1df5ad0e4c
commit 6dd03bc735
7 changed files with 31 additions and 7 deletions

View File

@ -131,6 +131,7 @@ static const wxChar ConfigurableToolbars[] = wxT( "ConfigurableToolbars" );
static const wxChar MaxPastedTextLength[] = wxT( "MaxPastedTextLength" ); static const wxChar MaxPastedTextLength[] = wxT( "MaxPastedTextLength" );
static const wxChar PNSProcessClusterTimeout[] = wxT( "PNSProcessClusterTimeout" ); static const wxChar PNSProcessClusterTimeout[] = wxT( "PNSProcessClusterTimeout" );
static const wxChar ImportSkipComponentBodies[] = wxT( "ImportSkipComponentBodies" ); static const wxChar ImportSkipComponentBodies[] = wxT( "ImportSkipComponentBodies" );
static const wxChar ScreenDPI[] = wxT( "ScreenDPI" );
} // namespace KEYS } // namespace KEYS
@ -320,6 +321,8 @@ ADVANCED_CFG::ADVANCED_CFG()
m_ImportSkipComponentBodies = false; m_ImportSkipComponentBodies = false;
m_ScreenDPI = 91;
loadFromConfigFile(); loadFromConfigFile();
} }
@ -634,6 +637,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_ImportSkipComponentBodies, &m_ImportSkipComponentBodies,
m_ImportSkipComponentBodies ) ); m_ImportSkipComponentBodies ) );
m_entries.push_back( std::make_unique<PARAM_CFG_INT>( true, AC_KEYS::ScreenDPI,
&m_ScreenDPI, m_ScreenDPI,
50, 500 ) );
// Special case for trace mask setting...we just grab them and set them immediately // Special case for trace mask setting...we just grab them and set them immediately
// Because we even use wxLogTrace inside of advanced config // Because we even use wxLogTrace inside of advanced config
m_entries.push_back( std::make_unique<PARAM_CFG_WXSTRING>( true, AC_KEYS::TraceMasks, &m_traceMasks, m_entries.push_back( std::make_unique<PARAM_CFG_WXSTRING>( true, AC_KEYS::TraceMasks, &m_traceMasks,

View File

@ -27,6 +27,8 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <dpi_scaling_common.h> #include <dpi_scaling_common.h>
#include <eda_draw_frame.h>
#include <gal/graphics_abstraction_layer.h>
#include <kiface_base.h> #include <kiface_base.h>
#include <kiplatform/ui.h> #include <kiplatform/ui.h>
#include <pgm_base.h> #include <pgm_base.h>

View File

@ -25,7 +25,7 @@
*/ */
#include <wx/log.h> #include <wx/log.h>
#include <advanced_config.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h> #include <gal/definitions.h>
#include <font/font.h> #include <font/font.h>
@ -62,7 +62,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
// wxDC::GetPPI() reports 96 DPI, but somehow this value // wxDC::GetPPI() reports 96 DPI, but somehow this value
// is the closest match to the legacy renderer // is the closest match to the legacy renderer
SetScreenDPI( 91 ); SetScreenDPI( ADVANCED_CFG::GetCfg().m_ScreenDPI );
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
SetLayerDepth( 0.0 ); SetLayerDepth( 0.0 );
SetFlip( false, false ); SetFlip( false, false );

View File

@ -23,6 +23,7 @@
* Released under GNU GPL v2+ * Released under GNU GPL v2+
*/ */
#include <advanced_config.h>
#include <widgets/zoom_correction_ctrl.h> #include <widgets/zoom_correction_ctrl.h>
#include <widgets/ui_common.h> #include <widgets/ui_common.h>
@ -55,7 +56,7 @@ private:
double value = parent->GetValue(); double value = parent->GetValue();
ZOOM_CORRECTION_UNITS units = static_cast<ZOOM_CORRECTION_UNITS>( parent->GetUnitsSelection() ); ZOOM_CORRECTION_UNITS units = static_cast<ZOOM_CORRECTION_UNITS>( parent->GetUnitsSelection() );
double dpi = GetDPI().x; double dpi = ADVANCED_CFG::GetCfg().m_ScreenDPI;
double unitsPerInch = 25.4; double unitsPerInch = 25.4;
if( units == ZOOM_CORRECTION_UNITS::CM ) if( units == ZOOM_CORRECTION_UNITS::CM )
@ -222,6 +223,7 @@ int ZOOM_CORRECTION_CTRL::GetUnitsSelection() const
return m_unitsChoice->GetSelection(); return m_unitsChoice->GetSelection();
} }
bool ZOOM_CORRECTION_CTRL::TransferDataToWindow() bool ZOOM_CORRECTION_CTRL::TransferDataToWindow()
{ {
m_slider->SetValue( (int)( *m_value * 100 ) ); m_slider->SetValue( (int)( *m_value * 100 ) );

View File

@ -803,6 +803,18 @@ public:
*/ */
bool m_ImportSkipComponentBodies; 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. wxString m_traceMasks; ///< Trace masks for wxLogTrace, loaded from the config file.
///@} ///@}

View File

@ -644,6 +644,7 @@ public:
* For instance a typical notebook with HD+ resolution (1600x900) has 106 DPI. * For instance a typical notebook with HD+ resolution (1600x900) has 106 DPI.
*/ */
void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; } void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; }
double GetScreenDPI() const { return m_screenDPI; }
/** /**
* Get/set the Point in world space to look at. * Get/set the Point in world space to look at.

View File

@ -49,11 +49,11 @@ class ZOOM_CORRECTION_CTRL : public wxPanel
public: public:
ZOOM_CORRECTION_CTRL( wxWindow* aParent, double& aValue ); ZOOM_CORRECTION_CTRL( wxWindow* aParent, double& aValue );
void SetDisplayedValue( double aValue ); void SetDisplayedValue( double aValue );
double GetValue() const; double GetValue() const;
int GetUnitsSelection() const; int GetUnitsSelection() const;
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
private: private:
void sliderChanged( wxCommandEvent& aEvent ); void sliderChanged( wxCommandEvent& aEvent );