GAL: update cursor position on panning and scrolling
Fixes: lp:1749082 * https://bugs.launchpad.net/kicad/+bug/1749082
This commit is contained in:
parent
c9d9cec6ad
commit
365ab99a6a
|
@ -153,6 +153,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
||||||
VECTOR2D delta( scrollX, scrollY );
|
VECTOR2D delta( scrollX, scrollY );
|
||||||
|
|
||||||
m_view->SetCenter( m_view->GetCenter() + delta );
|
m_view->SetCenter( m_view->GetCenter() + delta );
|
||||||
|
refreshMouse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -413,13 +414,13 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
||||||
|
|
||||||
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
||||||
{
|
{
|
||||||
wxPoint msp = wxGetMousePosition();
|
wxPoint msp = getMouseScreenPosition();
|
||||||
m_parentPanel->ScreenToClient( &msp.x, &msp.y );
|
|
||||||
VECTOR2D screenPos( msp.x, msp.y );
|
VECTOR2D screenPos( msp.x, msp.y );
|
||||||
|
|
||||||
return aWorldCoordinates ? m_view->ToWorld( screenPos ) : screenPos;
|
return aWorldCoordinates ? m_view->ToWorld( screenPos ) : screenPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const
|
VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const
|
||||||
{
|
{
|
||||||
if( aEnableSnapping )
|
if( aEnableSnapping )
|
||||||
|
@ -432,6 +433,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
|
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
|
||||||
{
|
{
|
||||||
if( m_settings.m_forceCursorPosition )
|
if( m_settings.m_forceCursorPosition )
|
||||||
|
@ -471,7 +473,7 @@ void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition, bo
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
|
void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
|
||||||
bool aWarpView ) const
|
bool aWarpView )
|
||||||
{
|
{
|
||||||
if( aWorldCoordinates )
|
if( aWorldCoordinates )
|
||||||
{
|
{
|
||||||
|
@ -575,10 +577,13 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::refreshMouse() const
|
void WX_VIEW_CONTROLS::refreshMouse()
|
||||||
{
|
{
|
||||||
// Notify tools that the cursor position has changed in the world coordinates
|
// Notify tools that the cursor position has changed in the world coordinates
|
||||||
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
|
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
|
||||||
|
wxPoint msp = getMouseScreenPosition();
|
||||||
|
moveEvent.SetX( msp.x );
|
||||||
|
moveEvent.SetY( msp.y );
|
||||||
|
|
||||||
// Set the modifiers state
|
// Set the modifiers state
|
||||||
#if wxCHECK_VERSION( 3, 0, 0 )
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
||||||
|
@ -593,6 +598,15 @@ void WX_VIEW_CONTROLS::refreshMouse() const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPostEvent( m_parentPanel, moveEvent );
|
wxPostEvent( m_parentPanel, moveEvent );
|
||||||
|
onMotion( moveEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxPoint WX_VIEW_CONTROLS::getMouseScreenPosition() const
|
||||||
|
{
|
||||||
|
wxPoint msp = wxGetMousePosition();
|
||||||
|
m_parentPanel->ScreenToClient( &msp.x, &msp.y );
|
||||||
|
return msp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ public:
|
||||||
* specified in the world coordinates and its not visible in the current viewport).
|
* specified in the world coordinates and its not visible in the current viewport).
|
||||||
*/
|
*/
|
||||||
virtual void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
|
virtual void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
|
||||||
bool aWarpView = false ) const = 0;
|
bool aWarpView = false ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function EnableCursorWarping()
|
* Function EnableCursorWarping()
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
/// @copydoc VIEW_CONTROLS::CursorWarp()
|
/// @copydoc VIEW_CONTROLS::CursorWarp()
|
||||||
void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
|
void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
|
||||||
bool aWarpView = false ) const override;
|
bool aWarpView = false ) override;
|
||||||
|
|
||||||
/// @copydoc VIEW_CONTROLS::CenterOnCursor()
|
/// @copydoc VIEW_CONTROLS::CenterOnCursor()
|
||||||
void CenterOnCursor() const override;
|
void CenterOnCursor() const override;
|
||||||
|
@ -124,7 +124,12 @@ private:
|
||||||
* that the cursor position in the world coordinates has changed, whereas the screen coordinates
|
* that the cursor position in the world coordinates has changed, whereas the screen coordinates
|
||||||
* remained the same (e.g. frame edge autopanning).
|
* remained the same (e.g. frame edge autopanning).
|
||||||
*/
|
*/
|
||||||
void refreshMouse() const;
|
void refreshMouse();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cursor position in the screen coordinates.
|
||||||
|
*/
|
||||||
|
wxPoint getMouseScreenPosition() const;
|
||||||
|
|
||||||
/// Current state of VIEW_CONTROLS
|
/// Current state of VIEW_CONTROLS
|
||||||
STATE m_state;
|
STATE m_state;
|
||||||
|
|
Loading…
Reference in New Issue