REMOVED: manual icon scale preference

This is now handled properly by wxWidgets on all platforms

See https://gitlab.com/kicad/code/kicad/-/issues/14119
This commit is contained in:
Jon Evans 2023-10-21 15:30:56 -04:00
parent e2cc678231
commit 50fe585827
8 changed files with 7 additions and 195 deletions

View File

@ -144,21 +144,10 @@ int KiIconScale( wxWindow* aWindow )
}
static int get_scale_factor( wxWindow* aWindow )
{
int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
if( requested_scale > 0 )
return requested_scale;
else
return KiIconScale( aWindow );
}
wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight, bool aQuantized )
{
// Bitmap conversions are cached because they can be slow.
int scale = get_scale_factor( aWindow );
int scale = KiIconScale( aWindow );
if( aQuantized )
scale = KiROUND( (double) scale / 4.0 ) * 4;
@ -189,7 +178,7 @@ void ClearScaledBitmapCache()
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow )
{
const int scale = get_scale_factor( aWindow );
const int scale = KiIconScale( aWindow );
if( scale == 4 )
{

View File

@ -45,11 +45,7 @@
*/
PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( wxWindow* aParent )
: PANEL_COMMON_SETTINGS_BASE( aParent ),
m_iconScaleLabel( nullptr ),
m_iconScaleSlider( nullptr ),
m_iconScaleAuto( nullptr ),
m_last_scale( -1 )
: PANEL_COMMON_SETTINGS_BASE( aParent )
{
/*
* Cairo canvas doesn't work on Mac, so no need for fallback anti-aliasing options
@ -72,31 +68,6 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( wxWindow* aParent )
m_rbIconThemeAuto->Show( false );
#endif
/*
* Automatic icon scaling works fine on Mac. It works mostly fine on MSW, but perhaps not
* uniformly enough to exclude the explicit controls there.
*/
#if defined( __WXGTK__ ) || defined( __WXMSW__ )
// Sadly wxSlider is poorly implemented and adds its legends as sibling windows (so that
// showing/hiding the control doesn't work). So we have to create it conditionally.
wxGridBagSizer* gb = m_gbUserInterface;
const int row_num = 0;
m_iconScaleLabel = new wxStaticText( this, wxID_ANY, _( "Icon scale:" ) );
m_iconScaleLabel->Wrap( -1 );
gb->Add( m_iconScaleLabel, wxGBPosition( row_num, 0 ),
wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_iconScaleSlider = new STEPPED_SLIDER( this, wxID_ANY, 100, 50, 275, wxDefaultPosition,
wxDefaultSize, wxSL_HORIZONTAL|wxSL_VALUE_LABEL );
m_iconScaleSlider->SetStep( 25 );
gb->Add( m_iconScaleSlider, wxGBPosition( row_num, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxBOTTOM, 5 );
m_iconScaleAuto = new wxCheckBox( this, wxID_ANY, _( "Automatic" ) );
gb->Add( m_iconScaleAuto, wxGBPosition( row_num, 2 ),
wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 15 );
#endif
/*
* Automatic canvas scaling works fine on all supported platforms, so manual scaling is disabled
*/
@ -141,40 +112,6 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( wxWindow* aParent )
m_scaleFonts->Show( false );
m_fontScalingHelp->Show( false );
if( m_iconScaleSlider )
{
m_iconScaleSlider->Connect( wxEVT_SCROLL_TOP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_BOTTOM,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_LINEUP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_LINEDOWN,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_PAGEUP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_PAGEDOWN,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBTRACK,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBRELEASE,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Connect( wxEVT_SCROLL_CHANGED,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleAuto->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED,
wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnIconScaleAuto ),
nullptr, this );
}
if( m_canvasScaleCtrl )
{
m_canvasScaleCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
@ -191,40 +128,6 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( wxWindow* aParent )
PANEL_COMMON_SETTINGS::~PANEL_COMMON_SETTINGS()
{
if( m_iconScaleSlider )
{
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_TOP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_BOTTOM,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_LINEUP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_LINEDOWN,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_PAGEUP,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_PAGEDOWN,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_THUMBTRACK,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_THUMBRELEASE,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleSlider->Disconnect( wxEVT_SCROLL_CHANGED,
wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ),
nullptr, this );
m_iconScaleAuto->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED,
wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnIconScaleAuto ),
nullptr, this );
}
if( m_canvasScaleCtrl )
{
m_canvasScaleCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
@ -262,12 +165,6 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
commonSettings->m_Graphics.opengl_aa_mode = m_antialiasing->GetSelection();
commonSettings->m_Graphics.cairo_aa_mode = m_antialiasingFallback->GetSelection();
if( m_iconScaleSlider )
{
int scale_fourths = m_iconScaleAuto->GetValue() ? -1 : m_iconScaleSlider->GetValue() / 25;
commonSettings->m_Appearance.icon_scale = scale_fourths;
}
if( m_canvasScaleCtrl )
{
DPI_SCALING_COMMON dpi( commonSettings, this );
@ -348,22 +245,6 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings )
m_Clear3DCacheFilesOlder->SetValue( aSettings.m_System.clear_3d_cache_interval );
if( m_iconScaleSlider )
{
int icon_scale_fourths = aSettings.m_Appearance.icon_scale;
if( icon_scale_fourths <= 0 )
{
m_iconScaleAuto->SetValue( true );
m_iconScaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
}
else
{
m_iconScaleAuto->SetValue( false );
m_iconScaleSlider->SetValue( icon_scale_fourths * 25 );
}
}
if( m_canvasScaleCtrl )
{
const DPI_SCALING_COMMON dpi( &aSettings, this );
@ -402,31 +283,6 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings )
}
void PANEL_COMMON_SETTINGS::OnScaleSlider( wxScrollEvent& aEvent )
{
m_iconScaleAuto->SetValue( false );
aEvent.Skip();
}
void PANEL_COMMON_SETTINGS::OnIconScaleAuto( wxCommandEvent& aEvent )
{
if( m_iconScaleSlider )
{
if( m_iconScaleAuto->GetValue() )
{
m_last_scale = m_iconScaleAuto->GetValue();
m_iconScaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
}
else
{
if( m_last_scale >= 0 )
m_iconScaleSlider->SetValue( m_last_scale );
}
}
}
void PANEL_COMMON_SETTINGS::OnCanvasScaleChange( wxCommandEvent& aEvent )
{
m_canvasScaleAuto->SetValue( false );

View File

@ -71,17 +71,6 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
m_Appearance.icon_theme = ICON_THEME::AUTO;
#endif
/*
* Automatic icon scaling works fine on Mac. It works mostly fine on MSW, but perhaps not
* uniformly enough to exclude the explicit controls there.
*/
#if defined( __WXGTK__ ) || defined( __WXMSW__ )
m_params.emplace_back( new PARAM<int>( "appearance.icon_scale",
&m_Appearance.icon_scale, 0 ) );
#else
m_Appearance.icon_scale = 0.0;
#endif
/*
* Automatic canvas scaling works fine on all supported platforms, so it's no longer exposed as
* a configuration option.

View File

@ -248,10 +248,7 @@ void ACTION_TOOLBAR::AddButton( const TOOL_ACTION& aAction )
void ACTION_TOOLBAR::AddScaledSeparator( wxWindow* aWindow )
{
int scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
if( scale == 0 )
scale = KiIconScale( aWindow );
int scale = KiIconScale( aWindow );
if( scale > 4 )
AddSpacer( 16 * ( scale - 4 ) / 4 );

View File

@ -109,16 +109,7 @@ wxFont getGUIFont( wxWindow* aWindow, int aRelativeSize )
font.SetPointSize( font.GetPointSize() + aRelativeSize );
if( Pgm().GetCommonSettings()->m_Appearance.apply_icon_scale_to_fonts )
{
double icon_scale_fourths;
if( Pgm().GetCommonSettings()->m_Appearance.icon_scale <= 0 )
icon_scale_fourths = KiIconScale( aWindow );
else
icon_scale_fourths = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
font.SetPointSize( KiROUND( icon_scale_fourths * font.GetPointSize() / 4.0 ) );
}
font.SetPointSize( KiROUND( KiIconScale( aWindow ) * font.GetPointSize() / 4.0 ) );
#ifdef __WXMAC__
// https://trac.wxwidgets.org/ticket/19210
@ -422,4 +413,4 @@ wxMenuItem* KIUI::AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const w
aMenu->Append( item );
return item;
}
}

View File

@ -46,8 +46,6 @@ protected:
void applySettingsToPanel( COMMON_SETTINGS& aSettings );
void OnScaleSlider( wxScrollEvent& aEvent );
void OnIconScaleAuto( wxCommandEvent& aEvent );
void OnTextEditorClick( wxCommandEvent& event ) override;
void OnPDFViewerClick( wxCommandEvent& event ) override;
void OnRadioButtonPdfViewer( wxCommandEvent& event ) override;
@ -64,13 +62,6 @@ protected:
private:
void setPdfViewerPathState();
protected:
wxStaticText* m_iconScaleLabel;
STEPPED_SLIDER* m_iconScaleSlider;
wxCheckBox* m_iconScaleAuto;
int m_last_scale; ///< saved icon scale when Auto selected
};
#endif //KICAD_DIALOG_SUITE_OPTIONS_H

View File

@ -51,7 +51,6 @@ public:
{
bool show_scrollbars;
double canvas_scale;
int icon_scale;
ICON_THEME icon_theme;
bool use_icons_in_menus;
bool apply_icon_scale_to_fonts;

View File

@ -103,7 +103,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
COLOR4D top_color, bottom_color, background_color;
bool change = aForceRebuild;
int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
int requested_scale = KiIconScale( this );
if( m_prevIconVal.previous_requested_scale != requested_scale )
{