← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] mousewheelpan + ctrl = zooming

 

New version of the patch that works in legacy/opengl/cairo/3d_viewer.

Also I noticed that in 3d_viewer pan step is to big, so I propose decrease
it.

2016-11-12 9:33 GMT+02:00 Константин Барановский <
baranovskiykonstantin@xxxxxxxxx>:

> Hmm. This patch really works only in legacy mode and doesn't work in GAL
> mode, but I don't understand why. It looks like both modes legacy and GAL
> used the same event  handler for mouse wheel event, but still does not
> work. Can anyone to point me to right direction for searching, please?
>
> 2016-11-11 21:46 GMT+02:00 Wayne Stambaugh <stambaughw@xxxxxxxxx>:
>
>> Thanks Bernhard.  The behavior should be the same for the gal canvas and
>> the 3d-viewer.
>>
>> On 11/11/2016 2:26 PM, Bernhard Stegmaier wrote:
>> > I’ll try to test ASAP, but I can’t promise when.
>> >
>> > At least on first glance it seems to be somewhat incomplete.
>> > It only seems to change legacy canvas, but not GAL canvas or 3d-viewer,
>> which
>> > should probably behave the same then?
>> >
>> >
>> > Regards,
>> > Bernhard
>> >
>> >> On 11 Nov 2016, at 16:04, Wayne Stambaugh <stambaughw@xxxxxxxxx>
>> wrote:
>> >>
>> >> This doesn't break anything on osx does it?  That is what I need to
>> know
>> >> before I commit the patch.  Would one of the osx devs please confirm
>> >> this form me when you get a chance?
>> >>
>> >> Thanks,
>> >>
>> >> Wayne
>> >>
>> >> On 11/11/2016 10:01 AM, Константин Барановский wrote:
>> >>> I'm using archlinux x86_64 on thinkpad t420 (that allows two-finger
>> >>> scrolling) and all modifier keys (ctrl, shift, alt) does nothing.
>> >>>
>> >>> 2016-11-11 16:31 GMT+02:00 Brano Panak <bpanak@xxxxxxxxx
>> >>> <mailto:bpanak@xxxxxxxxx>>:
>> >>>
>> >>>    in osx even without this patch this functionality works (cmd+ mouse
>> >>>    wheel is zooming).
>> >>>
>> >>>
>> >>>    On 10/11/16 11:41, Константин Барановский wrote:
>> >>>>    That patch allows to use mouse wheel + ctrl for zooming, when
>> >>>>    option "Use touchpad to pan" is enabled.
>> >>>>
>> >>>>
>> >>>>
>> >>>>    _______________________________________________
>> >>>>    Mailing list: https://launchpad.net/~kicad-developers
>> >>>>    <https://launchpad.net/~kicad-developers>
>> >>>>    Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> >>>>    <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> >>>>    Unsubscribe : https://launchpad.net/~kicad-developers
>> >>>>    <https://launchpad.net/~kicad-developers>
>> >>>>    More help   : https://help.launchpad.net/ListHelp
>> >>>>    <https://help.launchpad.net/ListHelp>
>> >>>
>> >>>
>> >>>    _______________________________________________
>> >>>    Mailing list: https://launchpad.net/~kicad-developers
>> >>>    <https://launchpad.net/~kicad-developers>
>> >>>    Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> >>>    <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> >>>    Unsubscribe : https://launchpad.net/~kicad-developers
>> >>>    <https://launchpad.net/~kicad-developers>
>> >>>    More help   : https://help.launchpad.net/ListHelp
>> >>>    <https://help.launchpad.net/ListHelp>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> Mailing list: https://launchpad.net/~kicad-developers
>> >>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> >>> Unsubscribe : https://launchpad.net/~kicad-developers
>> >>> More help   : https://help.launchpad.net/ListHelp
>> >>>
>> >>
>> >>
>> >> _______________________________________________
>> >> Mailing list: https://launchpad.net/~kicad-developers
>> >> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> >> Unsubscribe : https://launchpad.net/~kicad-developers
>> >> More help   : https://help.launchpad.net/ListHelp
>> >
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
>
>
diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
index 2688125..c5fb5cf 100644
--- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp
+++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
@@ -443,7 +443,15 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event )
         if( event.GetWheelRotation() < 0 )
             delta_move = -delta_move;
 
-    if( m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) )
+    // mousewheel_panning enabled:
+    //      wheel           -> pan;
+    //      wheel + ctrl    -> zooming.
+    // mousewheel_panning disabled:
+    //      wheel + shift   -> vertical scrolling;
+    //      wheel + ctrl    -> horizontal scrolling;
+    //      wheel           -> zooming;
+
+    if( m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) && !event.ControlDown() )
     {
         if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL )
             m_settings.CameraGet().Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
@@ -452,12 +460,12 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event )
 
         mouseActivity = true;
     }
-    else if( event.ShiftDown() )
+    else if( event.ShiftDown() &&  !m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) )
     {
         m_settings.CameraGet().Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
         mouseActivity = true;
     }
-    else if( event.ControlDown() )
+    else if( event.ControlDown() && !m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) )
     {
         m_settings.CameraGet().Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) );
         mouseActivity = true;
diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp
index a705791..72cf624 100644
--- a/common/draw_panel.cpp
+++ b/common/draw_panel.cpp
@@ -981,15 +981,26 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
 
     if( m_enableMousewheelPan )
     {
-        wxPoint newStart = GetViewStart();
-        if( axis == wxMOUSE_WHEEL_HORIZONTAL )
-            newStart.x += wheelRotation;
+        // MousewheelPAN + Ctrl = zooming
+        if( event.ControlDown() )
+        {
+            if( wheelRotation > 0 )
+                cmd.SetId( ID_POPUP_ZOOM_IN );
+            else if( wheelRotation < 0)
+                cmd.SetId( ID_POPUP_ZOOM_OUT );
+        }
         else
-            newStart.y -= wheelRotation;
-
-        wxPoint center = GetScreenCenterLogicalPosition();
-        GetParent()->SetScrollCenterPosition( center );
-        Scroll( newStart );
+        {
+            wxPoint newStart = GetViewStart();
+            if( axis == wxMOUSE_WHEEL_HORIZONTAL )
+                newStart.x += wheelRotation;
+            else
+                newStart.y -= wheelRotation;
+
+            wxPoint center = GetScreenCenterLogicalPosition();
+            GetParent()->SetScrollCenterPosition( center );
+            Scroll( newStart );
+        }
     }
     else if( wheelRotation > 0 )
     {
diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp
index 845d2af..3f80f62 100644
--- a/common/view/wx_view_controls.cpp
+++ b/common/view/wx_view_controls.cpp
@@ -98,7 +98,16 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
 {
     const double wheelPanSpeed = 0.001;
 
-    if( aEvent.ControlDown() || aEvent.ShiftDown() || m_enableMousewheelPan )
+    // mousewheelpan disabled:
+    //      wheel + ctrl    -> horizontal scrolling;
+    //      wheel + shift   -> vertical scrolling;
+    //      wheel           -> zooming;
+    // mousewheelpan enabled:
+    //      wheel           -> pan;
+    //      wheel + ctrl    -> zooming.
+
+    if( ( !m_enableMousewheelPan && ( aEvent.ControlDown() || aEvent.ShiftDown() ) ) ||
+        ( m_enableMousewheelPan && !aEvent.ControlDown() ) )
     {
         // Scrolling
         VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
index 2688125..fe715ca 100644
--- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp
+++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
@@ -438,12 +438,20 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event )
     float delta_move = m_delta_move_step_factor * m_settings.CameraGet().ZoomGet();
 
     if( m_settings.GetFlag( FL_MOUSEWHEEL_PANNING ) )
-        delta_move *= (0.05f * event.GetWheelRotation());
+        delta_move *= (0.01f * event.GetWheelRotation());
     else
         if( event.GetWheelRotation() < 0 )
             delta_move = -delta_move;
 

Follow ups

References