Use event point to determine if we're still in draggable item.

This commit is contained in:
Jeff Young 2022-11-09 10:51:17 +00:00
parent 85e44c2dae
commit 4066850f37
1 changed files with 25 additions and 23 deletions

View File

@ -342,14 +342,10 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
selectPoint( evt->Position() ); selectPoint( evt->Position() );
if( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T ) if( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T )
{
EnterGroup(); EnterGroup();
}
else else
{
m_toolMgr->RunAction( PCB_ACTIONS::properties, true ); m_toolMgr->RunAction( PCB_ACTIONS::properties, true );
} }
}
else if( evt->IsDblClick( BUT_MIDDLE ) ) else if( evt->IsDblClick( BUT_MIDDLE ) )
{ {
// Middle double click? Do zoom to fit or zoom to objects // Middle double click? Do zoom to fit or zoom to objects
@ -411,33 +407,39 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
aCollector.Remove( item ); aCollector.Remove( item );
}; };
// Selection is empty? try to start dragging the item under the point where drag // See if we can drag before falling back to selectMultiple()
// started bool doDrag = false;
if( m_selection.Empty() && selectCursor( false, zoneFilledAreaFilter ) )
m_selection.SetIsHover( true );
// Check if dragging has started within any of selected items bounding box. if( evt->HasPosition() )
// We verify "HasPosition()" first to protect against edge case involving
// moving off menus that causes problems (issue #5250)
if( evt->HasPosition() && selectionContains( evt->Position() ) )
{ {
// Yes -> run the move tool and wait till it finishes if( m_selection.Empty()
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( m_selection.GetItem( 0 ) ); && selectPoint( evt->DragOrigin(), false, nullptr, zoneFilledAreaFilter ) )
{
m_selection.SetIsHover( true );
doDrag = true;
}
// Check if dragging has started within any of selected items bounding box.
else if( selectionContains( evt->DragOrigin() ) )
{
doDrag = true;
}
}
// If there is only item in the selection and it's a track, then we need if( doDrag )
// to route it. {
bool doRouting = ( track && ( 1 == m_selection.GetSize() ) ); bool haveTrack = m_selection.GetSize() == 1
&& dynamic_cast<PCB_TRACK*>( m_selection.GetItem( 0 ) );
if( doRouting && trackDragAction == TRACK_DRAG_ACTION::DRAG ) if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG )
m_toolMgr->RunAction( PCB_ACTIONS::drag45Degree, true ); m_toolMgr->RunAction( PCB_ACTIONS::drag45Degree, true );
else if( doRouting && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE ) else if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
m_toolMgr->RunAction( PCB_ACTIONS::dragFreeAngle, true ); m_toolMgr->RunAction( PCB_ACTIONS::dragFreeAngle, true );
else else
m_toolMgr->RunAction( PCB_ACTIONS::move, true ); m_toolMgr->RunAction( PCB_ACTIONS::move, true );
} }
else else
{ {
// No -> drag a selection box // Otherwise drag a selection box
selectMultiple(); selectMultiple();
} }
} }