diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 30a7c8d8e2..01b33892bf 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -84,32 +84,33 @@ void EDIT_TOOL::Reset( RESET_REASON aReason ) m_statusPopup = std::make_unique( getEditFrame() ); } - -POSITIONING_TOOLS_MENU::POSITIONING_TOOLS_MENU( TOOL_INTERACTIVE* aTool ) : - CONDITIONAL_MENU( aTool ) +static std::shared_ptr makePositioningToolsMenu( TOOL_INTERACTIVE* aTool ) { - SetIcon( BITMAPS::special_tools ); - SetTitle( _( "Positioning Tools" ) ); + auto menu = std::make_shared( aTool ); - auto notMovingCondition = - []( const SELECTION& aSelection ) - { - return aSelection.Empty() || !aSelection.Front()->IsMoving(); - }; + menu->SetIcon( BITMAPS::special_tools ); + menu->SetTitle( _( "Positioning Tools" ) ); - AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); - AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); - AddItem( PCB_ACTIONS::copyWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); - AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); -} + auto notMovingCondition = []( const SELECTION& aSelection ) + { + return aSelection.Empty() || !aSelection.Front()->IsMoving(); + }; + // clang-format off + menu->AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); + menu->AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); + menu->AddItem( PCB_ACTIONS::copyWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); + menu->AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); + // clang-format on + return menu; +}; bool EDIT_TOOL::Init() { // Find the selection tool, so they can cooperate m_selectionTool = m_toolMgr->GetTool(); - auto positioningToolsSubMenu = std::make_shared( this ); + std::shared_ptr positioningToolsSubMenu = makePositioningToolsMenu( this ); m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu ); auto propertiesCondition = diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index b5ae56c7ff..556d54daff 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -45,19 +45,12 @@ namespace KIGFX::PREVIEW } -class POSITIONING_TOOLS_MENU : public CONDITIONAL_MENU -{ -public: - POSITIONING_TOOLS_MENU( TOOL_INTERACTIVE* aTool ); -}; - /** * The interactive edit tool. * * Allows one to move, rotate, flip and change properties of items selected using the * pcbnew.InteractiveSelection tool. */ - class EDIT_TOOL : public PCB_TOOL_BASE { public: