Commit efafe11f authored by Garth Corral's avatar Garth Corral

- Fixed and issue where Cmd+Shift-modifed (off-center) mousewheel zoom direction was

  inverted due to wxWidgets handling of the axis and wheel rotation of shifted events.
parent 4b9db692
......@@ -946,20 +946,26 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
wxPoint delta;
wxPoint start = GetViewStart();
int wheelRotation = event.GetWheelRotation();
if( ( m_enableMousewheelPan || event.ShiftDown() ) && !event.ControlDown() )
{
if( axis == wxMOUSE_WHEEL_HORIZONTAL )
delta.x = -event.GetWheelRotation();
delta.x = -wheelRotation;
else
delta.y = event.GetWheelRotation();
delta.y = wheelRotation;
}
else if( event.ControlDown() && !event.ShiftDown() && !m_enableMousewheelPan )
delta.y = event.GetWheelRotation();
delta.y = wheelRotation;
else if( offCenterReq )
cmd.SetId( event.GetWheelRotation() > 0 ? ID_OFFCENTER_ZOOM_IN : ID_OFFCENTER_ZOOM_OUT );
{
// Don't let wxWidgets invert the wheel rotation when shift+ctrl-modified.
if( axis == wxMOUSE_WHEEL_HORIZONTAL )
wheelRotation = -wheelRotation;
cmd.SetId( wheelRotation > 0 ? ID_OFFCENTER_ZOOM_IN : ID_OFFCENTER_ZOOM_OUT );
}
else
cmd.SetId( event.GetWheelRotation() > 0 ? ID_POPUP_ZOOM_IN : ID_POPUP_ZOOM_OUT );
cmd.SetId( wheelRotation > 0 ? ID_POPUP_ZOOM_IN : ID_POPUP_ZOOM_OUT );
if( cmd.GetId() )
{
......
......@@ -137,18 +137,18 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
const double wheelPanSpeed = 0.001;
VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
bool mousewheelPanEnabled = ((EDA_DRAW_PANEL_GAL *)m_parentPanel)->GetEnableMousewheelPan();
if( !aEvent.ControlDown() && ( aEvent.ShiftDown() || ((EDA_DRAW_PANEL_GAL *)m_parentPanel)->GetEnableMousewheelPan() ) )
int axis = aEvent.GetWheelAxis();
if( !aEvent.ControlDown() && ( aEvent.ShiftDown() || mousewheelPanEnabled) )
{
// Scrolling
int axis = aEvent.GetWheelAxis();
VECTOR2D delta( axis == wxMOUSE_WHEEL_HORIZONTAL ? scrollVec.x : 0.0,
axis == wxMOUSE_WHEEL_VERTICAL ? -scrollVec.y : 0.0 );
setCenter( m_view->GetCenter() + delta );
}
else if( aEvent.ControlDown() && !aEvent.ShiftDown() && !((EDA_DRAW_PANEL_GAL *)m_parentPanel)->GetEnableMousewheelPan() )
else if( aEvent.ControlDown() && !aEvent.ShiftDown() && !mousewheelPanEnabled )
{
VECTOR2D delta( 0.0, -scrollVec.y );
setCenter( m_view->GetCenter() + delta );
......@@ -161,16 +161,21 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
m_timeStamp = timeStamp;
double zoomScale;
int wheelRotation = aEvent.GetWheelRotation();
// Don't let wxWidgets invert the wheel rotation when shift+ctrl-modified.
if( axis == wxMOUSE_WHEEL_HORIZONTAL )
wheelRotation = -wheelRotation;
// Set scaling speed depending on scroll wheel event interval
if( timeDiff < 500 && timeDiff > 0 )
{
zoomScale = ( aEvent.GetWheelRotation() > 0 ) ? 2.05 - timeDiff / 500 :
zoomScale = ( wheelRotation > 0 ) ? 2.05 - timeDiff / 500 :
1.0 / ( 2.05 - timeDiff / 500 );
}
else
{
zoomScale = ( aEvent.GetWheelRotation() > 0 ) ? 1.05 : 0.95;
zoomScale = ( wheelRotation > 0 ) ? 1.05 : 0.95;
}
VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment