Fields in symbols: Ensure visibility is correctly set when reading a file

Also ensure default fields visibility is correctly set when creating a symbol
Change default field visibility to true in SCH_FIELD Ctor

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17767
This commit is contained in:
jean-pierre charras 2024-04-15 18:19:19 +02:00
parent ac36feda41
commit b7f035964f
3 changed files with 16 additions and 1 deletions

View File

@ -112,6 +112,17 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB*
for( int i = 0; i < MANDATORY_FIELDS; i++ )
m_drawings[SCH_FIELD_T].push_back( new SCH_FIELD( this, i ) );
// Ensure reference and value fields are visible when creating a lib symbol
// whatever the SCH_FIELD Ctor default value is.
GetReferenceField().SetVisible( true );
GetValueField().SetVisible( true );
// Set visibilty to false for these other mandatory fields (at lest for now)
// whatever the SCH_FIELD Ctor default value is.
GetFootprintField().SetVisible( false );
GetDatasheetField().SetVisible( false );
GetDescriptionField().SetVisible( false );
SetName( aName );
if( aParent )

View File

@ -71,7 +71,7 @@ SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
SetTextPos( aPos );
SetId( aFieldId ); // will also set the layer
SetVisible( false );
SetVisible( true );
}

View File

@ -891,6 +891,10 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( aSymbol.get(),
MANDATORY_FIELDS );
// By default, fieds are visible.
// Invisible fields have the hide style or keyword specified in file
field->SetVisible( true );
T token = NextTok();
if( !IsSymbol( token ) )