Browse Source

Fix long-standing issue with arrow keys moving in both axes.

merge-requests/20/head
Jeff Young 6 years ago
parent
commit
1f07505b27
  1. 2
      common/tool/common_tools.cpp
  2. 3
      common/view/wx_view_controls.cpp
  3. 6
      include/view/view_controls.h
  4. 3
      include/view/wx_view_controls.h
  5. 14
      pcbnew/tools/edit_tool.cpp

2
common/tool/common_tools.cpp

@ -113,7 +113,7 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
wxFAIL_MSG( "CursorControl(): unexpected request" );
}
getViewControls()->SetCursorPosition( cursor, true, true );
getViewControls()->SetCursorPosition( cursor, true, true, type );
m_toolMgr->RunAction( ACTIONS::refreshPreview );
return 0;

3
common/view/wx_view_controls.cpp

@ -487,7 +487,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView,
bool aTriggeredByArrows )
bool aTriggeredByArrows, long aArrowCommand )
{
m_updateCursor = false;
@ -495,6 +495,7 @@ void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpV
{
m_settings.m_lastKeyboardCursorPositionValid = true;
m_settings.m_lastKeyboardCursorPosition = aPosition;
m_settings.m_lastKeyboardCursorCommand = aArrowCommand;
m_cursorWarped = false;
}
else

6
include/view/view_controls.h

@ -96,6 +96,9 @@ struct VC_SETTINGS
///> Is last cursor motion event coming from keyboard arrow cursor motion action
bool m_lastKeyboardCursorPositionValid;
///> ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
long m_lastKeyboardCursorCommand;
///> Position of the above event
VECTOR2D m_lastKeyboardCursorPosition;
};
@ -248,7 +251,8 @@ public:
* @param aPosition is the requested cursor position in the world coordinates.
* @param aWarpView enables/disables view warp if the cursor is outside the current viewport.
*/
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true, bool aTriggeredByArrows = false ) = 0;
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
/**

3
include/view/wx_view_controls.h

@ -85,7 +85,8 @@ public:
/// @copydoc VIEW_CONTROLS::GetRawCursorPosition()
VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const override;
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView, bool aTriggeredByArrows ) override;
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView,
bool aTriggeredByArrows, long aArrowCommand ) override;
/// @copydoc VIEW_CONTROLS::SetCrossHairCursorPosition()
void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView ) override;

14
pcbnew/tools/edit_tool.cpp

@ -323,7 +323,21 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent )
if( m_dragging && evt->Category() == TC_MOUSE )
{
VECTOR2I mousePos( controls->GetMousePosition() );
m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
if( controls->GetSettings().m_lastKeyboardCursorPositionValid )
{
long action = controls->GetSettings().m_lastKeyboardCursorCommand;
// The arrow keys are by definition SINGLE AXIS. Do not allow the other
// axis to be snapped to the grid.
if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
m_cursor.y = prevPos.y;
else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
m_cursor.x = prevPos.x;
}
controls->ForceCursorPosition( true, m_cursor );
selection.SetReferencePoint( m_cursor );

Loading…
Cancel
Save