pcbnew: disable autopanning when cursor entered auto-pan margin following a keyboard cursor move command
Fixes: lp:1803523 * https://bugs.launchpad.net/kicad/+bug/1803523
This commit is contained in:
parent
10887868dc
commit
bebbe6ed22
|
@ -116,7 +116,7 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
|||
break;
|
||||
}
|
||||
|
||||
getViewControls()->SetCursorPosition( cursor );
|
||||
getViewControls()->SetCursorPosition( cursor, true, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
|
|||
m_panTimer.SetOwner( this );
|
||||
this->Connect( wxEVT_TIMER,
|
||||
wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), NULL, this );
|
||||
|
||||
m_settings.m_lastKeyboardCursorPositionValid = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -439,9 +441,16 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
|
|||
}
|
||||
|
||||
|
||||
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView )
|
||||
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView, bool aTriggeredByArrows )
|
||||
{
|
||||
m_updateCursor = false;
|
||||
if( aTriggeredByArrows )
|
||||
{
|
||||
m_settings.m_lastKeyboardCursorPositionValid = true;
|
||||
m_settings.m_lastKeyboardCursorPosition = aPosition;
|
||||
} else {
|
||||
m_settings.m_lastKeyboardCursorPositionValid = false;
|
||||
}
|
||||
WarpCursor( aPosition, true, aWarpView );
|
||||
m_cursorPos = aPosition;
|
||||
}
|
||||
|
@ -508,13 +517,23 @@ void WX_VIEW_CONTROLS::CenterOnCursor() const
|
|||
|
||||
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
||||
{
|
||||
VECTOR2D p( aEvent.GetX(), aEvent.GetY() );
|
||||
VECTOR2I p( aEvent.GetX(), aEvent.GetY() );
|
||||
VECTOR2I pKey( m_view->ToScreen(m_settings.m_lastKeyboardCursorPosition ) );
|
||||
|
||||
if( m_settings.m_lastKeyboardCursorPositionValid && (p == pKey) )
|
||||
{
|
||||
// last cursor move event came from keyboard cursor control. If auto-panning is enabled and
|
||||
// the next position is inside the autopan zone, check if it really came from a mouse event, otherwise
|
||||
// disable autopan temporarily.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compute areas where autopanning is active
|
||||
double borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
||||
int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
||||
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
||||
double borderEndX = m_view->GetScreenPixelSize().x - borderStart;
|
||||
double borderEndY = m_view->GetScreenPixelSize().y - borderStart;
|
||||
int borderEndX = m_view->GetScreenPixelSize().x - borderStart;
|
||||
int borderEndY = m_view->GetScreenPixelSize().y - borderStart;
|
||||
|
||||
if( p.x < borderStart )
|
||||
m_panDirection.x = -( borderStart - p.x );
|
||||
|
@ -642,3 +661,9 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
|
|||
m_scrollPos = newScroll;
|
||||
}
|
||||
}
|
||||
|
||||
void WX_VIEW_CONTROLS::ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition )
|
||||
{
|
||||
m_settings.m_forceCursorPosition = aEnabled;
|
||||
m_settings.m_forcedPosition = aPosition;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,12 @@ struct VC_SETTINGS
|
|||
|
||||
///> Allow panning with the left button in addition to middle
|
||||
bool m_panWithLeftButton;
|
||||
|
||||
///> Is last cursor motion event coming from keyboard arrow cursor motion action
|
||||
bool m_lastKeyboardCursorPositionValid;
|
||||
|
||||
///> Position of the above event
|
||||
VECTOR2D m_lastKeyboardCursorPosition;
|
||||
};
|
||||
|
||||
|
||||
|
@ -233,7 +239,7 @@ 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 ) = 0;
|
||||
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true, bool aTriggeredByArrows = false ) = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
/// @copydoc VIEW_CONTROLS::GetRawCursorPosition()
|
||||
VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const override;
|
||||
|
||||
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView ) override;
|
||||
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView, bool aTriggeredByArrows ) override;
|
||||
|
||||
/// @copydoc VIEW_CONTROLS::SetCrossHairCursorPosition()
|
||||
void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView ) override;
|
||||
|
@ -100,6 +100,8 @@ public:
|
|||
/// Adjusts the scrollbars position to match the current viewport.
|
||||
void UpdateScrollbars();
|
||||
|
||||
void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) ) override;
|
||||
|
||||
/// Event that forces mouse move event in the dispatcher (eg. used in autopanning, when mouse
|
||||
/// cursor does not move in screen coordinates, but does in world coordinates)
|
||||
static const wxEventType EVT_REFRESH_MOUSE;
|
||||
|
|
|
@ -128,6 +128,7 @@ void LENGTH_TUNER_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
void LENGTH_TUNER_TOOL::updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup )
|
||||
{
|
||||
// fixme: wx code not allowed inside tools!
|
||||
wxPoint p = wxGetMousePosition();
|
||||
|
||||
p.x += 20;
|
||||
|
|
Loading…
Reference in New Issue