From 2cdeb0cd7c618d2ff3f5dc95c53a6b217a55af9d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 31 Aug 2025 07:52:35 -0700 Subject: [PATCH] Second pass at fixing warping and grids First attempt caused additional problems for #21535 Fixes https://gitlab.com/kicad/code/kicad/-/issues/18196 --- pcbnew/tools/edit_tool_move_fct.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index fda022bbbd..7527f1bb1b 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -665,15 +665,30 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit } else { - // Check if user wants to warp the mouse to origin of moved object - if( !editFrame->GetMoveWarpsCursor() ) - m_cursor = originalCursorPos; // No, so use original mouse pos instead + VECTOR2I snapped = grid.Align( m_cursor, grid.GetSelectionGrid( selection ) ); + VECTOR2I delta = snapped - m_cursor; - selection.SetReferencePoint( m_cursor ); - grid.SetAuxAxes( true, m_cursor ); + if( delta.x || delta.y ) + { + for( BOARD_ITEM* item : sel_items ) + { + if( item->GetParent() && item->GetParent()->IsSelected() ) + continue; + + item->Move( delta ); + } + } + + selection.SetReferencePoint( snapped ); + grid.SetAuxAxes( true, snapped ); + + if( !editFrame->GetMoveWarpsCursor() ) + m_cursor = originalCursorPos; + else + m_cursor = snapped; } - originalPos = m_cursor; + originalPos = selection.GetReferencePoint(); } // Update variables for bounding box collision calculations