PAD_TOOL: enable 'Apply' after copying a pad
This commit is contained in:
parent
2fa17b4460
commit
6fdccc1829
|
@ -90,14 +90,11 @@ private:
|
|||
ENABLEMENTS enablements;
|
||||
|
||||
auto anyPadSel = S_C::HasType( PCB_PAD_T );
|
||||
|
||||
auto singlePadSel = S_C::Count( 1 )
|
||||
&& S_C::OnlyType( PCB_PAD_T );
|
||||
auto singlePadSel = S_C::Count( 1 ) && S_C::OnlyType( PCB_PAD_T );
|
||||
|
||||
// Apply pads enabled when any pads selected (it applies to each one
|
||||
// individually), plus need a valid global pad setting
|
||||
enablements.canImport = m_haveGlobalPadSettings()
|
||||
&& ( anyPadSel )( aSelection );
|
||||
enablements.canImport = m_haveGlobalPadSettings() && ( anyPadSel )( aSelection );
|
||||
|
||||
// Copy pads item enabled only when there is a single pad selected
|
||||
// (otherwise how would we know which one to copy?)
|
||||
|
@ -127,7 +124,7 @@ private:
|
|||
|
||||
|
||||
PAD_TOOL::PAD_TOOL() :
|
||||
PCB_TOOL( "pcbnew.PadTool" )
|
||||
PCB_TOOL( "pcbnew.PadTool" ), m_padCopied( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -138,14 +135,7 @@ PAD_TOOL::~PAD_TOOL()
|
|||
|
||||
void PAD_TOOL::Reset( RESET_REASON aReason )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool PAD_TOOL::hasMasterPadSettings()
|
||||
{
|
||||
auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
D_PAD& masterPad = frame.GetDesignSettings().m_Pad_Master;
|
||||
return masterPad.GetParent() != nullptr;
|
||||
m_padCopied = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,13 +148,8 @@ bool PAD_TOOL::haveFootprints()
|
|||
|
||||
bool PAD_TOOL::Init()
|
||||
{
|
||||
// functor to report if the current frame has master pad settings
|
||||
std::function<bool()> haveMasterPad = [this] () {
|
||||
return hasMasterPadSettings();
|
||||
};
|
||||
|
||||
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>(
|
||||
EditingModules(), haveMasterPad );
|
||||
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>( EditingModules(),
|
||||
[this]() { return m_padCopied; } );
|
||||
contextMenu->SetTool( this );
|
||||
|
||||
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
@ -243,6 +228,7 @@ int PAD_TOOL::copyPadSettings( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
const auto& selPad = static_cast<const D_PAD&>( *item );
|
||||
masterPad.ImportSettingsFromMaster( selPad );
|
||||
m_padCopied = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +290,6 @@ static void globalChangePadSettings( BOARD& board,
|
|||
}
|
||||
|
||||
|
||||
|
||||
int PAD_TOOL::pushPadSettings( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
@ -377,6 +362,7 @@ int PAD_TOOL::pushPadSettings( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PAD_TOOL::SetTransitions()
|
||||
{
|
||||
Go( &PAD_TOOL::applyPadSettings, COMMON_ACTIONS::applyPadSettings.MakeEvent() );
|
||||
|
|
|
@ -50,9 +50,6 @@ public:
|
|||
void SetTransitions() override;
|
||||
|
||||
private:
|
||||
///> Determine if the frame has a valid master pad setting
|
||||
bool hasMasterPadSettings();
|
||||
|
||||
///> Determine if there are any footprints on the board
|
||||
bool haveFootprints();
|
||||
|
||||
|
@ -64,7 +61,9 @@ private:
|
|||
|
||||
///> Push pad settings from a pad to other pads on board or module
|
||||
int pushPadSettings( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Flag to indicate there are valid settings stored in the Master Pad object
|
||||
bool m_padCopied;
|
||||
};
|
||||
|
||||
|
||||
#endif // __PAD_TOOL_H
|
||||
|
|
Loading…
Reference in New Issue