Symbol editor: fix several internal units bugs.
When opening the symbol editor without loading the schematic editor the default text size setting is not loaded and was defaulting to the old mils setting. Convert the default text size to internal units in case the symbol editor is launched first. Set default line, bus, and selection highlight width to internal units. Change new symbol dialog pin position offset control from a spin control to a text control so the unit binder object can handle converting to and from internal units. Fixes #3802 https://gitlab.com/kicad/code/kicad/issues/3802
This commit is contained in:
parent
bcc68b2dd9
commit
bc68c7d949
|
@ -90,7 +90,7 @@ LIB_PART::LIB_PART( const wxString& aName, LIB_PART* aParent, PART_LIB* aLibrary
|
|||
{
|
||||
m_dateLastEdition = 0;
|
||||
m_unitCount = 1;
|
||||
m_pinNameOffset = 40;
|
||||
m_pinNameOffset = Mils2iu( 40 );
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
m_showPinNumbers = true;
|
||||
|
|
|
@ -184,7 +184,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataToWindow()
|
|||
m_ShowPinNumButt->SetValue( m_libEntry->ShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( m_libEntry->ShowPinNames() );
|
||||
m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
|
||||
m_pinNameOffset.SetValue( Mils2iu( m_libEntry->GetPinNameOffset() ) );
|
||||
m_pinNameOffset.SetValue( m_libEntry->GetPinNameOffset() );
|
||||
|
||||
wxArrayString tmp = m_libEntry->GetFootprints();
|
||||
m_FootprintFilterListBox->Append( tmp );
|
||||
|
@ -344,7 +344,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataFromWindow()
|
|||
|
||||
if( m_PinsNameInsideButt->GetValue() )
|
||||
{
|
||||
int offset = KiROUND( (double) m_pinNameOffset.GetValue() / IU_PER_MILS );
|
||||
int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
|
||||
|
||||
// We interpret an offset of 0 as "outside", so make sure it's non-zero
|
||||
m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -22,13 +22,17 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <eda_draw_frame.h>
|
||||
|
||||
#include <dialog_lib_new_component.h>
|
||||
#include <sch_validators.h>
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT( wxWindow* parent,
|
||||
DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT( EDA_DRAW_FRAME* aParent,
|
||||
const wxArrayString* aRootSymbolNames ) :
|
||||
DIALOG_LIB_NEW_COMPONENT_BASE( parent )
|
||||
DIALOG_LIB_NEW_COMPONENT_BASE( dynamic_cast<wxWindow*>( aParent ) ),
|
||||
m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
|
||||
m_staticPinTextPositionUnits, true )
|
||||
{
|
||||
if( aRootSymbolNames && aRootSymbolNames->GetCount() )
|
||||
m_comboInheritanceSelect->Append( *aRootSymbolNames );
|
||||
|
@ -36,6 +40,8 @@ DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT( wxWindow* parent,
|
|||
m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE ) );
|
||||
m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE ) );
|
||||
|
||||
m_pinTextPosition.SetValue( Mils2iu( 40 ) );
|
||||
|
||||
// initial focus should be on first editable field.
|
||||
m_textName->SetFocus();
|
||||
|
||||
|
@ -62,8 +68,9 @@ void DIALOG_LIB_NEW_COMPONENT::syncControls( bool aIsDerivedPart )
|
|||
m_checkLockItems->Enable( !aIsDerivedPart );
|
||||
m_checkHasConversion->Enable( !aIsDerivedPart );
|
||||
m_checkIsPowerSymbol->Enable( !aIsDerivedPart );
|
||||
m_staticText12->Enable( !aIsDerivedPart );
|
||||
m_spinPinTextPosition->Enable( !aIsDerivedPart );
|
||||
m_staticPinTextPositionLabel->Enable( !aIsDerivedPart );
|
||||
m_textPinTextPosition->Enable( !aIsDerivedPart );
|
||||
m_staticPinTextPositionUnits->Enable( !aIsDerivedPart );
|
||||
m_checkShowPinNumber->Enable( !aIsDerivedPart );
|
||||
m_checkShowPinName->Enable( !aIsDerivedPart );
|
||||
m_checkShowPinNameInside->Enable( !aIsDerivedPart );
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009-2105 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2015-2019 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -30,14 +30,20 @@
|
|||
* Subclass of DIALOG_LIB_NEW_COMPONENT, which is generated by wxFormBuilder.
|
||||
*/
|
||||
|
||||
#include <widgets/unit_binder.h>
|
||||
|
||||
#include <dialog_lib_new_component_base.h>
|
||||
|
||||
class EDA_DRAW_FRAME;
|
||||
class wxArrayString;
|
||||
|
||||
/** Implementing DIALOG_LIB_NEW_COMPONENT */
|
||||
class DIALOG_LIB_NEW_COMPONENT : public DIALOG_LIB_NEW_COMPONENT_BASE
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
DIALOG_LIB_NEW_COMPONENT( wxWindow* parent, const wxArrayString* aRootSymbolNames = nullptr );
|
||||
DIALOG_LIB_NEW_COMPONENT( EDA_DRAW_FRAME* parent,
|
||||
const wxArrayString* aRootSymbolNames = nullptr );
|
||||
|
||||
void SetName( const wxString& name ) override { m_textName->SetValue( name ); }
|
||||
wxString GetName( void ) const override { return m_textName->GetValue(); }
|
||||
|
@ -73,9 +79,9 @@ public:
|
|||
|
||||
void SetPinTextPosition( int position )
|
||||
{
|
||||
m_spinPinTextPosition->SetValue( position );
|
||||
m_pinTextPosition.SetValue( position );
|
||||
}
|
||||
int GetPinTextPosition( void ) { return m_spinPinTextPosition->GetValue(); }
|
||||
int GetPinTextPosition( void ) { return m_pinTextPosition.GetValue(); }
|
||||
|
||||
void SetShowPinNumber( bool show )
|
||||
{
|
||||
|
@ -100,6 +106,8 @@ protected:
|
|||
|
||||
private:
|
||||
void syncControls( bool aIsDerivedPart );
|
||||
|
||||
UNIT_BINDER m_pinTextPosition;
|
||||
};
|
||||
|
||||
#endif // __dialog_lib_new_component__
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version v3.8.0)
|
||||
// C++ code generated with wxFormBuilder (version 3.9.0 Jan 23 2020)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -86,17 +86,21 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent,
|
|||
bSizerBottom = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer4;
|
||||
fgSizer4 = new wxFlexGridSizer( 0, 2, 6, 6 );
|
||||
fgSizer4 = new wxFlexGridSizer( 0, 3, 6, 6 );
|
||||
fgSizer4->AddGrowableCol( 1 );
|
||||
fgSizer4->SetFlexibleDirection( wxBOTH );
|
||||
fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_staticText12 = new wxStaticText( this, wxID_ANY, _("Pin text position offset:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText12->Wrap( -1 );
|
||||
fgSizer4->Add( m_staticText12, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
m_staticPinTextPositionLabel = new wxStaticText( this, wxID_ANY, _("Pin text position offset:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticPinTextPositionLabel->Wrap( -1 );
|
||||
fgSizer4->Add( m_staticPinTextPositionLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 40 );
|
||||
fgSizer4->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
m_textPinTextPosition = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer4->Add( m_textPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_staticPinTextPositionUnits = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticPinTextPositionUnits->Wrap( -1 );
|
||||
fgSizer4->Add( m_staticPinTextPositionUnits, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
bSizerBottom->Add( fgSizer4, 0, wxALL|wxEXPAND, 5 );
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<property name="file">dialog_lib_new_component_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">dialog_lib_new_component</property>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">1</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Dialog" expanded="1">
|
||||
|
@ -804,7 +806,7 @@
|
|||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxFlexGridSizer" expanded="1">
|
||||
<property name="cols">2</property>
|
||||
<property name="cols">3</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">1</property>
|
||||
<property name="growablerows"></property>
|
||||
|
@ -856,7 +858,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_staticText12</property>
|
||||
<property name="name">m_staticPinTextPositionLabel</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -880,7 +882,7 @@
|
|||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxSpinCtrl" expanded="1">
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -908,17 +910,15 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="initial">40</property>
|
||||
<property name="max">100</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min">1</property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_spinPinTextPosition</property>
|
||||
<property name="name">m_textPinTextPosition</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -928,16 +928,81 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxSP_ARROW_KEYS</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="value">40</property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">mils</property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_staticPinTextPositionUnits</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version v3.8.0)
|
||||
// C++ code generated with wxFormBuilder (version 3.9.0 Jan 23 2020)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -51,8 +51,9 @@ class DIALOG_LIB_NEW_COMPONENT_BASE : public DIALOG_SHIM
|
|||
wxCheckBox* m_checkLockItems;
|
||||
wxCheckBox* m_checkHasConversion;
|
||||
wxCheckBox* m_checkIsPowerSymbol;
|
||||
wxStaticText* m_staticText12;
|
||||
wxSpinCtrl* m_spinPinTextPosition;
|
||||
wxStaticText* m_staticPinTextPositionLabel;
|
||||
wxTextCtrl* m_textPinTextPosition;
|
||||
wxStaticText* m_staticPinTextPositionUnits;
|
||||
wxCheckBox* m_checkShowPinNumber;
|
||||
wxCheckBox* m_checkShowPinName;
|
||||
wxCheckBox* m_checkShowPinNameInside;
|
||||
|
|
|
@ -47,14 +47,14 @@
|
|||
#include <gr_text.h>
|
||||
#include "sch_junction.h"
|
||||
|
||||
static int s_defaultBusThickness = DEFAULTBUSTHICKNESS;
|
||||
static int s_defaultWireThickness = DEFAULTDRAWLINETHICKNESS;
|
||||
static int s_defaultTextSize = DEFAULT_SIZE_TEXT;
|
||||
static int s_defaultBusThickness = Mils2iu( DEFAULTBUSTHICKNESS );
|
||||
static int s_defaultWireThickness = Mils2iu( DEFAULTDRAWLINETHICKNESS );
|
||||
static int s_defaultTextSize = Mils2iu( DEFAULT_SIZE_TEXT );
|
||||
static int s_drawDefaultLineThickness = -1;
|
||||
static bool s_selectTextAsBox = false;
|
||||
static bool s_selectDrawChildren = true;
|
||||
static bool s_selectFillShapes = false;
|
||||
static int s_selectThickness = DEFAULTSELECTIONTHICKNESS;
|
||||
static int s_selectThickness = Mils2iu( DEFAULTSELECTIONTHICKNESS );
|
||||
|
||||
int GetDefaultBusThickness()
|
||||
{
|
||||
|
@ -402,7 +402,8 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
SetSelectionDrawChildItems( aCfg->ReadBool( drawSelectedChildren, true ) );
|
||||
SetSelectionFillShapes( aCfg->ReadBool( selectionFillShapes, false ) );
|
||||
SetSelectionThickness(
|
||||
static_cast<int>( aCfg->Read( selectionThickness, DEFAULTSELECTIONTHICKNESS ) ) );
|
||||
Mils2iu( static_cast<int>( aCfg->Read( selectionThickness,
|
||||
DEFAULTSELECTIONTHICKNESS ) ) ) );
|
||||
|
||||
SetTextMarkupFlags( (int) aCfg->Read( TextMarkupFlagsEntry, 0L ) );
|
||||
|
||||
|
@ -467,7 +468,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
|||
aCfg->Write( boxedSelectedText, GetSelectionTextAsBox() );
|
||||
aCfg->Write( drawSelectedChildren, GetSelectionDrawChildItems() );
|
||||
aCfg->Write( selectionFillShapes, GetSelectionFillShapes() );
|
||||
aCfg->Write( selectionThickness, GetSelectionThickness() );
|
||||
aCfg->Write( selectionThickness, Iu2Mils( GetSelectionThickness() ) );
|
||||
aCfg->Write( NavigatorStaysOpenEntry, m_navigatorStaysOpen );
|
||||
|
||||
// Save template fieldnames
|
||||
|
|
|
@ -235,7 +235,7 @@ float SCH_PAINTER::getShadowWidth()
|
|||
// For best visuals the selection width must be a cross between the zoom level and the
|
||||
// default line width.
|
||||
return static_cast<float>(
|
||||
fabs( matrix.GetScale().x * 2.75 ) + Mils2iu( GetSelectionThickness() ) );
|
||||
fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue