Improve layer pair icon drawing and update; generate more sizes.

This commit is contained in:
Alex Shvartzkop
2026-01-07 17:17:18 +05:00
parent b93d6d8ef1
commit 2dd484f034
4 changed files with 16 additions and 18 deletions
+8 -4
View File
@@ -74,8 +74,6 @@ void LAYER_PRESENTATION::DrawColorSwatch( wxBitmap& aLayerbmp, int aLayer ) cons
// Helper function to create a single bitmap at a specific size using vector graphics
static wxBitmap createLayerPairBitmapAtSize( const COLOR4D& aTopColor, const COLOR4D& aBottomColor, int aSize )
{
double scale = aSize / 24.0;
wxBitmap bitmap( aSize, aSize );
wxMemoryDC memDC;
memDC.SelectObject( bitmap );
@@ -116,12 +114,14 @@ static wxBitmap createLayerPairBitmapAtSize( const COLOR4D& aTopColor, const COL
gc->SetBrush( bottomBrush );
gc->DrawPath( bottomPath );
int lineScale = std::max( 1, wxRound( aSize / 24.0 ) );
// Draw separator line with white outline and black center
wxPen whiteLine( *wxWHITE, 3 * scale );
wxPen whiteLine( *wxWHITE, 3 * lineScale );
gc->SetPen( whiteLine );
gc->StrokeLine( sepTopX, sepTopY, sepBotX, sepBotY );
wxPen blackLine( *wxBLACK, 1 * scale );
wxPen blackLine( *wxBLACK, 1 * lineScale );
gc->SetPen( blackLine );
gc->StrokeLine( sepTopX, sepTopY, sepBotX, sepBotY );
@@ -137,7 +137,11 @@ wxBitmapBundle LAYER_PRESENTATION::CreateLayerPairIcon( const COLOR4D& aTopColor
wxVector<wxBitmap> bitmaps;
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize ) );
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize * 1.3334 ) );
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize * 1.5 ) );
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize * 2 ) );
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize * 2.6667 ) );
bitmaps.push_back( createLayerPairBitmapAtSize( aTopColor, aBottomColor, aDefSize * 3 ) );
return wxBitmapBundle::FromBitmaps( bitmaps );
}
+2
View File
@@ -2900,6 +2900,8 @@ void PCB_EDIT_FRAME::CommonSettingsChanged( int aFlags )
{
PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aFlags );
PrepareLayerIndicator();
GetAppearancePanel()->OnColorThemeChanged();
SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
+2 -2
View File
@@ -713,13 +713,13 @@ protected:
*/
struct LAYER_TOOLBAR_ICON_VALUES
{
int previous_requested_scale;
int previous_icon_size;
COLOR4D previous_Route_Layer_TOP_color;
COLOR4D previous_Route_Layer_BOTTOM_color;
COLOR4D previous_background_color;
LAYER_TOOLBAR_ICON_VALUES()
: previous_requested_scale( 0 ),
: previous_icon_size( 0 ),
previous_Route_Layer_TOP_color( COLOR4D::UNSPECIFIED ),
previous_Route_Layer_BOTTOM_color( COLOR4D::UNSPECIFIED ),
previous_background_color( COLOR4D::UNSPECIFIED )
+4 -12
View File
@@ -76,11 +76,11 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
COLOR4D top_color, bottom_color, background_color;
bool change = aForceRebuild;
int requested_scale = KiIconScale( this );
int icon_size = Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size;
if( m_prevIconVal.previous_requested_scale != requested_scale )
if( m_prevIconVal.previous_icon_size != icon_size )
{
m_prevIconVal.previous_requested_scale = requested_scale;
m_prevIconVal.previous_icon_size = icon_size;
change = true;
}
@@ -100,17 +100,9 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
change = true;
}
background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
if( m_prevIconVal.previous_background_color != background_color )
{
m_prevIconVal.previous_background_color = background_color;
change = true;
}
if( change || !LayerPairBitmap.IsOk() )
{
LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color );
LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color, icon_size );
if( m_tbTopAux )
{