From f5a2eb1ab09515fbac2c49fe0b81d09408086e2e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 7 Apr 2019 20:57:10 -0700 Subject: [PATCH] pcbnew: Allow click+drag of tracks This behavior existed in 5.0.x but did not properly exit the edit tool in 5.1. This removes stops the edit tool when we begin dragging a track using the interactive router. Fixes: lp:1820312 * https://bugs.launchpad.net/kicad/+bug/1820312 (cherry picked from commit c8118e3ce49dba90eec5d4bfd7f56e99b6645eb1) --- pcbnew/tools/edit_tool.cpp | 136 ++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 13517454d2..0685bfff25 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -426,79 +426,77 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) } else if( !m_dragging ) // Prepare to start dragging { - bool invokedRouter = false; - if ( !evt->IsAction( &PCB_ACTIONS::move ) && isInteractiveDragEnabled() ) - invokedRouter = invokeInlineRouter( PNS::DM_ANY ); - - if( !invokedRouter ) { - // deal with locked items (override lock or abort the operation) - SELECTION_LOCK_FLAGS lockFlags = m_selectionTool->CheckLock(); - - if( lockFlags == SELECTION_LOCKED ) + if( invokeInlineRouter( PNS::DM_ANY ) ) break; - - // When editing modules, all items have the same parent - if( EditingModules() ) - { - m_commit->Modify( selection.Front() ); - } - else - { - // Save items, so changes can be undone - for( auto item : selection ) - { - // Don't double move footprint pads, fields, etc. - if( item->GetParent() && item->GetParent()->IsSelected() ) - continue; - - m_commit->Modify( item ); - } - } - - editFrame->UndoRedoBlock( true ); - m_cursor = controls->GetCursorPosition(); - - if ( selection.HasReferencePoint() ) - { - // start moving with the reference point attached to the cursor - grid.SetAuxAxes( false ); - - auto delta = m_cursor - selection.GetReferencePoint(); - - // Drag items to the current cursor position - for( auto item : selection ) - { - // Don't double move footprint pads, fields, etc. - if( item->GetParent() && item->GetParent()->IsSelected() ) - continue; - - static_cast( item )->Move( delta ); - } - - selection.SetReferencePoint( m_cursor ); - } - else if( selection.Size() == 1 ) - { - // Set the current cursor position to the first dragged item origin, so the - // movement vector could be computed later - updateModificationPoint( selection ); - m_cursor = grid.BestDragOrigin( originalCursorPos, curr_item ); - grid.SetAuxAxes( true, m_cursor ); - } - else - { - updateModificationPoint( selection ); - m_cursor = grid.Align( m_cursor ); - } - - controls->SetCursorPosition( m_cursor, false ); - - prevPos = m_cursor; - controls->SetAutoPan( true ); - m_dragging = true; } + + // deal with locked items (override lock or abort the operation) + SELECTION_LOCK_FLAGS lockFlags = m_selectionTool->CheckLock(); + + if( lockFlags == SELECTION_LOCKED ) + break; + + // When editing modules, all items have the same parent + if( EditingModules() ) + { + m_commit->Modify( selection.Front() ); + } + else + { + // Save items, so changes can be undone + for( auto item : selection ) + { + // Don't double move footprint pads, fields, etc. + if( item->GetParent() && item->GetParent()->IsSelected() ) + continue; + + m_commit->Modify( item ); + } + } + + editFrame->UndoRedoBlock( true ); + m_cursor = controls->GetCursorPosition(); + + if ( selection.HasReferencePoint() ) + { + // start moving with the reference point attached to the cursor + grid.SetAuxAxes( false ); + + auto delta = m_cursor - selection.GetReferencePoint(); + + // Drag items to the current cursor position + for( auto item : selection ) + { + // Don't double move footprint pads, fields, etc. + if( item->GetParent() && item->GetParent()->IsSelected() ) + continue; + + static_cast( item )->Move( delta ); + } + + selection.SetReferencePoint( m_cursor ); + } + else if( selection.Size() == 1 ) + { + // Set the current cursor position to the first dragged item origin, so the + // movement vector could be computed later + updateModificationPoint( selection ); + m_cursor = grid.BestDragOrigin( originalCursorPos, curr_item ); + grid.SetAuxAxes( true, m_cursor ); + } + else + { + updateModificationPoint( selection ); + m_cursor = grid.Align( m_cursor ); + } + + controls->SetCursorPosition( m_cursor, false ); + + prevPos = m_cursor; + controls->SetAutoPan( true ); + m_dragging = true; } m_toolMgr->RunAction( PCB_ACTIONS::selectionModified, false );