Don't update text items until modified explicitly

Ensures that any complex formatting in text items created by importers
or pasted S-expressions is preserved.
This commit is contained in:
Roberto Fernandez Bautista 2021-09-03 19:25:23 +01:00
parent 36449cc5da
commit a06f3f1d14
3 changed files with 17 additions and 7 deletions

View File

@ -280,7 +280,10 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
void DIALOG_FIELD_PROPERTIES::updateText( EDA_TEXT* aText )
{
aText->SetTextPos( m_position );
aText->SetTextSize( wxSize( m_size, m_size ) );
if( aText->GetTextWidth() != m_size )
aText->SetTextSize( wxSize( m_size, m_size ) );
aText->SetVisible( m_isVisible );
aText->SetTextAngle( m_isVertical ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ );
aText->SetItalic( m_isItalic );

View File

@ -121,7 +121,9 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
m_graphicText->SetText( m_TextCtrl->GetValue() );
m_graphicText->SetPosition( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) );
m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
if( m_textSize.GetValue() != m_graphicText->GetTextWidth() )
m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
m_graphicText->SetTextAngle( m_orientChoice->GetSelection() ? TEXT_ANGLE_VERT
: TEXT_ANGLE_HORIZ );

View File

@ -350,9 +350,14 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
return false;
}
m_CurrentText->SetLabelSpinStyle( (LABEL_SPIN_STYLE::SPIN) m_TextOrient->GetSelection() );
LABEL_SPIN_STYLE selectedSpinStyle(
static_cast<LABEL_SPIN_STYLE::SPIN>( m_TextOrient->GetSelection() ) );
m_CurrentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
if( m_CurrentText->GetLabelSpinStyle() != selectedSpinStyle )
m_CurrentText->SetLabelSpinStyle( selectedSpinStyle );
if( m_CurrentText->GetTextWidth() != m_textSize.GetValue() )
m_CurrentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
if( m_TextShape )
m_CurrentText->SetShape( (PINSHEETLABEL_SHAPE) m_TextShape->GetSelection() );
@ -361,15 +366,15 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
m_CurrentText->SetItalic( ( style & 1 ) );
if( ( style & 2 ) )
if( ( style & 2 ) && !m_CurrentText->IsBold() )
{
m_CurrentText->SetBold( true );
m_CurrentText->SetTextThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
}
else
else if( m_CurrentText->IsBold() )
{
m_CurrentText->SetBold( false );
m_CurrentText->SetTextThickness( 0 ); // Use default pen width
m_CurrentText->SetTextThickness( 0 ); // Use default pen width
}
m_Parent->UpdateItem( m_CurrentText );