Add an explicit border property to textboxes
This means it can remember the last border stroke between enabling/disabling the border
This commit is contained in:
parent
87513b4a04
commit
2dcb7caacf
|
@ -54,6 +54,7 @@ blind
|
|||
blind_buried_vias_allowed
|
||||
board_only
|
||||
bold
|
||||
border
|
||||
bottom
|
||||
bottom_left
|
||||
bottom_right
|
||||
|
|
|
@ -357,28 +357,21 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
|
|||
|
||||
m_textBox->SetMirrored( m_mirrored->IsChecked() );
|
||||
|
||||
|
||||
if( m_borderCheckbox->GetValue() )
|
||||
{
|
||||
STROKE_PARAMS stroke = m_textBox->GetStroke();
|
||||
if( !m_borderWidth.IsIndeterminate() )
|
||||
stroke.SetWidth( m_borderWidth.GetValue() );
|
||||
m_textBox->SetBorderEnabled( 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() );
|
||||
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 );
|
||||
}
|
||||
if( it == lineTypeNames.end() )
|
||||
stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT );
|
||||
else
|
||||
{
|
||||
m_textBox->DisableBorder();
|
||||
}
|
||||
stroke.SetPlotStyle( it->first );
|
||||
|
||||
m_textBox->SetStroke( stroke );
|
||||
|
||||
m_textBox->ClearBoundingBoxCache();
|
||||
m_textBox->ClearRenderCache();
|
||||
|
|
|
@ -2151,7 +2151,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
|||
|
||||
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
{
|
||||
if( thickness > 0 )
|
||||
if( aTextBox->IsBorderEnabled() && thickness > 0 )
|
||||
{
|
||||
std::vector<VECTOR2I> pts = aTextBox->GetCorners();
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
|
||||
PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* parent ) :
|
||||
PCB_SHAPE( parent, PCB_TEXTBOX_T, SHAPE_T::RECTANGLE ),
|
||||
EDA_TEXT( pcbIUScale )
|
||||
EDA_TEXT( pcbIUScale ),
|
||||
m_borderEnabled( true )
|
||||
{
|
||||
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
|
@ -522,7 +523,7 @@ void PCB_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
|
|||
for( const VECTOR2I& pt : pts )
|
||||
aBuffer.Append( pt );
|
||||
|
||||
if( width > 0 )
|
||||
if( m_borderEnabled && width > 0 )
|
||||
{
|
||||
// Add in segments
|
||||
TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aMaxError, aErrorLoc );
|
||||
|
@ -540,7 +541,7 @@ void PCB_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
|
|||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
aBuffer.Append( poly.GetPoint( ii ) );
|
||||
|
||||
if( width > 0 )
|
||||
if( m_borderEnabled && width > 0 )
|
||||
{
|
||||
for( int ii = 0; ii < poly.SegmentCount(); ++ii )
|
||||
{
|
||||
|
@ -554,13 +555,13 @@ void PCB_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
|
|||
|
||||
bool PCB_TEXTBOX::IsBorderEnabled() const
|
||||
{
|
||||
return m_stroke.GetWidth() >= 0;
|
||||
return m_borderEnabled;
|
||||
}
|
||||
|
||||
|
||||
void PCB_TEXTBOX::DisableBorder()
|
||||
void PCB_TEXTBOX::SetBorderEnabled( bool enabled )
|
||||
{
|
||||
m_stroke.SetWidth( -1 );
|
||||
m_borderEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
|
@ -582,5 +583,12 @@ static struct PCB_TEXTBOX_DESC
|
|||
propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
|
||||
propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
|
||||
propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Style" ) );
|
||||
|
||||
const wxString textBoxProps = _( "Text Box" );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool>( _HKI( "Border" ),
|
||||
&PCB_TEXTBOX::SetBorderEnabled,
|
||||
&PCB_TEXTBOX::IsBorderEnabled ),
|
||||
textBoxProps );
|
||||
}
|
||||
} _PCB_TEXTBOX_DESC;
|
||||
|
|
|
@ -142,9 +142,11 @@ public:
|
|||
bool IsBorderEnabled() const;
|
||||
|
||||
///< Disables the border, this is done by changing the stroke internally
|
||||
void DisableBorder();
|
||||
void SetBorderEnabled( bool enabled );
|
||||
|
||||
protected:
|
||||
bool m_borderEnabled; ///< Controls drawing the border (as defined by the stroke members)
|
||||
|
||||
virtual void swapData( BOARD_ITEM* aImage ) override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
|
|
@ -3242,6 +3242,11 @@ PCB_TEXTBOX* PCB_PARSER::parsePCB_TEXTBOX( BOARD_ITEM* aParent )
|
|||
break;
|
||||
}
|
||||
|
||||
case T_border:
|
||||
textbox->SetBorderEnabled( parseBool() );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_layer:
|
||||
textbox->SetLayer( parseBoardItemLayer() );
|
||||
NeedRIGHT();
|
||||
|
@ -3268,6 +3273,10 @@ PCB_TEXTBOX* PCB_PARSER::parsePCB_TEXTBOX( BOARD_ITEM* aParent )
|
|||
|
||||
textbox->SetStroke( stroke );
|
||||
|
||||
if( m_requiredVersion < 20230825 ) // compat, we move to an explicit flag
|
||||
textbox->SetBorderEnabled( stroke.GetWidth() >= 0 );
|
||||
|
||||
|
||||
if( FOOTPRINT* parentFP = dynamic_cast<FOOTPRINT*>( aParent ) )
|
||||
{
|
||||
textbox->Rotate( { 0, 0 }, parentFP->GetOrientation() );
|
||||
|
|
|
@ -1896,8 +1896,14 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
|
|||
// PCB_TEXTBOXes are never hidden, so always omit "hide" attribute
|
||||
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
|
||||
|
||||
if( aTextBox->GetStroke().GetWidth() > 0 )
|
||||
aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
|
||||
m_out->Print( aNestLevel + 1, "(border" );
|
||||
|
||||
if( aTextBox->IsBorderEnabled() )
|
||||
m_out->Print( 0, " yes)" );
|
||||
else
|
||||
m_out->Print( 0, " no)" );
|
||||
|
||||
aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
|
||||
|
||||
if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() )
|
||||
formatRenderCache( aTextBox, aNestLevel + 1 );
|
||||
|
|
|
@ -137,7 +137,8 @@ class PCB_PLUGIN; // forward decl
|
|||
//#define SEXPR_BOARD_FILE_VERSION 20230410 // DNP attribute propagated from schematic to attr
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20230517 // Teardrop parameters for pads and vias
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20230620 // PCB Fields
|
||||
#define SEXPR_BOARD_FILE_VERSION 20230730 // Connectivity for graphic shapes
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20230730 // Connectivity for graphic shapes
|
||||
#define SEXPR_BOARD_FILE_VERSION 20230825 // Textbox explicit border flag
|
||||
|
||||
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag
|
||||
#define LEGACY_ARC_FORMATTING 20210925 ///< These were the last to use old arc formatting
|
||||
|
|
Loading…
Reference in New Issue