diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 1c508a4a32..6fffdd60ab 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -106,6 +106,27 @@ static std::shared_ptr makePositioningToolsMenu( TOOL_INTERACT return menu; }; +static std::shared_ptr makeShapeModificationMenu( TOOL_INTERACTIVE* aTool ) +{ + auto menu = std::make_shared( aTool ); + + menu->SetTitle( _( "Shape Modification" ) ); + + static std::vector filletChamferTypes = { PCB_SHAPE_LOCATE_POLY_T, + PCB_SHAPE_LOCATE_RECT_T, + PCB_SHAPE_LOCATE_SEGMENT_T }; + + static std::vector lineExtendTypes = { PCB_SHAPE_LOCATE_SEGMENT_T }; + + // clang-format off + menu->AddItem( PCB_ACTIONS::filletLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) ); + menu->AddItem( PCB_ACTIONS::chamferLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) ); + menu->AddItem( PCB_ACTIONS::extendLines, SELECTION_CONDITIONS::OnlyTypes( lineExtendTypes ) + && SELECTION_CONDITIONS::Count( 2 ) ); + // clang-format on + return menu; +}; + bool EDIT_TOOL::Init() { // Find the selection tool, so they can cooperate @@ -114,6 +135,9 @@ bool EDIT_TOOL::Init() std::shared_ptr positioningToolsSubMenu = makePositioningToolsMenu( this ); m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu ); + std::shared_ptr shapeModificationSubMenu = makeShapeModificationMenu( this ); + m_selectionTool->GetToolMenu().RegisterSubMenu( shapeModificationSubMenu ); + auto propertiesCondition = [&]( const SELECTION& aSel ) { @@ -204,15 +228,10 @@ bool EDIT_TOOL::Init() PCB_ARC_T, PCB_VIA_T }; - static std::vector filletChamferTypes = { PCB_SHAPE_LOCATE_POLY_T, - PCB_SHAPE_LOCATE_RECT_T, - PCB_SHAPE_LOCATE_SEGMENT_T }; - - static std::vector lineExtendTypes = { PCB_SHAPE_LOCATE_SEGMENT_T }; - // Add context menu entries that are displayed when selection tool is active CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu(); + // clang-format off menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); menu.AddItem( PCB_ACTIONS::unrouteSelected, SELECTION_CONDITIONS::NotEmpty @@ -230,10 +249,6 @@ bool EDIT_TOOL::Init() && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems ) && !SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) ); menu.AddItem( PCB_ACTIONS::filletTracks, SELECTION_CONDITIONS::OnlyTypes( trackTypes ) ); - menu.AddItem( PCB_ACTIONS::filletLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) ); - menu.AddItem( PCB_ACTIONS::chamferLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) ); - menu.AddItem( PCB_ACTIONS::extendLines, SELECTION_CONDITIONS::OnlyTypes( lineExtendTypes ) - && SELECTION_CONDITIONS::Count( 2 ) ); menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty ); menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty ); menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty ); @@ -255,8 +270,9 @@ bool EDIT_TOOL::Init() menu.AddItem( PCB_ACTIONS::updateFootprint, singleFootprintCondition ); menu.AddItem( PCB_ACTIONS::changeFootprint, singleFootprintCondition ); - // Add the submenu for the special positioning tools + // 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.AddSeparator( 150 ); @@ -271,7 +287,8 @@ bool EDIT_TOOL::Init() menu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty, 150 ); menu.AddSeparator( 150 ); - menu.AddItem( ACTIONS::selectAll, noItemsCondition, 150 ); + menu.AddItem( ACTIONS::selectAll, noItemsCondition, 150 ); + // clang-format on return true; }