CHANGED: Fields may now optionally display their name before their value
Fixes https://gitlab.com/kicad/code/kicad/-/issues/11457
This commit is contained in:
parent
ca5d95a62b
commit
4ea0a80df0
|
@ -331,6 +331,7 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow()
|
|||
}
|
||||
|
||||
m_visible->SetValue( m_isVisible );
|
||||
m_nameVisible->SetValue( m_isNameVisible );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -400,6 +401,7 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
|
|||
m_verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
|
||||
|
||||
m_isVisible = m_visible->GetValue();
|
||||
m_isNameVisible = m_nameVisible->GetValue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -424,6 +426,7 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
|||
DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField )
|
||||
{
|
||||
m_fieldId = aField->GetId();
|
||||
m_isNameVisible = aField->IsNameShown();
|
||||
|
||||
if( m_fieldId == VALUE_FIELD )
|
||||
m_text = UnescapeString( aField->GetText() );
|
||||
|
@ -449,6 +452,8 @@ void DIALOG_LIB_FIELD_PROPERTIES::UpdateField( LIB_FIELD* aField )
|
|||
|
||||
updateText( aField );
|
||||
|
||||
aField->SetNameShown( m_isNameVisible );
|
||||
|
||||
aField->SetHorizJustify( EDA_TEXT::MapHorizJustify( m_horizontalJustification ) );
|
||||
aField->SetVertJustify( EDA_TEXT::MapVertJustify( m_verticalJustification ) );
|
||||
aField->SetTextPos( m_position );
|
||||
|
@ -504,6 +509,8 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
|||
|
||||
m_position = m_field->GetPosition();
|
||||
|
||||
m_isNameVisible = m_field->IsNameShown();
|
||||
|
||||
m_horizontalJustification = m_field->GetEffectiveHorizJustify();
|
||||
m_verticalJustification = m_field->GetEffectiveVertJustify();
|
||||
|
||||
|
@ -664,6 +671,8 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH
|
|||
|
||||
aField->SetFont( m_font );
|
||||
|
||||
aField->SetNameShown( m_isNameVisible );
|
||||
|
||||
// Note that we must set justifications before we can ask if they're flipped. If the old
|
||||
// justification is center then it won't know (whereas if the new justification is center
|
||||
// the we don't care).
|
||||
|
|
|
@ -101,6 +101,7 @@ protected:
|
|||
GR_TEXT_V_ALIGN_T m_verticalJustification;
|
||||
GR_TEXT_H_ALIGN_T m_horizontalJustification;
|
||||
bool m_isVisible;
|
||||
bool m_isNameVisible;
|
||||
|
||||
bool m_firstFocus;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -82,11 +82,16 @@ DIALOG_FIELD_PROPERTIES_BASE::DIALOG_FIELD_PROPERTIES_BASE( wxWindow* parent, wx
|
|||
bPropertiesSizer->Add( bUpperBoxSizer, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer9;
|
||||
bSizer9 = new wxBoxSizer( wxVERTICAL );
|
||||
bSizer9 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_visible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer9->Add( m_visible, 0, wxALIGN_LEFT|wxBOTTOM, 2 );
|
||||
|
||||
m_nameVisible = new wxCheckBox( this, wxID_ANY, _("Show field name"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_nameVisible->SetToolTip( _("Show the field name in addtion to its value") );
|
||||
|
||||
bSizer9->Add( m_nameVisible, 0, wxLEFT, 5 );
|
||||
|
||||
|
||||
bPropertiesSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@
|
|||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer9</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">2</property>
|
||||
|
@ -496,6 +496,70 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Show field name</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_nameVisible</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Show the field name in addtion to its value</property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -52,6 +52,7 @@ class DIALOG_FIELD_PROPERTIES_BASE : public DIALOG_SHIM
|
|||
wxBitmapButton* m_TextValueSelectButton;
|
||||
wxStaticText* m_note;
|
||||
wxCheckBox* m_visible;
|
||||
wxCheckBox* m_nameVisible;
|
||||
wxStaticText* m_fontLabel;
|
||||
FONT_CHOICE* m_fontCtrl;
|
||||
BITMAP_BUTTON* m_separator1;
|
||||
|
|
|
@ -163,7 +163,10 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
|
|||
field.SetText( parentField->GetText() );
|
||||
|
||||
if( resetVis )
|
||||
{
|
||||
field.SetVisible( parentField->IsVisible() );
|
||||
field.SetNameShown( parentField->IsNameShown() );
|
||||
}
|
||||
|
||||
if( resetEffects )
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@ LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field )
|
|||
m_name = field.m_name;
|
||||
m_parent = field.m_parent;
|
||||
m_autoAdded = field.m_autoAdded;
|
||||
m_showName = field.m_showName;
|
||||
|
||||
SetText( field.GetText() );
|
||||
SetAttributes( field );
|
||||
|
@ -101,6 +102,7 @@ void LIB_FIELD::Init( int aId )
|
|||
SetVisible( false );
|
||||
|
||||
m_autoAdded = false;
|
||||
m_showName = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,6 +195,7 @@ EDA_ITEM* LIB_FIELD::Clone() const
|
|||
void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
|
||||
{
|
||||
aTarget->m_name = m_name;
|
||||
aTarget->m_showName = m_showName;
|
||||
|
||||
aTarget->CopyText( *this );
|
||||
aTarget->SetAttributes( *this );
|
||||
|
@ -368,6 +371,17 @@ wxString LIB_FIELD::GetFullText( int unit ) const
|
|||
}
|
||||
|
||||
|
||||
wxString LIB_FIELD::GetShownText( int aDepth ) const
|
||||
{
|
||||
wxString text = EDA_TEXT::GetShownText( aDepth );
|
||||
|
||||
if( IsNameShown() )
|
||||
text = GetName() << wxT( ": " ) << text;
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
const BOX2I LIB_FIELD::GetBoundingBox() const
|
||||
{
|
||||
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
|
||||
|
|
|
@ -148,6 +148,8 @@ public:
|
|||
*/
|
||||
wxString GetFullText( int unit = 1 ) const;
|
||||
|
||||
wxString GetShownText( int aDepth = 0 ) const override;
|
||||
|
||||
SCH_LAYER_ID GetDefaultLayer() const;
|
||||
|
||||
void BeginEdit( const VECTOR2I& aStartPoint ) override;
|
||||
|
@ -176,6 +178,9 @@ public:
|
|||
bool IsAutoAdded() const { return m_autoAdded; }
|
||||
void SetAutoAdded( bool aAutoAdded ) { m_autoAdded = aAutoAdded; }
|
||||
|
||||
bool IsNameShown() const { return m_showName; }
|
||||
void SetNameShown( bool aShown = true ) { m_showName = aShown; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -213,6 +218,7 @@ private:
|
|||
int m_id; ///< @see enum MANDATORY_FIELD_T
|
||||
wxString m_name; ///< Name (not the field text value itself, that is #EDA_TEXT::m_Text)
|
||||
bool m_autoAdded; ///< Was this field automatically added to a LIB_SYMBOL?
|
||||
bool m_showName; ///< Render the field's name in addition to its value
|
||||
};
|
||||
|
||||
#endif // CLASS_LIBENTRY_FIELDS_H
|
||||
|
|
|
@ -199,6 +199,9 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
|
|||
PROJECT* project = nullptr;
|
||||
wxString text = EDA_TEXT::GetShownText();
|
||||
|
||||
if( IsNameShown() )
|
||||
text = GetName() << wxT( ": " ) << text;
|
||||
|
||||
if( text == "~" ) // Legacy placeholder for empty string
|
||||
{
|
||||
text = "";
|
||||
|
@ -361,6 +364,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
|||
void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
|
||||
{
|
||||
SetAttributes( aSource );
|
||||
SetNameShown( aSource.IsNameShown() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,6 +376,7 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
|
|||
SCH_FIELD* item = (SCH_FIELD*) aItem;
|
||||
|
||||
std::swap( m_layer, item->m_layer );
|
||||
std::swap( m_showName, item->m_showName );
|
||||
SwapText( *item );
|
||||
SwapAttributes( *item );
|
||||
}
|
||||
|
|
|
@ -136,6 +136,9 @@ public:
|
|||
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const;
|
||||
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const;
|
||||
|
||||
bool IsNameShown() const { return m_showName; }
|
||||
void SetNameShown( bool aShown = true ) { m_showName = aShown; }
|
||||
|
||||
/**
|
||||
* @return true if the field is either empty or holds "~".
|
||||
*/
|
||||
|
@ -230,6 +233,8 @@ private:
|
|||
|
||||
wxString m_name;
|
||||
|
||||
bool m_showName; ///< Render the field name in addition to its value
|
||||
|
||||
mutable bool m_renderCacheValid;
|
||||
mutable VECTOR2I m_renderCachePos;
|
||||
mutable std::vector<std::unique_ptr<KIFONT::GLYPH>> m_renderCache;
|
||||
|
|
|
@ -893,7 +893,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
|
|||
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
||||
attrs.m_StrokeWidth = getTextThickness( aField );
|
||||
|
||||
strokeText( UnescapeString( aField->GetText() ), textpos, attrs );
|
||||
strokeText( UnescapeString( aField->GetShownText() ), textpos, attrs );
|
||||
}
|
||||
|
||||
// Draw the umbilical line when in the schematic editor
|
||||
|
|
|
@ -391,7 +391,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor
|
|||
if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
|
||||
fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), false );
|
||||
|
||||
aFormatter.Print( aNestLevel, "(property %s %s (id %d) (at %s %s %g)\n",
|
||||
aFormatter.Print( aNestLevel, "(property %s %s (id %d) (at %s %s %g)",
|
||||
aFormatter.Quotew( fieldName ).c_str(),
|
||||
aFormatter.Quotew( aField->GetText() ).c_str(),
|
||||
aField->GetId(),
|
||||
|
@ -399,8 +399,11 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor
|
|||
FormatInternalUnits( aField->GetPosition().y ).c_str(),
|
||||
aField->GetTextAngle().AsDegrees() );
|
||||
|
||||
if( aField->IsNameShown() )
|
||||
aFormatter.Print( aNestLevel, " (show_name)" );
|
||||
|
||||
aField->Format( &aFormatter, aNestLevel, 0 );
|
||||
aFormatter.Print( aNestLevel, ")\n" );
|
||||
aFormatter.Print( aNestLevel, "\n)\n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -795,8 +795,13 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
|
|||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ), field->GetId() == VALUE_FIELD );
|
||||
break;
|
||||
|
||||
case T_show_name:
|
||||
field->SetNameShown();
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
default:
|
||||
Expecting( "id, at or effects" );
|
||||
Expecting( "id, at, show_name, or effects" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1902,8 +1907,13 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
|||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ), field->GetId() == VALUE_FIELD );
|
||||
break;
|
||||
|
||||
case T_show_name:
|
||||
field->SetNameShown();
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
default:
|
||||
Expecting( "at or effects" );
|
||||
Expecting( "id, show_name, at or effects" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -813,6 +813,9 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel )
|
|||
FormatInternalUnits( aField->GetPosition().y ).c_str(),
|
||||
EDA_UNIT_UTILS::FormatAngle( aField->GetTextAngle() ).c_str() );
|
||||
|
||||
if( aField->IsNameShown() )
|
||||
m_out->Print( aNestLevel, " (show_name)" );
|
||||
|
||||
if( !aField->IsDefaultFormatting()
|
||||
|| ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
|
||||
{
|
||||
|
|
|
@ -114,6 +114,7 @@ scale
|
|||
shape
|
||||
sheet
|
||||
sheet_instances
|
||||
show_name
|
||||
size
|
||||
start
|
||||
stroke
|
||||
|
|
Loading…
Reference in New Issue