Properties: initial infrastructure for symbol editor
This commit is contained in:
parent
d5fc2b757d
commit
000fa28ffc
|
@ -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<LIB_FIELD, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_FIELD, EDA_TEXT> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( LIB_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_FIELD, bool>( _HKI( "Show Field Name" ),
|
||||
&LIB_FIELD::SetNameShown, &LIB_FIELD::IsNameShown ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_FIELD, bool>( _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;
|
||||
|
|
|
@ -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<LIB_PIN, wxString>( _HKI( "Pin Name" ),
|
||||
NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetName ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Number" ),
|
||||
NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetNumber ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Length" ),
|
||||
NO_SETTER( LIB_PIN, int ), &LIB_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) );
|
||||
}
|
||||
} _LIB_PIN_DESC;
|
||||
|
|
|
@ -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<LIB_SHAPE, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_SHAPE, EDA_SHAPE> );
|
||||
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<LIB_SHAPE*>( 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;
|
||||
|
|
|
@ -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<LIB_TEXT, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, EDA_TEXT> );
|
||||
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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <tool/common_tools.h>
|
||||
#include <tool/editor_conditions.h>
|
||||
#include <tool/picker_tool.h>
|
||||
#include <tool/properties_tool.h>
|
||||
#include <tool/selection.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
@ -68,6 +69,7 @@
|
|||
#include <widgets/wx_infobar.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <widgets/wx_progress_reporters.h>
|
||||
#include <widgets/sch_properties_panel.h>
|
||||
#include <widgets/symbol_tree_pane.h>
|
||||
#include <widgets/wx_aui_utils.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
@ -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& )
|
||||
|
|
|
@ -182,6 +182,8 @@ public:
|
|||
|
||||
void OnToggleSymbolTree( wxCommandEvent& event );
|
||||
|
||||
void ToggleProperties() override;
|
||||
|
||||
bool IsSymbolTreeShown() const;
|
||||
void FreezeLibraryTree();
|
||||
void ThawLibraryTree();
|
||||
|
|
|
@ -46,6 +46,15 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() :
|
|||
// Init settings:
|
||||
SetLegacyFilename( wxS( "eeschema" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
|
||||
&m_AuiPanels.show_properties, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
|
||||
&m_AuiPanels.properties_panel_width, -1 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
|
||||
&m_AuiPanels.properties_splitter_proportion, 0.5f ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "defaults.line_width",
|
||||
&m_Defaults.line_width, 0 ) );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -27,11 +27,15 @@
|
|||
#include <eeschema_id.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <sch_painter.h>
|
||||
#include <symbol_editor_settings.h>
|
||||
#include <symbol_library_manager.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <widgets/sch_properties_panel.h>
|
||||
#include <widgets/sch_properties_panel.h>
|
||||
#include <widgets/wx_aui_utils.h>
|
||||
|
||||
#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<EE_SELECTION_TOOL>();
|
||||
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SYMBOL_EDIT_FRAME>()->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() );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue