From a6c94e26f6fac9340ee4a90aa9f5f6fe2ccd7b6d Mon Sep 17 00:00:00 2001 From: Henrik Nyberg Date: Wed, 12 Aug 2015 10:15:45 +0200 Subject: [PATCH] Improved code for handling zone corner dragging (GAL). --- pcbnew/tools/point_editor.cpp | 31 ++++++++++++++++++++++--------- pcbnew/tools/point_editor.h | 3 +++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 99b6915db8..049e5f585f 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -219,6 +219,24 @@ bool POINT_EDITOR::Init() } +void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent ) +{ + EDIT_POINT* point = NULL; + + if( aEvent.IsMotion() ) + { + point = m_editPoints->FindPoint( aEvent.Position() ); + } + else if( aEvent.IsDrag( BUT_LEFT ) ) + { + point = m_editPoints->FindPoint( aEvent.DragOrigin() ); + } + + if( m_editedPoint != point ) + setEditedPoint( point ); +} + + int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) { const SELECTION& selection = m_selectionTool->GetSelection(); @@ -251,16 +269,11 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) { break; } + + if ( !modified ) + updateEditedPoint( *evt ); - if( evt->IsMotion() ) - { - EDIT_POINT* point = m_editPoints->FindPoint( evt->Position() ); - - if( m_editedPoint != point ) - setEditedPoint( point ); - } - - else if( evt->IsAction( &COMMON_ACTIONS::pointEditorAddCorner ) ) + if( evt->IsAction( &COMMON_ACTIONS::pointEditorAddCorner ) ) { addCorner( controls->GetCursorPosition() ); updatePoints(); diff --git a/pcbnew/tools/point_editor.h b/pcbnew/tools/point_editor.h index 681105ba8e..fc4c6a0126 100644 --- a/pcbnew/tools/point_editor.h +++ b/pcbnew/tools/point_editor.h @@ -86,6 +86,9 @@ private: ///> Updates edit points with item's points. void updatePoints(); + ///> Updates which point is being edited. + void updateEditedPoint( const TOOL_EVENT& aEvent ); + ///> Sets the current point being edited. NULL means none. void setEditedPoint( EDIT_POINT* aPoint );