Symbol editor: simpler creation of a new derived symbol
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13407
This commit is contained in:
parent
c6e417c19c
commit
80b55f5980
|
@ -29,7 +29,9 @@
|
|||
#include <template_fieldnames.h>
|
||||
|
||||
DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
|
||||
const wxArrayString* aRootSymbolNames ) :
|
||||
const wxString& message,
|
||||
const wxArrayString* aRootSymbolNames,
|
||||
const wxString& inheritFromSymbolName ) :
|
||||
DIALOG_LIB_NEW_SYMBOL_BASE( dynamic_cast<wxWindow*>( aParent ) ),
|
||||
m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
|
||||
m_staticPinTextPositionUnits, true )
|
||||
|
@ -42,6 +44,18 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
|
|||
escapedNames.Add( UnescapeString( name ) );
|
||||
|
||||
m_comboInheritanceSelect->Append( escapedNames );
|
||||
|
||||
if( !inheritFromSymbolName.IsEmpty() )
|
||||
{
|
||||
m_comboInheritanceSelect->SetStringSelection( inheritFromSymbolName );
|
||||
syncControls( !m_comboInheritanceSelect->GetValue().IsEmpty() );
|
||||
}
|
||||
}
|
||||
|
||||
if( !message.IsEmpty() )
|
||||
{
|
||||
m_infoBar->RemoveAllButtons();
|
||||
m_infoBar->ShowMessage( message );
|
||||
}
|
||||
|
||||
m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
|
||||
|
|
|
@ -36,7 +36,9 @@ class DIALOG_LIB_NEW_SYMBOL : public DIALOG_LIB_NEW_SYMBOL_BASE
|
|||
{
|
||||
public:
|
||||
DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* parent,
|
||||
const wxArrayString* aRootSymbolNames = nullptr );
|
||||
const wxString& message,
|
||||
const wxArrayString* aRootSymbolNames = nullptr,
|
||||
const wxString& inheritFromSymbolName = wxEmptyString );
|
||||
|
||||
void SetName( const wxString& name ) override
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "widgets/wx_infobar.h"
|
||||
|
||||
#include "dialog_lib_new_symbol_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -21,6 +23,13 @@ DIALOG_LIB_NEW_SYMBOL_BASE::DIALOG_LIB_NEW_SYMBOL_BASE( wxWindow* parent, wxWind
|
|||
wxBoxSizer* bSizerMain;
|
||||
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_infoBar = new WX_INFOBAR( this );
|
||||
m_infoBar->SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE );
|
||||
m_infoBar->SetEffectDuration( 500 );
|
||||
m_infoBar->Hide();
|
||||
|
||||
bSizerMain->Add( m_infoBar, 0, wxBOTTOM|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizerTop;
|
||||
bSizerTop = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="15" />
|
||||
<FileVersion major="1" minor="16" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -14,6 +14,7 @@
|
|||
<property name="file">dialog_lib_new_symbol_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_symbol_base</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">
|
||||
|
@ -50,6 +52,7 @@
|
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">New Symbol</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
@ -58,6 +61,66 @@
|
|||
<property name="name">bSizerMain</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxBOTTOM|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxInfoBar" 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="duration">500</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">1</property>
|
||||
<property name="hide_effect">wxSHOW_EFFECT_NONE</property>
|
||||
<property name="id">wxID_ANY</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_infoBar</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="show_effect">wxSHOW_EFFECT_NONE</property>
|
||||
<property name="size"></property>
|
||||
<property name="subclass">WX_INFOBAR; widgets/wx_infobar.h; 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>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -10,13 +10,16 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class WX_INFOBAR;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/infobar.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/spinctrl.h>
|
||||
|
@ -41,6 +44,7 @@ class DIALOG_LIB_NEW_SYMBOL_BASE : public DIALOG_SHIM
|
|||
|
||||
|
||||
protected:
|
||||
WX_INFOBAR* m_infoBar;
|
||||
wxStaticText* m_staticTextName;
|
||||
wxTextCtrl* m_textName;
|
||||
wxStaticText* m_staticText5;
|
||||
|
@ -64,7 +68,7 @@ class DIALOG_LIB_NEW_SYMBOL_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnParentSymbolSelect( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPowerCheckBox( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
@ -72,6 +76,7 @@ class DIALOG_LIB_NEW_SYMBOL_BASE : public DIALOG_SHIM
|
|||
public:
|
||||
|
||||
DIALOG_LIB_NEW_SYMBOL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("New Symbol"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
~DIALOG_LIB_NEW_SYMBOL_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
/**
|
||||
* Create a new symbol in the selected library.
|
||||
*/
|
||||
void CreateNewSymbol();
|
||||
void CreateNewSymbol( const wxString& inheritFromSymbolName = wxEmptyString );
|
||||
|
||||
void ImportSymbol();
|
||||
void ExportSymbol();
|
||||
|
|
|
@ -324,7 +324,7 @@ void SYMBOL_EDIT_FRAME::SaveAll()
|
|||
}
|
||||
|
||||
|
||||
void SYMBOL_EDIT_FRAME::CreateNewSymbol()
|
||||
void SYMBOL_EDIT_FRAME::CreateNewSymbol( const wxString& inheritFromSymbolName )
|
||||
{
|
||||
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
|
||||
|
||||
|
@ -343,7 +343,31 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol()
|
|||
|
||||
rootSymbols.Sort();
|
||||
|
||||
DIALOG_LIB_NEW_SYMBOL dlg( this, &rootSymbols );
|
||||
wxString _inheritSymbolName;
|
||||
wxString _infoMessage;
|
||||
|
||||
// if the symbol being inherited from isn't a root symbol, find its root symbol
|
||||
// and use that symbol instead
|
||||
if( !inheritFromSymbolName.IsEmpty() )
|
||||
{
|
||||
LIB_SYMBOL* inheritFromSymbol = m_libMgr->GetBufferedSymbol( inheritFromSymbolName, lib );
|
||||
|
||||
if( inheritFromSymbol && !inheritFromSymbol->IsRoot() )
|
||||
{
|
||||
std::shared_ptr<LIB_SYMBOL> parent = inheritFromSymbol->GetParent().lock();
|
||||
wxString rootSymbolName = parent->GetName();
|
||||
_inheritSymbolName = rootSymbolName;
|
||||
_infoMessage = wxString::Format( _( "Deriving from '%s', the root symbol of '%s'." ),
|
||||
_inheritSymbolName,
|
||||
inheritFromSymbolName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_inheritSymbolName = inheritFromSymbolName;
|
||||
}
|
||||
}
|
||||
|
||||
DIALOG_LIB_NEW_SYMBOL dlg( this, _infoMessage, &rootSymbols, _inheritSymbolName );
|
||||
dlg.SetMinSize( dlg.GetSize() );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
|
|
|
@ -127,6 +127,11 @@ TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.SymbolLibraryControl.newSymbol",
|
|||
_( "New Symbol..." ), _( "Create a new symbol" ),
|
||||
BITMAPS::new_component );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::deriveFromExistingSymbol( "eeschema.SymbolLibraryControl.deriveFromExistingSymbol",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Derive from existing symbol" ), _( "Create a new symbol, derived from an existing symbol" ),
|
||||
BITMAPS::new_component );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::editSymbol( "eeschema.SymbolLibraryControl.editSymbol",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ),
|
||||
|
|
|
@ -181,6 +181,7 @@ public:
|
|||
static TOOL_ACTION saveLibraryAs;
|
||||
static TOOL_ACTION saveSymbolAs;
|
||||
static TOOL_ACTION newSymbol;
|
||||
static TOOL_ACTION deriveFromExistingSymbol;
|
||||
static TOOL_ACTION editSymbol;
|
||||
static TOOL_ACTION duplicateSymbol;
|
||||
static TOOL_ACTION renameSymbol;
|
||||
|
|
|
@ -102,6 +102,7 @@ bool SYMBOL_EDITOR_CONTROL::Init()
|
|||
|
||||
ctxMenu.AddSeparator();
|
||||
ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition );
|
||||
ctxMenu.AddItem( EE_ACTIONS::deriveFromExistingSymbol, symbolSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator();
|
||||
ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition );
|
||||
|
@ -190,9 +191,17 @@ int SYMBOL_EDITOR_CONTROL::AddSymbol( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) )
|
||||
{
|
||||
editFrame->CreateNewSymbol();
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::deriveFromExistingSymbol ) )
|
||||
{
|
||||
editFrame->CreateNewSymbol( sel.GetLibItemName() );
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
|
||||
{
|
||||
editFrame->ImportSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -680,6 +689,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
|
|||
Go( &SYMBOL_EDITOR_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, EE_ACTIONS::newSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, EE_ACTIONS::deriveFromExistingSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, EE_ACTIONS::importSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::EditSymbol, EE_ACTIONS::editSymbol.MakeEvent() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue