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,14 +212,8 @@ 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" ),

View File

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

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;
item->Restore( this );
*item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
}
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 );
if( dlg.ShowModal() == wxID_OK )
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true );
else
m_frame->RollbackSchematicFromUndo();

View File

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

View File

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

View File

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

View File

@ -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<BOARD_ITEM*>( pad ) :
static_cast<BOARD_ITEM*>( module )
);
GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, true,
pad ? (BOARD_ITEM*) pad : (BOARD_ITEM*) module );
}
}

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_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<FP_TREE_SYNCHRONIZING_ADAPTER*>( 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 );
}

View File

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

View File

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

View File

@ -30,7 +30,7 @@
#include <footprint_edit_frame.h>
#include <fp_lib_table.h>
#include <menus_helpers.h>
#include <tools/pcb_actions.h>
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<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
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();

View File

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

View File

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

View File

@ -51,12 +51,11 @@ 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 ----------------------------------------------------------
@ -78,8 +77,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
#endif
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::saveAs, libraryPartCondition );
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
@ -143,24 +145,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
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();
@ -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;
@ -306,7 +295,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
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" ),

View File

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@
#include <fctsys.h>
#include <tool/actions.h>
#include <pcbnew.h>
#include <class_board.h>
#include <footprint_edit_frame.h>
#include <dialog_helpers.h>
#include <pcbnew_id.h>
@ -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() );

View File

@ -54,7 +54,28 @@
using namespace std::placeholders;
#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
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<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 )
{
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 )
{
struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
@ -544,7 +623,16 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
void MODULE_EDITOR_TOOLS::setTransitions()
{
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::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() );

View File

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

View File

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

View File

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

View File

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

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;
item->Restore( this );
*item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
}
break;