From 7ed5963b4fe84954b841a0eece5207cb0d2d2fa2 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 --- pcbnew/tools/edit_tool.cpp | 18 +++++++++++------- pcbnew/tools/edit_tool_move_fct.cpp | 20 +++++++------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 2f82c49664..088303c03c 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -91,10 +91,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 ); } @@ -165,9 +171,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 7f4f07245b..68e70851c6 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -564,7 +564,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit if( item->GetParent() && item->GetParent()->IsSelected() ) continue; - if( !item->IsNew() && item->IsMoving() + if( !item->IsNew() && !item->IsMoving() && ( !IsFootprintEditor() || aCommit->Empty() ) ) { aCommit->Modify( item ); @@ -682,17 +682,6 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit 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 @@ -747,7 +736,12 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit displayConstraintsMessage( hv45Mode ); evt->SetPassEvent( false ); } - else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) || evt->IsAction( &ACTIONS::redo )) + 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(); }