Put pad enumerate tool in PAD_TOOL submenu

Prior to this, it was in the top level of the selection
menu, and was always shown, even if the module editor
didn't have a loaded footprint.
This commit is contained in:
John Beard 2017-02-09 08:54:32 +08:00 committed by Maciej Suminski
parent ca91c27852
commit 2fa17b4460
4 changed files with 18 additions and 24 deletions

View File

@ -958,12 +958,14 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new MODULE_EDITOR_TOOLS );
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
m_toolManager->RegisterTool( new PICKER_TOOL );
m_toolManager->InitTools();
m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
m_toolManager->InitTools();
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
}

View File

@ -87,23 +87,6 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
}
bool MODULE_EDITOR_TOOLS::Init()
{
// Find the selection tool, so they can cooperate
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( !selectionTool )
{
DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
return false;
}
selectionTool->GetToolMenu().GetMenu().AddItem( COMMON_ACTIONS::enumeratePads );
return true;
}
int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );

View File

@ -50,9 +50,6 @@ public:
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
/**
* Function PlacePad()
* Places a pad in module editor.

View File

@ -47,7 +47,9 @@ public:
using SHOW_FUNCTOR = std::function<bool()>;
PAD_CONTEXT_MENU( SHOW_FUNCTOR aHaveGlobalPadSetting):
PAD_CONTEXT_MENU( bool aEditingFootprint,
SHOW_FUNCTOR aHaveGlobalPadSetting ):
m_editingFootprint( aEditingFootprint ),
m_haveGlobalPadSettings( aHaveGlobalPadSetting )
{
SetIcon( pad_xpm );
@ -56,13 +58,21 @@ public:
Add( COMMON_ACTIONS::copyPadSettings );
Add( COMMON_ACTIONS::applyPadSettings );
Add( COMMON_ACTIONS::pushPadSettings );
// show modedit-specific items
if( m_editingFootprint )
{
AppendSeparator();
Add( COMMON_ACTIONS::enumeratePads );
}
}
protected:
CONTEXT_MENU* create() const override
{
return new PAD_CONTEXT_MENU( m_haveGlobalPadSettings );
return new PAD_CONTEXT_MENU( m_editingFootprint, m_haveGlobalPadSettings );
}
private:
@ -111,6 +121,7 @@ private:
Enable( getMenuId( COMMON_ACTIONS::pushPadSettings ), enablements.canPush );
}
bool m_editingFootprint;
SHOW_FUNCTOR m_haveGlobalPadSettings;
};
@ -152,7 +163,8 @@ bool PAD_TOOL::Init()
return hasMasterPadSettings();
};
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>( haveMasterPad );
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>(
EditingModules(), haveMasterPad );
contextMenu->SetTool( this );
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();