Handle view centering properly when drag-panning and zooming.

This commit is contained in:
Alex 2023-01-02 14:20:43 +05:00
parent f2fcd4b8e1
commit c1ea90abc6
3 changed files with 5 additions and 4 deletions

View File

@ -808,7 +808,7 @@ void WX_VIEW_CONTROLS::WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCo
}
void WX_VIEW_CONTROLS::CenterOnCursor() const
void WX_VIEW_CONTROLS::CenterOnCursor()
{
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
VECTOR2I screenCenter( screenSize / 2 );
@ -816,7 +816,8 @@ void WX_VIEW_CONTROLS::CenterOnCursor() const
if( GetMousePosition( false ) != screenCenter )
{
m_view->SetCenter( GetCursorPosition() );
KIPLATFORM::UI::WarpPointer( m_parentPanel, KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
m_dragStartPoint = screenCenter;
KIPLATFORM::UI::WarpPointer( m_parentPanel, screenCenter.x, screenCenter.y );
}
}

View File

@ -354,7 +354,7 @@ public:
* Set the viewport center to the current cursor position and warps the cursor to the
* screen center.
*/
virtual void CenterOnCursor() const = 0;
virtual void CenterOnCursor() = 0;
/**
* Restore the default VIEW_CONTROLS settings.

View File

@ -100,7 +100,7 @@ public:
bool aWarpView = false ) override;
///< @copydoc VIEW_CONTROLS::CenterOnCursor()
void CenterOnCursor() const override;
void CenterOnCursor() override;
///< Adjusts the scrollbars position to match the current viewport.
void UpdateScrollbars();