From 1bf04d17221cb250c513d7807e9c13f86604991e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 4 Jun 2019 00:50:44 +0100 Subject: [PATCH] More ACTIONs work. --- eeschema/libedit/menubar_libedit.cpp | 12 +-- eeschema/sch_edit_frame.cpp | 2 +- eeschema/schematic_undo_redo.cpp | 2 +- eeschema/tools/sch_editor_control.cpp | 2 +- gerbview/gerbview_frame.cpp | 2 +- pagelayout_editor/pl_editor_undo_redo.cpp | 6 +- pagelayout_editor/tools/pl_editor_control.cpp | 2 +- pcbnew/cross-probing.cpp | 24 ++--- pcbnew/footprint_edit_frame.cpp | 26 +---- pcbnew/footprint_edit_frame.h | 7 +- pcbnew/footprint_editor_utils.cpp | 52 +++------ pcbnew/footprint_tree_pane.cpp | 12 +-- pcbnew/footprint_wizard_frame.cpp | 2 +- pcbnew/load_select_footprint.cpp | 5 +- pcbnew/menubar_footprint_editor.cpp | 96 ++++++++--------- pcbnew/pcb_edit_frame.cpp | 2 +- pcbnew/pcbnew_id.h | 3 - pcbnew/router/router_tool.cpp | 2 +- pcbnew/toolbars_footprint_editor.cpp | 32 +++--- pcbnew/tools/footprint_editor_tools.cpp | 100 ++++++++++++++++-- pcbnew/tools/footprint_editor_tools.h | 11 ++ pcbnew/tools/pcb_actions.h | 10 ++ pcbnew/tools/pcb_editor_control.cpp | 10 +- pcbnew/tools/selection_tool.cpp | 2 +- pcbnew/undo_redo.cpp | 2 +- 25 files changed, 226 insertions(+), 200 deletions(-) diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index 425577302e..0ad21b7772 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -212,18 +212,12 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; }; - prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ), - _( "Edit path configuration environment variables" ), - 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( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways ); + prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, AddHotkeyName( _( "Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES ), _( "Show preferences for all open tools" ), - preference_xpm, EE_CONDITIONS::ShowAlways ); + preference_xpm, EE_CONDITIONS::ShowAlways ); prefsMenu->AddSeparator(); Pgm().AddMenuLanguageList( prefsMenu ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 51d0d3c26c..e32d3750f7 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -307,7 +307,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_auimgr.Update(); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); if( GetGalCanvas() ) GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index efef170628..d91ebfae29 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -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; item->Restore( this ); *item = alt_item; - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); } else if( dynamic_cast( eda_item ) ) { diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 74d269e52b..53fa5e4fb6 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -215,7 +215,7 @@ int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); if( dlg.ShowModal() == wxID_OK ) - m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); + m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true ); else m_frame->RollbackSchematicFromUndo(); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 766b50be7b..8ee9378c80 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -161,7 +161,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_auimgr.Update(); SetActiveLayer( 0, true ); - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting(); diff --git a/pagelayout_editor/pl_editor_undo_redo.cpp b/pagelayout_editor/pl_editor_undo_redo.cpp index 01e01fe0cb..f9881cc626 100644 --- a/pagelayout_editor/pl_editor_undo_redo.cpp +++ b/pagelayout_editor/pl_editor_undo_redo.cpp @@ -76,7 +76,7 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList() if( pageSettingsAndTitleBlock ) { - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); HardRedraw(); // items based off of corners will need re-calculating } else @@ -116,7 +116,7 @@ void PL_EDITOR_FRAME::GetLayoutFromUndoList() if( pageSettingsAndTitleBlock ) { - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); HardRedraw(); // items based off of corners will need re-calculating } else @@ -148,7 +148,7 @@ void PL_EDITOR_FRAME::RollbackFromUndo() if( pageSettingsAndTitleBlock ) { - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); HardRedraw(); // items based off of corners will need re-calculating } else diff --git a/pagelayout_editor/tools/pl_editor_control.cpp b/pagelayout_editor/tools/pl_editor_control.cpp index 1f5704ddfa..1b76cc8987 100644 --- a/pagelayout_editor/tools/pl_editor_control.cpp +++ b/pagelayout_editor/tools/pl_editor_control.cpp @@ -106,7 +106,7 @@ int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) } else { - m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); + m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true ); m_frame->HardRedraw(); } return 0; diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 8eefdb1453..57abce5375 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -241,29 +241,19 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) } if( module == NULL ) - { msg.Printf( _( "%s not found" ), modName ); - } else if( pad == NULL ) - { msg.Printf( _( "%s pin %s not found" ), modName, pinName ); - } else - { msg.Printf( _( "%s pin %s found" ), modName, pinName ); - } SetStatusText( msg ); } if( module ) // if found, center the module on screen, and redraw the screen. { - GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, - true, - pad ? - static_cast( pad ) : - static_cast( module ) - ); + GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, true, + pad ? (BOARD_ITEM*) pad : (BOARD_ITEM*) module ); } } @@ -287,8 +277,8 @@ std::string FormatProbeItem( BOARD_ITEM* aItem ) wxString pad = ((D_PAD*)aItem)->GetName(); return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"", - TO_UTF8( module->GetReference() ), - TO_UTF8( pad ) ); + TO_UTF8( module->GetReference() ), + TO_UTF8( pad ) ); } case PCB_MODULE_TEXT_T: @@ -309,9 +299,9 @@ std::string FormatProbeItem( BOARD_ITEM* aItem ) break; return StrPrintf( "$PART: \"%s\" %s \"%s\"", - TO_UTF8( module->GetReference() ), - text_key, - TO_UTF8( text_mod->GetText() ) ); + TO_UTF8( module->GetReference() ), + text_key, + TO_UTF8( text_mod->GetText() ) ); } default: diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index d42dd697fd..0307edaad1 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -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_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_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng ) 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_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_FROM_WIZARD, 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_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_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_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 ) @@ -117,15 +111,11 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) // UI update events. - EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted ) EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard ) EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, 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 ) END_EVENT_TABLE() @@ -249,7 +239,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_auimgr.Update(); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); updateTitle(); 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(); 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 ) { 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(); auto adapter = static_cast( m_adapter.get() ); - LIB_ID target = getTargetFPID(); + LIB_ID target = GetTargetFPID(); bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() ); // 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 ); -} diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index c04ecec55b..f1a27777fd 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -184,11 +184,6 @@ public: */ void OnModify() override; - /** - * Install the print dialog - */ - void ToPrinter( wxCommandEvent& event ); - // BOARD handling /** @@ -199,7 +194,7 @@ public: bool Clear_Pcb( bool aQuery ); /// 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. LIB_ID GetLoadedFPID() const; diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index d28a5aa7fe..f01d973553 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -123,9 +123,12 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID) updateView(); 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 ) + { + ReCreateMenuBar(); ReCreateHToolbar(); + } m_treePane->GetLibTree()->ExpandLibId( aFPID ); m_treePane->GetLibTree()->CenterLibId( aFPID ); @@ -143,10 +146,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) switch( id ) { - case wxID_CUT: - case wxID_COPY: case ID_TOOLBARH_PCB_SELECT_LAYER: - case ID_MODEDIT_PAD_SETTINGS: break; default: @@ -182,16 +182,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } break; - case ID_MODEDIT_DELETE_PART: - if( DeleteModuleFromLibrary( getTargetFPID(), true ) ) - { - if( getTargetFPID() == GetLoadedFPID() ) - Clear_Pcb( false ); - - SyncLibraryTree( true ); - } - break; - case ID_MODEDIT_NEW_MODULE: { LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId(); @@ -302,7 +292,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SAVE: - if( getTargetFPID() == GetLoadedFPID() ) + if( GetTargetFPID() == GetLoadedFPID() ) { if( SaveFootprint( GetBoard()->GetFirstModule() ) ) { @@ -317,16 +307,16 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SAVE_AS: - if( getTargetFPID().GetLibItemName().empty() ) + if( GetTargetFPID().GetLibItemName().empty() ) { // Save Library As - const wxString& src_libNickname = getTargetFPID().GetLibNickname(); + const wxString& src_libNickname = GetTargetFPID().GetLibNickname(); wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname ); if( SaveLibraryAs( src_libFullName ) ) SyncLibraryTree( true ); } - else if( getTargetFPID() == GetLoadedFPID() ) + else if( GetTargetFPID() == GetLoadedFPID() ) { // Save Board Footprint As MODULE* footprint = GetBoard()->GetFirstModule(); @@ -344,7 +334,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) else { // Save Selected Footprint As - MODULE* footprint = LoadFootprint( getTargetFPID() ); + MODULE* footprint = LoadFootprint( GetTargetFPID() ); if( footprint && SaveFootprintAs( footprint ) ) SyncLibraryTree( true ); @@ -355,9 +345,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_MODEDIT_CUT_PART: case ID_MODEDIT_COPY_PART: - if( getTargetFPID().IsValid() ) + if( GetTargetFPID().IsValid() ) { - LIB_ID fpID = getTargetFPID(); + LIB_ID fpID = GetTargetFPID(); if( fpID == GetLoadedFPID() ) m_copiedModule.reset( new MODULE( *GetBoard()->GetFirstModule() ) ); @@ -377,9 +367,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; 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() ); wxString newName = newModule->GetFPID().GetLibItemName(); @@ -416,32 +406,20 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_EXPORT_PART: - if( getTargetFPID() == GetLoadedFPID() ) + if( GetTargetFPID() == GetLoadedFPID() ) Export_Module( GetBoard()->GetFirstModule() ); else - Export_Module( LoadFootprint( getTargetFPID() ) ); + Export_Module( LoadFootprint( GetTargetFPID() ) ); break; case ID_MODEDIT_EDIT_MODULE: LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() ); break; - case ID_MODEDIT_PAD_SETTINGS: - InstallPadOptionsFrame( NULL ); - break; - case ID_MODEDIT_CHECK: // Currently: not implemented break; - case ID_MODEDIT_EDIT_MODULE_PROPERTIES: - if( GetBoard()->GetFirstModule() ) - { - editFootprintProperties( GetBoard()->GetFirstModule() ); - GetGalCanvas()->Refresh(); - } - break; - default: wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) ); break; diff --git a/pcbnew/footprint_tree_pane.cpp b/pcbnew/footprint_tree_pane.cpp index 714168df3c..3534057dab 100644 --- a/pcbnew/footprint_tree_pane.cpp +++ b/pcbnew/footprint_tree_pane.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) : wxPanel( aParent ), @@ -50,8 +50,8 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) std::unique_ptr menuLibrary = std::make_unique(); menuLibrary->Add( ACTIONS::newLibrary ); menuLibrary->Add( ACTIONS::addLibrary ); - menuLibrary->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm ); - menuLibrary->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm ); + menuLibrary->Add( ACTIONS::save ); + menuLibrary->Add( ACTIONS::saveAs ); menuLibrary->AppendSeparator(); 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->AppendSeparator(); - menuPart->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm ); - menuPart->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm ); - menuPart->Add( _( "Delete" ), ID_MODEDIT_DELETE_PART, delete_xpm ); + menuPart->Add( ACTIONS::save ); + menuPart->Add( ACTIONS::saveCopyAs ); + menuPart->Add( PCB_ACTIONS::deleteFootprint ); menuPart->Add( ACTIONS::revert ); menuPart->AppendSeparator(); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 2508205f89..3522320315 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -227,7 +227,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent updateView(); 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. // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal; diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index b26dd07257..5b4592e355 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -146,9 +146,12 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) GetScreen()->ClearUndoRedoList(); 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 ) + { + ReCreateMenuBar(); ReCreateHToolbar(); + } Update3DView( true ); updateView(); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index f8b01bc80e..88c7869f4f 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -51,36 +51,38 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() auto modifiedDocumentCondition = [this]( const SELECTION& sel ) { return !GetBoard()->Modules().empty() && GetScreen()->IsModify(); }; - auto libraryPartCondition = [ this ] ( const SELECTION& sel ) { - LIB_ID libId = getTargetFPID(); - const wxString& libName = libId.GetLibNickname(); - const wxString& partName = libId.GetLibItemName(); - - return( !libName.IsEmpty() || !partName.IsEmpty() ); + auto haveFootprintCondition = [ this ] ( const SELECTION& aSelection ) { + return GetBoard()->GetFirstModule() != nullptr; + }; + auto footprintTargettedCondition = [ this ] ( const SELECTION& aSelection ) { + return GetTargetFPID().IsValid(); }; //-- File menu ---------------------------------------------------------- // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); - fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ID_MODEDIT_NEW_MODULE, AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ), _( "Create a new footprint" ), - new_footprint_xpm, SELECTION_CONDITIONS::ShowAlways ); + new_footprint_xpm, SELECTION_CONDITIONS::ShowAlways ); #ifdef KICAD_SCRIPTING fileMenu->AddItem( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, _( "&Create Footprint..." ), _( "Create a new footprint using the footprint wizard" ), - module_wizard_xpm, SELECTION_CONDITIONS::ShowAlways ); + module_wizard_xpm, SELECTION_CONDITIONS::ShowAlways ); #endif fileMenu->AddSeparator(); - fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); - fileMenu->AddItem( ACTIONS::saveAs, libraryPartCondition ); - fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); + if( IsCurrentFPFromBoard() ) + fileMenu->AddItem( PCB_ACTIONS::saveToBoard, modifiedDocumentCondition ); + else + fileMenu->AddItem( PCB_ACTIONS::saveToLibrary, modifiedDocumentCondition ); + fileMenu->AddItem( ACTIONS::saveAs, footprintTargettedCondition ); + fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); fileMenu->AddSeparator(); @@ -114,7 +116,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( ACTIONS::print, haveFootprintCondition ); fileMenu->AddSeparator(); // 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; }; - editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); - editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); + editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); + editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::paste, noActiveToolCondition ); + editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); + editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); + editMenu->AddItem( ACTIONS::paste, noActiveToolCondition ); + editMenu->AddItem( PCB_ACTIONS::deleteFootprint, footprintTargettedCondition ); - // Properties - AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES, - _( "&Footprint Properties..." ), - _( "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->AddSeparator(); + editMenu->AddItem( PCB_ACTIONS::footprintProperties, haveFootprintCondition ); + editMenu->AddItem( PCB_ACTIONS::defaultPadProperties, SELECTION_CONDITIONS::ShowAlways ); editMenu->Resolve(); @@ -201,7 +190,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() _( "Browse footprint libraries" ), modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); + viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AddSeparator(); viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); @@ -256,29 +245,29 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() // 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->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways ); - placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways ); - placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways ); - placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways ); - placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways ); + placeMenu->AddItem( PCB_ACTIONS::placeText, haveFootprintCondition ); + placeMenu->AddItem( PCB_ACTIONS::drawArc, haveFootprintCondition ); + placeMenu->AddItem( PCB_ACTIONS::drawCircle, haveFootprintCondition ); + placeMenu->AddItem( PCB_ACTIONS::drawLine, haveFootprintCondition ); + placeMenu->AddItem( PCB_ACTIONS::drawPolygon, haveFootprintCondition ); placeMenu->AppendSeparator(); - placeMenu->AddItem( PCB_ACTIONS::setAnchor, SELECTION_CONDITIONS::ShowAlways ); - placeMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways ); + placeMenu->AddItem( PCB_ACTIONS::setAnchor, haveFootprintCondition ); + placeMenu->AddItem( ACTIONS::gridSetOrigin, haveFootprintCondition ); placeMenu->Resolve(); - //-- Inspect menu ------------------------------------------------------- + //-- Inspect menu ------------------------------------------------------ // CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); - inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); + inspectMenu->AddItem( ACTIONS::measureTool, haveFootprintCondition ); inspectMenu->Resolve(); - //-- Tools menu ------------------------------------------------------- + //-- Tools menu -------------------------------------------------------- // wxMenu* toolsMenu = new wxMenu; @@ -304,20 +293,19 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; }; - prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways ); - prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways ); - + prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways ); + prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, AddHotkeyName( _( "Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ), _( "Show preferences for all open tools" ), - preference_xpm, SELECTION_CONDITIONS::ShowAlways ); + preference_xpm, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddSeparator(); Pgm().AddMenuLanguageList( prefsMenu ); prefsMenu->AddSeparator(); - prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); - prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); + prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); + prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); prefsMenu->Resolve(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index b6944b15cb..33d1b33185 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -301,7 +301,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.Update(); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); m_canvasType = LoadCanvasTypeSetting(); diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 645a254bdd..957c158e92 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -161,7 +161,6 @@ enum pcbnew_ids ID_MODEDIT_SAVE, ID_MODEDIT_SAVE_AS, ID_MODEDIT_SAVE_PNG, - ID_MODEDIT_DELETE_PART, ID_MODEDIT_COPY_PART, ID_MODEDIT_CUT_PART, ID_MODEDIT_PASTE_PART, @@ -169,9 +168,7 @@ enum pcbnew_ids ID_MODEDIT_NEW_MODULE_FROM_WIZARD, ID_MODEDIT_SHEET_SET, ID_MODEDIT_EDIT_MODULE, - ID_MODEDIT_PAD_SETTINGS, ID_MODEDIT_LOAD_MODULE_FROM_BOARD, - ID_MODEDIT_EDIT_MODULE_PROPERTIES, ID_MODEDIT_IMPORT_PART, ID_MODEDIT_EXPORT_PART, ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 17be6fa1af..bb0f44881b 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1289,7 +1289,7 @@ int ROUTER_TOOL::CustomTrackWidthDialog( const TOOL_EVENT& aEvent ) if( sizeDlg.ShowModal() ) { bds.UseCustomTrackViaSize( true ); - m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); + m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true ); } return 0; diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 9e0851e2b0..b0200ac8cc 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -59,22 +60,12 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() #endif if( IsCurrentFPFromBoard() ) - { - m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString, - KiScaledBitmap( save_fp_to_board_xpm, this ), - _( "Update footprint on board" ) ); - } + m_mainToolBar->Add( PCB_ACTIONS::saveToBoard ); else - { - m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString, - KiScaledBitmap( save_xpm, this ), - _( "Save changes to library" ) ); - } + m_mainToolBar->Add( PCB_ACTIONS::saveToLibrary ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, - KiScaledBitmap( print_button_xpm, this ), - _( "Print footprint" ) ); + m_mainToolBar->Add( ACTIONS::print ); KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->Add( ACTIONS::undo ); @@ -88,13 +79,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString, - KiScaledBitmap( module_options_xpm, this ), - _( "Footprint properties" ) ); - - m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString, - KiScaledBitmap( options_pad_xpm, this ), - _( "Default pad properties" ) ); + m_mainToolBar->Add( PCB_ACTIONS::footprintProperties ); + m_mainToolBar->Add( PCB_ACTIONS::defaultPadProperties ); KiScaledSeparator( m_mainToolBar, this ); 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(); + 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::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); + m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() ); m_mainToolBar->Refresh(); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index a2f6170dbc..bab8a0865f 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -54,7 +54,28 @@ using namespace std::placeholders; #include + +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 +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", AS_GLOBAL, 0, _( "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", 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() : @@ -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()->Process_Special_Functions( evt ); + return 0; +} + + +int MODULE_EDITOR_TOOLS::SaveAs( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE_AS ); + getEditFrame()->Process_Special_Functions( evt ); + return 0; +} + + int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent ) { getEditFrame()->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(); + + 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()->OnEditItemRequest( footprint ); + frame()->GetGalCanvas()->Refresh(); + } + return 0; +} + + +int MODULE_EDITOR_TOOLS::DefaultPadProperties( const TOOL_EVENT& aEvent ) +{ + getEditFrame()->InstallPadOptionsFrame( nullptr ); + return 0; +} + + int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) { 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() { - 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::CreatePadFromShapes, PCB_ACTIONS::createPadFromShapes.MakeEvent() ); - Go( &MODULE_EDITOR_TOOLS::ExplodePadToShapes, PCB_ACTIONS::explodePadToShapes.MakeEvent() ); - Go( &MODULE_EDITOR_TOOLS::EnumeratePads, PCB_ACTIONS::enumeratePads.MakeEvent() ); + Go( &MODULE_EDITOR_TOOLS::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() ); + Go( &MODULE_EDITOR_TOOLS::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.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() ); } diff --git a/pcbnew/tools/footprint_editor_tools.h b/pcbnew/tools/footprint_editor_tools.h index 50200fc898..cfd8e52884 100644 --- a/pcbnew/tools/footprint_editor_tools.h +++ b/pcbnew/tools/footprint_editor_tools.h @@ -49,7 +49,17 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() 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 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() @@ -84,6 +94,7 @@ public: */ int ExplodePadToShapes( const TOOL_EVENT& aEvent ); +private: ///> Sets up handlers for various events. void setTransitions() override; diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index bb32d5f6b3..2ccca2123a 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -270,6 +270,14 @@ public: static TOOL_ACTION showPythonConsole; // 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) static TOOL_ACTION placePad; @@ -286,6 +294,8 @@ public: static TOOL_ACTION moduleEdgeOutlines; // Pad tools + static TOOL_ACTION defaultPadProperties; + /// Copy the selected pad's settings to the board design settings static TOOL_ACTION copyPadSettings; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 867ce8b3bb..8316619416 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -424,7 +424,7 @@ int PCB_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent ) dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); if( dlg.ShowModal() == wxID_OK ) - m_toolMgr->RunAction( ACTIONS::zoomFitScreen ); + m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true ); else m_frame->RollbackFromUndo(); @@ -489,7 +489,7 @@ int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent ) board->GetDesignSettings().SetTrackWidthIndex( widthIndex ); board->GetDesignSettings().UseCustomTrackViaSize( false ); - m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); + m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true ); return 0; } @@ -506,7 +506,7 @@ int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent ) board->GetDesignSettings().SetTrackWidthIndex( widthIndex ); board->GetDesignSettings().UseCustomTrackViaSize( false ); - m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); + m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true ); return 0; } @@ -523,7 +523,7 @@ int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent ) board->GetDesignSettings().SetViaSizeIndex( sizeIndex ); board->GetDesignSettings().UseCustomTrackViaSize( false ); - m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); + m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true ); return 0; } @@ -540,7 +540,7 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent ) board->GetDesignSettings().SetViaSizeIndex( sizeIndex ); board->GetDesignSettings().UseCustomTrackViaSize( false ); - m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged ); + m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true ); return 0; } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 8239e4a8e6..f4c12ba97b 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -313,7 +313,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_selection.Empty() ) 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 diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 88aa8b8491..96bc1ce1ca 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -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; item->Restore( this ); *item = alt_item; - GetToolManager()->RunAction( ACTIONS::zoomFitScreen ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); } break;