diff --git a/common/properties/pg_cell_renderer.cpp b/common/properties/pg_cell_renderer.cpp index bbc31de69d..58b59a3f6f 100644 --- a/common/properties/pg_cell_renderer.cpp +++ b/common/properties/pg_cell_renderer.cpp @@ -41,19 +41,14 @@ bool PG_CELL_RENDERER::Render( wxDC &aDC, const wxRect &aRect, const wxPropertyG wxAny av = colorProp->GetValue().GetAny(); KIGFX::COLOR4D color = av.IsNull() ? KIGFX::COLOR4D::UNSPECIFIED : av.As(); - KIGFX::COLOR4D background; - - PreDrawCell( aDC, aRect, aGrid, cell, aFlags ); wxSize swatchSize = aGrid->ConvertDialogToPixels( wxSize( 24, 16 ) ); int offset = ( aRect.GetHeight() - swatchSize.GetHeight() ) / 2; wxRect swatch( aRect.GetPosition() + wxPoint( offset, offset ), swatchSize ); - COLOR_SWATCH::RenderToDC( &aDC, color, background, swatch, + COLOR_SWATCH::RenderToDC( &aDC, color, colorProp->GetBackgroundColor(), swatch, aGrid->ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ), - aGrid->GetParent()->GetBackgroundColour() ); - - PostDrawCell( aDC, aGrid, cell, aFlags ); + aGrid->GetBackgroundColour() ); return true; } diff --git a/common/properties/pg_properties.cpp b/common/properties/pg_properties.cpp index 3c3ae47f57..e0bc1ee6dc 100644 --- a/common/properties/pg_properties.cpp +++ b/common/properties/pg_properties.cpp @@ -406,8 +406,9 @@ const wxPGEditor* PGPROPERTY_BOOL::DoGetEditorClass() const PGPROPERTY_COLOR4D::PGPROPERTY_COLOR4D( const wxString& aLabel, const wxString& aName, - COLOR4D aValue ) : - wxStringProperty( aLabel, aName, aValue.ToCSSString() ) + COLOR4D aValue, COLOR4D aBackgroundColor ) : + wxStringProperty( aLabel, aName, aValue.ToCSSString() ), + m_backgroundColor( aBackgroundColor ) { SetEditor( PG_COLOR_EDITOR::EDITOR_NAME ); SetFlag( wxPG_PROP_NOEDITOR ); diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 87ddae63b1..38dd17572e 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -82,11 +82,11 @@ void COLOR_SWATCH::RenderToDC( wxDC* aDC, const KIGFX::COLOR4D& aColor, rowCycle = false; } - for( int x = aRect.GetTop(); x < aRect.GetBottom(); x += aCheckerboardSize.x ) + for( int x = aRect.GetLeft(); x < aRect.GetRight(); x += aCheckerboardSize.x ) { bool colCycle = rowCycle; - for( int y = aRect.GetLeft(); y < aRect.GetRight(); y += aCheckerboardSize.y ) + for( int y = aRect.GetTop(); y < aRect.GetBottom(); y += aCheckerboardSize.y ) { COLOR4D color = colCycle ? black : white; brush.SetColour( color.ToColour() ); @@ -94,7 +94,7 @@ void COLOR_SWATCH::RenderToDC( wxDC* aDC, const KIGFX::COLOR4D& aColor, aDC->SetBrush( brush ); aDC->SetPen( pen ); - aDC->DrawRectangle( x, y, x + aCheckerboardSize.x, y + aCheckerboardSize.y ); + aDC->DrawRectangle( x, y, aCheckerboardSize.x, aCheckerboardSize.y ); colCycle = !colCycle; } diff --git a/eeschema/widgets/sch_properties_panel.cpp b/eeschema/widgets/sch_properties_panel.cpp index 3b96d3dad2..96d8b5690c 100644 --- a/eeschema/widgets/sch_properties_panel.cpp +++ b/eeschema/widgets/sch_properties_panel.cpp @@ -124,7 +124,15 @@ void SCH_PROPERTIES_PANEL::AfterCommit() wxPGProperty* SCH_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProperty ) const { - return PGPropertyFactory( aProperty, m_frame ); + wxPGProperty* prop = PGPropertyFactory( aProperty, m_frame ); + + if( auto colorProp = dynamic_cast( prop ) ) + { + COLOR4D bg = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); + colorProp->SetBackgroundColor( bg ); + } + + return prop; } diff --git a/include/properties/pg_properties.h b/include/properties/pg_properties.h index c9b3270649..e6766c9afd 100644 --- a/include/properties/pg_properties.h +++ b/include/properties/pg_properties.h @@ -194,7 +194,8 @@ class PGPROPERTY_COLOR4D : public wxStringProperty { public: PGPROPERTY_COLOR4D( const wxString& aLabel = wxPG_LABEL, const wxString& aName = wxPG_LABEL, - KIGFX::COLOR4D aValue = KIGFX::COLOR4D::UNSPECIFIED ); + KIGFX::COLOR4D aValue = KIGFX::COLOR4D::UNSPECIFIED, + KIGFX::COLOR4D aBackground = KIGFX::COLOR4D::UNSPECIFIED ); virtual ~PGPROPERTY_COLOR4D() = default; @@ -202,6 +203,13 @@ public: bool StringToValue( wxVariant &aVariant, const wxString &aText, int aFlags = 0 ) const override; + + void SetBackgroundColor( const KIGFX::COLOR4D& aColor ) { m_backgroundColor = aColor; } + const KIGFX::COLOR4D& GetBackgroundColor() const { return m_backgroundColor; } + + private: + /// Used for rendering colors with opacity + KIGFX::COLOR4D m_backgroundColor; }; #endif /* PG_PROPERTIES_H */