diff --git a/pcbnew/dialogs/dialog_textbox_properties.cpp b/pcbnew/dialogs/dialog_textbox_properties.cpp index fe4ca782d2..451b8f0c6e 100644 --- a/pcbnew/dialogs/dialog_textbox_properties.cpp +++ b/pcbnew/dialogs/dialog_textbox_properties.cpp @@ -196,7 +196,7 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow() m_orientation.SetAngleValue( orientation.Normalize180() ); STROKE_PARAMS stroke = m_textBox->GetStroke(); - m_borderCheckbox->SetValue( stroke.GetWidth() >= 0 ); + m_borderCheckbox->SetValue( m_textBox->IsBorderEnabled() ); if( stroke.GetWidth() >= 0 ) m_borderWidth.SetValue( stroke.GetWidth() ); @@ -357,28 +357,29 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow() m_textBox->SetMirrored( m_mirrored->IsChecked() ); - STROKE_PARAMS stroke = m_textBox->GetStroke(); if( m_borderCheckbox->GetValue() ) { + STROKE_PARAMS stroke = m_textBox->GetStroke(); if( !m_borderWidth.IsIndeterminate() ) stroke.SetWidth( m_borderWidth.GetValue() ); + + + auto it = lineTypeNames.begin(); + std::advance( it, m_borderStyleCombo->GetSelection() ); + + if( it == lineTypeNames.end() ) + stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); + else + stroke.SetPlotStyle( it->first ); + + m_textBox->SetStroke( stroke ); } else { - stroke.SetWidth( -1 ); + m_textBox->DisableBorder(); } - auto it = lineTypeNames.begin(); - std::advance( it, m_borderStyleCombo->GetSelection() ); - - if( it == lineTypeNames.end() ) - stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); - else - stroke.SetPlotStyle( it->first ); - - m_textBox->SetStroke( stroke ); - m_textBox->ClearBoundingBoxCache(); m_textBox->ClearRenderCache(); diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index b83a5dfdb7..9b3e574cc6 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -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 { PCB_TEXTBOX_DESC() diff --git a/pcbnew/pcb_textbox.h b/pcbnew/pcb_textbox.h index d9a920f36c..65ac74807d 100644 --- a/pcbnew/pcb_textbox.h +++ b/pcbnew/pcb_textbox.h @@ -136,6 +136,12 @@ public: 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: virtual void swapData( BOARD_ITEM* aImage ) override; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index a1a11e9971..0932cd5ffc 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -359,7 +359,8 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item ) { const PCB_TEXTBOX* textbox = static_cast( item ); PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() ); - PlotShape( textbox ); + if( textbox->IsBorderEnabled() ) + PlotShape( textbox ); break; } @@ -517,7 +518,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) { PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() ); - PlotShape( textbox ); + if( textbox->IsBorderEnabled() ) + PlotShape( textbox ); } break;