Reduce the auto-panning margin and implement acceleration.
This commit is contained in:
parent
e03281a9ae
commit
65c88ba2c3
|
@ -63,8 +63,9 @@ void VC_SETTINGS::Reset()
|
|||
m_grabMouse = false;
|
||||
m_autoPanEnabled = false;
|
||||
m_autoPanSettingEnabled = false;
|
||||
m_autoPanMargin = 0.1f;
|
||||
m_autoPanMargin = 0.02f;
|
||||
m_autoPanSpeed = 0.15f;
|
||||
m_autoPanAcceleration = 1.5f;
|
||||
m_warpCursor = false;
|
||||
m_enableMousewheelPan = false;
|
||||
m_panWithRightButton = false;
|
||||
|
@ -82,5 +83,6 @@ void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
|
|||
SetAutoPan( aSettings.m_autoPanEnabled );
|
||||
SetAutoPanMargin( aSettings.m_autoPanMargin );
|
||||
SetAutoPanSpeed( aSettings.m_autoPanSpeed );
|
||||
SetAutoPanAcceleration( aSettings.m_autoPanAcceleration );
|
||||
ForceCursorPosition( aSettings.m_forceCursorPosition, aSettings.m_forcedPosition );
|
||||
}
|
||||
|
|
|
@ -363,11 +363,13 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|||
|
||||
VECTOR2D dir( m_panDirection );
|
||||
|
||||
if( dir.EuclideanNorm() > borderSize )
|
||||
if( dir.EuclideanNorm() > borderSize / 2 )
|
||||
dir = dir.Resize( pow( borderSize, m_settings.m_autoPanAcceleration ) );
|
||||
else if( dir.EuclideanNorm() > borderSize )
|
||||
dir = dir.Resize( borderSize );
|
||||
|
||||
dir = m_view->ToWorld( dir, false );
|
||||
m_view->SetCenter( m_view->GetCenter() + dir * m_settings.m_autoPanSpeed );
|
||||
m_view->SetCenter( m_view->GetCenter() + dir );
|
||||
|
||||
refreshMouse();
|
||||
}
|
||||
|
@ -591,6 +593,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
|||
// Compute areas where autopanning is active
|
||||
int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
||||
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
||||
borderStart = std::max( borderStart, 2 );
|
||||
int borderEndX = m_view->GetScreenPixelSize().x - borderStart;
|
||||
int borderEndY = m_view->GetScreenPixelSize().y - borderStart;
|
||||
|
||||
|
|
|
@ -81,6 +81,9 @@ struct VC_SETTINGS
|
|||
///> How fast is panning when in auto mode
|
||||
float m_autoPanSpeed;
|
||||
|
||||
///> How fast does panning accelerate when approaching the window boundary
|
||||
float m_autoPanAcceleration;
|
||||
|
||||
///> If the cursor is allowed to be warped
|
||||
bool m_warpCursor;
|
||||
|
||||
|
@ -181,6 +184,16 @@ public:
|
|||
m_settings.m_autoPanSpeed = aSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetAutoPanSpeed()
|
||||
* Sets speed of autopanning.
|
||||
* @param aSpeed is a new speed for autopanning.
|
||||
*/
|
||||
virtual void SetAutoPanAcceleration( float aAcceleration )
|
||||
{
|
||||
m_settings.m_autoPanAcceleration = aAcceleration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetAutoPanMArgin()
|
||||
* Sets margin for autopanning (ie. the area when autopanning becomes active).
|
||||
|
|
Loading…
Reference in New Issue