Finish moving symbol editor tree context menu to ACTIONs.

This commit is contained in:
Jeff Young 2019-06-05 23:29:59 +01:00
parent 6fab7cc025
commit 469fc3b572
16 changed files with 194 additions and 227 deletions

View File

@ -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,

View File

@ -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" )

View File

@ -49,7 +49,6 @@
#include <wx/progdlg.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_menu.h>
#include <tool/common_tools.h>
#include <tool/zoom_tool.h>
#include <tools/ee_actions.h>
@ -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 );
}

View File

@ -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();
/**

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <fctsys.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <symbol_lib_table.h>
#include <general.h>
#include <lib_edit_frame.h>
#include <class_library.h>
#include <wildcards_and_files_ext.h>
#include <eeschema_id.h>
#include <lib_manager.h>
#include <wx/filename.h>
@ -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;
}

View File

@ -24,17 +24,10 @@
*/
#include <fctsys.h>
#include <kiway.h>
#include <gr_basic.h>
#include <macros.h>
#include <pgm_base.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <gestfich.h>
#include <eeschema_id.h>
#include <tools/ee_actions.h>
#include <general.h>
#include <lib_edit_frame.h>
#include <class_library.h>
#include <template_fieldnames.h>
@ -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 );
}

View File

@ -31,8 +31,6 @@
#include <tools/ee_selection_tool.h>
#include <lib_manager.h>
#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 );

View File

@ -32,7 +32,6 @@
#include <dialog_helpers.h>
#include <bitmaps.h>
#include <lib_manager.h>
#include <help_common_strings.h>
#include <tools/ee_actions.h>
#ifdef __UNIX__

View File

@ -31,10 +31,7 @@
#include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_actions.h>
#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 );

View File

@ -28,11 +28,9 @@
#include <sch_edit_frame.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <ee_hotkeys.h>
#include <eeschema_id.h>
#include <tool/tool_manager.h>
#include <tool/action_toolbar.h>
#include <help_common_strings.h>
#include <tools/ee_actions.h>
/* 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();

View File

@ -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 <symbol_lib_table.h>
#include <tool/conditional_menu.h>

View File

@ -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;

View File

@ -31,6 +31,51 @@
#include <viewlib_frame.h>
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<LIB_EDIT_FRAME*>( m_frame )->CreateNewPart();
else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
static_cast<LIB_EDIT_FRAME*>( m_frame )->ImportPart();
LIB_EDIT_FRAME* editFrame = static_cast<LIB_EDIT_FRAME*>( 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<LIB_EDIT_FRAME*>( m_frame )->OnSave();
{
LIB_EDIT_FRAME* editFrame = static_cast<LIB_EDIT_FRAME*>( 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<LIB_EDIT_FRAME*>( m_frame )->OnSaveAs();
{
LIB_EDIT_FRAME* editFrame = static_cast<LIB_EDIT_FRAME*>( m_frame );
return 0;
}
int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( 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<LIB_EDIT_FRAME*>( m_frame )->OnRevert();
static_cast<LIB_EDIT_FRAME*>( m_frame )->Revert();
return 0;
}
int LIB_CONTROL::ExportSymbol( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( 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<LIB_EDIT_FRAME*>( 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<LIB_EDIT_FRAME*>( 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() );

View File

@ -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 );

View File

@ -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" ),

View File

@ -23,11 +23,12 @@
*/
#include "symbol_tree_pane.h"
#include <widgets/lib_tree.h>
#include <lib_manager.h>
#include <lib_edit_frame.h>
#include <symbol_lib_table.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
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();
}