From 4f74bf88f1f074cd2c968c8a875aef9ea9648e61 Mon Sep 17 00:00:00 2001 From: lajos kamocsay Date: Thu, 12 Apr 2012 09:58:12 +0200 Subject: [PATCH] Fix small issue when panning with middle button. --- common/drawpanel.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index dab3732318..c6b23f51ee 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -338,6 +338,9 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) GetClientSize( &csizeX, &csizeY ); GetVirtualSize( &unitsX, &unitsY ); + int tmpX = x; + int tmpY = y; + csizeX /= ppux; csizeY /= ppuy; @@ -399,6 +402,13 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ), ppux, ppuy, unitsX, unitsY, x, y ); + double scale = GetParent()->GetScreen()->GetScalingFactor(); + + wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); + center.x += wxRound( (double) ( x - tmpX ) / scale ); + center.y += wxRound( (double) ( y - tmpY ) / scale ); + GetParent()->GetScreen()->SetScrollCenterPosition( center ); + Scroll( x, y ); event.Skip(); } @@ -1007,11 +1017,13 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) if( m_panScrollbarLimits ) { int x, y; + int tmpX, tmpY; int ppux, ppuy; int maxX, maxY; int vsizeX, vsizeY; int csizeX, csizeY; + GetViewStart( &tmpX, &tmpY ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetVirtualSize( &vsizeX, &vsizeY ); GetClientSize( &csizeX, &csizeY ); @@ -1057,6 +1069,13 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) Scroll( x/ppux, y/ppuy ); + double scale = GetParent()->GetScreen()->GetScalingFactor(); + + wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); + center.x += wxRound( (double) ( x - tmpX ) / scale ) / ppux; + center.y += wxRound( (double) ( y - tmpY ) / scale ) / ppuy; + GetParent()->GetScreen()->SetScrollCenterPosition( center ); + Refresh(); Update(); }