← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Support of horizontal scrolling events in pcbnew and 3d-viewer

 

On Sun, Nov 01, 2015 at 03:37:42PM +0100, Nick Østergaard wrote:
> By the way, could you please attach patches instead of inlining in the mail?

OK, patch is attached to this message. Inlining of patches is standard
way in git-driven workflow but if attaching is preferrable, no problem.

-- 
Yauhen Kharuzhy
			skype: jekhor
>From d6dd8800b4524feb944374fb68e428d58fa941c9 Mon Sep 17 00:00:00 2001
From: Yauhen Kharuzhy <jekhor@xxxxxxxxx>
Date: Sun, 1 Nov 2015 13:46:49 +0300
Subject: [PATCH] Support of horizontal scrolling events in pcbnew and
 3d-viewer

Add handling of horizontal mouse wheel scrolling to new GL pcbnew canvas
and to 3d-viewer like eeschema has (left-right panning with Shift key down).

Horizontal scrolling events are usual case for touchpads and TrackPoint
devices.

Signed-off-by: Yauhen Kharuzhy <jekhor@xxxxxxxxx>
---
 3d-viewer/3d_canvas.cpp          |  6 ++++--
 common/view/wx_view_controls.cpp | 26 ++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp
index 24d022a..c8d7e84 100644
--- a/3d-viewer/3d_canvas.cpp
+++ b/3d-viewer/3d_canvas.cpp
@@ -285,12 +285,14 @@ void EDA_3D_CANVAS::SetView3D( int keycode )
 
 void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
 {
+    int axis = event.GetWheelAxis();
+
     if( event.ShiftDown() )
     {
         if( event.GetWheelRotation() < 0 )
-            SetView3D( WXK_UP );    // move up
+            SetView3D( (axis == wxMOUSE_WHEEL_VERTICAL) ? WXK_UP : WXK_RIGHT );
         else
-            SetView3D( WXK_DOWN );  // move down
+            SetView3D( (axis == wxMOUSE_WHEEL_VERTICAL) ? WXK_DOWN : WXK_LEFT );
     }
     else if( event.ControlDown() )
     {
diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp
index 3484a15..b745d1b 100644
--- a/common/view/wx_view_controls.cpp
+++ b/common/view/wx_view_controls.cpp
@@ -102,14 +102,36 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
         VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
                              ( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
         double   scrollSpeed;
+        double   deltaX = 0.0, deltaY = 0.0;
 
         if( std::abs( scrollVec.x ) > std::abs( scrollVec.y ) )
             scrollSpeed = scrollVec.x;
         else
             scrollSpeed = scrollVec.y;
 
-        VECTOR2D delta( aEvent.ControlDown() ? -scrollSpeed : 0.0,
-                        aEvent.ShiftDown() ? -scrollSpeed : 0.0 );
+        int axis = aEvent.GetWheelAxis();
+
+        switch( axis )
+        {
+        case wxMOUSE_WHEEL_VERTICAL:
+            if( aEvent.ControlDown() )
+            {
+                deltaX = -scrollSpeed;
+                deltaY = 0.0;
+            }
+            else
+            {
+                deltaY = -scrollSpeed;
+                deltaX = 0;
+            }
+            break;
+        case wxMOUSE_WHEEL_HORIZONTAL:
+            deltaX = scrollSpeed;
+            deltaY = 0.0;
+            break;
+        }
+
+        VECTOR2D delta( deltaX, deltaY );
 
         m_view->SetCenter( m_view->GetCenter() + delta );
     }
-- 
2.5.3


References