From b7f035964fc8f4db6acb37dc3fe4718ed7b59169 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 15 Apr 2024 18:19:19 +0200 Subject: [PATCH] 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 --- eeschema/lib_symbol.cpp | 11 +++++++++++ eeschema/sch_field.cpp | 2 +- .../sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 508a989fd6..dbcc305acd 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -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 ) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 162498d387..2d701b2a29 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -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 ); } diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index 8be57134f2..e36613249b 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -891,6 +891,10 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr std::unique_ptr field = std::make_unique( 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 ) )