From 17f02b2ff082503e4a1c96b882ea3ec838d3ad44 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 30 Jun 2023 20:21:29 +0100 Subject: [PATCH] Disable positioning tools when a move is in progress. Also fixes a typo in EDIT_TOOL::doMoveSelection(). Fixes https://gitlab.com/kicad/code/kicad/-/issues/15090 (cherry picked from commit 7ed5963b4fe84954b841a0eece5207cb0d2d2fa2) --- pcbnew/tools/edit_tool.cpp | 18 +++++++++++------- pcbnew/tools/edit_tool_move_fct.cpp | 18 ++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index bb01cd8799..a5351a40d3 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -95,10 +95,16 @@ POSITIONING_TOOLS_MENU::POSITIONING_TOOLS_MENU( TOOL_INTERACTIVE* aTool ) : SetIcon( BITMAPS::special_tools ); SetTitle( _( "Positioning Tools" ) ); - AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::ShowAlways ); - AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::ShowAlways ); - AddItem( PCB_ACTIONS::copyWithReference, SELECTION_CONDITIONS::ShowAlways ); - AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::ShowAlways ); + auto notMovingCondition = + [ this ]( const SELECTION& aSelection ) + { + return aSelection.Empty() || !aSelection.Front()->IsMoving(); + }; + + 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 ); } @@ -169,9 +175,7 @@ bool EDIT_TOOL::Init() auto notMovingCondition = [ this ]( const SELECTION& aSelection ) { - return !frame()->IsCurrentTool( PCB_ACTIONS::move ) - && !frame()->IsCurrentTool( PCB_ACTIONS::moveWithReference ) - && !frame()->IsCurrentTool( PCB_ACTIONS::moveIndividually ); + return aSelection.Empty() || !aSelection.Front()->IsMoving(); }; auto noItemsCondition = diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 1f21fdac2c..96b802f65c 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -713,17 +713,6 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, const wxString& aCommi eatFirstMouseUp = false; evt->SetPassEvent(); } - else if( evt->IsAction( &PCB_ACTIONS::moveExact ) ) - { - // Reset positions so the Move Exactly is from the start. - for( EDA_ITEM* item : selection ) - { - BOARD_ITEM* i = static_cast( item ); - i->Move( -totalMovement ); - } - - break; // finish -- we moved exactly, so we are finished - } else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) || isSkip ) { // Eat mouse-up/-click events that leaked through from the lock dialog @@ -778,7 +767,12 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, const wxString& aCommi displayConstraintsMessage( hv45Mode ); evt->SetPassEvent( false ); } - else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) ) + else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) + || evt->IsAction( &PCB_ACTIONS::moveExact ) + || evt->IsAction( &PCB_ACTIONS::moveWithReference ) + || evt->IsAction( &PCB_ACTIONS::copyWithReference ) + || evt->IsAction( &PCB_ACTIONS::positionRelative ) + || evt->IsAction( &ACTIONS::redo ) ) { wxBell(); }