diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 1196e63afa..3640ecea74 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -90,22 +90,9 @@ enum id_eeschema_frm ID_SCH_DRAG, ID_SCH_UNFOLD_BUS, - // Schematic editor commmands. These are command IDs that are generated by multiple - // events (menus, toolbar, context menu, etc.) that result in the same event handler. - ID_CANCEL_CURRENT_COMMAND, - ID_HOTKEY_HIGHLIGHT, ID_ADD_PART_TO_SCHEMATIC, - /* Library editor: edit events */ - ID_LIBEDIT_EDIT_PART, - ID_LIBEDIT_EXPORT_PART, - ID_LIBEDIT_REMOVE_PART, - ID_LIBEDIT_CUT_PART, - ID_LIBEDIT_COPY_PART, - ID_LIBEDIT_PASTE_PART, - ID_LIBEDIT_DUPLICATE_PART, - /* Library editor horizontal toolbar IDs. */ ID_LIBEDIT_SYNC_PIN_EDIT, ID_LIBEDIT_SELECT_PART_NUMBER, diff --git a/eeschema/help_common_strings.h b/eeschema/help_common_strings.h deleted file mode 100644 index 8d51f1cd05..0000000000 --- a/eeschema/help_common_strings.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2010 CERN - * Copyright (C) 2014-2018 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * These strings are used in menus and tools, that do the same command - * But they are internationalized, and therefore must be created - * at run time, on the fly. - * So they cannot be static. - * - * Therefore they are defined by \#define, used inside menu constructors - */ - -#define HELP_ZOOM_IN _( "Zoom in" ) -#define HELP_ZOOM_OUT _( "Zoom out" ) -#define HELP_ZOOM_FIT _( "Zoom to fit schematic page" ) -#define HELP_ZOOM_REDRAW _( "Redraw schematic view" ) - -// Schematic editor: -#define HELP_IMPORT_FOOTPRINTS \ - _( "Back-import symbol footprint association fields from the .cmp back import file created by Pcbnew" ) - diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index f924ca8184..8039bb9f8b 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -83,15 +82,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow ) EVT_SIZE( LIB_EDIT_FRAME::OnSize ) - // Actions - EVT_TOOL( ID_LIBEDIT_EDIT_PART, LIB_EDIT_FRAME::OnEditPart ) - EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart ) - EVT_TOOL( ID_LIBEDIT_REMOVE_PART, LIB_EDIT_FRAME::OnRemovePart ) - EVT_TOOL( ID_LIBEDIT_CUT_PART, LIB_EDIT_FRAME::OnCopyCutPart ) - EVT_TOOL( ID_LIBEDIT_COPY_PART, LIB_EDIT_FRAME::OnCopyCutPart ) - EVT_TOOL( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart ) - EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart ) - // Main horizontal toolbar. EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer ) EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick ) @@ -114,7 +104,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_EDIT_FRAME::Process_Config ) // Update user interface elements. - EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart ) EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) @@ -355,12 +344,6 @@ void LIB_EDIT_FRAME::ThawSearchTree() } -void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( getTargetLibId().IsValid() ); -} - - void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event ) { LIB_PART* part = GetCurPart(); @@ -592,9 +575,9 @@ bool LIB_EDIT_FRAME::AddLibraryFile( bool aCreateNew ) } -LIB_ID LIB_EDIT_FRAME::GetTreeLIBID() const +LIB_ID LIB_EDIT_FRAME::GetTreeLIBID( int* aUnit ) const { - return m_treePane->GetLibTree()->GetSelectedLibId(); + return m_treePane->GetLibTree()->GetSelectedLibId( aUnit ); } diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 3fdd671f52..40b491b6c5 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -140,7 +140,7 @@ public: /** * Return the LIB_ID of the library or symbol selected in the symbol tree. */ - LIB_ID GetTreeLIBID() const; + LIB_ID GetTreeLIBID( int* aUnit = nullptr ) const; /** * Return the current part being edited or NULL if none selected. @@ -209,24 +209,8 @@ public: */ void CreateNewPart(); - /** - * Opens the selected part for editing. - */ - void OnEditPart( wxCommandEvent& aEvent ); - - /** - * Routine to read one part. - * The format is that of libraries, but it loads only 1 component. - * Or 1 component if there are several. - * If the first component is an alias, it will load the corresponding root. - */ void ImportPart(); - - /** - * Creates a new library and backup the current component in this library or exports - * the component of the current library. - */ - void OnExportPart( wxCommandEvent& event ); + void ExportPart(); /** * Add the current part to the schematic @@ -236,30 +220,33 @@ public: /** * Saves the selected part or library. */ - void OnSave(); + void Save(); /** * Saves the selected part or library to a new name and/or location. */ - void OnSaveAs(); + void SaveAs(); /** * Saves all modified parts and libraries. */ - void OnSaveAll(); + void SaveAll(); /** * Reverts unsaved changes in a part, restoring to the last saved state. */ - void OnRevert(); + void Revert(); + + void DeletePartFromLibrary(); + + void CopyPartToClipboard(); + + void LoadPart( const wxString& aLibrary, const wxString& aPart, int Unit ); /** - * Removes a part from the working copy of a library. + * Inserts a duplicate part. If aFromClipboard is true then action is a paste. */ - void OnRemovePart( wxCommandEvent& aEvent ); - - void OnCopyCutPart( wxCommandEvent& aEvent ); - void OnPasteDuplicatePart( wxCommandEvent& aEvent ); + void DuplicatePart( bool aFromClipboard ); void OnSelectUnit( wxCommandEvent& event ); @@ -269,7 +256,6 @@ public: void FreezeSearchTree(); void ThawSearchTree(); - void OnUpdateHavePart( wxUpdateUIEvent& aEvent ); void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event ); @@ -321,8 +307,6 @@ private: // Sets up the tool framework void setupTools(); - void loadPart( const wxString& aLibrary, const wxString& aPart, int Unit ); - void savePartAs(); /** diff --git a/eeschema/libedit/lib_export.cpp b/eeschema/libedit/lib_export.cpp index 3fbe5c332e..9a03aff6fd 100644 --- a/eeschema/libedit/lib_export.cpp +++ b/eeschema/libedit/lib_export.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,14 +24,11 @@ */ #include -#include #include #include -#include #include #include #include -#include #include #include @@ -49,9 +46,8 @@ void LIB_EDIT_FRAME::ImportPart() return; } - wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, - wxEmptyString, SchematicLibraryFileWildcard(), - wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, wxEmptyString, + SchematicLibraryFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return; @@ -93,11 +89,11 @@ void LIB_EDIT_FRAME::ImportPart() m_libMgr->UpdatePart( entry->GetPart(), libName ); SyncLibraries( false ); - loadPart( symbolName, libName, 1 ); + LoadPart( symbolName, libName, 1 ); } -void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) +void LIB_EDIT_FRAME::ExportPart() { wxString msg, title; LIB_PART* part = getTargetPart(); @@ -160,7 +156,8 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) if( fn.Exists() && !fn.IsDirWritable() ) { - msg.Printf( _( "Write permissions are required to save library \"%s\"." ), fn.GetFullPath() ); + msg.Printf( _( "Write permissions are required to save library \"%s\"." ), + fn.GetFullPath() ); DisplayError( this, msg ); return; } diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 9a76052984..cb59815dac 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -24,17 +24,10 @@ */ #include -#include -#include -#include #include -#include #include #include - -#include #include -#include #include #include #include @@ -212,8 +205,8 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in * @param aCurrentScreen the existing frame screen * @param aIncomingScreen a screen that is intended to replace the current screen */ -static void synchronizeLibEditScreenSettings( - const SCH_SCREEN& aCurrentScreen, SCH_SCREEN& aIncomingScreen ) +static void synchronizeLibEditScreenSettings( const SCH_SCREEN& aCurrentScreen, + SCH_SCREEN& aIncomingScreen ) { aIncomingScreen.SetGrid( aCurrentScreen.GetGridSize() ); } @@ -269,7 +262,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a } -void LIB_EDIT_FRAME::OnSaveAll() +void LIB_EDIT_FRAME::SaveAll() { saveAllLibraries( false ); m_treePane->Refresh(); @@ -345,25 +338,16 @@ void LIB_EDIT_FRAME::CreateNewPart() m_libMgr->UpdatePart( &new_part, lib ); SyncLibraries( false ); - loadPart( name, lib, 1 ); + LoadPart( name, lib, 1 ); new_part.SetConversion( dlg.GetAlternateBodyStyle() ); // must be called after loadPart, that calls SetShowDeMorgan, but // because the symbol is empty,it looks like it has no alternate body SetShowDeMorgan( dlg.GetAlternateBodyStyle() ); - } -void LIB_EDIT_FRAME::OnEditPart( wxCommandEvent& aEvent ) -{ - int unit = 0; - LIB_ID partId = m_treePane->GetLibTree()->GetSelectedLibId( &unit ); - loadPart( partId.GetLibItemName(), partId.GetLibNickname(), unit ); -} - - -void LIB_EDIT_FRAME::OnSave() +void LIB_EDIT_FRAME::Save() { LIB_ID libId = getTargetLibId(); const wxString& libName = libId.GetLibNickname(); @@ -385,7 +369,7 @@ void LIB_EDIT_FRAME::OnSave() } -void LIB_EDIT_FRAME::OnSaveAs() +void LIB_EDIT_FRAME::SaveAs() { LIB_ID libId = getTargetLibId(); const wxString& libName = libId.GetLibNickname(); @@ -493,7 +477,7 @@ void LIB_EDIT_FRAME::savePartAs() m_treePane->GetLibTree()->SelectLibId( LIB_ID( new_lib, new_part.GetName() ) ); if( isCurrentPart( old_lib_id ) ) - loadPart( new_name, new_lib, m_unit ); + LoadPart( new_name, new_lib, m_unit ); } } @@ -536,14 +520,14 @@ void LIB_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName, wxArrayStr } -void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent ) +void LIB_EDIT_FRAME::DeletePartFromLibrary() { LIB_ID libId = getTargetLibId(); if( m_libMgr->IsPartModified( libId.GetLibItemName(), libId.GetLibNickname() ) && !IsOK( this, _( wxString::Format( "Component %s has been modified\n" - "Do you want to remove it from the library?", - libId.GetUniStringLibItemName() ) ) ) ) + "Do you want to remove it from the library?", + libId.GetUniStringLibItemName() ) ) ) ) { return; } @@ -557,7 +541,7 @@ void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent ) } -void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent ) +void LIB_EDIT_FRAME::CopyPartToClipboard() { int dummyUnit; LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit ); @@ -579,13 +563,10 @@ void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent ) clipboard->SetData( data ); clipboard->Flush(); - - if( aEvent.GetId() == ID_LIBEDIT_CUT_PART ) - OnRemovePart( aEvent ); } -void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent ) +void LIB_EDIT_FRAME::DuplicatePart( bool aFromClipboard ) { int dummyUnit; LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit ); @@ -597,12 +578,7 @@ void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent ) LIB_PART* srcPart = nullptr; LIB_PART* newPart = nullptr; - if( aEvent.GetId() == ID_LIBEDIT_DUPLICATE_PART ) - { - srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib ); - newPart = new LIB_PART( *srcPart ); - } - else if( aEvent.GetId() == ID_LIBEDIT_PASTE_PART ) + if( aFromClipboard ) { auto clipboard = wxTheClipboard; wxClipboardLocker clipboardLock( clipboard ); @@ -628,7 +604,10 @@ void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent ) } } else - wxFAIL; + { + srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib ); + newPart = new LIB_PART( *srcPart ); + } if( !newPart ) return; @@ -669,7 +648,7 @@ void LIB_EDIT_FRAME::fixDuplicateAliases( LIB_PART* aPart, const wxString& aLibr } -void LIB_EDIT_FRAME::OnRevert() +void LIB_EDIT_FRAME::Revert() { LIB_ID libId = getTargetLibId(); const wxString& libName = libId.GetLibNickname(); @@ -718,14 +697,14 @@ void LIB_EDIT_FRAME::OnRevert() } if( reload_currentPart && m_libMgr->PartExists( curr_partName, libName ) ) - loadPart( curr_partName, libName, unit ); + LoadPart( curr_partName, libName, unit ); m_treePane->Refresh(); refreshSchematic(); } -void LIB_EDIT_FRAME::loadPart( const wxString& aAlias, const wxString& aLibrary, int aUnit ) +void LIB_EDIT_FRAME::LoadPart( const wxString& aAlias, const wxString& aLibrary, int aUnit ) { wxCHECK( m_libMgr->PartExists( aAlias, aLibrary ), /* void */ ); LIB_PART* part = m_libMgr->GetBufferedPart( aAlias, aLibrary ); @@ -743,7 +722,7 @@ void LIB_EDIT_FRAME::loadPart( const wxString& aAlias, const wxString& aLibrary, // Optimize default edit options for this symbol // Usually if units are locked, graphic items are specific to each unit // and if units are interchangeable, graphic items are common to units - m_DrawSpecificUnit = part->UnitsLocked() ? true : false; + m_DrawSpecificUnit = part->UnitsLocked(); LoadOneLibraryPartAux( alias, aLibrary, aUnit, 0 ); } diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index 358dff288a..e7dc8f06e7 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -31,8 +31,6 @@ #include #include #include "eeschema_id.h" -#include "general.h" -#include "help_common_strings.h" #include "ee_hotkeys.h" #include "lib_edit_frame.h" @@ -80,9 +78,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( export_xpm ); - submenuExport->Add( _( "Symbol..." ), - _( "Create a new library file containing the current symbol" ), - ID_LIBEDIT_EXPORT_PART, export_part_xpm ); + submenuExport->Add( EE_ACTIONS::exportSymbol ); submenuExport->Add( _( "View as PNG..." ), _( "Create a PNG file from the current view" ), ID_LIBEDIT_GEN_PNG_FILE, plot_xpm ); diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 7aee3104a3..6ff5a48afc 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #ifdef __UNIX__ diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index a0361cb9fc..1495bd27cc 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -31,10 +31,7 @@ #include #include #include - #include "eeschema_id.h" -#include "general.h" -#include "help_common_strings.h" #include "ee_hotkeys.h" #include "sch_edit_frame.h" @@ -102,7 +99,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( import_xpm ); - submenuImport->Add( _( "Footprint Association File..." ), HELP_IMPORT_FOOTPRINTS, + submenuImport->Add( _( "Footprint Association File..." ), + _( "Back-import symbol footprint associations from .cmp file created by Pcbnew" ), ID_BACKANNO_ITEMS, import_footprint_names_xpm ); fileMenu->AddMenu( submenuImport, EE_CONDITIONS::ShowAlways ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 1cfd444229..1291b4015f 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -28,11 +28,9 @@ #include #include #include -#include #include #include #include -#include #include /* Create the main Horizontal Toolbar for the schematic editor @@ -105,7 +103,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString, KiScaledBitmap( import_footprint_names_xpm, this ), - HELP_IMPORT_FOOTPRINTS ); + _( "Back-import symbol footprint associations from .cmp file created by Pcbnew" ) ); // after adding the tools to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index 109eba4e7c..4dc8362b66 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -27,8 +27,6 @@ #include "class_library.h" #include "eeschema_id.h" #include "general.h" -#include "help_common_strings.h" -#include "ee_hotkeys.h" #include "viewlib_frame.h" #include #include diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index ace3b6935f..e4bd3d868e 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -167,7 +167,14 @@ public: // Library management static TOOL_ACTION newSymbol; + static TOOL_ACTION editSymbol; + static TOOL_ACTION duplicateSymbol; + static TOOL_ACTION deleteSymbol; + static TOOL_ACTION cutSymbol; + static TOOL_ACTION copySymbol; + static TOOL_ACTION pasteSymbol; static TOOL_ACTION importSymbol; + static TOOL_ACTION exportSymbol; // Hierarchy navigation static TOOL_ACTION enterSheet; diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index d70136e9ee..0aa1b07c51 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -31,6 +31,51 @@ #include +TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.SymbolLibraryControl.newSymbol", + AS_GLOBAL, 0, + _( "New Symbol..." ), _( "Create a new symbol" ), + new_component_xpm ); + +TOOL_ACTION EE_ACTIONS::editSymbol( "eeschema.SymbolLibraryControl.editSymbol", + AS_GLOBAL, 0, + _( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ), + edit_xpm ); + +TOOL_ACTION EE_ACTIONS::duplicateSymbol( "eeschema.SymbolLibraryControl.duplicateSymbol", + AS_GLOBAL, 0, + _( "Duplicate Symbol" ), _( "Make a copy of the selected symbol" ), + duplicate_xpm ); + +TOOL_ACTION EE_ACTIONS::deleteSymbol( "eeschema.SymbolLibraryControl.deleteSymbol", + AS_GLOBAL, 0, + _( "Delete Symbol" ), _( "Remove the selected symbol from its library" ), + delete_xpm ); + +TOOL_ACTION EE_ACTIONS::cutSymbol( "eeschema.SymbolLibraryControl.cutSymbol", + AS_GLOBAL, 0, + _( "Cut Symbol" ), "", + cut_xpm ); + +TOOL_ACTION EE_ACTIONS::copySymbol( "eeschema.SymbolLibraryControl.copySymbol", + AS_GLOBAL, 0, + _( "Copy Symbol" ), "", + copy_xpm ); + +TOOL_ACTION EE_ACTIONS::pasteSymbol( "eeschema.SymbolLibraryControl.pasteSymbol", + AS_GLOBAL, 0, + _( "Paste Symbol" ), "", + paste_xpm ); + +TOOL_ACTION EE_ACTIONS::importSymbol( "eeschema.SymbolLibraryControl.importSymbol", + AS_GLOBAL, 0, + _( "Import Symbol..." ), _( "Import a symbol to the current library" ), + import_part_xpm ); + +TOOL_ACTION EE_ACTIONS::exportSymbol( "eeschema.SymbolLibraryControl.exportSymbol", + AS_GLOBAL, 0, + _( "Export Symbol..." ), _( "Export a symbol to a new library file" ), + export_part_xpm ); + TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes", AS_GLOBAL, 0, _( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ), @@ -45,6 +90,8 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo bool LIB_CONTROL::Init() { + EE_TOOL_BASE::Init(); + if( m_isLibEdit ) { CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); @@ -67,33 +114,23 @@ bool LIB_CONTROL::Init() ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); ctxMenu.AddItem( EE_ACTIONS::newSymbol, SELECTION_CONDITIONS::ShowAlways ); - ctxMenu.AddItem( ID_LIBEDIT_EDIT_PART, - _( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ), - edit_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::editSymbol, symbolSelectedCondition ); ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition ); ctxMenu.AddItem( ACTIONS::saveCopyAs, symbolSelectedCondition ); - ctxMenu.AddItem( ID_LIBEDIT_DUPLICATE_PART, - _( "Duplicate" ), _( "Make a copy of the selected symbol" ), - duplicate_xpm, symbolSelectedCondition ); - ctxMenu.AddItem( ID_LIBEDIT_REMOVE_PART, - _( "Delete" ), _( "Remove the selected symbol from the library" ), - delete_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::duplicateSymbol, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::deleteSymbol, symbolSelectedCondition ); ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition ); ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); - ctxMenu.AddItem( ID_LIBEDIT_CUT_PART, _( "Cut Symbol" ), "", - cut_xpm, symbolSelectedCondition ); - ctxMenu.AddItem( ID_LIBEDIT_COPY_PART, _( "Copy Symbol" ), "", - copy_xpm, symbolSelectedCondition ); - ctxMenu.AddItem( ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ), "", - paste_xpm, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::copySymbol, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::pasteSymbol, SELECTION_CONDITIONS::ShowAlways ); ctxMenu.AddSeparator( symbolSelectedCondition ); ctxMenu.AddItem( EE_ACTIONS::importSymbol, SELECTION_CONDITIONS::ShowAlways ); - ctxMenu.AddItem( ID_LIBEDIT_EXPORT_PART, _( "Export Symbol..." ), "", - export_part_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::exportSymbol, symbolSelectedCondition ); } return true; @@ -111,42 +148,50 @@ int LIB_CONTROL::AddLibrary( const TOOL_EVENT& aEvent ) } -int LIB_CONTROL::AddSymbol( const TOOL_EVENT& aEvent ) +int LIB_CONTROL::EditSymbol( const TOOL_EVENT& aEvent ) { if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) { - if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) ) - static_cast( m_frame )->CreateNewPart(); - else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) ) - static_cast( m_frame )->ImportPart(); + LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); + int unit = 0; + LIB_ID partId = editFrame->GetTreeLIBID( &unit ); + + editFrame->LoadPart( partId.GetLibItemName(), partId.GetLibNickname(), unit ); } return 0; } -int LIB_CONTROL::Save( const TOOL_EVENT& aEvent ) +int LIB_CONTROL::AddSymbol( const TOOL_EVENT& aEvent ) { if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) - static_cast( m_frame )->OnSave(); + { + LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); + + if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) ) + editFrame->CreateNewPart(); + else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) ) + editFrame->ImportPart(); + } return 0; } -int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent ) +int LIB_CONTROL::Save( const TOOL_EVENT& aEvt ) { if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) - static_cast( m_frame )->OnSaveAs(); + { + LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); - return 0; -} - - -int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent ) -{ - if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) - static_cast( m_frame )->OnSaveAll(); + if( aEvt.IsAction( &EE_ACTIONS::save ) ) + editFrame->Save(); + else if( aEvt.IsAction( &EE_ACTIONS::saveAs ) || aEvt.IsAction( &EE_ACTIONS::saveCopyAs ) ) + editFrame->SaveAs(); + else if( aEvt.IsAction( &EE_ACTIONS::saveAll ) ) + editFrame->SaveAll(); + } return 0; } @@ -155,7 +200,45 @@ int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent ) int LIB_CONTROL::Revert( const TOOL_EVENT& aEvent ) { if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) - static_cast( m_frame )->OnRevert(); + static_cast( m_frame )->Revert(); + + return 0; +} + + +int LIB_CONTROL::ExportSymbol( const TOOL_EVENT& aEvent ) +{ + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + static_cast( m_frame )->ExportPart(); + + return 0; +} + + +int LIB_CONTROL::CutCopyDelete( const TOOL_EVENT& aEvt ) +{ + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + { + LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); + + if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::copySymbol ) ) + editFrame->CopyPartToClipboard(); + + if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::deleteSymbol ) ) + editFrame->DeletePartFromLibrary(); + } + + return 0; +} + + +int LIB_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent ) +{ + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + { + LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); + editFrame->DuplicatePart( aEvent.IsAction( &EE_ACTIONS::pasteSymbol ) ); + } return 0; } @@ -227,13 +310,21 @@ void LIB_CONTROL::setTransitions() Go( &LIB_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() ); Go( &LIB_CONTROL::AddSymbol, EE_ACTIONS::newSymbol.MakeEvent() ); Go( &LIB_CONTROL::AddSymbol, EE_ACTIONS::importSymbol.MakeEvent() ); + Go( &LIB_CONTROL::EditSymbol, EE_ACTIONS::editSymbol.MakeEvent() ); Go( &LIB_CONTROL::Save, ACTIONS::save.MakeEvent() ); - Go( &LIB_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() ); // for libraries - Go( &LIB_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() ); // for symbols - Go( &LIB_CONTROL::SaveAll, ACTIONS::saveAll.MakeEvent() ); + Go( &LIB_CONTROL::Save, ACTIONS::saveAs.MakeEvent() ); // for libraries + Go( &LIB_CONTROL::Save, ACTIONS::saveCopyAs.MakeEvent() ); // for symbols + Go( &LIB_CONTROL::Save, ACTIONS::saveAll.MakeEvent() ); Go( &LIB_CONTROL::Revert, ACTIONS::revert.MakeEvent() ); + Go( &LIB_CONTROL::DuplicateSymbol, EE_ACTIONS::duplicateSymbol.MakeEvent() ); + Go( &LIB_CONTROL::CutCopyDelete, EE_ACTIONS::deleteSymbol.MakeEvent() ); + Go( &LIB_CONTROL::CutCopyDelete, EE_ACTIONS::cutSymbol.MakeEvent() ); + Go( &LIB_CONTROL::CutCopyDelete, EE_ACTIONS::copySymbol.MakeEvent() ); + Go( &LIB_CONTROL::DuplicateSymbol, EE_ACTIONS::pasteSymbol.MakeEvent() ); + Go( &LIB_CONTROL::ExportSymbol, EE_ACTIONS::exportSymbol.MakeEvent() ); + Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() ); Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() ); diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index fe51c384f5..5b7f79c80f 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -49,12 +49,15 @@ public: int AddLibrary( const TOOL_EVENT& aEvent ); int AddSymbol( const TOOL_EVENT& aEvent ); + int EditSymbol( const TOOL_EVENT& aEvent ); - int Save( const TOOL_EVENT& aEvent ); - int SaveAs( const TOOL_EVENT& aEvent ); - int SaveAll( const TOOL_EVENT& aEvent ); + int Save( const TOOL_EVENT& aEvt ); int Revert( const TOOL_EVENT& aEvent ); + int CutCopyDelete( const TOOL_EVENT& aEvent ); + int DuplicateSymbol( const TOOL_EVENT& aEvent ); + int ExportSymbol( const TOOL_EVENT& aEvent ); + int OnDeMorgan( const TOOL_EVENT& aEvent ); int ShowLibraryBrowser( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 58f955fa7d..8f98f93858 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -121,16 +121,6 @@ TOOL_ACTION EE_ACTIONS::generateBOM( "eeschema.EditorControl.generateBOM", _( "Generate BOM..." ), _( "Generate a bill of materials for the current schematic" ), bom_xpm ); -TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.EditorControl.newSymbol", - AS_GLOBAL, 0, - _( "New Symbol..." ), _( "Create a new symbol" ), - new_component_xpm ); - -TOOL_ACTION EE_ACTIONS::importSymbol( "eeschema.EditorControl.importSymbol", - AS_GLOBAL, 0, - _( "Import Symbol..." ), _( "Import a symbol to the current library" ), - import_part_xpm ); - TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet", AS_GLOBAL, 0, _( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ), diff --git a/eeschema/widgets/symbol_tree_pane.cpp b/eeschema/widgets/symbol_tree_pane.cpp index c35eeaca6f..308d777958 100644 --- a/eeschema/widgets/symbol_tree_pane.cpp +++ b/eeschema/widgets/symbol_tree_pane.cpp @@ -23,11 +23,12 @@ */ #include "symbol_tree_pane.h" - #include #include #include #include +#include +#include SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr ) : wxPanel( aParent ), @@ -65,9 +66,7 @@ void SYMBOL_TREE_PANE::Regenerate() void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent ) { - wxCommandEvent dummy; - m_libEditFrame->OnEditPart( dummy ); - - // Make sure current-part highlighting doesn't get lost in seleciton highlighting + m_libEditFrame->GetToolManager()->RunAction( EE_ACTIONS::editSymbol, true ); + // Make sure current-part highlighting doesn't get lost in selection highlighting m_tree->Unselect(); }