Eeschema: fix color issues in symbol body graphic items drawings.

- fix incorrect colors (outlines and filled shapes)
- fix issues in DIALOG_SHAPE_PROPERTIES (incorrect colors)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17799
This commit is contained in:
jean-pierre charras 2024-04-19 15:26:15 +02:00
parent 5f16c5892c
commit c04cd81231
5 changed files with 57 additions and 24 deletions

View File

@ -248,30 +248,30 @@ void DIALOG_SHAPE_PROPERTIES::onFillRadioButton( wxCommandEvent& event )
if( event.GetId() == NO_FILL ) if( event.GetId() == NO_FILL )
{ {
m_rbFillNone->SetValue( true ); m_rbFillNone->SetValue( true );
m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); m_customColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
} }
else if( event.GetId() == FILLED_SHAPE ) else if( event.GetId() == FILLED_SHAPE )
{ {
m_rbFillOutline->SetValue( true ); m_rbFillOutline->SetValue( true );
COLOR4D color = m_shape->GetStroke().GetColor(); COLOR4D color = m_borderColorSwatch->GetSwatchColor();
if( color == COLOR4D::UNSPECIFIED ) if( color == COLOR4D::UNSPECIFIED || !m_rbFillOutline->GetValue() )
color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE ); color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE );
m_fillColorSwatch->SetSwatchColor( color, false ); m_customColorSwatch->SetSwatchColor( color, false );
} }
else if( event.GetId() == FILLED_WITH_BG_BODYCOLOR ) else if( event.GetId() == FILLED_WITH_BG_BODYCOLOR )
{ {
m_rbFillBackground->SetValue( true ); m_rbFillBackground->SetValue( true );
COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND );
m_fillColorSwatch->SetSwatchColor( color, false ); m_customColorSwatch->SetSwatchColor( color, false );
} }
else if( event.GetId() == FILLED_WITH_COLOR ) else if( event.GetId() == FILLED_WITH_COLOR )
{ {
m_rbFillCustom->SetValue( true ); m_rbFillCustom->SetValue( true );
m_fillColorSwatch->GetNewSwatchColor(); m_customColorSwatch->GetNewSwatchColor();
} }
} }
@ -280,6 +280,19 @@ void DIALOG_SHAPE_PROPERTIES::onBorderSwatch( wxCommandEvent& aEvent )
{ {
if( m_rbFillOutline->GetValue() ) if( m_rbFillOutline->GetValue() )
m_fillColorSwatch->SetSwatchColor( m_borderColorSwatch->GetSwatchColor(), false ); m_fillColorSwatch->SetSwatchColor( m_borderColorSwatch->GetSwatchColor(), false );
if( m_rbFillOutline->IsEnabled() && m_rbFillOutline->GetValue() )
{
COLOR4D color = COLOR4D::UNSPECIFIED;
if( m_rbFillOutline->GetValue() )
color = m_fillColorSwatch->GetSwatchColor();
if( color == COLOR4D::UNSPECIFIED )
color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE );
m_customColorSwatch->SetSwatchColor( color, false );
}
} }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) // C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf02)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -16,9 +16,9 @@ BEGIN_EVENT_TABLE( DIALOG_SHAPE_PROPERTIES_BASE, DIALOG_SHIM )
EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked ) EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked )
EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillChecked ) EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillChecked )
EVT_RADIOBUTTON( NO_FILL, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton ) EVT_RADIOBUTTON( NO_FILL, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton )
EVT_RADIOBUTTON( FILLED_SHAPE, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) EVT_RADIOBUTTON( FILLED_SHAPE, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton )
EVT_RADIOBUTTON( FILLED_WITH_BG_BODYCOLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) EVT_RADIOBUTTON( FILLED_WITH_BG_BODYCOLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton )
EVT_RADIOBUTTON( FILLED_WITH_COLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) EVT_RADIOBUTTON( FILLED_WITH_COLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton )
END_EVENT_TABLE() END_EVENT_TABLE()
DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
@ -174,7 +174,7 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx
m_rbFillCustom = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, _("Fill with:"), wxDefaultPosition, wxDefaultSize, 0 ); m_rbFillCustom = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, _("Fill with:"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_rbFillCustom, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); gbSizer1->Add( m_rbFillCustom, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_customColorSwatch = new COLOR_SWATCH( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, wxDefaultPosition, wxDefaultSize, 0 ); m_customColorSwatch = new COLOR_SWATCH( bSizerFill->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_customColorSwatch, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); gbSizer1->Add( m_customColorSwatch, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );

View File

@ -1527,7 +1527,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnRadioButton">onFill</event> <event name="OnRadioButton">onFillRadioButton</event>
</object> </object>
</object> </object>
<object class="gbsizeritem" expanded="true"> <object class="gbsizeritem" expanded="true">
@ -1596,7 +1596,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnRadioButton">onFill</event> <event name="OnRadioButton">onFillRadioButton</event>
</object> </object>
</object> </object>
<object class="gbsizeritem" expanded="true"> <object class="gbsizeritem" expanded="true">
@ -1665,7 +1665,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnRadioButton">onFill</event> <event name="OnRadioButton">onFillRadioButton</event>
</object> </object>
</object> </object>
<object class="gbsizeritem" expanded="true"> <object class="gbsizeritem" expanded="true">
@ -1706,7 +1706,7 @@
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">FILLED_WITH_COLOR</property> <property name="id">wxID_ANY</property>
<property name="include"></property> <property name="include"></property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) // C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf02)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -47,7 +47,6 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM
void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); }
void _wxFB_onFillChecked( wxCommandEvent& event ){ onFillChecked( event ); } void _wxFB_onFillChecked( wxCommandEvent& event ){ onFillChecked( event ); }
void _wxFB_onFillRadioButton( wxCommandEvent& event ){ onFillRadioButton( event ); } void _wxFB_onFillRadioButton( wxCommandEvent& event ){ onFillRadioButton( event ); }
void _wxFB_onFill( wxCommandEvent& event ){ onFill( event ); }
protected: protected:
@ -97,7 +96,6 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM
virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); }
virtual void onFillChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onFillChecked( wxCommandEvent& event ) { event.Skip(); }
virtual void onFillRadioButton( wxCommandEvent& event ) { event.Skip(); } virtual void onFillRadioButton( wxCommandEvent& event ) { event.Skip(); }
virtual void onFill( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -315,10 +315,21 @@ float SCH_PAINTER::getShadowWidth( bool aForHighlight ) const
} }
// A helper function to know if a EDA_ITEM is a member of a footprint
static bool IsItemFPMember( const EDA_ITEM* aItem )
{
return aItem->GetParent() && ( aItem->GetParent()->Type() == LIB_SYMBOL_T
|| aItem->GetParent()->Type() == SCH_SYMBOL_T );
}
COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows, COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows,
bool aDimmed ) const bool aDimmed ) const
{ {
COLOR4D color = m_schSettings.GetLayerColor( aLayer ); COLOR4D color = m_schSettings.GetLayerColor( aLayer );
// Graphic items of a SYMBOL frequently use the LAYER_DEVICE layer color
// (i.e. when no specific color is set)
bool isFpMember = IsItemFPMember( aItem );
if( aItem->Type() == SCH_LINE_T ) if( aItem->Type() == SCH_LINE_T )
{ {
@ -348,14 +359,22 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem ); const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
color = shape->GetFillColor(); {
if( !isFpMember || shape->GetFillColor() != COLOR4D::UNSPECIFIED )
color = shape->GetFillColor();
if( isFpMember && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
color = shape->GetStroke().GetColor();
}
else else
color = shape->GetStroke().GetColor(); {
if( !isFpMember || shape->GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
color = shape->GetStroke().GetColor();
}
// A filled shape means filled; if they didn't specify a fill colour then use the // A filled shape means filled; if they didn't specify a fill colour then use the
// border colour. // border colour.
if( color == COLOR4D::UNSPECIFIED ) if( color == COLOR4D::UNSPECIFIED )
color = m_schSettings.GetLayerColor( LAYER_NOTES ); color = m_schSettings.GetLayerColor( isFpMember ? LAYER_DEVICE : LAYER_NOTES );
} }
else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) ) else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
{ {
@ -371,12 +390,13 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
color = textBox->GetFillColor(); color = textBox->GetFillColor();
else else if( !isFpMember || textBox->GetTextColor() != COLOR4D::UNSPECIFIED )
color = textBox->GetTextColor(); color = textBox->GetTextColor();
} }
else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) ) else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
{ {
color = otherTextItem->GetTextColor(); if( !isFpMember || otherTextItem->GetTextColor() != COLOR4D::UNSPECIFIED )
color = otherTextItem->GetTextColor();
} }
} }
@ -1679,7 +1699,9 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break; case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break; case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break; case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break;
case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break; case SCH_TEXT_T:
aLayer = IsItemFPMember( aText ) ? LAYER_DEVICE : LAYER_NOTES;
break;
default: aLayer = LAYER_NOTES; break; default: aLayer = LAYER_NOTES; break;
} }