From c8676db84ecca066b9ea10c11e966b6c361c424c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 12 Dec 2016 16:43:43 +0100 Subject: [PATCH] Fixed panning & cursor control with arrow keys in flipped view --- include/view/view.h | 18 ++++++++++++++++++ pcbnew/tools/pcbnew_control.cpp | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/view/view.h b/include/view/view.h index 2ad3f71301..4f7014345f 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -218,6 +218,24 @@ public: */ void SetMirror( bool aMirrorX, bool aMirrorY ); + /** + * Function IsMirroredX() + * Returns true if view is flipped across the X axis. + */ + bool IsMirroredX() const + { + return m_mirrorX; + } + + /** + * Function IsMirroredX() + * Returns true if view is flipped across the Y axis. + */ + bool IsMirroredY() const + { + return m_mirrorY; + } + /** * Function SetScale() * Sets the scaling factor. Scale = 1 corresponds to the real world size of the objects diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index f056964277..c6cd77fb4e 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -438,6 +438,7 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent ) long type = aEvent.Parameter(); bool fastMove = type & COMMON_ACTIONS::CURSOR_FAST_MOVE; type &= ~COMMON_ACTIONS::CURSOR_FAST_MOVE; + bool mirroredX = getView()->IsMirroredX(); GRID_HELPER gridHelper( m_frame ); VECTOR2D cursor = getViewControls()->GetCursorPosition(); @@ -458,11 +459,11 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent ) break; case COMMON_ACTIONS::CURSOR_LEFT: - newCursor -= VECTOR2D( gridSize.x, 0 ); + newCursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); break; case COMMON_ACTIONS::CURSOR_RIGHT: - newCursor += VECTOR2D( gridSize.x, 0 ); + newCursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); break; case COMMON_ACTIONS::CURSOR_CLICK: // fall through @@ -547,6 +548,7 @@ int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent ) GRID_HELPER gridHelper( m_frame ); VECTOR2D center = view->GetCenter(); VECTOR2I gridSize = gridHelper.GetGrid() * 10; + bool mirroredX = view->IsMirroredX(); switch( type ) { @@ -559,11 +561,11 @@ int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent ) break; case COMMON_ACTIONS::CURSOR_LEFT: - center -= VECTOR2D( gridSize.x, 0 ); + center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); break; case COMMON_ACTIONS::CURSOR_RIGHT: - center += VECTOR2D( gridSize.x, 0 ); + center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); break; default: