From f75c72ebb547987ec856d8e9b58561dcf2f99db5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 13 Feb 2024 18:21:20 +0000 Subject: [PATCH] Use background color for checkerboard when not UNSPECIFIED. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16961 --- common/widgets/color_swatch.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index ac791e2f43..4f6d93a1fd 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -65,17 +65,35 @@ void COLOR_SWATCH::RenderToDC( wxDC* aDC, const KIGFX::COLOR4D& aColor, COLOR4D black; bool rowCycle; - if( aCheckerboardBackground.GetBrightness() > 0.4 ) + if( aColor == COLOR4D::UNSPECIFIED ) { - white = COLOR4D::WHITE; - black = white.Darkened( 0.15 ); - rowCycle = true; + if( aCheckerboardBackground.GetBrightness() > 0.4 ) + { + white = COLOR4D::WHITE; + black = white.Darkened( 0.15 ); + rowCycle = true; + } + else + { + black = COLOR4D::BLACK; + white = black.Brightened( 0.15 ); + rowCycle = false; + } } else { - black = COLOR4D::BLACK; - white = black.Brightened( 0.15 ); - rowCycle = false; + if( aBackground.GetBrightness() > 0.4 ) + { + white = aBackground; + black = white.Darkened( 0.15 ); + rowCycle = true; + } + else + { + black = COLOR4D::BLACK; + white = black.Brightened( 0.15 ); + rowCycle = false; + } } for( int x = aRect.GetLeft(); x <= aRect.GetRight(); x += aCheckerboardSize.x )