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 7ed5963b4f)
This commit is contained in:
Jeff Young 2023-06-30 20:21:29 +01:00
parent 6316b78a5e
commit 17f02b2ff0
2 changed files with 17 additions and 19 deletions

View File

@ -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 =

View File

@ -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<BOARD_ITEM*>( 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();
}