diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index c04bde8e2a..56664cd6f1 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -586,3 +586,32 @@ bool LIB_FIELD::IsMandatory() const { return m_id >= 0 && m_id < MANDATORY_FIELDS; } + + +static struct LIB_FIELD_DESC +{ + LIB_FIELD_DESC() + { + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); + REGISTER_TYPE( LIB_FIELD ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( LIB_ITEM ) ); + propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Show Field Name" ), + &LIB_FIELD::SetNameShown, &LIB_FIELD::IsNameShown ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Allow Autoplacement" ), + &LIB_FIELD::SetCanAutoplace, &LIB_FIELD::CanAutoplace ) ); + + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) ); + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) ); + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) ); + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) ); + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) ); + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) ); + + propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) ); + } +} _LIB_FIELD_DESC; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 9572415ace..97421f26de 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1457,3 +1457,23 @@ void LIB_PIN::CalcEdit( const VECTOR2I& aPosition ) if( IsMoving() ) MoveTo( aPosition ); } + + +static struct LIB_PIN_DESC +{ + LIB_PIN_DESC() + { + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); + REGISTER_TYPE( LIB_PIN ); + propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Pin Name" ), + NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetName ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Pin Number" ), + NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetNumber ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Length" ), + NO_SETTER( LIB_PIN, int ), &LIB_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) ); + } +} _LIB_PIN_DESC; diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 5ea53b39a9..99ae1ddafe 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -540,3 +540,33 @@ void LIB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND; aLayers[2] = LAYER_SELECTION_SHADOWS; } + + +static struct LIB_SHAPE_DESC +{ + LIB_SHAPE_DESC() + { + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); + REGISTER_TYPE( LIB_SHAPE ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ) ); + propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ) ); + + // Only polygons have meaningful Position properties. + // On other shapes, these are duplicates of the Start properties. + auto isPolygon = + []( INSPECTABLE* aItem ) -> bool + { + if( LIB_SHAPE* shape = dynamic_cast( aItem ) ) + return shape->GetShape() == SHAPE_T::POLY; + + return false; + }; + + propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ), + _HKI( "Position X" ), isPolygon ); + propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ), + _HKI( "Position Y" ), isPolygon ); + } +} _LIB_SHAPE_DESC; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 0672ef19da..2a5ca15fde 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -497,3 +497,25 @@ void LIB_TEXT::CalcEdit( const VECTOR2I& aPosition ) { SetTextPos( aPosition ); } + + +static struct LIB_TEXT_DESC +{ + LIB_TEXT_DESC() + { + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); + REGISTER_TYPE( LIB_TEXT ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( LIB_ITEM ) ); + propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ) ); + + propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) ); + propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) ); + propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) ); + propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) ); + + // Orientation is exposed differently in schematic; mask the base for now + propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) ); + } +} _LIB_TEXT_DESC; diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 650e4d7d75..5d714a034e 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -107,6 +107,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar() ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool ); viewMenu->Add( ACTIONS::showSymbolBrowser ); + viewMenu->Add( ACTIONS::showProperties, ACTION_MENU::CHECK ); viewMenu->AppendSeparator(); viewMenu->Add( ACTIONS::zoomInCenter ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 087363b7f9..2df2e5ee9d 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -174,6 +176,9 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : UpdateSymbolMsgPanelInfo(); RebuildSymbolUnitsList(); + m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this ); + m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter_proportion ); + m_auimgr.SetManagedWindow( this ); CreateInfoBar(); @@ -190,6 +195,9 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : .Left().Layer( 3 ) .Caption( _( "Libraries" ) ) .MinSize( 250, -1 ).BestSize( 250, -1 ) ); + + m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo() ); + m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) .Left().Layer( 2 ) ); @@ -336,6 +344,7 @@ void SYMBOL_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL ); m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL ); m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); + m_toolManager->RegisterTool( new PROPERTIES_TOOL ); m_toolManager->InitTools(); // Run the selection tool, it is supposed to be always active @@ -440,9 +449,16 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() return IsSymbolTreeShown(); }; + auto propertiesCond = + [this] ( const SELECTION& ) + { + return m_auimgr.GetPane( PropertiesPaneName() ).IsShown(); + }; + mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) ); mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) ); + mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) ); auto demorganCond = [this]( const SELECTION& ) diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 2cc5e629ab..5cbf4f223c 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -182,6 +182,8 @@ public: void OnToggleSymbolTree( wxCommandEvent& event ); + void ToggleProperties() override; + bool IsSymbolTreeShown() const; void FreezeLibraryTree(); void ThawLibraryTree(); diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index d61d6df1d5..2de754e48a 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -46,6 +46,15 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() : // Init settings: SetLegacyFilename( wxS( "eeschema" ) ); + m_params.emplace_back( new PARAM( "aui.show_properties", + &m_AuiPanels.show_properties, true ) ); + + m_params.emplace_back( new PARAM( "aui.properties_panel_width", + &m_AuiPanels.properties_panel_width, -1 ) ); + + m_params.emplace_back( new PARAM( "aui.properties_splitter_proportion", + &m_AuiPanels.properties_splitter_proportion, 0.5f ) ); + m_params.emplace_back( new PARAM( "defaults.line_width", &m_Defaults.line_width, 0 ) ); diff --git a/eeschema/symbol_editor/symbol_editor_settings.h b/eeschema/symbol_editor/symbol_editor_settings.h index 0e3e4d91a9..686c3dfac1 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.h +++ b/eeschema/symbol_editor/symbol_editor_settings.h @@ -31,6 +31,13 @@ class SYMBOL_EDITOR_SETTINGS : public APP_SETTINGS_BASE { public: + struct AUI_PANELS + { + int properties_panel_width; + float properties_splitter_proportion; + bool show_properties; + }; + struct DEFAULTS { int line_width; @@ -52,6 +59,8 @@ public: virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; + AUI_PANELS m_AuiPanels; + DEFAULTS m_Defaults; REPEAT m_Repeat; diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index b656a3b709..39ee344f93 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -27,11 +27,15 @@ #include #include #include +#include #include #include #include #include #include +#include +#include +#include #ifdef __UNIX__ #define LISTBOX_WIDTH 140 @@ -167,6 +171,7 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( EE_ACTIONS::showSymbolTree, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( ACTIONS::showProperties, ACTION_TOOLBAR::TOGGLE ); EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); std::unique_ptr gridMenu = std::make_unique( false, selTool ); @@ -175,3 +180,26 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Realize(); } + + +void SYMBOL_EDIT_FRAME::ToggleProperties() +{ + if( !m_propertiesPanel ) + return; + + bool show = !m_propertiesPanel->IsShownOnScreen(); + + wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() ); + propertiesPaneInfo.Show( show ); + + if( show ) + { + SetAuiPaneSize( m_auimgr, propertiesPaneInfo, + m_settings->m_AuiPanels.properties_panel_width, -1 ); + } + else + { + m_settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x; + m_auimgr.Update(); + } +} diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 32a102f152..93668cf2d2 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -487,6 +487,15 @@ int SYMBOL_EDITOR_CONTROL::ToggleSymbolTree( const TOOL_EVENT& aEvent ) } +int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent ) +{ + if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) + getEditFrame()->ToggleProperties(); + + return 0; +} + + int SYMBOL_EDITOR_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent ) { KIGFX::SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings(); @@ -726,4 +735,5 @@ void SYMBOL_EDITOR_CONTROL::setTransitions() Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); + Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() ); } diff --git a/eeschema/tools/symbol_editor_control.h b/eeschema/tools/symbol_editor_control.h index 58649e1ff2..7f229b4f79 100644 --- a/eeschema/tools/symbol_editor_control.h +++ b/eeschema/tools/symbol_editor_control.h @@ -68,6 +68,7 @@ public: int PinLibrary( const TOOL_EVENT& aEvent ); int UnpinLibrary( const TOOL_EVENT& aEvent ); int ToggleSymbolTree( const TOOL_EVENT& aEvent ); + int ToggleProperties( const TOOL_EVENT& aEvent ); int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ); int DdAddLibrary( const TOOL_EVENT& aEvent );