Commit 2f5103bc authored by Maciej Suminski's avatar Maciej Suminski

Fixed jumpy zoom when hotkeys and scroll wheel were used alternatively.

parent 50193f17
...@@ -160,12 +160,12 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) ...@@ -160,12 +160,12 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
// Set scaling speed depending on scroll wheel event interval // Set scaling speed depending on scroll wheel event interval
if( timeDiff < 500 && timeDiff > 0 ) if( timeDiff < 500 && timeDiff > 0 )
{ {
zoomScale = ( aEvent.GetWheelRotation() > 0.0 ) ? 2.05 - timeDiff / 500 : zoomScale = ( aEvent.GetWheelRotation() > 0 ) ? 2.05 - timeDiff / 500 :
1.0 / ( 2.05 - timeDiff / 500 ); 1.0 / ( 2.05 - timeDiff / 500 );
} }
else else
{ {
zoomScale = ( aEvent.GetWheelRotation() > 0.0 ) ? 1.05 : 0.95; zoomScale = ( aEvent.GetWheelRotation() > 0 ) ? 1.05 : 0.95;
} }
VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) ); VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
......
...@@ -61,17 +61,14 @@ bool PCBNEW_CONTROL::Init() ...@@ -61,17 +61,14 @@ bool PCBNEW_CONTROL::Init()
int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent )
{ {
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL(); double zoomScale = 1.0;
if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) ) if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
m_frame->SetPrevZoom(); zoomScale = 1.3;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) ) else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
m_frame->SetNextZoom(); zoomScale = 0.7;
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );
view->SetScale( zoom, getViewControls()->GetCursorPosition() ); view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );
setTransitions(); setTransitions();
return 0; return 0;
...@@ -81,17 +78,14 @@ int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent ) ...@@ -81,17 +78,14 @@ int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent )
{ {
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL(); double zoomScale = 1.0;
if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
m_frame->SetPrevZoom();
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
m_frame->SetNextZoom();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() ); zoomScale = 1.3;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
zoomScale = 0.7;
view->SetScale( zoom ); view->SetScale( view->GetScale() * zoomScale );
setTransitions(); setTransitions();
return 0; return 0;
...@@ -119,10 +113,6 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent ) ...@@ -119,10 +113,6 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
double iuPerY = screenSize.y ? boardBBox.GetHeight() / screenSize.y : 1.0; double iuPerY = screenSize.y ? boardBBox.GetHeight() / screenSize.y : 1.0;
double bestZoom = std::max( iuPerX, iuPerY ); double bestZoom = std::max( iuPerX, iuPerY );
// This is needed to avoid "jumpy" zooms if first hot key was used and then mouse scroll
// (or other way round).
m_frame->GetScreen()->SetZoom( bestZoom );
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * bestZoom ); double zoom = 1.0 / ( zoomFactor * bestZoom );
......
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