More ACTIONs work.

This commit is contained in:
Jeff Young 2019-06-04 00:50:44 +01:00
parent 584ed9e204
commit 1bf04d1722
25 changed files with 226 additions and 200 deletions

View File

@ -212,18 +212,12 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
}; };
prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ), prefsMenu->AddItem( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways );
_( "Edit path configuration environment variables" ), prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways );
path_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddItem( ID_EDIT_SYM_LIB_TABLE, _( "Manage &Symbol Libraries..." ),
_( "Edit the global and project symbol library tables." ),
library_table_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddItem( wxID_PREFERENCES, prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES ), AddHotkeyName( _( "Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ), _( "Show preferences for all open tools" ),
preference_xpm, EE_CONDITIONS::ShowAlways ); preference_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddSeparator(); prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu ); Pgm().AddMenuLanguageList( prefsMenu );

View File

@ -307,7 +307,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.Update(); m_auimgr.Update();
GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
if( GetGalCanvas() ) if( GetGalCanvas() )
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );

View File

@ -291,7 +291,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item; WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item;
item->Restore( this ); item->Restore( this );
*item = alt_item; *item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
} }
else if( dynamic_cast<SCH_ITEM*>( eda_item ) ) else if( dynamic_cast<SCH_ITEM*>( eda_item ) )
{ {

View File

@ -215,7 +215,7 @@ int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true );
else else
m_frame->RollbackSchematicFromUndo(); m_frame->RollbackSchematicFromUndo();

View File

@ -161,7 +161,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.Update(); m_auimgr.Update();
SetActiveLayer( 0, true ); SetActiveLayer( 0, true );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting(); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();

View File

@ -76,7 +76,7 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList()
if( pageSettingsAndTitleBlock ) if( pageSettingsAndTitleBlock )
{ {
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
HardRedraw(); // items based off of corners will need re-calculating HardRedraw(); // items based off of corners will need re-calculating
} }
else else
@ -116,7 +116,7 @@ void PL_EDITOR_FRAME::GetLayoutFromUndoList()
if( pageSettingsAndTitleBlock ) if( pageSettingsAndTitleBlock )
{ {
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
HardRedraw(); // items based off of corners will need re-calculating HardRedraw(); // items based off of corners will need re-calculating
} }
else else
@ -148,7 +148,7 @@ void PL_EDITOR_FRAME::RollbackFromUndo()
if( pageSettingsAndTitleBlock ) if( pageSettingsAndTitleBlock )
{ {
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
HardRedraw(); // items based off of corners will need re-calculating HardRedraw(); // items based off of corners will need re-calculating
} }
else else

View File

@ -106,7 +106,7 @@ int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
} }
else else
{ {
m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true );
m_frame->HardRedraw(); m_frame->HardRedraw();
} }
return 0; return 0;

View File

@ -241,29 +241,19 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
} }
if( module == NULL ) if( module == NULL )
{
msg.Printf( _( "%s not found" ), modName ); msg.Printf( _( "%s not found" ), modName );
}
else if( pad == NULL ) else if( pad == NULL )
{
msg.Printf( _( "%s pin %s not found" ), modName, pinName ); msg.Printf( _( "%s pin %s not found" ), modName, pinName );
}
else else
{
msg.Printf( _( "%s pin %s found" ), modName, pinName ); msg.Printf( _( "%s pin %s found" ), modName, pinName );
}
SetStatusText( msg ); SetStatusText( msg );
} }
if( module ) // if found, center the module on screen, and redraw the screen. if( module ) // if found, center the module on screen, and redraw the screen.
{ {
GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, true,
true, pad ? (BOARD_ITEM*) pad : (BOARD_ITEM*) module );
pad ?
static_cast<BOARD_ITEM*>( pad ) :
static_cast<BOARD_ITEM*>( module )
);
} }
} }
@ -287,8 +277,8 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
wxString pad = ((D_PAD*)aItem)->GetName(); wxString pad = ((D_PAD*)aItem)->GetName();
return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"", return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
TO_UTF8( module->GetReference() ), TO_UTF8( module->GetReference() ),
TO_UTF8( pad ) ); TO_UTF8( pad ) );
} }
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
@ -309,9 +299,9 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
break; break;
return StrPrintf( "$PART: \"%s\" %s \"%s\"", return StrPrintf( "$PART: \"%s\" %s \"%s\"",
TO_UTF8( module->GetReference() ), TO_UTF8( module->GetReference() ),
text_key, text_key,
TO_UTF8( text_mod->GetText() ) ); TO_UTF8( text_mod->GetText() ) );
} }
default: default:

View File

@ -85,27 +85,21 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom ) EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid ) EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
EVT_TOOL( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng ) EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_PASTE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_PASTE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard ) EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, FOOTPRINT_EDIT_FRAME::OnToggleSearchTree ) EVT_TOOL( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, FOOTPRINT_EDIT_FRAME::OnToggleSearchTree )
@ -117,15 +111,11 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings )
// UI update events. // UI update events.
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard ) FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard ) FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
EVT_UPDATE_UI( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -249,7 +239,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_auimgr.Update(); m_auimgr.Update();
GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
updateTitle(); updateTitle();
Raise(); // On some window managers, this is needed Raise(); // On some window managers, this is needed
@ -309,7 +299,7 @@ BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
} }
LIB_ID FOOTPRINT_EDIT_FRAME::getTargetFPID() const LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const
{ {
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId(); LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
wxString nickname = id.GetLibNickname(); wxString nickname = id.GetLibNickname();
@ -513,12 +503,6 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
} }
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( getTargetFPID().IsValid() );
}
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent ) void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
{ {
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
@ -705,7 +689,7 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
{ {
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs(); FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() ); auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
LIB_ID target = getTargetFPID(); LIB_ID target = GetTargetFPID();
bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() ); bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
// Sync FOOTPRINT_INFO list to the libraries on disk // Sync FOOTPRINT_INFO list to the libraries on disk
@ -906,7 +890,3 @@ void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
} }
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
{
GetToolManager()->RunAction( ACTIONS::print );
}

View File

@ -184,11 +184,6 @@ public:
*/ */
void OnModify() override; void OnModify() override;
/**
* Install the print dialog
*/
void ToPrinter( wxCommandEvent& event );
// BOARD handling // BOARD handling
/** /**
@ -199,7 +194,7 @@ public:
bool Clear_Pcb( bool aQuery ); bool Clear_Pcb( bool aQuery );
/// Return the LIB_ID of the part selected in the footprint or the part being edited. /// Return the LIB_ID of the part selected in the footprint or the part being edited.
LIB_ID getTargetFPID() const; LIB_ID GetTargetFPID() const;
/// Return the LIB_ID of the part being edited. /// Return the LIB_ID of the part being edited.
LIB_ID GetLoadedFPID() const; LIB_ID GetLoadedFPID() const;

View File

@ -123,9 +123,12 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
updateView(); updateView();
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
// Update the bitmap of the ID_MODEDIT_SAVE tool if needed. // Update the save items if needed.
if( is_last_fp_from_brd ) if( is_last_fp_from_brd )
{
ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
}
m_treePane->GetLibTree()->ExpandLibId( aFPID ); m_treePane->GetLibTree()->ExpandLibId( aFPID );
m_treePane->GetLibTree()->CenterLibId( aFPID ); m_treePane->GetLibTree()->CenterLibId( aFPID );
@ -143,10 +146,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case wxID_CUT:
case wxID_COPY:
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_MODEDIT_PAD_SETTINGS:
break; break;
default: default:
@ -182,16 +182,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_MODEDIT_DELETE_PART:
if( DeleteModuleFromLibrary( getTargetFPID(), true ) )
{
if( getTargetFPID() == GetLoadedFPID() )
Clear_Pcb( false );
SyncLibraryTree( true );
}
break;
case ID_MODEDIT_NEW_MODULE: case ID_MODEDIT_NEW_MODULE:
{ {
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId(); LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
@ -302,7 +292,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_SAVE: case ID_MODEDIT_SAVE:
if( getTargetFPID() == GetLoadedFPID() ) if( GetTargetFPID() == GetLoadedFPID() )
{ {
if( SaveFootprint( GetBoard()->GetFirstModule() ) ) if( SaveFootprint( GetBoard()->GetFirstModule() ) )
{ {
@ -317,16 +307,16 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_SAVE_AS: case ID_MODEDIT_SAVE_AS:
if( getTargetFPID().GetLibItemName().empty() ) if( GetTargetFPID().GetLibItemName().empty() )
{ {
// Save Library As // Save Library As
const wxString& src_libNickname = getTargetFPID().GetLibNickname(); const wxString& src_libNickname = GetTargetFPID().GetLibNickname();
wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname ); wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname );
if( SaveLibraryAs( src_libFullName ) ) if( SaveLibraryAs( src_libFullName ) )
SyncLibraryTree( true ); SyncLibraryTree( true );
} }
else if( getTargetFPID() == GetLoadedFPID() ) else if( GetTargetFPID() == GetLoadedFPID() )
{ {
// Save Board Footprint As // Save Board Footprint As
MODULE* footprint = GetBoard()->GetFirstModule(); MODULE* footprint = GetBoard()->GetFirstModule();
@ -344,7 +334,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
else else
{ {
// Save Selected Footprint As // Save Selected Footprint As
MODULE* footprint = LoadFootprint( getTargetFPID() ); MODULE* footprint = LoadFootprint( GetTargetFPID() );
if( footprint && SaveFootprintAs( footprint ) ) if( footprint && SaveFootprintAs( footprint ) )
SyncLibraryTree( true ); SyncLibraryTree( true );
@ -355,9 +345,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_CUT_PART: case ID_MODEDIT_CUT_PART:
case ID_MODEDIT_COPY_PART: case ID_MODEDIT_COPY_PART:
if( getTargetFPID().IsValid() ) if( GetTargetFPID().IsValid() )
{ {
LIB_ID fpID = getTargetFPID(); LIB_ID fpID = GetTargetFPID();
if( fpID == GetLoadedFPID() ) if( fpID == GetLoadedFPID() )
m_copiedModule.reset( new MODULE( *GetBoard()->GetFirstModule() ) ); m_copiedModule.reset( new MODULE( *GetBoard()->GetFirstModule() ) );
@ -377,9 +367,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_PASTE_PART: case ID_MODEDIT_PASTE_PART:
if( m_copiedModule && !getTargetFPID().GetLibNickname().empty() ) if( m_copiedModule && !GetTargetFPID().GetLibNickname().empty() )
{ {
wxString newLib = getTargetFPID().GetLibNickname(); wxString newLib = GetTargetFPID().GetLibNickname();
MODULE* newModule( m_copiedModule.get() ); MODULE* newModule( m_copiedModule.get() );
wxString newName = newModule->GetFPID().GetLibItemName(); wxString newName = newModule->GetFPID().GetLibItemName();
@ -416,32 +406,20 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_EXPORT_PART: case ID_MODEDIT_EXPORT_PART:
if( getTargetFPID() == GetLoadedFPID() ) if( GetTargetFPID() == GetLoadedFPID() )
Export_Module( GetBoard()->GetFirstModule() ); Export_Module( GetBoard()->GetFirstModule() );
else else
Export_Module( LoadFootprint( getTargetFPID() ) ); Export_Module( LoadFootprint( GetTargetFPID() ) );
break; break;
case ID_MODEDIT_EDIT_MODULE: case ID_MODEDIT_EDIT_MODULE:
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() ); LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
break; break;
case ID_MODEDIT_PAD_SETTINGS:
InstallPadOptionsFrame( NULL );
break;
case ID_MODEDIT_CHECK: case ID_MODEDIT_CHECK:
// Currently: not implemented // Currently: not implemented
break; break;
case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
if( GetBoard()->GetFirstModule() )
{
editFootprintProperties( GetBoard()->GetFirstModule() );
GetGalCanvas()->Refresh();
}
break;
default: default:
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) ); wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
break; break;

View File

@ -30,7 +30,7 @@
#include <footprint_edit_frame.h> #include <footprint_edit_frame.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <tools/pcb_actions.h>
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
: wxPanel( aParent ), : wxPanel( aParent ),
@ -50,8 +50,8 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>(); std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
menuLibrary->Add( ACTIONS::newLibrary ); menuLibrary->Add( ACTIONS::newLibrary );
menuLibrary->Add( ACTIONS::addLibrary ); menuLibrary->Add( ACTIONS::addLibrary );
menuLibrary->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm ); menuLibrary->Add( ACTIONS::save );
menuLibrary->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm ); menuLibrary->Add( ACTIONS::saveAs );
menuLibrary->AppendSeparator(); menuLibrary->AppendSeparator();
menuLibrary->Add( _( "New Footprint..." ), ID_MODEDIT_NEW_MODULE, new_footprint_xpm ); menuLibrary->Add( _( "New Footprint..." ), ID_MODEDIT_NEW_MODULE, new_footprint_xpm );
@ -65,9 +65,9 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm ); menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm );
menuPart->AppendSeparator(); menuPart->AppendSeparator();
menuPart->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm ); menuPart->Add( ACTIONS::save );
menuPart->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm ); menuPart->Add( ACTIONS::saveCopyAs );
menuPart->Add( _( "Delete" ), ID_MODEDIT_DELETE_PART, delete_xpm ); menuPart->Add( PCB_ACTIONS::deleteFootprint );
menuPart->Add( ACTIONS::revert ); menuPart->Add( ACTIONS::revert );
menuPart->AppendSeparator(); menuPart->AppendSeparator();

View File

@ -227,7 +227,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
updateView(); updateView();
SetActiveLayer( F_Cu ); SetActiveLayer( F_Cu );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
// Do not Run a dialog here: on some Window Managers, it creates issues. // Do not Run a dialog here: on some Window Managers, it creates issues.
// Reason: the FOOTPRINT_WIZARD_FRAME is run as modal; // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;

View File

@ -146,9 +146,12 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
GetScreen()->ClrModify(); GetScreen()->ClrModify();
// Update the bitmap of the ID_MODEDIT_SAVE tool if needed. // Update the save items if needed.
if( !is_last_fp_from_brd ) if( !is_last_fp_from_brd )
{
ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
}
Update3DView( true ); Update3DView( true );
updateView(); updateView();

View File

@ -51,36 +51,38 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
auto modifiedDocumentCondition = [this]( const SELECTION& sel ) { auto modifiedDocumentCondition = [this]( const SELECTION& sel ) {
return !GetBoard()->Modules().empty() && GetScreen()->IsModify(); return !GetBoard()->Modules().empty() && GetScreen()->IsModify();
}; };
auto libraryPartCondition = [ this ] ( const SELECTION& sel ) { auto haveFootprintCondition = [ this ] ( const SELECTION& aSelection ) {
LIB_ID libId = getTargetFPID(); return GetBoard()->GetFirstModule() != nullptr;
const wxString& libName = libId.GetLibNickname(); };
const wxString& partName = libId.GetLibItemName(); auto footprintTargettedCondition = [ this ] ( const SELECTION& aSelection ) {
return GetTargetFPID().IsValid();
return( !libName.IsEmpty() || !partName.IsEmpty() );
}; };
//-- File menu ---------------------------------------------------------- //-- File menu ----------------------------------------------------------
// //
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE, fileMenu->AddItem( ID_MODEDIT_NEW_MODULE,
AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ), AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ),
_( "Create a new footprint" ), _( "Create a new footprint" ),
new_footprint_xpm, SELECTION_CONDITIONS::ShowAlways ); new_footprint_xpm, SELECTION_CONDITIONS::ShowAlways );
#ifdef KICAD_SCRIPTING #ifdef KICAD_SCRIPTING
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, fileMenu->AddItem( ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
_( "&Create Footprint..." ), _( "&Create Footprint..." ),
_( "Create a new footprint using the footprint wizard" ), _( "Create a new footprint using the footprint wizard" ),
module_wizard_xpm, SELECTION_CONDITIONS::ShowAlways ); module_wizard_xpm, SELECTION_CONDITIONS::ShowAlways );
#endif #endif
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); if( IsCurrentFPFromBoard() )
fileMenu->AddItem( ACTIONS::saveAs, libraryPartCondition ); fileMenu->AddItem( PCB_ACTIONS::saveToBoard, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); else
fileMenu->AddItem( PCB_ACTIONS::saveToLibrary, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::saveAs, footprintTargettedCondition );
fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
@ -114,7 +116,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, haveFootprintCondition );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
@ -136,31 +138,18 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
return GetToolId() == ID_NO_TOOL_SELECTED; return GetToolId() == ID_NO_TOOL_SELECTED;
}; };
editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
editMenu->AddSeparator(); editMenu->AddSeparator();
editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::paste, noActiveToolCondition ); editMenu->AddItem( ACTIONS::paste, noActiveToolCondition );
editMenu->AddItem( PCB_ACTIONS::deleteFootprint, footprintTargettedCondition );
// Properties editMenu->AddSeparator();
AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES, editMenu->AddItem( PCB_ACTIONS::footprintProperties, haveFootprintCondition );
_( "&Footprint Properties..." ), editMenu->AddItem( PCB_ACTIONS::defaultPadProperties, SELECTION_CONDITIONS::ShowAlways );
_( "Edit footprint properties" ),
KiBitmap( module_options_xpm ) );
AddMenuItem( editMenu, ID_MODEDIT_PAD_SETTINGS,
_( "Default Pad Properties..." ),
_( "Edit default pad properties" ),
KiBitmap( options_pad_xpm ) );
editMenu->AppendSeparator();
AddMenuItem( editMenu, ID_MODEDIT_DELETE_PART,
_( "&Delete Footprint from Library" ),
_( "Delete the current footprint" ),
KiBitmap( delete_xpm ) );
editMenu->Resolve(); editMenu->Resolve();
@ -201,7 +190,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
_( "Browse footprint libraries" ), _( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways ); modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator(); viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
@ -256,29 +245,29 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
// //
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
placeMenu->AddItem( PCB_ACTIONS::placePad, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::placePad, haveFootprintCondition );
placeMenu->AppendSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::placeText, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawArc, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawCircle, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawLine, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawPolygon, haveFootprintCondition );
placeMenu->AppendSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::setAnchor, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::setAnchor, haveFootprintCondition );
placeMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( ACTIONS::gridSetOrigin, haveFootprintCondition );
placeMenu->Resolve(); placeMenu->Resolve();
//-- Inspect menu ------------------------------------------------------- //-- Inspect menu ------------------------------------------------------
// //
CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool );
inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->AddItem( ACTIONS::measureTool, haveFootprintCondition );
inspectMenu->Resolve(); inspectMenu->Resolve();
//-- Tools menu ------------------------------------------------------- //-- Tools menu --------------------------------------------------------
// //
wxMenu* toolsMenu = new wxMenu; wxMenu* toolsMenu = new wxMenu;
@ -304,20 +293,19 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
}; };
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddItem( wxID_PREFERENCES, prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ), AddHotkeyName( _( "Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ), _( "Show preferences for all open tools" ),
preference_xpm, SELECTION_CONDITIONS::ShowAlways ); preference_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddSeparator(); prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu ); Pgm().AddMenuLanguageList( prefsMenu );
prefsMenu->AddSeparator(); prefsMenu->AddSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
prefsMenu->Resolve(); prefsMenu->Resolve();

View File

@ -301,7 +301,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.Update(); m_auimgr.Update();
GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
m_canvasType = LoadCanvasTypeSetting(); m_canvasType = LoadCanvasTypeSetting();

View File

@ -161,7 +161,6 @@ enum pcbnew_ids
ID_MODEDIT_SAVE, ID_MODEDIT_SAVE,
ID_MODEDIT_SAVE_AS, ID_MODEDIT_SAVE_AS,
ID_MODEDIT_SAVE_PNG, ID_MODEDIT_SAVE_PNG,
ID_MODEDIT_DELETE_PART,
ID_MODEDIT_COPY_PART, ID_MODEDIT_COPY_PART,
ID_MODEDIT_CUT_PART, ID_MODEDIT_CUT_PART,
ID_MODEDIT_PASTE_PART, ID_MODEDIT_PASTE_PART,
@ -169,9 +168,7 @@ enum pcbnew_ids
ID_MODEDIT_NEW_MODULE_FROM_WIZARD, ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
ID_MODEDIT_SHEET_SET, ID_MODEDIT_SHEET_SET,
ID_MODEDIT_EDIT_MODULE, ID_MODEDIT_EDIT_MODULE,
ID_MODEDIT_PAD_SETTINGS,
ID_MODEDIT_LOAD_MODULE_FROM_BOARD, ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
ID_MODEDIT_EDIT_MODULE_PROPERTIES,
ID_MODEDIT_IMPORT_PART, ID_MODEDIT_IMPORT_PART,
ID_MODEDIT_EXPORT_PART, ID_MODEDIT_EXPORT_PART,
ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, ID_MODEDIT_SHOW_HIDE_SEARCH_TREE,

View File

@ -1289,7 +1289,7 @@ int ROUTER_TOOL::CustomTrackWidthDialog( const TOOL_EVENT& aEvent )
if( sizeDlg.ShowModal() ) if( sizeDlg.ShowModal() )
{ {
bds.UseCustomTrackViaSize( true ); bds.UseCustomTrackViaSize( true );
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
} }
return 0; return 0;

View File

@ -23,6 +23,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <class_board.h>
#include <footprint_edit_frame.h> #include <footprint_edit_frame.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
@ -59,22 +60,12 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
#endif #endif
if( IsCurrentFPFromBoard() ) if( IsCurrentFPFromBoard() )
{ m_mainToolBar->Add( PCB_ACTIONS::saveToBoard );
m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
KiScaledBitmap( save_fp_to_board_xpm, this ),
_( "Update footprint on board" ) );
}
else else
{ m_mainToolBar->Add( PCB_ACTIONS::saveToLibrary );
m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
KiScaledBitmap( save_xpm, this ),
_( "Save changes to library" ) );
}
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, m_mainToolBar->Add( ACTIONS::print );
KiScaledBitmap( print_button_xpm, this ),
_( "Print footprint" ) );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::undo ); m_mainToolBar->Add( ACTIONS::undo );
@ -88,13 +79,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE ); m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString, m_mainToolBar->Add( PCB_ACTIONS::footprintProperties );
KiScaledBitmap( module_options_xpm, this ), m_mainToolBar->Add( PCB_ACTIONS::defaultPadProperties );
_( "Footprint properties" ) );
m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
KiScaledBitmap( options_pad_xpm, this ),
_( "Default pad properties" ) );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString, m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
@ -197,9 +183,15 @@ void FOOTPRINT_EDIT_FRAME::SyncMenusAndToolbars()
{ {
PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
if( IsCurrentFPFromBoard() )
m_mainToolBar->Toggle( PCB_ACTIONS::saveToBoard, GetScreen() && GetScreen()->IsModify() );
else
m_mainToolBar->Toggle( PCB_ACTIONS::saveToLibrary, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );
m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );

View File

@ -54,7 +54,28 @@
using namespace std::placeholders; using namespace std::placeholders;
#include <wx/defs.h> #include <wx/defs.h>
TOOL_ACTION PCB_ACTIONS::saveToBoard( "pcbnew.ModuleEditor.saveToBoard",
AS_GLOBAL, 0,
_( "Save to Board" ), _( "Update footprint on board" ),
save_fp_to_board_xpm );
TOOL_ACTION PCB_ACTIONS::saveToLibrary( "pcbnew.ModuleEditor.saveToLibrary",
AS_GLOBAL, 0,
_( "Save to Library" ), _( "Save changes to library" ),
save_xpm );
// Module editor tools // Module editor tools
TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties",
AS_GLOBAL, 0,
_( "Footprint Properties..." ), "",
module_options_xpm );
TOOL_ACTION PCB_ACTIONS::deleteFootprint( "pcbnew.ModuleEditor.deleteFootprint",
AS_GLOBAL, 0,
_( "Delete Footprint from Library" ), "",
delete_xpm );
TOOL_ACTION PCB_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", TOOL_ACTION PCB_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
AS_GLOBAL, 0, AS_GLOBAL, 0,
_( "Add Pad" ), _( "Add a pad" ), _( "Add Pad" ), _( "Add a pad" ),
@ -74,7 +95,13 @@ TOOL_ACTION PCB_ACTIONS::explodePadToShapes( "pcbnew.ModuleEditor.explodePadToSh
TOOL_ACTION PCB_ACTIONS::enumeratePads( "pcbnew.ModuleEditor.enumeratePads", TOOL_ACTION PCB_ACTIONS::enumeratePads( "pcbnew.ModuleEditor.enumeratePads",
AS_GLOBAL, 0, AS_GLOBAL, 0,
_( "Renumber Pads..." ), _( "Renumber pads by clicking on them in the desired order" ), pad_enumerate_xpm, AF_ACTIVATE ); _( "Renumber Pads..." ), _( "Renumber pads by clicking on them in the desired order" ),
pad_enumerate_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::defaultPadProperties( "pcbnew.ModuleEditor.defaultPadProperties",
AS_GLOBAL, 0,
_( "Default Pad Properties..." ), _( "Edit the pad properties used when creating new pads" ),
options_pad_xpm );
MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() : MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() :
@ -93,6 +120,22 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
} }
int MODULE_EDITOR_TOOLS::Save( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE );
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
return 0;
}
int MODULE_EDITOR_TOOLS::SaveAs( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE_AS );
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
return 0;
}
int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent )
{ {
getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint(); getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
@ -100,6 +143,42 @@ int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent )
} }
int MODULE_EDITOR_TOOLS::Delete( const TOOL_EVENT& aEvent )
{
FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
if( frame->DeleteModuleFromLibrary( frame->GetTargetFPID(), true ) )
{
if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
frame->Clear_Pcb( false );
frame->SyncLibraryTree( true );
}
return 0;
}
int MODULE_EDITOR_TOOLS::Properties( const TOOL_EVENT& aEvent )
{
MODULE* footprint = frame()->GetBoard()->GetFirstModule();
if( footprint )
{
getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
frame()->GetGalCanvas()->Refresh();
}
return 0;
}
int MODULE_EDITOR_TOOLS::DefaultPadProperties( const TOOL_EVENT& aEvent )
{
getEditFrame<FOOTPRINT_EDIT_FRAME>()->InstallPadOptionsFrame( nullptr );
return 0;
}
int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{ {
struct PAD_PLACER : public INTERACTIVE_PLACER_BASE struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
@ -544,10 +623,19 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
void MODULE_EDITOR_TOOLS::setTransitions() void MODULE_EDITOR_TOOLS::setTransitions()
{ {
Go( &MODULE_EDITOR_TOOLS::Revert, ACTIONS::revert.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::Save, ACTIONS::save.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Save, PCB_ACTIONS::saveToBoard.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Save, PCB_ACTIONS::saveToLibrary.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Revert, ACTIONS::revert.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Delete, PCB_ACTIONS::deleteFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::PlacePad, PCB_ACTIONS::placePad.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::CreatePadFromShapes, PCB_ACTIONS::createPadFromShapes.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::ExplodePadToShapes, PCB_ACTIONS::explodePadToShapes.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::EnumeratePads, PCB_ACTIONS::enumeratePads.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::PlacePad, PCB_ACTIONS::placePad.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::CreatePadFromShapes, PCB_ACTIONS::createPadFromShapes.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::ExplodePadToShapes, PCB_ACTIONS::explodePadToShapes.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::EnumeratePads, PCB_ACTIONS::enumeratePads.MakeEvent() );
} }

View File

@ -49,7 +49,17 @@ public:
/// @copydoc TOOL_INTERACTIVE::Reset() /// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
int Save( const TOOL_EVENT& aEvent );
int SaveAs( const TOOL_EVENT& aEvent );
int Revert( const TOOL_EVENT& aEvent ); int Revert( const TOOL_EVENT& aEvent );
int Delete( const TOOL_EVENT& aEvent );
int Properties( const TOOL_EVENT& aEvent );
/**
* Edit the properties used for new pad creation.
*/
int DefaultPadProperties( const TOOL_EVENT& aEvent );
/** /**
* Function PlacePad() * Function PlacePad()
@ -84,6 +94,7 @@ public:
*/ */
int ExplodePadToShapes( const TOOL_EVENT& aEvent ); int ExplodePadToShapes( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -270,6 +270,14 @@ public:
static TOOL_ACTION showPythonConsole; static TOOL_ACTION showPythonConsole;
// Module editor tools // Module editor tools
// These are distinct so that they can have individual tooltips and icons.
static TOOL_ACTION saveToBoard;
static TOOL_ACTION saveToLibrary;
static TOOL_ACTION deleteFootprint;
static TOOL_ACTION footprintProperties;
/// Activation of the drawing tool (placing a PAD) /// Activation of the drawing tool (placing a PAD)
static TOOL_ACTION placePad; static TOOL_ACTION placePad;
@ -286,6 +294,8 @@ public:
static TOOL_ACTION moduleEdgeOutlines; static TOOL_ACTION moduleEdgeOutlines;
// Pad tools // Pad tools
static TOOL_ACTION defaultPadProperties;
/// Copy the selected pad's settings to the board design settings /// Copy the selected pad's settings to the board design settings
static TOOL_ACTION copyPadSettings; static TOOL_ACTION copyPadSettings;

View File

@ -424,7 +424,7 @@ int PCB_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true );
else else
m_frame->RollbackFromUndo(); m_frame->RollbackFromUndo();
@ -489,7 +489,7 @@ int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
board->GetDesignSettings().SetTrackWidthIndex( widthIndex ); board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
board->GetDesignSettings().UseCustomTrackViaSize( false ); board->GetDesignSettings().UseCustomTrackViaSize( false );
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
return 0; return 0;
} }
@ -506,7 +506,7 @@ int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
board->GetDesignSettings().SetTrackWidthIndex( widthIndex ); board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
board->GetDesignSettings().UseCustomTrackViaSize( false ); board->GetDesignSettings().UseCustomTrackViaSize( false );
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
return 0; return 0;
} }
@ -523,7 +523,7 @@ int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
board->GetDesignSettings().SetViaSizeIndex( sizeIndex ); board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
board->GetDesignSettings().UseCustomTrackViaSize( false ); board->GetDesignSettings().UseCustomTrackViaSize( false );
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
return 0; return 0;
} }
@ -540,7 +540,7 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
board->GetDesignSettings().SetViaSizeIndex( sizeIndex ); board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
board->GetDesignSettings().UseCustomTrackViaSize( false ); board->GetDesignSettings().UseCustomTrackViaSize( false );
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
return 0; return 0;
} }

View File

@ -313,7 +313,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
if( m_selection.Empty() ) if( m_selection.Empty() )
selectPoint( evt->Position() ); selectPoint( evt->Position() );
m_toolMgr->RunAction( PCB_ACTIONS::properties ); m_toolMgr->RunAction( PCB_ACTIONS::properties, true );
} }
// drag with LMB? Select multiple objects (or at least draw a selection box) or drag them // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them

View File

@ -549,7 +549,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item; WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item;
item->Restore( this ); item->Restore( this );
*item = alt_item; *item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
} }
break; break;