Avoid inheriting for POSITIONING_TOOLS_MENU
This only uses the public interface of CONDITIONAL_MENU, so we can just make on of those and save declaring a wrapper type.
This commit is contained in:
parent
88ffcec4b5
commit
ef8cf2d12b
|
@ -84,32 +84,33 @@ void EDIT_TOOL::Reset( RESET_REASON aReason )
|
||||||
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
|
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<CONDITIONAL_MENU> makePositioningToolsMenu( TOOL_INTERACTIVE* aTool )
|
||||||
POSITIONING_TOOLS_MENU::POSITIONING_TOOLS_MENU( TOOL_INTERACTIVE* aTool ) :
|
|
||||||
CONDITIONAL_MENU( aTool )
|
|
||||||
{
|
{
|
||||||
SetIcon( BITMAPS::special_tools );
|
auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
|
||||||
SetTitle( _( "Positioning Tools" ) );
|
|
||||||
|
|
||||||
auto notMovingCondition =
|
menu->SetIcon( BITMAPS::special_tools );
|
||||||
[]( const SELECTION& aSelection )
|
menu->SetTitle( _( "Positioning Tools" ) );
|
||||||
{
|
|
||||||
return aSelection.Empty() || !aSelection.Front()->IsMoving();
|
|
||||||
};
|
|
||||||
|
|
||||||
AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
auto notMovingCondition = []( const SELECTION& aSelection )
|
||||||
AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
{
|
||||||
AddItem( PCB_ACTIONS::copyWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
return aSelection.Empty() || !aSelection.Front()->IsMoving();
|
||||||
AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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()
|
bool EDIT_TOOL::Init()
|
||||||
{
|
{
|
||||||
// Find the selection tool, so they can cooperate
|
// Find the selection tool, so they can cooperate
|
||||||
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
||||||
|
|
||||||
auto positioningToolsSubMenu = std::make_shared<POSITIONING_TOOLS_MENU>( this );
|
std::shared_ptr<CONDITIONAL_MENU> positioningToolsSubMenu = makePositioningToolsMenu( this );
|
||||||
m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu );
|
m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu );
|
||||||
|
|
||||||
auto propertiesCondition =
|
auto propertiesCondition =
|
||||||
|
|
|
@ -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.
|
* The interactive edit tool.
|
||||||
*
|
*
|
||||||
* Allows one to move, rotate, flip and change properties of items selected using the
|
* Allows one to move, rotate, flip and change properties of items selected using the
|
||||||
* pcbnew.InteractiveSelection tool.
|
* pcbnew.InteractiveSelection tool.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class EDIT_TOOL : public PCB_TOOL_BASE
|
class EDIT_TOOL : public PCB_TOOL_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue