Fixed jumpy zoom when hotkeys and scroll wheel were used alternatively.
This commit is contained in:
parent
f092fac22e
commit
ef7e71e93a
|
@ -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()
|
||||||
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();
|
view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );
|
||||||
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );
|
|
||||||
|
|
||||||
view->SetScale( zoom, getViewControls()->GetCursorPosition() );
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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 ) )
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
|
||||||
m_frame->SetPrevZoom();
|
zoomScale = 1.3;
|
||||||
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
|
||||||
m_frame->SetNextZoom();
|
zoomScale = 0.7;
|
||||||
|
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
view->SetScale( view->GetScale() * zoomScale );
|
||||||
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );
|
|
||||||
|
|
||||||
view->SetScale( zoom );
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue