From feebb3a36c665fa6a5fdf3b6070969b4deaa0191 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 18 Jun 2018 22:02:16 +0100 Subject: [PATCH] Don't double-move module text when parent is also selected. Fixes: lp:1776871 * https://bugs.launchpad.net/kicad/+bug/1776871 --- pcbnew/tools/edit_tool.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 4dde7ffc6f..ad86f0725d 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -416,11 +416,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events do { - bool matchingAction = evt->IsAction( &PCB_ACTIONS::editActivate ) - || evt->IsAction( &PCB_ACTIONS::move ); - - if( matchingAction - || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) + if( evt->IsAction( &PCB_ACTIONS::editActivate ) || + evt->IsAction( &PCB_ACTIONS::move ) || + evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) { if( selection.Empty() ) break; @@ -433,7 +431,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) controls->ForceCursorPosition( true, m_cursor ); VECTOR2I movement( m_cursor - prevPos ); - selection.SetReferencePoint(m_cursor); + selection.SetReferencePoint( m_cursor ); totalMovement += movement; prevPos = m_cursor; @@ -441,6 +439,10 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // 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( movement ); } @@ -463,7 +465,13 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // 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 ); + } m_cursor = controls->GetCursorPosition(); @@ -476,7 +484,13 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // 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 ); }