Legacy canvas: fix issue when zooming in/out using mousewheel: slightly shifts screen up/down.

It happens only when the 'warp and center cursor on zoom' option is disabled.

Was created after modifying the code in EDA_DRAW_FRAME::AdjustScrollBars(),
making EDA_DRAW_FRAME::RedrawScreen2() not working very well.

(partial fix of bug 1562173)
This commit is contained in:
jean-pierre charras 2018-06-19 19:52:08 +02:00
parent f6f726acab
commit f52763f22b
2 changed files with 8 additions and 2 deletions

View File

@ -990,6 +990,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
// Full drawing or "page" rectangle in internal units // Full drawing or "page" rectangle in internal units
DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) ); DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
// Remark: if something is modified here, perhaps EDA_DRAW_FRAME::RedrawScreen2()
// will need changes accordint to the way the center is computed
// Account for scrollbars // Account for scrollbars
wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize(); wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale); wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);

View File

@ -64,8 +64,12 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
return; return;
// relative screen position to center before zoom // Account for scrollbars (see EDA_DRAW_FRAME::AdjustScrollBars that takes
wxPoint dPos = posBefore - m_canvas->GetClientSize() / 2; // in account scroolbars area to adjust scroll bars)
wxSize scrollbarSize = m_canvas->GetSize() - m_canvas->GetClientSize();
wxSize sizeAdjusted = m_canvas->GetClientSize() - scrollbarSize;
wxPoint dPos = posBefore - sizeAdjusted / 2;
// screen position of crosshair after zoom // screen position of crosshair after zoom
wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() );