Fixed panning & cursor control with arrow keys in flipped view

This commit is contained in:
Maciej Suminski 2016-12-12 16:43:43 +01:00
parent 3ea8f12555
commit c8676db84e
2 changed files with 24 additions and 4 deletions

View File

@ -218,6 +218,24 @@ public:
*/ */
void SetMirror( bool aMirrorX, bool aMirrorY ); 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() * Function SetScale()
* Sets the scaling factor. Scale = 1 corresponds to the real world size of the objects * Sets the scaling factor. Scale = 1 corresponds to the real world size of the objects

View File

@ -438,6 +438,7 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
long type = aEvent.Parameter<intptr_t>(); long type = aEvent.Parameter<intptr_t>();
bool fastMove = type & COMMON_ACTIONS::CURSOR_FAST_MOVE; bool fastMove = type & COMMON_ACTIONS::CURSOR_FAST_MOVE;
type &= ~COMMON_ACTIONS::CURSOR_FAST_MOVE; type &= ~COMMON_ACTIONS::CURSOR_FAST_MOVE;
bool mirroredX = getView()->IsMirroredX();
GRID_HELPER gridHelper( m_frame ); GRID_HELPER gridHelper( m_frame );
VECTOR2D cursor = getViewControls()->GetCursorPosition(); VECTOR2D cursor = getViewControls()->GetCursorPosition();
@ -458,11 +459,11 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
break; break;
case COMMON_ACTIONS::CURSOR_LEFT: case COMMON_ACTIONS::CURSOR_LEFT:
newCursor -= VECTOR2D( gridSize.x, 0 ); newCursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break; break;
case COMMON_ACTIONS::CURSOR_RIGHT: case COMMON_ACTIONS::CURSOR_RIGHT:
newCursor += VECTOR2D( gridSize.x, 0 ); newCursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break; break;
case COMMON_ACTIONS::CURSOR_CLICK: // fall through case COMMON_ACTIONS::CURSOR_CLICK: // fall through
@ -547,6 +548,7 @@ int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent )
GRID_HELPER gridHelper( m_frame ); GRID_HELPER gridHelper( m_frame );
VECTOR2D center = view->GetCenter(); VECTOR2D center = view->GetCenter();
VECTOR2I gridSize = gridHelper.GetGrid() * 10; VECTOR2I gridSize = gridHelper.GetGrid() * 10;
bool mirroredX = view->IsMirroredX();
switch( type ) switch( type )
{ {
@ -559,11 +561,11 @@ int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent )
break; break;
case COMMON_ACTIONS::CURSOR_LEFT: case COMMON_ACTIONS::CURSOR_LEFT:
center -= VECTOR2D( gridSize.x, 0 ); center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break; break;
case COMMON_ACTIONS::CURSOR_RIGHT: case COMMON_ACTIONS::CURSOR_RIGHT:
center += VECTOR2D( gridSize.x, 0 ); center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break; break;
default: default: