From b76a6210c5c46fff5fba904a136810bd7b7a28a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Thu, 16 Nov 2017 00:42:40 +0100 Subject: [PATCH] pcbnew: fixed stuck cursor when ForceCursorPosition() is active and cursor is moved by keyboard arrows Fixes: lp:1729301 * https://bugs.launchpad.net/kicad/+bug/1729301 --- common/view/wx_view_controls.cpp | 16 ++++++++++++---- include/view/view_controls.h | 8 ++++++++ include/view/wx_view_controls.h | 3 +++ pcbnew/tools/pcbnew_control.cpp | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index bd951806a6..e92d2b86f9 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -411,6 +411,17 @@ VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const return aWorldCoordinates ? m_view->ToWorld( screenPos ) : screenPos; } +VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const +{ + if( aEnableSnapping ) + { + return m_view->GetGAL()->GetGridPoint( m_cursorPos ); + } + else + { + return m_cursorPos; + } +} VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const { @@ -420,10 +431,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const } else { - if( aEnableSnapping ) - return m_view->GetGAL()->GetGridPoint( m_cursorPos ); - else - return m_cursorPos; + return GetRawCursorPosition( aEnableSnapping ); } } diff --git a/include/view/view_controls.h b/include/view/view_controls.h index d7601a16b2..c4470107df 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -183,6 +183,14 @@ public: return GetCursorPosition( m_settings.m_snappingEnabled ); } + /** + * Returns the current cursor position in world coordinates - ingoring the cursorUp + * position force mode. + * + * @return The current cursor position in world coordinates. + */ + virtual VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const = 0; + /** * Returns the current cursor position in world coordinates. Note, that it may be * different from the mouse pointer position if snapping is enabled or cursor position diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h index af0cf938bc..970015fbe3 100644 --- a/include/view/wx_view_controls.h +++ b/include/view/wx_view_controls.h @@ -78,6 +78,9 @@ public: /// @copydoc VIEW_CONTROLS::GetCursorPosition() VECTOR2D GetCursorPosition( bool aSnappingEnabled ) const override; + /// @copydoc VIEW_CONTROLS::GetRawCursorPosition() + VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const override; + void SetCursorPosition( const VECTOR2D& aPosition, bool warpView ) override; /// @copydoc VIEW_CONTROLS::CursorWarp() diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 970e9016e1..4c954539a3 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -484,7 +484,7 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent ) bool mirroredX = getView()->IsMirroredX(); GRID_HELPER gridHelper( m_frame ); - VECTOR2D cursor = getViewControls()->GetCursorPosition(); + VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true ); VECTOR2I gridSize = gridHelper.GetGrid(); if( fastMove )