Add a quantized scaling mode for bitmaps.

125% scaled bitmaps look bad in the Launcher so we pin to 100%,
200%, 300%, etc.
This commit is contained in:
Jeff Young 2021-09-11 20:06:51 +01:00
parent 0a5bb093d0
commit 769ca2d255
3 changed files with 17 additions and 12 deletions

View File

@ -145,10 +145,13 @@ static int get_scale_factor( wxWindow* aWindow )
} }
wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight ) wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight, bool aQuantized )
{ {
// Bitmap conversions are cached because they can be slow. // Bitmap conversions are cached because they can be slow.
const int scale = get_scale_factor( aWindow ); int scale = get_scale_factor( aWindow );
if( aQuantized )
scale = KiROUND( (double) scale / 4.0 ) * 4;
SCALED_BITMAP_ID id = { static_cast<BITMAPS>( aBitmap ), scale }; SCALED_BITMAP_ID id = { static_cast<BITMAPS>( aBitmap ), scale };

View File

@ -75,8 +75,10 @@ void ClearScaledBitmapCache();
* @param aBitmap is from the BITMAPS enum in bitmaps_list.h * @param aBitmap is from the BITMAPS enum in bitmaps_list.h
* @param aWindow target window for scaling context * @param aWindow target window for scaling context
* @param aHeight is the requested image height for the source bitmap, or -1 for any height * @param aHeight is the requested image height for the source bitmap, or -1 for any height
* @param aQuantized if true scaling will be rounded to integers (2X, 3X, etc.).
*/ */
wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1 ); wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
bool aQuantized = false );
/** /**
* Overload of the above function that takes another wxBitmap as a parameter. * Overload of the above function that takes another wxBitmap as a parameter.

View File

@ -104,41 +104,41 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
}; };
addLauncher( KICAD_MANAGER_ACTIONS::editSchematic, addLauncher( KICAD_MANAGER_ACTIONS::editSchematic,
KiScaledBitmap( BITMAPS::icon_eeschema, this, 48 ), KiScaledBitmap( BITMAPS::icon_eeschema, this, 48, true ),
_( "Edit the project schematic" ) ); _( "Edit the project schematic" ) );
addLauncher( KICAD_MANAGER_ACTIONS::editSymbols, addLauncher( KICAD_MANAGER_ACTIONS::editSymbols,
KiScaledBitmap( BITMAPS::icon_libedit, this, 48 ), KiScaledBitmap( BITMAPS::icon_libedit, this, 48, true ),
_( "Edit global and/or project schematic symbol libraries" ) ); _( "Edit global and/or project schematic symbol libraries" ) );
addLauncher( KICAD_MANAGER_ACTIONS::editPCB, addLauncher( KICAD_MANAGER_ACTIONS::editPCB,
KiScaledBitmap( BITMAPS::icon_pcbnew, this, 48 ), KiScaledBitmap( BITMAPS::icon_pcbnew, this, 48, true ),
_( "Edit the project PCB design" ) ); _( "Edit the project PCB design" ) );
addLauncher( KICAD_MANAGER_ACTIONS::editFootprints, addLauncher( KICAD_MANAGER_ACTIONS::editFootprints,
KiScaledBitmap( BITMAPS::icon_modedit, this, 48 ), KiScaledBitmap( BITMAPS::icon_modedit, this, 48, true ),
_( "Edit global and/or project PCB footprint libraries" ) ); _( "Edit global and/or project PCB footprint libraries" ) );
addLauncher( KICAD_MANAGER_ACTIONS::viewGerbers, addLauncher( KICAD_MANAGER_ACTIONS::viewGerbers,
KiScaledBitmap( BITMAPS::icon_gerbview, this, 48 ), KiScaledBitmap( BITMAPS::icon_gerbview, this, 48, true ),
_( "Preview Gerber files" ) ); _( "Preview Gerber files" ) );
addLauncher( KICAD_MANAGER_ACTIONS::convertImage, addLauncher( KICAD_MANAGER_ACTIONS::convertImage,
KiScaledBitmap( BITMAPS::icon_bitmap2component, this, 48 ), KiScaledBitmap( BITMAPS::icon_bitmap2component, this, 48, true ),
_( "Convert bitmap images to schematic symbols or PCB footprints" ) ); _( "Convert bitmap images to schematic symbols or PCB footprints" ) );
addLauncher( KICAD_MANAGER_ACTIONS::showCalculator, addLauncher( KICAD_MANAGER_ACTIONS::showCalculator,
KiScaledBitmap( BITMAPS::icon_pcbcalculator, this, 48 ), KiScaledBitmap( BITMAPS::icon_pcbcalculator, this, 48, true ),
_( "Show tools for calculating resistance, current capacity, etc." ) ); _( "Show tools for calculating resistance, current capacity, etc." ) );
addLauncher( KICAD_MANAGER_ACTIONS::editDrawingSheet, addLauncher( KICAD_MANAGER_ACTIONS::editDrawingSheet,
KiScaledBitmap( BITMAPS::icon_pagelayout_editor, this, 48 ), KiScaledBitmap( BITMAPS::icon_pagelayout_editor, this, 48, true ),
_( "Edit drawing sheet borders and title blocks for use in schematics and PCB " _( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
"designs" ) ); "designs" ) );
#ifdef PCM #ifdef PCM
addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager, addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager,
KiScaledBitmap( BITMAPS::icon_pcm, this, 48 ), KiScaledBitmap( BITMAPS::icon_pcm, this, 48, true ),
_( "Manage downloadable packages from KiCad and 3rd party repositories" ) ); _( "Manage downloadable packages from KiCad and 3rd party repositories" ) );
#endif #endif