From 3cb7ca1db43d78d82567c6a65259564a5aad0859 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 9 Dec 2021 18:36:44 -0500 Subject: [PATCH] Remove manual canvas scale from GTK Fixes https://gitlab.com/kicad/code/kicad/-/issues/9912 --- common/advanced_config.cpp | 7 +++ common/dialogs/panel_common_settings.cpp | 62 ++++++++++++------------ common/settings/common_settings.cpp | 9 +--- include/advanced_config.h | 2 + 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index fca3fbda82..362d03fb14 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -181,6 +181,8 @@ static const wxChar ShowRepairSchematic[] = wxT( "ShowRepairSchematic" ); static const wxChar ShowEventCounters[] = wxT( "ShowEventCounters" ); +static const wxChar AllowManualCanvasScale[] = wxT( "AllowManualCanvasScale" ); + } // namespace KEYS @@ -288,6 +290,7 @@ ADVANCED_CFG::ADVANCED_CFG() m_Skip3DModelMemoryCache = false; m_HideVersionFromTitle = false; m_ShowEventCounters = false; + m_AllowManualCanvasScale = false; loadFromConfigFile(); } @@ -406,6 +409,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ShowEventCounters, &m_ShowEventCounters, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::AllowManualCanvasScale, + &m_AllowManualCanvasScale, false ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config wxString traceMasks = ""; @@ -416,6 +422,7 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) // Now actually set the trace masks wxStringTokenizer traceMaskTokenizer( traceMasks, "," ); + while( traceMaskTokenizer.HasMoreTokens() ) { wxString mask = traceMaskTokenizer.GetNextToken(); diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index 7259c875e3..30f532ea53 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -95,40 +95,42 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aP #endif /* - * Automatic canvas scaling works fine on Mac and MSW, and on GTK under wxWidgets 3.1 or - * better. + * Automatic canvas scaling works fine on all supported platforms, so manual scaling is disabled */ -#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 ) - static constexpr int dpi_scaling_precision = 1; - static constexpr double dpi_scaling_increment = 0.5; + if( ADVANCED_CFG::GetCfg().m_AllowManualCanvasScale ) + { + static constexpr int dpi_scaling_precision = 1; + static constexpr double dpi_scaling_increment = 0.5; - m_canvasScaleCtrl->SetRange( DPI_SCALING::GetMinScaleFactor(), - DPI_SCALING::GetMaxScaleFactor() ); - m_canvasScaleCtrl->SetDigits( dpi_scaling_precision ); - m_canvasScaleCtrl->SetIncrement( dpi_scaling_increment ); - m_canvasScaleCtrl->SetValue( DPI_SCALING::GetDefaultScaleFactor() ); + m_canvasScaleCtrl->SetRange( DPI_SCALING::GetMinScaleFactor(), + DPI_SCALING::GetMaxScaleFactor() ); + m_canvasScaleCtrl->SetDigits( dpi_scaling_precision ); + m_canvasScaleCtrl->SetIncrement( dpi_scaling_increment ); + m_canvasScaleCtrl->SetValue( DPI_SCALING::GetDefaultScaleFactor() ); - m_canvasScaleCtrl->SetToolTip( - _( "Set the scale for the canvas." - "\n\n" - "On high-DPI displays on some platforms, KiCad cannot determine the " - "scaling factor. In this case you may need to set this to a value to " - "match your system's DPI scaling. 2.0 is a common value. " - "\n\n" - "If this does not match the system DPI scaling, the canvas will " - "not match the window size and cursor position." ) ); + m_canvasScaleCtrl->SetToolTip( + _( "Set the scale for the canvas." + "\n\n" + "On high-DPI displays on some platforms, KiCad cannot determine the " + "scaling factor. In this case you may need to set this to a value to " + "match your system's DPI scaling. 2.0 is a common value. " + "\n\n" + "If this does not match the system DPI scaling, the canvas will " + "not match the window size and cursor position." ) ); - m_canvasScaleAuto->SetToolTip( - _( "Use an automatic value for the canvas scale." - "\n\n" - "On some platforms, the automatic value is incorrect and should be " - "set manually." ) ); -#else - m_staticTextCanvasScale->Show( false ); - m_canvasScaleCtrl->Show( false ); - m_canvasScaleCtrl = nullptr; - m_canvasScaleAuto->Show( false ); -#endif + m_canvasScaleAuto->SetToolTip( + _( "Use an automatic value for the canvas scale." + "\n\n" + "On some platforms, the automatic value is incorrect and should be " + "set manually." ) ); + } + else + { + m_staticTextCanvasScale->Show( false ); + m_canvasScaleCtrl->Show( false ); + m_canvasScaleCtrl = nullptr; + m_canvasScaleAuto->Show( false ); + } /* * Font scaling hacks are only needed on GTK under wxWidgets 3.0. diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index 468587affa..2df21f51f8 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -77,15 +77,10 @@ COMMON_SETTINGS::COMMON_SETTINGS() : #endif /* - * Automatic canvas scaling works fine on Mac and MSW, and on GTK under wxWidgets 3.1 or - * better. + * Automatic canvas scaling works fine on all supported platforms, so it's no longer exposed as + * a configuration option. */ -#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 ) - m_params.emplace_back( new PARAM( "appearance.canvas_scale", - &m_Appearance.canvas_scale, 1.0 ) ); -#else m_Appearance.canvas_scale = 0.0; -#endif /* * Menu icons are off by default on OSX and on for all other platforms. diff --git a/include/advanced_config.h b/include/advanced_config.h index ba8e500a18..6a32a41e63 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -202,6 +202,8 @@ public: */ bool m_ShowEventCounters; + bool m_AllowManualCanvasScale; + private: ADVANCED_CFG();