Improve indicator icons in hidpi monitors.

This commit is contained in:
Alex Shvartzkop 2024-05-26 01:16:44 +03:00
parent f1aea810cb
commit 0b4ff7b859
6 changed files with 42 additions and 29 deletions

View File

@ -100,7 +100,8 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
{
DPI_SCALING_COMMON dpi( nullptr, m_frame );
int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x / dpi.GetContentScaleFactor();
const int c_indicatorSizeDIP = 10;
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
m_pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
@ -153,13 +154,13 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ),
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
if( screenHeight <= 900 && m_pointSize >= indicatorSize )
if( screenHeight <= 900 && m_pointSize >= FromDIP( c_indicatorSizeDIP ) )
m_pointSize = m_pointSize * 8 / 10;
m_cbLayerPresets->Bind( wxEVT_CHOICE, &APPEARANCE_CONTROLS_3D::onLayerPresetChanged, this );
m_toggleGridRenderer = new GRID_BITMAP_TOGGLE_RENDERER( KiBitmap( BITMAPS::visibility ),
KiBitmap( BITMAPS::visibility_off ) );
m_toggleGridRenderer = new GRID_BITMAP_TOGGLE_RENDERER(
KiBitmapBundle( BITMAPS::visibility ), KiBitmapBundle( BITMAPS::visibility_off ) );
m_frame->Bind( EDA_LANG_CHANGED, &APPEARANCE_CONTROLS_3D::OnLanguageChanged, this );
}
@ -521,10 +522,9 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers()
}
else
{
BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowLayers, layer,
KiBitmap( BITMAPS::visibility ),
KiBitmap( BITMAPS::visibility_off ),
aSetting->m_Visible );
BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE(
m_windowLayers, layer, KiBitmapBundle( BITMAPS::visibility ),
KiBitmapBundle( BITMAPS::visibility_off ), aSetting->m_Visible );
btn_visible->Bind( TOGGLE_CHANGED,
[this]( wxCommandEvent& aEvent )

View File

@ -175,7 +175,7 @@ public:
m_dlg( aParentDlg ),
m_preselect( aPreselect )
{
SetButtonBitmaps( KiBitmap( BITMAPS::small_library ) );
SetButtonBitmaps( KiBitmapBundle( BITMAPS::small_library ) );
// win32 fix, avoids drawing the "native dropdown caret"
Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
@ -239,7 +239,7 @@ public:
m_preselect( aPreselect ),
m_symbolNetlist( aSymbolNetlist.ToStdString() )
{
SetButtonBitmaps( KiBitmap( BITMAPS::small_library ) );
SetButtonBitmaps( KiBitmapBundle( BITMAPS::small_library ) );
// win32 fix, avoids drawing the "native dropdown caret"
Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
@ -321,7 +321,7 @@ public:
m_dlg( aParentDlg ),
m_searchStack( aSearchStack )
{
SetButtonBitmaps( KiBitmap( BITMAPS::www ) );
SetButtonBitmaps( KiBitmapBundle( BITMAPS::www ) );
// win32 fix, avoids drawing the "native dropdown caret"
Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
@ -380,7 +380,7 @@ public:
m_normalizeBasePath( aNormalizeBasePath ),
m_fileFilter( aFileFilter )
{
SetButtonBitmaps( KiBitmap( BITMAPS::small_folder ) );
SetButtonBitmaps( KiBitmapBundle( BITMAPS::small_folder ) );
// win32 fix, avoids drawing the "native dropdown caret"
Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
@ -400,7 +400,7 @@ public:
m_normalizeBasePath( aNormalizeBasePath ),
m_fileFilterFn( std::move( aFileFilterFn ) )
{
SetButtonBitmaps( KiBitmap( BITMAPS::small_folder ) );
SetButtonBitmaps( KiBitmapBundle( BITMAPS::small_folder ) );
// win32 fix, avoids drawing the "native dropdown caret"
Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );

View File

@ -92,7 +92,7 @@ wxImage createBlankImage( int size )
// Create an arrow icon of a particular size, colour and direction. 0 points up, 1 points
// right, and so forth.
wxBitmap createArrow( int size, int aDirection, wxColour aColour )
wxBitmap createArrow( int size, double aScaleFactor, int aDirection, wxColour aColour )
{
wxImage image = createBlankImage( size );
@ -117,12 +117,14 @@ wxBitmap createArrow( int size, int aDirection, wxColour aColour )
for( int i = 0; i < aDirection; ++i )
image = image.Rotate90();
return wxBitmap( image );
wxBitmap bmp( image );
bmp.SetScaleFactor( aScaleFactor );
return bmp;
}
// Create a diamond icon of a particular size and colour.
wxBitmap createDiamond( int size, wxColour aColour )
wxBitmap createDiamond( int size, double aScaleFactor, wxColour aColour )
{
wxImage image = createBlankImage( size );
@ -152,17 +154,29 @@ wxBitmap createDiamond( int size, wxColour aColour )
}
}
return wxBitmap( image );
wxBitmap bmp( image );
bmp.SetScaleFactor( aScaleFactor );
return bmp;
}
ROW_ICON_PROVIDER::ROW_ICON_PROVIDER( int aSize )
ROW_ICON_PROVIDER::ROW_ICON_PROVIDER( int aSizeDIP, wxWindow* aWindow )
{
m_blankBitmap = wxBitmap( createBlankImage( aSize ) );
m_rightArrowBitmap = createArrow( aSize, 1, wxColour( 64, 72, 255 ) );
m_upArrowBitmap = createArrow( aSize - 2, 0, wxSystemSettings().GetColour( wxSYS_COLOUR_3DDKSHADOW ) );
m_downArrowBitmap = createArrow( aSize - 2, 2, wxSystemSettings().GetColour( wxSYS_COLOUR_3DDKSHADOW ) );
m_dotBitmap = createDiamond( aSize, wxColour( 128, 144, 255 ) );
auto toPhys = [&]( int dip )
{
return aWindow->ToPhys( aWindow->FromDIP( dip ) );
};
double scale = aWindow->GetDPIScaleFactor();
wxColour shadowColor = wxSystemSettings().GetColour( wxSYS_COLOUR_3DDKSHADOW );
m_blankBitmap = wxBitmap( createBlankImage( toPhys( aSizeDIP ) ) );
m_blankBitmap.SetScaleFactor( scale );
m_rightArrowBitmap = createArrow( toPhys( aSizeDIP ), scale, 1, wxColour( 64, 72, 255 ) );
m_upArrowBitmap = createArrow( toPhys( aSizeDIP - 2 ), scale, 0, shadowColor );
m_downArrowBitmap = createArrow( toPhys( aSizeDIP - 2 ), scale, 2, shadowColor );
m_dotBitmap = createDiamond( toPhys( aSizeDIP ), scale, wxColour( 128, 144, 255 ) );
}

View File

@ -489,7 +489,7 @@ LAYER_WIDGET::LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, wxWindowID
m_smallestLayerString( wxT( "M...M" ) )
{
int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
m_IconProvider = new ROW_ICON_PROVIDER( indicatorSize );
m_IconProvider = new ROW_ICON_PROVIDER( indicatorSize, this );
int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );

View File

@ -142,7 +142,7 @@ public:
* @param aAlt false: normal icons (blue arrow/blank), true:
* alternative icons (blue arrow/green diamond)
*/
ROW_ICON_PROVIDER( int aSize );
ROW_ICON_PROVIDER( int aSizeDIP, wxWindow* aWindow );
///< @copydoc INDICATOR_ICON::ICON_PROVIDER::GetIndicatorIcon()
const wxBitmap& GetIndicatorIcon( INDICATOR_ICON::ICON_ID aIconId ) const override;

View File

@ -413,11 +413,10 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
// Correct the min size from wxformbuilder not using fromdip
SetMinSize( FromDIP( GetMinSize() ) );
DPI_SCALING_COMMON dpi( nullptr, m_frame );
const int c_indicatorSizeDIP = 10;
int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x / dpi.GetContentScaleFactor();
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
m_iconProvider = new ROW_ICON_PROVIDER( indicatorSize );
m_iconProvider = new ROW_ICON_PROVIDER( c_indicatorSizeDIP, this );
m_pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 );
@ -466,7 +465,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
m_txtNetFilter->SetHint( _( "Filter nets" ) );
if( screenHeight <= 900 && m_pointSize >= indicatorSize )
if( screenHeight <= 900 && m_pointSize >= FromDIP( c_indicatorSizeDIP ) )
m_pointSize = m_pointSize * 8 / 10;
wxFont font = m_notebook->GetFont();