From 35883bb74b3f6daa0911ef53e7ddff071660a3a3 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Tue, 7 Jun 2016 20:28:11 -0400 Subject: [PATCH] Account for scrollbars when centering --- common/draw_frame.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index b28e63d8b7..442e110e6c 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -903,9 +903,14 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) // Full drawing or "page" rectangle in internal units DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) ); + // Account for scrollbars + wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize(); + wxSize scrollbarSizeIU = scrollbarSizeDU * scale; + wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2; + // The upper left corner of the client rectangle in internal units. - double xIU = aCenterPositionIU.x - clientSizeIU.x / 2.0; - double yIU = aCenterPositionIU.y - clientSizeIU.y / 2.0; + double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0; + double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0; // If drawn around the center, adjust the client rectangle accordingly. if( screen->m_Center )