Draw x2 and x3 swatch bitmaps in layer selectors.

This commit is contained in:
Alex Shvartzkop 2024-05-23 05:09:35 +03:00
parent c2a80092d7
commit cd83666b72
2 changed files with 28 additions and 9 deletions

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2021 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2024 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -50,11 +50,21 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
if ( images.GetGbrImage( layerid ) == nullptr ) if ( images.GetGbrImage( layerid ) == nullptr )
continue; continue;
// Prepare Bitmap // Prepare Bitmaps
wxBitmap bmp( size, size ); wxVector<wxBitmap> bitmaps;
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
Append( getLayerName( layerid ), bmp, (void*)(intptr_t) layerid ); for( int scale = 1; scale <= 3; scale++ )
{
wxBitmap bmp( size * scale, size * scale );
bmp.SetScaleFactor( scale );
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
bitmaps.push_back( bmp );
}
Append( getLayerName( layerid ), wxBitmapBundle::FromBitmaps( bitmaps ),
(void*) (intptr_t) layerid );
} }
// Ensure the size of the widget is enough to show the text and the icon // Ensure the size of the widget is enough to show the text and the icon

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 1992-2015 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr> * Copyright (C) 1992-2015 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -58,8 +58,17 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
else else
layerstatus.Empty(); layerstatus.Empty();
wxBitmap bmp( size, size ); wxVector<wxBitmap> bitmaps;
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
for( int scale = 1; scale <= 3; scale++ )
{
wxBitmap bmp( size * scale, size * scale );
bmp.SetScaleFactor( scale );
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
bitmaps.push_back( bmp );
}
wxString layername = getLayerName( layerid ) + layerstatus; wxString layername = getLayerName( layerid ) + layerstatus;
@ -71,7 +80,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
layername = AddHotkeyName( layername, action->GetHotKey(), IS_COMMENT ); layername = AddHotkeyName( layername, action->GetHotKey(), IS_COMMENT );
} }
Append( layername, bmp, (void*)(intptr_t) layerid ); Append( layername, wxBitmapBundle::FromBitmaps( bitmaps ), (void*) (intptr_t) layerid );
} }
if( !m_undefinedLayerName.IsEmpty() ) if( !m_undefinedLayerName.IsEmpty() )