← Back to team overview

kicad-developers team mailing list archive

[PATCH] Flip horizontal scrollbar behavior in flipped board view mode

 

See: https://bugs.launchpad.net/kicad/+bug/1741327
From a2241312c5ce18038c6e648da91b154c98746bc6 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Thu, 4 Jan 2018 16:56:58 -0500
Subject: [PATCH] Flip horizontal scrollbar behavior in flipped board view mode

Fixes: lp:1741327
* https://bugs.launchpad.net/kicad/+bug/1741327
---
 common/view/wx_view_controls.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp
index e34c8d34f..1e4f07a47 100644
--- a/common/view/wx_view_controls.cpp
+++ b/common/view/wx_view_controls.cpp
@@ -347,8 +347,13 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
         VECTOR2D center = m_view->GetCenter();
         const BOX2I& boundary = m_view->GetBoundary();
 
+        // Flip scroll direction in flipped view
+        const double xstart = ( m_view->IsMirroredX() ?
+                                boundary.GetRight() : boundary.GetLeft() );
+        const double xdelta = ( m_view->IsMirroredX() ? -1 : 1 );
+
         if( dir == wxHORIZONTAL )
-            center.x = boundary.GetLeft() + aEvent.GetPosition() / m_scrollScale.x;
+            center.x = xstart + xdelta * ( aEvent.GetPosition() / m_scrollScale.x );
         else
             center.y = boundary.GetTop() + aEvent.GetPosition() / m_scrollScale.y;
 
@@ -580,6 +585,10 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
     VECTOR2I newScroll( ( viewport.Centre().x - boundary.GetLeft() ) * m_scrollScale.x,
                 ( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
 
+    // Flip scroll direction in flipped view
+    if( m_view->IsMirroredX() )
+        newScroll.x = ( boundary.GetRight() - viewport.Centre().x ) * m_scrollScale.x;
+
     // Adjust scrollbars only if it is needed. Otherwise there are cases when canvas is continuosly
     // refreshed (Windows)
     if( m_scrollPos != newScroll )
-- 
2.14.1


Follow ups