Fix accidental plotting of disabled textbox borders

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15252
This commit is contained in:
Marek Roszko 2023-08-24 21:00:19 -04:00
parent d193334a10
commit 339684263c
4 changed files with 36 additions and 15 deletions

View File

@ -196,7 +196,7 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow()
m_orientation.SetAngleValue( orientation.Normalize180() ); m_orientation.SetAngleValue( orientation.Normalize180() );
STROKE_PARAMS stroke = m_textBox->GetStroke(); STROKE_PARAMS stroke = m_textBox->GetStroke();
m_borderCheckbox->SetValue( stroke.GetWidth() >= 0 ); m_borderCheckbox->SetValue( m_textBox->IsBorderEnabled() );
if( stroke.GetWidth() >= 0 ) if( stroke.GetWidth() >= 0 )
m_borderWidth.SetValue( stroke.GetWidth() ); m_borderWidth.SetValue( stroke.GetWidth() );
@ -357,17 +357,13 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
m_textBox->SetMirrored( m_mirrored->IsChecked() ); m_textBox->SetMirrored( m_mirrored->IsChecked() );
STROKE_PARAMS stroke = m_textBox->GetStroke();
if( m_borderCheckbox->GetValue() ) if( m_borderCheckbox->GetValue() )
{ {
STROKE_PARAMS stroke = m_textBox->GetStroke();
if( !m_borderWidth.IsIndeterminate() ) if( !m_borderWidth.IsIndeterminate() )
stroke.SetWidth( m_borderWidth.GetValue() ); stroke.SetWidth( m_borderWidth.GetValue() );
}
else
{
stroke.SetWidth( -1 );
}
auto it = lineTypeNames.begin(); auto it = lineTypeNames.begin();
std::advance( it, m_borderStyleCombo->GetSelection() ); std::advance( it, m_borderStyleCombo->GetSelection() );
@ -378,6 +374,11 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
stroke.SetPlotStyle( it->first ); stroke.SetPlotStyle( it->first );
m_textBox->SetStroke( stroke ); m_textBox->SetStroke( stroke );
}
else
{
m_textBox->DisableBorder();
}
m_textBox->ClearBoundingBoxCache(); m_textBox->ClearBoundingBoxCache();
m_textBox->ClearRenderCache(); m_textBox->ClearRenderCache();

View File

@ -552,6 +552,18 @@ void PCB_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
} }
bool PCB_TEXTBOX::IsBorderEnabled() const
{
return m_stroke.GetWidth() != -1;
}
void PCB_TEXTBOX::DisableBorder()
{
m_stroke.SetWidth( -1 );
}
static struct PCB_TEXTBOX_DESC static struct PCB_TEXTBOX_DESC
{ {
PCB_TEXTBOX_DESC() PCB_TEXTBOX_DESC()

View File

@ -136,6 +136,12 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
///< Tests whether the border is disabled, as configured by the stroke
bool IsBorderEnabled() const;
///< Disables the border, this is done by changing the stroke internally
void DisableBorder();
protected: protected:
virtual void swapData( BOARD_ITEM* aImage ) override; virtual void swapData( BOARD_ITEM* aImage ) override;

View File

@ -359,6 +359,7 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item )
{ {
const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item ); const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() ); PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
if( textbox->IsBorderEnabled() )
PlotShape( textbox ); PlotShape( textbox );
break; break;
} }
@ -517,6 +518,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
{ {
PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
textbox->GetFontMetrics() ); textbox->GetFontMetrics() );
if( textbox->IsBorderEnabled() )
PlotShape( textbox ); PlotShape( textbox );
} }