diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 73adf100c0..02b902f5b1 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -124,7 +124,7 @@ void CONDITIONAL_MENU::Resolve() } -void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) +void CONDITIONAL_MENU::Evaluate( const SELECTION& aSelection ) { Clear(); diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h index 9025898b50..b6d3fc267d 100644 --- a/include/tool/conditional_menu.h +++ b/include/tool/conditional_menu.h @@ -108,7 +108,7 @@ public: /** * Update the contents of the menu based on the supplied conditions. */ - void Evaluate( SELECTION& aSelection ); + void Evaluate( const SELECTION& aSelection ); /** * Update the initial contents so that wxWidgets doesn't get its knickers tied in a knot diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index eefb6b6b65..d0b5eff9a0 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -182,6 +182,22 @@ bool EDIT_TOOL::Init() std::shared_ptr shapeModificationSubMenu = makeShapeModificationMenu( this ); m_selectionTool->GetToolMenu().RegisterSubMenu( shapeModificationSubMenu ); + auto positioningToolsCondition = + [&]( const SELECTION& aSel ) + { + std::shared_ptr subMenu = makePositioningToolsMenu( this ); + subMenu->Evaluate( aSel ); + return subMenu->GetMenuItemCount() > 0; + }; + + auto shapeModificationCondition = + [&]( const SELECTION& aSel ) + { + std::shared_ptr subMenu = makeShapeModificationMenu( this ); + subMenu->Evaluate( aSel ); + return subMenu->GetMenuItemCount() > 0; + }; + auto propertiesCondition = [&]( const SELECTION& aSel ) { @@ -337,8 +353,8 @@ bool EDIT_TOOL::Init() // Add the submenu for the special tools: modfiers and positioning tools menu.AddSeparator( 100 ); - menu.AddMenu( shapeModificationSubMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 ); - menu.AddMenu( positioningToolsSubMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 ); + menu.AddMenu( shapeModificationSubMenu.get(), shapeModificationCondition, 100 ); + menu.AddMenu( positioningToolsSubMenu.get(), positioningToolsCondition, 100 ); menu.AddSeparator( 150 ); menu.AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty, 150 );