diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index d320ee1c1e..08aeaaafe7 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -86,7 +86,7 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent ) // Since selection tools are run permanently underneath the toolStack, this is really // just a cancel of whatever other tools might be running. - m_toolMgr->ProcessEvent( TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL ) ); + m_toolMgr->ProcessEvent( TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL, ID_SEL_TOOL ) ); return 0; } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index ca04263dc1..f89b0f0d6a 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -206,7 +206,15 @@ bool EE_SELECTION_TOOL::Init() && editFrame->GetCurrentSheet().Last() != &editFrame->Schematic().Root(); }; - auto haveSymbolCondition = + auto haveHighlight = + [&]( const SELECTION& sel ) + { + SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); + + return editFrame && editFrame->GetHighlightedConnection() != nullptr; + }; + + auto haveSymbol = [&]( const SELECTION& sel ) { return m_isSymbolEditor && @@ -215,9 +223,12 @@ bool EE_SELECTION_TOOL::Init() auto& menu = m_menu.GetMenu(); - menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 ); - menu.AddItem( EE_ACTIONS::selectOnPCB, crossProbingSelection && EE_CONDITIONS::Idle, 1 ); - menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 1 ); + menu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 ); + menu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 ); + + menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 2 ); + menu.AddItem( EE_ACTIONS::selectOnPCB, crossProbingSelection && EE_CONDITIONS::Idle, 2 ); + menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 ); menu.AddSeparator( 100 ); menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 ); @@ -243,10 +254,8 @@ bool EE_SELECTION_TOOL::Init() menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 ); menu.AddSeparator( 400 ); - menu.AddItem( EE_ACTIONS::symbolProperties, - haveSymbolCondition && EE_CONDITIONS::Empty, 400 ); - menu.AddItem( EE_ACTIONS::pinTable, - haveSymbolCondition && EE_CONDITIONS::Empty, 400 ); + menu.AddItem( EE_ACTIONS::symbolProperties, haveSymbol && EE_CONDITIONS::Empty, 400 ); + menu.AddItem( EE_ACTIONS::pinTable, haveSymbol && EE_CONDITIONS::Empty, 400 ); menu.AddSeparator( 1000 ); m_frame->AddStandardSubMenus( m_menu ); @@ -576,7 +585,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { ClearSelection(); } - else if( evt->FirstResponder() == this ) + else if( evt->FirstResponder() == this && evt->GetCommandId() != (int) ID_SEL_TOOL ) { SCH_EDITOR_CONTROL* editor = m_toolMgr->GetTool(); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 12402ce39e..d044c1bce5 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -178,6 +178,14 @@ bool SCH_EDIT_TOOL::Init() auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T ); + auto haveHighlight = + [&]( const SELECTION& sel ) + { + SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); + + return editFrame && editFrame->GetHighlightedConnection() != nullptr; + }; + auto anyTextTool = [this]( const SELECTION& aSel ) { @@ -394,8 +402,11 @@ bool SCH_EDIT_TOOL::Init() // CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu(); - drawMenu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 ); - drawMenu.AddSeparator( sheetSelection && EE_CONDITIONS::Idle, 1 ); + drawMenu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 ); + drawMenu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 ); + + drawMenu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 ); + drawMenu.AddSeparator( sheetSelection && EE_CONDITIONS::Idle, 1 ); drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 ); drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 ); @@ -404,7 +415,7 @@ bool SCH_EDIT_TOOL::Init() drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 ); - CONDITIONAL_MENU* editDrawItemSubMenu = new CONDITIONAL_MENU(drawingTools); + CONDITIONAL_MENU* editDrawItemSubMenu = new CONDITIONAL_MENU( drawingTools ); editDrawItemSubMenu->SetTitle( _( "Edit Main Fields" ) ); editDrawItemSubMenu->SetIcon( BITMAPS::right ); drawMenu.AddMenu( editDrawItemSubMenu, E_C::SingleSymbol, 200 ); @@ -413,9 +424,9 @@ bool SCH_EDIT_TOOL::Init() editDrawItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 ); editDrawItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 ); - drawMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol, 200 ); + drawMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol, 200 ); - drawMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 ); + drawMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 ); std::shared_ptr symUnitMenu2 = std::make_shared(); symUnitMenu2->SetTool( drawingTools ); @@ -441,7 +452,7 @@ bool SCH_EDIT_TOOL::Init() selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 ); - CONDITIONAL_MENU* editSelItemSubMenu = new CONDITIONAL_MENU(moveTool); + CONDITIONAL_MENU* editSelItemSubMenu = new CONDITIONAL_MENU( moveTool ); editSelItemSubMenu->SetTitle( _( "Edit Main Fields" ) ); editSelItemSubMenu->SetIcon( BITMAPS::right ); selToolMenu.AddMenu( editSelItemSubMenu, E_C::SingleSymbol, 200 ); @@ -450,8 +461,8 @@ bool SCH_EDIT_TOOL::Init() editSelItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 ); editSelItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 ); - selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 ); - selToolMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleSymbol, 200 ); + selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 ); + selToolMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleSymbol, 200 ); std::shared_ptr symUnitMenu3 = std::make_shared(); symUnitMenu3->SetTool( m_selectionTool ); @@ -462,16 +473,17 @@ bool SCH_EDIT_TOOL::Init() selToolMenu.AddItem( EE_ACTIONS::changeSymbol, E_C::SingleSymbolOrPower, 200 ); selToolMenu.AddItem( EE_ACTIONS::updateSymbol, E_C::SingleSymbolOrPower, 200 ); - CONDITIONAL_MENU* convertToSelSubMenu = new CONDITIONAL_MENU(m_selectionTool); - convertToSelSubMenu->SetTitle( _( "Change To" ) ); - convertToSelSubMenu->SetIcon( BITMAPS::right ); - selToolMenu.AddMenu( convertToSelSubMenu, toChangeCondition, 200 ); + CONDITIONAL_MENU* convertToSubMenu = new CONDITIONAL_MENU( m_selectionTool ); + convertToSubMenu->SetTitle( _( "Change To" ) ); + convertToSubMenu->SetIcon( BITMAPS::right ); + selToolMenu.AddMenu( convertToSubMenu, toChangeCondition, 200 ); + + convertToSubMenu->AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 ); + convertToSubMenu->AddItem( EE_ACTIONS::toCLabel, toCLabelCondition, 200 ); + convertToSubMenu->AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 ); + convertToSubMenu->AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 ); + convertToSubMenu->AddItem( EE_ACTIONS::toText, toTextCondition, 200 ); - convertToSelSubMenu->AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 ); - convertToSelSubMenu->AddItem( EE_ACTIONS::toCLabel, toCLabelCondition, 200 ); - convertToSelSubMenu->AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 ); - convertToSelSubMenu->AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 ); - convertToSelSubMenu->AddItem( EE_ACTIONS::toText, toTextCondition, 200 ); selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetHasUndefinedPins, 250 ); selToolMenu.AddSeparator( 300 ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 533b1a4a65..8edb8963c9 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -202,41 +202,52 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init() auto busSelection = EE_CONDITIONS::MoreThan( 0 ) && EE_CONDITIONS::OnlyType( SCH_ITEM_LOCATE_BUS_T ); + auto haveHighlight = + [&]( const SELECTION& sel ) + { + SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); + + return editFrame && editFrame->GetHighlightedConnection() != nullptr; + }; + auto& ctxMenu = m_menu.GetMenu(); // Build the tool menu // - ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 ); + ctxMenu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 ); + ctxMenu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 ); + + ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 ); ctxMenu.AddSeparator( 10 ); - ctxMenu.AddItem( EE_ACTIONS::drawWire, wireOrBusTool && EE_CONDITIONS::Idle, 10 ); - ctxMenu.AddItem( EE_ACTIONS::drawBus, wireOrBusTool && EE_CONDITIONS::Idle, 10 ); - ctxMenu.AddItem( EE_ACTIONS::drawLines, lineTool && EE_CONDITIONS::Idle, 10 ); + ctxMenu.AddItem( EE_ACTIONS::drawWire, wireOrBusTool && EE_CONDITIONS::Idle, 10 ); + ctxMenu.AddItem( EE_ACTIONS::drawBus, wireOrBusTool && EE_CONDITIONS::Idle, 10 ); + ctxMenu.AddItem( EE_ACTIONS::drawLines, lineTool && EE_CONDITIONS::Idle, 10 ); ctxMenu.AddItem( EE_ACTIONS::undoLastSegment, EE_CONDITIONS::ShowAlways, 10 ); ctxMenu.AddItem( EE_ACTIONS::switchSegmentPosture, EE_CONDITIONS::ShowAlways, 10 ); - ctxMenu.AddItem( EE_ACTIONS::finishWire, IsDrawingWire, 10 ); - ctxMenu.AddItem( EE_ACTIONS::finishBus, IsDrawingBus, 10 ); - ctxMenu.AddItem( EE_ACTIONS::finishLine, IsDrawingLine, 10 ); + ctxMenu.AddItem( EE_ACTIONS::finishWire, IsDrawingWire, 10 ); + ctxMenu.AddItem( EE_ACTIONS::finishBus, IsDrawingBus, 10 ); + ctxMenu.AddItem( EE_ACTIONS::finishLine, IsDrawingLine, 10 ); std::shared_ptr busUnfoldMenu = std::make_shared(); busUnfoldMenu->SetTool( this ); m_menu.AddSubMenu( busUnfoldMenu ); - ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 ); + ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 ); ctxMenu.AddSeparator( 100 ); - ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddSeparator( 200 ); - ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); - ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); + ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); + ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); // Add bus unfolding to the selection tool // @@ -245,7 +256,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init() std::shared_ptr selBusUnfoldMenu = std::make_shared(); selBusUnfoldMenu->SetTool( m_selectionTool ); m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu ); - selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && EE_CONDITIONS::Idle, 100 ); + selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && EE_CONDITIONS::Idle, 100 ); return true; } diff --git a/include/id.h b/include/id.h index 7c682938d3..baeac94865 100644 --- a/include/id.h +++ b/include/id.h @@ -71,9 +71,7 @@ enum main_id { - ID_RUN_PCB = wxID_HIGHEST, - - ID_APPEND_PROJECT, + ID_APPEND_PROJECT = wxID_HIGHEST, ID_LOAD_FILE, ID_NEW_BOARD, ID_SAVE_BOARD, @@ -88,11 +86,7 @@ enum main_id ID_FILE_LIST_EMPTY, ID_FILE_LIST_CLEAR, - ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, - ID_PREFERENCES_CONFIGURE_PATHS, ID_PREFERENCES_RESET_PANEL, - ID_EDIT_SYMBOL_LIBRARY_TABLE, - ID_EDIT_FOOTPRINT_LIBRARY_TABLE, ID_GEN_PLOT, ID_GEN_PLOT_PS, @@ -102,17 +96,13 @@ enum main_id ID_GEN_PLOT_DXF, ID_GEN_PLOT_PDF, - ID_GEN_EXPORT_FILE, - ID_GEN_IMPORT_FILE, - // id for toolbars ID_H_TOOLBAR, ID_V_TOOLBAR, ID_OPT_TOOLBAR, ID_AUX_TOOLBAR, - ID_EDIT_HOTKEY, - ID_NO_TOOL_SELECTED, + ID_SEL_TOOL, ID_LANGUAGE_CHOICE, ID_LANGUAGE_DANISH, @@ -152,17 +142,12 @@ enum main_id ID_LANGUAGE_UKRANIAN, ID_LANGUAGE_CHOICE_END, - // Popup Menu (mouse Right button) (id consecutifs) - ID_ON_ZOOM_SELECT, - ID_POPUP_ZOOM_START_RANGE, // first zoom id - ID_POPUP_CANCEL, - ID_POPUP_ZOOM_IN, - ID_POPUP_ZOOM_OUT, - ID_POPUP_ZOOM_SELECT, - ID_POPUP_ZOOM_CENTER, - ID_POPUP_ZOOM_PAGE, - ID_POPUP_ZOOM_REDRAW, + + ID_ON_GRID_SELECT, + ID_GRID_SETTINGS, + + // Popup Menu (mouse Right button) (id consecutifs) /* Reserve IDs for popup menu zoom levels. If you need more * levels of zoom, change ID_POPUP_ZOOM_LEVEL_END. Note that more @@ -176,19 +161,6 @@ enum main_id ID_POPUP_GRID_START, ID_POPUP_GRID_END = ID_POPUP_ZOOM_LEVEL_START + 99, - ID_ON_GRID_SELECT, - ID_GRID_SETTINGS, - - ID_ZOOM_BEGIN, - ID_VIEWER_ZOOM_IN = ID_ZOOM_BEGIN, - ID_VIEWER_ZOOM_OUT, - ID_VIEWER_ZOOM_PAGE, - ID_VIEWER_ZOOM_REDRAW, - // zoom commands for non center zooming - ID_OFFCENTER_ZOOM_IN, - ID_OFFCENTER_ZOOM_OUT, - ID_ZOOM_END, - // KiFace server for standalone operation ID_EDA_SOCKET_EVENT_SERV, ID_EDA_SOCKET_EVENT, diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index e972758b62..4329b00ff3 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -43,6 +43,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include @@ -445,15 +446,25 @@ bool ROUTER_TOOL::Init() m_diffPairMenu->SetTool( this ); m_menu.AddSubMenu( m_diffPairMenu ); + auto haveHighlight = + [&]( const SELECTION& sel ) + { + KIGFX::RENDER_SETTINGS* cfg = m_toolMgr->GetView()->GetPainter()->GetSettings(); + + return !cfg->GetHighlightNetCodes().empty(); + }; + auto notRoutingCond = [this]( const SELECTION& ) { return !m_router->RoutingInProgress(); }; - menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways ); + menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 ); + menu.AddSeparator( 1 ); - menu.AddSeparator(); + menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 2 ); + menu.AddSeparator( haveHighlight, 2 ); menu.AddItem( PCB_ACTIONS::routeSingleTrack, notRoutingCond ); menu.AddItem( PCB_ACTIONS::routeDiffPair, notRoutingCond ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index a5a34f9244..9caed037a0 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -181,42 +181,57 @@ DRAWING_TOOL::~DRAWING_TOOL() bool DRAWING_TOOL::Init() { - auto activeToolFunctor = [this]( const SELECTION& aSel ) - { - return m_mode != MODE::NONE; - }; + auto haveHighlight = + [&]( const SELECTION& sel ) + { + KIGFX::RENDER_SETTINGS* cfg = m_toolMgr->GetView()->GetPainter()->GetSettings(); + + return !cfg->GetHighlightNetCodes().empty(); + }; + + auto activeToolFunctor = + [this]( const SELECTION& aSel ) + { + return m_mode != MODE::NONE; + }; // some interactive drawing tools can undo the last point - auto canUndoPoint = [this]( const SELECTION& aSel ) - { - return ( m_mode == MODE::ARC - || m_mode == MODE::ZONE - || m_mode == MODE::KEEPOUT - || m_mode == MODE::GRAPHIC_POLYGON ); - }; + auto canUndoPoint = + [this]( const SELECTION& aSel ) + { + return ( m_mode == MODE::ARC + || m_mode == MODE::ZONE + || m_mode == MODE::KEEPOUT + || m_mode == MODE::GRAPHIC_POLYGON ); + }; // functor for tools that can automatically close the outline - auto canCloseOutline = [this]( const SELECTION& aSel ) - { - return ( m_mode == MODE::ZONE - || m_mode == MODE::KEEPOUT - || m_mode == MODE::GRAPHIC_POLYGON ); - }; + auto canCloseOutline = + [this]( const SELECTION& aSel ) + { + return ( m_mode == MODE::ZONE + || m_mode == MODE::KEEPOUT + || m_mode == MODE::GRAPHIC_POLYGON ); + }; - auto viaToolActive = [this]( const SELECTION& aSel ) - { - return m_mode == MODE::VIA; - }; + auto viaToolActive = + [this]( const SELECTION& aSel ) + { + return m_mode == MODE::VIA; + }; auto& ctxMenu = m_menu.GetMenu(); // cancel current tool goes in main context menu at the top if present - ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 ); + ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 ); ctxMenu.AddSeparator( 1 ); + ctxMenu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 2 ); + ctxMenu.AddSeparator( haveHighlight, 2 ); + // tool-specific actions - ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 ); - ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 ); ctxMenu.AddCheckItem( PCB_ACTIONS::toggleHV45Mode, SELECTION_CONDITIONS::ShowAlways, 250 ); ctxMenu.AddSeparator( 500 ); @@ -224,7 +239,7 @@ bool DRAWING_TOOL::Init() std::shared_ptr viaSizeMenu = std::make_shared(); viaSizeMenu->SetTool( this ); m_menu.AddSubMenu( viaSizeMenu ); - ctxMenu.AddMenu( viaSizeMenu.get(), viaToolActive, 500 ); + ctxMenu.AddMenu( viaSizeMenu.get(), viaToolActive, 500 ); ctxMenu.AddSeparator( 500 ); diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 61f9e93073..bc1f88e57e 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -159,6 +159,14 @@ bool PCB_SELECTION_TOOL::Init() return !frame->ToolStackIsEmpty(); }; + auto haveHighlight = + [&]( const SELECTION& sel ) + { + KIGFX::RENDER_SETTINGS* cfg = m_toolMgr->GetView()->GetPainter()->GetSettings(); + + return !cfg->GetHighlightNetCodes().empty(); + }; + auto inGroupCondition = [this] ( const SELECTION& ) { @@ -172,8 +180,10 @@ bool PCB_SELECTION_TOOL::Init() } // "Cancel" goes at the top of the context menu when a tool is active - menu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 ); - menu.AddItem( PCB_ACTIONS::groupLeave, inGroupCondition, 1 ); + menu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 ); + menu.AddItem( PCB_ACTIONS::groupLeave, inGroupCondition, 1 ); + menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 1 ); + menu.AddSeparator( 1 ); if( frame )