From 79c7d55a4055a1007d7f335865169beb65c6a113 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 6 Feb 2022 18:44:03 +0000 Subject: [PATCH] Add a checkbox for LIB_SHAPE borders. (We already have them for LIB_TEXTBOXes.) Fixes https://gitlab.com/kicad/code/kicad/issues/10365 --- .../dialogs/dialog_lib_shape_properties.cpp | 38 ++++++- .../dialogs/dialog_lib_shape_properties.h | 1 + .../dialog_lib_shape_properties_base.cpp | 20 +++- .../dialog_lib_shape_properties_base.fbp | 99 +++++++++++++++++-- .../dialog_lib_shape_properties_base.h | 7 +- 5 files changed, 147 insertions(+), 18 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_shape_properties.cpp b/eeschema/dialogs/dialog_lib_shape_properties.cpp index a41ff54eab..8ce8ff6b36 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -71,8 +72,15 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow() EDA_SHAPE* shape = dynamic_cast( m_item ); if( shape ) + m_checkBorder->SetValue( shape->GetWidth() >= 0 ); + + if( shape && shape->GetWidth() >= 0 ) m_lineWidth.SetValue( shape->GetWidth() ); + m_checkBorder->Enable( shape ); + m_lineWidth.Enable( shape && shape->GetWidth() >= 0 ); + m_helpLabel->Enable( shape && shape->GetWidth() >= 0 ); + m_privateCheckbox->SetValue( m_item->IsPrivate() ); m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 ); m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); @@ -168,6 +176,20 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow() if( shape ) { + STROKE_PARAMS stroke = shape->GetStroke(); + + if( m_checkBorder->GetValue() ) + { + if( !m_lineWidth.IsIndeterminate() ) + stroke.SetWidth( m_lineWidth.GetValue() ); + } + else + { + stroke.SetWidth( -1 ); + } + + shape->SetStroke( stroke ); + if( m_rbFillOutline->GetValue() ) shape->SetFillMode( FILL_T::FILLED_SHAPE ); else if( m_rbFillBackground->GetValue() ) @@ -178,10 +200,6 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow() shape->SetFillMode( FILL_T::NO_FILL ); shape->SetFillColor( m_colorSwatch->GetSwatchColor() ); - - STROKE_PARAMS stroke = shape->GetStroke(); - stroke.SetWidth( m_lineWidth.GetValue() ); - shape->SetStroke( stroke ); } m_item->SetPrivate( m_privateCheckbox->GetValue() ); @@ -200,6 +218,18 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow() } +void DIALOG_LIB_SHAPE_PROPERTIES::onBorderChecked( wxCommandEvent& event ) +{ + bool border = m_checkBorder->GetValue(); + + if( border && m_lineWidth.GetValue() < 0 ) + m_lineWidth.SetValue( Mils2iu( m_frame->libeditconfig()->m_Defaults.line_width ) ); + + m_lineWidth.Enable( border ); + m_helpLabel->Enable( border ); +} + + bool DIALOG_LIB_SHAPE_PROPERTIES::GetApplyToAllConversions() { return m_checkApplyToAllConversions->IsChecked(); diff --git a/eeschema/dialogs/dialog_lib_shape_properties.h b/eeschema/dialogs/dialog_lib_shape_properties.h index 7b793df58a..c845b2b673 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties.h +++ b/eeschema/dialogs/dialog_lib_shape_properties.h @@ -50,6 +50,7 @@ public: private: void onFill(wxCommandEvent &event) override; + void onBorderChecked( wxCommandEvent& event ) override; void onSwatch( wxCommandEvent& aEvent ); private: diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp b/eeschema/dialogs/dialog_lib_shape_properties_base.cpp index ef7ce2f556..590322beba 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.cpp @@ -12,6 +12,7 @@ /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( DIALOG_LIB_SHAPE_PROPERTIES_BASE, DIALOG_SHIM ) + EVT_CHECKBOX( wxID_ANY, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked ) EVT_RADIOBUTTON( NO_FILL, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) EVT_RADIOBUTTON( FILLED_SHAPE, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) EVT_RADIOBUTTON( FILLED_WITH_BG_BODYCOLOR, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) @@ -28,15 +29,18 @@ DIALOG_LIB_SHAPE_PROPERTIES_BASE::DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* pa wxBoxSizer* dlgBorderSizer; dlgBorderSizer = new wxBoxSizer( wxVERTICAL ); + m_checkBorder = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 ); + dlgBorderSizer->Add( m_checkBorder, 0, wxTOP|wxRIGHT|wxLEFT, 3 ); + wxBoxSizer* bSizerLineWidth; bSizerLineWidth = new wxBoxSizer( wxHORIZONTAL ); - m_widthLabel = new wxStaticText( this, wxID_ANY, _("Line width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_widthLabel = new wxStaticText( this, wxID_ANY, _("Border width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_widthLabel->Wrap( -1 ); bSizerLineWidth->Add( m_widthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_widthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerLineWidth->Add( m_widthCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizerLineWidth->Add( m_widthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_widthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_widthUnits->Wrap( -1 ); @@ -45,9 +49,12 @@ DIALOG_LIB_SHAPE_PROPERTIES_BASE::DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* pa dlgBorderSizer->Add( bSizerLineWidth, 0, wxEXPAND, 5 ); - m_helpLabel = new wxStaticText( this, wxID_ANY, _("Set width to 0 to use Schematic default symbol line width."), wxDefaultPosition, wxDefaultSize, 0 ); - m_helpLabel->Wrap( 333 ); - dlgBorderSizer->Add( m_helpLabel, 0, wxALL, 5 ); + m_helpLabel = new wxStaticText( this, wxID_ANY, _("Set border width to 0 to use Schematic default symbol line width."), wxDefaultPosition, wxDefaultSize, 0 ); + m_helpLabel->Wrap( 320 ); + dlgBorderSizer->Add( m_helpLabel, 0, wxALL, 3 ); + + + dlgBorderSizer->Add( 0, 3, 0, 0, 5 ); wxStaticBoxSizer* bSizerFill; bSizerFill = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fill Style") ), wxVERTICAL ); @@ -78,6 +85,9 @@ DIALOG_LIB_SHAPE_PROPERTIES_BASE::DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* pa dlgBorderSizer->Add( bSizerFill, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + + dlgBorderSizer->Add( 0, 3, 0, 0, 5 ); + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); dlgBorderSizer->Add( m_privateCheckbox, 0, wxALL, 3 ); diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp b/eeschema/dialogs/dialog_lib_shape_properties_base.fbp index b3a2c5e91c..d1a86473df 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.fbp @@ -67,11 +67,76 @@ dlgBorderSizer wxVERTICAL none - + + 3 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border + + 0 + + + 0 + + 1 + m_checkBorder + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onBorderChecked + + + 5 wxEXPAND 0 - + bSizerLineWidth wxHORIZONTAL @@ -108,7 +173,7 @@ 0 0 wxID_ANY - Line width: + Border width: 0 0 @@ -140,7 +205,7 @@ 3 wxALIGN_CENTER_VERTICAL|wxALL - 1 + 0 1 1 @@ -265,7 +330,7 @@ - 5 + 3 wxALL 0 @@ -296,7 +361,7 @@ 0 0 wxID_ANY - Set width to 0 to use Schematic default symbol line width. + Set border width to 0 to use Schematic default symbol line width. 0 0 @@ -322,7 +387,17 @@ - 333 + 320 + + + + 5 + + 0 + + 3 + protected + 0 @@ -693,6 +768,16 @@ + + 5 + + 0 + + 3 + protected + 0 + + 3 wxALL diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.h b/eeschema/dialogs/dialog_lib_shape_properties_base.h index 33d70b26b3..5e25d0b843 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.h +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.h @@ -14,17 +14,17 @@ class COLOR_SWATCH; #include "dialog_shim.h" #include -#include +#include #include #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -40,6 +40,7 @@ class DIALOG_LIB_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM private: // Private event handlers + void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } void _wxFB_onFill( wxCommandEvent& event ){ onFill( event ); } @@ -52,6 +53,7 @@ class DIALOG_LIB_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM FILLED_WITH_COLOR }; + wxCheckBox* m_checkBorder; wxStaticText* m_widthLabel; wxTextCtrl* m_widthCtrl; wxStaticText* m_widthUnits; @@ -70,6 +72,7 @@ class DIALOG_LIB_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onFill( wxCommandEvent& event ) { event.Skip(); }