diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 93ec30f06d..af4812e3c3 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -185,22 +185,42 @@ enum id_eeschema_frm /* Library editor main menubar IDs. */ ID_LIBEDIT_DIMENSIONS, - /* Library editor horizontal toolbar IDs. */ - ID_LIBEDIT_SAVE_CURRENT_PART, - ID_LIBEDIT_SELECT_PART, - ID_LIBEDIT_SELECT_CURRENT_LIB, - ID_LIBEDIT_SAVE_CURRENT_LIB, + /* Library editor: part edit events */ ID_LIBEDIT_NEW_PART, - ID_LIBEDIT_NEW_PART_FROM_EXISTING, - ID_LIBEDIT_GET_FRAME_EDIT_PART, - ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, + ID_LIBEDIT_EDIT_PART, + ID_LIBEDIT_IMPORT_PART, + ID_LIBEDIT_EXPORT_PART, + ID_LIBEDIT_SAVE_PART, + ID_LIBEDIT_SAVE_CURRENT_PART, + ID_LIBEDIT_REMOVE_PART, + ID_LIBEDIT_CUT_PART, + ID_LIBEDIT_COPY_PART, + ID_LIBEDIT_PASTE_PART, + ID_LIBEDIT_RENAME_PART, + ID_LIBEDIT_REVERT_PART, ID_LIBEDIT_DELETE_PART, + + /* Library editor: library edit events */ + + ID_LIBEDIT_NEW_LIBRARY, + ID_LIBEDIT_ADD_LIBRARY, + ID_LIBEDIT_SAVE_LIBRARY, + ID_LIBEDIT_SAVE_LIBRARY_AS, + ID_LIBEDIT_SAVE_CURRENT_LIB, // TODO merge with save_library? + ID_LIBEDIT_SAVE_CURRENT_LIB_AS, + ID_LIBEDIT_SAVE_ALL_LIBS, + ID_LIBEDIT_REVERT_LIBRARY, + ID_LIBEDIT_REMOVE_LIBRARY, + + /* Library editor horizontal toolbar IDs. */ ID_DE_MORGAN_NORMAL_BUTT, ID_DE_MORGAN_CONVERT_BUTT, ID_LIBEDIT_EDIT_PIN_BY_PIN, ID_LIBEDIT_EDIT_PIN_BY_TABLE, ID_LIBEDIT_VIEW_DOC, ID_LIBEDIT_CHECK_PART, + ID_LIBEDIT_GET_FRAME_EDIT_PART, + ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, ID_LIBEDIT_SELECT_PART_NUMBER, ID_LIBEDIT_SELECT_ALIAS, @@ -240,9 +260,9 @@ enum id_eeschema_frm /* Library editor toolbar options IDs */ ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, + ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, /* Library editor menubar IDs */ - ID_LIBEDIT_SAVE_CURRENT_LIB_AS, ID_LIBEDIT_GEN_PNG_FILE, ID_LIBEDIT_GEN_SVG_FILE, @@ -273,7 +293,6 @@ enum id_eeschema_frm ID_SIM_SHOW, ID_END_EESCHEMA_ID_LIST - }; diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 90f19aca05..feb160d25b 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -37,13 +37,11 @@ #include #include #include +#include #include -extern int ExportPartId; - - void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) { wxString msg; @@ -99,8 +97,6 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) { wxString msg, title; - bool createLib = ( event.GetId() == ExportPartId ) ? false : true; - LIB_PART* part = GetCurPart(); if( !part ) @@ -114,9 +110,7 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) fn.SetName( part->GetName().Lower() ); fn.SetExt( SchematicLibraryFileExtension ); - title = createLib ? _( "New Symbol Library" ) : _( "Export Symbol" ); - - wxFileDialog dlg( this, title, m_mruPath, fn.GetFullName(), + wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(), SchematicLibraryFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index cecce6b8f6..6248b93f79 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -53,17 +53,11 @@ #include #include +#include + #include -/* This method guarantees unique IDs for the library this run of Eeschema - * which prevents ID conflicts and eliminates the need to recompile every - * source file in the project when adding IDs to include/id.h. */ -int ExportPartId = ::wxNewId(); -int ImportPartId = ::wxNewId(); -int CreateNewLibAndSavePartId = ::wxNewId(); - - wxString LIB_EDIT_FRAME:: m_aliasName; int LIB_EDIT_FRAME:: m_unit = 1; int LIB_EDIT_FRAME:: m_convert = 1; @@ -90,13 +84,10 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Main horizontal toolbar. EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnSaveActiveLibrary ) - EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart ) EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer ) EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart ) - EVT_TOOL( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnCreateNewPartFromExisting ) - EVT_TOOL( ID_LIBEDIT_SELECT_PART, LIB_EDIT_FRAME::LoadOneLibraryPart ) EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList ) EVT_TOOL( wxID_REDO, LIB_EDIT_FRAME::GetComponentFromRedoList ) EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnEditComponentProperties ) @@ -107,9 +98,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc ) EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnOpenPinTable ) - EVT_TOOL( ExportPartId, LIB_EDIT_FRAME::OnExportPart ) - EVT_TOOL( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnExportPart ) - EVT_TOOL( ImportPartId, LIB_EDIT_FRAME::OnImportPart ) + EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart ) + EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart ) EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::OnSaveCurrentPart ) EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart ) @@ -123,6 +113,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Left vertical toolbar (option toolbar). EVT_TOOL( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnShowElectricalType ) + EVT_TOOL( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, LIB_EDIT_FRAME::OnToggleSearchTree ) // menubar commands EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow ) @@ -155,18 +146,17 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU_RANGE( ID_LIBEDIT_MIRROR_X, ID_LIBEDIT_ORIENT_NORMAL, LIB_EDIT_FRAME::OnOrient ) + // Update user interface elements. - EVT_UPDATE_UI( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart ) - EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart ) + EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) - EVT_UPDATE_UI( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo ) EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib ) - EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnUpdateSaveCurrentLibAs ) + EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveCurrentLibAs ) EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable ) @@ -199,6 +189,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_my_part = NULL; m_tempCopyComponent = NULL; + m_componentTree = nullptr; // Delayed initialization if( m_textSize == -1 ) @@ -233,6 +224,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); + createComponentTree(); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); @@ -280,13 +272,16 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxAuiPaneInfo( vert ).Name( "m_VToolBar" ).Right() ); m_auimgr.AddPane( m_optionsToolBar, - wxAuiPaneInfo( vert ).Name( "m_optionsToolBar" ).Left() ); + wxAuiPaneInfo( vert ).Name( "m_optionsToolBar" ).Left().Row( 0 ) ); m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() ); m_auimgr.AddPane( m_messagePanel, - wxAuiPaneInfo( mesg ).Name( "MsgPanel" ).Bottom().Layer(10) ); + wxAuiPaneInfo( mesg ).Name( "MsgPanel" ).Bottom().Layer( 10 ) ); + + m_auimgr.AddPane( m_componentTree, + wxAuiPaneInfo( vert ).Name( "ComponentTree" ).Left().Row( 1 ) ); m_auimgr.Update(); @@ -461,6 +456,20 @@ void LIB_EDIT_FRAME::OnShowElectricalType( wxCommandEvent& event ) } +void LIB_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event ) +{ + auto& treePane = m_auimgr.GetPane( m_componentTree ); + treePane.Show( !IsSearchTreeShown() ); + m_auimgr.Update(); +} + + +bool LIB_EDIT_FRAME::IsSearchTreeShown() +{ + return m_auimgr.GetPane( m_componentTree ).IsShown(); +} + + void LIB_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { aEvent.Check( GetToolId() == aEvent.GetId() ); @@ -770,10 +779,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_CANCEL_EDITING: break; - case ID_LIBEDIT_SELECT_CURRENT_LIB: - SelectActiveLibrary(); - break; - case ID_LIBEDIT_EDIT_PIN_BY_PIN: m_editPinsPerPartOrConvert = m_mainToolBar->GetToolToggled( ID_LIBEDIT_EDIT_PIN_BY_PIN ); break; @@ -1092,22 +1097,6 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) } -void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) -{ - LIB_PART* part = GetCurPart(); - - wxCHECK_RET( part, "Cannot create new part from non-existent current part." ); - - INSTALL_UNBUFFERED_DC( dc, m_canvas ); - m_canvas->CrossHairOff( &dc ); - - EditField( &part->GetValueField() ); - - m_canvas->MoveCursorToCrossHair(); - m_canvas->CrossHairOn( &dc ); -} - - void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) { int id = aEvent.GetId(); @@ -1402,6 +1391,53 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC ) } +void LIB_EDIT_FRAME::createComponentTree() +{ + SYMBOL_LIB_TABLE* table = Prj().SchSymbolLibTable(); + auto adapter( CMP_TREE_MODEL_ADAPTER::Create( table ) ); + + for( const wxString& lib : table->GetLogicalLibs() ) + adapter->AddLibrary( lib ); + + adapter->ShowUnits( true ); + m_componentTree = new COMPONENT_TREE( this, table, adapter, COMPONENT_TREE::SEARCH ); + m_libMgr = new LIB_MANAGER( *this ); + + std::unique_ptr menuLibrary = std::make_unique(); + menuLibrary->Append( ID_LIBEDIT_NEW_LIBRARY, _( "New library..." ) ); + menuLibrary->Append( ID_LIBEDIT_ADD_LIBRARY, _( "Add existing library..." ) ); + menuLibrary->Append( ID_LIBEDIT_SAVE_LIBRARY, _( "Save library" ) ); + menuLibrary->Append( ID_LIBEDIT_SAVE_LIBRARY_AS, _( "Save library as..." ) ); + menuLibrary->Append( ID_LIBEDIT_REVERT_LIBRARY, _( "Revert library" ) ); + menuLibrary->Append( ID_LIBEDIT_REMOVE_LIBRARY, _( "Remove library" ) ); + menuLibrary->AppendSeparator(); + menuLibrary->Append( ID_LIBEDIT_NEW_PART, _( "New component..." ) ); + menuLibrary->Append( ID_LIBEDIT_PASTE_PART, _( "Paste component" ) ); + menuLibrary->Append( ID_LIBEDIT_IMPORT_PART, _( "Import component..." ) ); + + std::unique_ptr menuPart = std::make_unique(); + menuPart->Append( ID_LIBEDIT_EDIT_PART, _( "Edit" ) ); + menuPart->Append( ID_LIBEDIT_CUT_PART, _( "Cut" ) ); + menuPart->Append( ID_LIBEDIT_COPY_PART, _( "Copy" ) ); + menuPart->Append( ID_LIBEDIT_RENAME_PART, _( "Rename" ) ); + menuPart->Append( ID_LIBEDIT_REMOVE_PART, _( "Remove" ) ); + menuPart->Append( ID_LIBEDIT_EXPORT_PART, _( "Export..." ) ); + menuPart->Append( ID_LIBEDIT_SAVE_PART, _( "Save" ) ); + menuPart->Append( ID_LIBEDIT_REVERT_PART, _( "Revert" ) ); + menuPart->AppendSeparator(); + + // Append the library menu to the component menu + for( size_t i = 0; i < menuLibrary->GetMenuItemCount(); ++i ) + { + wxMenuItem* menuItem = menuLibrary->FindItemByPosition( i ); + menuPart->Append( menuItem->GetId(), menuItem->GetItemLabel() ); + } + + m_componentTree->SetMenu( CMP_TREE_NODE::ALIAS, std::move( menuPart ) ); + m_componentTree->SetMenu( CMP_TREE_NODE::LIB, std::move( menuLibrary ) ); +} + + void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent ) { int id = aEvent.GetId(); diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 5242fe3987..3bb321cc9a 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -43,6 +43,7 @@ class LIB_PART; class LIB_ALIAS; class LIB_FIELD; class DIALOG_LIB_EDIT_TEXT; +class COMPONENT_TREE; class LIB_ID; @@ -56,6 +57,7 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME LIB_COLLECTOR m_collectedItems; ///< Used for hit testing. wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any) wxComboBox* m_aliasSelectBox; ///< a box to select the alias to edit (if any) + COMPONENT_TREE* m_componentTree; ///< component search tree widget /** Convert of the item currently being drawn. */ bool m_drawSpecificConvert; @@ -130,6 +132,8 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME LIB_ITEM* locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] ); + void createComponentTree(); + public: LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); @@ -218,6 +222,7 @@ public: * the component of the current library. */ void OnExportPart( wxCommandEvent& event ); + void OnSelectAlias( wxCommandEvent& event ); void OnSelectPart( wxCommandEvent& event ); @@ -226,6 +231,10 @@ public: */ void OnShowElectricalType( wxCommandEvent& event ); + void OnToggleSearchTree( wxCommandEvent& event ); + + bool IsSearchTreeShown(); + /** * Delete a symbol from the current library. * @@ -247,7 +256,6 @@ public: */ void CreateNewLibraryPart( wxCommandEvent& event ); - void OnCreateNewPartFromExisting( wxCommandEvent& event ); void OnEditComponentProperties( wxCommandEvent& event ); void InstallFieldsEditorDialog( wxCommandEvent& event ); diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index ae40769f4d..dec1eef8ea 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -37,8 +37,6 @@ #include "hotkeys.h" #include "libeditframe.h" -extern int CreateNewLibAndSavePartId; - /** * @brief (Re)Create the menubar for the component editor frame @@ -64,33 +62,40 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() // Menu File: wxMenu* fileMenu = new wxMenu; - // Select current library + // Creating/loading libraries AddMenuItem( fileMenu, - ID_LIBEDIT_SELECT_CURRENT_LIB, - _( "Select &Current Library" ), - _( "Select working library" ), - KiBitmap( library_xpm ) ); + ID_LIBEDIT_NEW_LIBRARY, + _( "&Create New Library" ), + _( "Creates an empty library" ), + KiBitmap( new_library_xpm ) ); + + AddMenuItem( fileMenu, + ID_LIBEDIT_ADD_LIBRARY, + _( "&Add Existing Library" ), + _( "Adds a previously created library" ), + KiBitmap( open_library_xpm ) ); + + // Separator fileMenu->AppendSeparator(); - // Save current library - text = AddHotkeyName( _( "&Save Current Library" ), g_Libedit_Hokeys_Descr, HK_SAVE_LIB ); + // Save library variants + text = AddHotkeyName( _( "&Save Library" ), g_Libedit_Hokeys_Descr, HK_SAVE_LIB ); AddMenuItem( fileMenu, - ID_LIBEDIT_SAVE_CURRENT_LIB, text, + ID_LIBEDIT_SAVE_LIBRARY, text, _( "Save the current active library" ), KiBitmap( save_xpm ) ); - // Save current library as... AddMenuItem( fileMenu, - ID_LIBEDIT_SAVE_CURRENT_LIB_AS, - _( "Save Current Library &As..." ), - _( "Save current active library as..." ), + ID_LIBEDIT_SAVE_LIBRARY_AS, + _( "&Save Library As.." ), + _( "Save the current library to a new file" ), KiBitmap( save_as_xpm ) ); AddMenuItem( fileMenu, - CreateNewLibAndSavePartId, - _( "Create &New Library and Save Current Component" ), - _( "Save current component to new library" ), - KiBitmap( new_library_xpm ) ); + ID_LIBEDIT_SAVE_ALL_LIBS, + _( "&Save All Libraries" ), + _( "Save all library changes" ), + KiBitmap( save_xpm ) ); // Separator fileMenu->AppendSeparator(); @@ -139,16 +144,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() _( "Redo the last undo command" ), KiBitmap( redo_xpm ) ); - // Separator - editMenu->AppendSeparator(); - - // Delete - AddMenuItem( editMenu, - ID_LIBEDIT_DELETE_ITEM_BUTT, - _( "&Delete" ), - HELP_DELETE_ITEMS, - KiBitmap( delete_xpm ) ); - // Menu View: wxMenu* viewMenu = new wxMenu; @@ -177,13 +172,76 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() text = AddHotkeyName( _( "&Fit on Screen" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO ); AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) ); - // Separator - viewMenu->AppendSeparator(); - // Redraw text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW ); AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) ); + // Separator + viewMenu->AppendSeparator(); + + AddMenuItem( viewMenu, + ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, + _( "&Search tree" ), + _( "Toggles the search tree visibility" ), + KiBitmap( search_tree_xpm ) ); + + // Menu Component: + wxMenu* componentMenu = new wxMenu; + + AddMenuItem( componentMenu, + ID_LIBEDIT_NEW_PART, + _( "Create &New Component" ), + _( "Create a new empty component" ), + KiBitmap( new_component_xpm ) ); + + AddMenuItem( componentMenu, + ID_LIBEDIT_SAVE_PART, + _( "&Save Component" ), + _( "Saves the current component to the library" ), + KiBitmap( save_xpm ) ); + + componentMenu->AppendSeparator(); + + AddMenuItem( componentMenu, + ID_LIBEDIT_IMPORT_PART, + _( "&Import" ), + _( "Import a component to the current library" ), + KiBitmap( export_xpm ) ); + + AddMenuItem( componentMenu, + ID_LIBEDIT_EXPORT_PART, + _( "&Export" ), + _( "Export the current component" ), + KiBitmap( import_xpm ) ); + + componentMenu->AppendSeparator(); + + AddMenuItem( componentMenu, + ID_LIBEDIT_GET_FRAME_EDIT_PART, + _( "&Properties" ), + _( "Edit part properties" ), + KiBitmap( part_properties_xpm ) ); + + AddMenuItem( componentMenu, + ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, + _( "&Fields" ), + _( "Edit field properties" ), + KiBitmap( edit_text_xpm ) ); + + componentMenu->AppendSeparator(); + + AddMenuItem( componentMenu, + ID_LIBEDIT_EDIT_PIN_BY_TABLE, + _( "Pi&n table" ), + _( "Show pin table" ), + KiBitmap( pin_table_xpm ) ); + + AddMenuItem( componentMenu, + ID_LIBEDIT_CHECK_PART, + _( "ERC" ), + _( "Check duplicate and off grid pins" ), + KiBitmap( erc_xpm ) ); + // Menu Place: wxMenu* placeMenu = new wxMenu; @@ -293,6 +351,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); + menuBar->Append( componentMenu, _( "&Component" ) ); menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( preferencesMenu, _( "P&references" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 2a06cc832c..61b8f79a6c 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -45,11 +45,6 @@ #endif -extern int ExportPartId; -extern int ImportPartId; -extern int CreateNewLibAndSavePartId; - - void LIB_EDIT_FRAME::ReCreateVToolbar() { if( m_drawToolBar != NULL ) @@ -108,43 +103,26 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); // Set up toolbar - m_mainToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, KiBitmap( library_xpm ), - _( "Select working library" ) ); + m_mainToolBar->AddTool( ID_LIBEDIT_NEW_LIBRARY, wxEmptyString, + KiBitmap( new_library_xpm ), + _( "Create a new library" ) ); m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, KiBitmap( save_library_xpm ), - _( "Save into current library" ) ); - - m_mainToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString, KiBitmap( new_library_xpm ), - _( "Save current component to new library" ) ); - - m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ), - HELP_RUN_LIB_VIEWER ); - - m_mainToolBar->AddSeparator(); - m_mainToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, KiBitmap( delete_xpm ), - _( "Delete component in current library" ) ); + _( "Save current library" ) ); m_mainToolBar->AddSeparator(); m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, KiBitmap( new_component_xpm ), _( "Create new component" ) ); - m_mainToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString, - KiBitmap( import_cmp_from_lib_xpm ), - _( "Load component from current library" ) ); - - m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART_FROM_EXISTING, wxEmptyString, - KiBitmap( copycomponent_xpm ), - _( "Create new component from current component" ) ); - m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString, - KiBitmap( save_part_in_mem_xpm ), - _( "Update current component in current library" ) ); + KiBitmap( save_part_in_mem_xpm ), // TODO change icon + _( "Save component" ) ); - m_mainToolBar->AddTool( ImportPartId, wxEmptyString, KiBitmap( import_xpm ), + m_mainToolBar->AddTool( ID_LIBEDIT_IMPORT_PART, wxEmptyString, KiBitmap( import_xpm ), _( "Import component" ) ); - m_mainToolBar->AddTool( ExportPartId, wxEmptyString, KiBitmap( export_xpm ), + m_mainToolBar->AddTool( ID_LIBEDIT_EXPORT_PART, wxEmptyString, KiBitmap( export_xpm ), _( "Export component" ) ); m_mainToolBar->AddSeparator(); @@ -250,5 +228,9 @@ void LIB_EDIT_FRAME::CreateOptionToolbar() KiBitmap( pin_show_etype_xpm ), _( "Show pins electrical type" ), wxITEM_CHECK ); + m_optionsToolBar->AddTool( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString, + KiBitmap( search_tree_xpm ), + _( "Toggles the search tree" ), wxITEM_CHECK ); + m_optionsToolBar->Realize(); }