From c1ea90abc65eb67bf9b065d8cf49c5e82169b67f Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Jan 2023 14:20:43 +0500 Subject: [PATCH] Handle view centering properly when drag-panning and zooming. --- common/view/wx_view_controls.cpp | 5 +++-- include/view/view_controls.h | 2 +- include/view/wx_view_controls.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 97f51a67d8..d87078a084 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -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 ); } } diff --git a/include/view/view_controls.h b/include/view/view_controls.h index a360e9906b..e612c613eb 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -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. diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h index 1a3e3b2d12..3147049cc5 100644 --- a/include/view/wx_view_controls.h +++ b/include/view/wx_view_controls.h @@ -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();