shorten XYWnd::ZoomIn() / Out logic
fix odd wxywnd updates on zoom out of scale bounds
This commit is contained in:
parent
4e82cdf2f4
commit
154b5f3619
|
|
@ -240,42 +240,26 @@ inline unsigned int buttons_for_state( guint state ){
|
||||||
|
|
||||||
|
|
||||||
void XYWnd::SetScale( float f ){
|
void XYWnd::SetScale( float f ){
|
||||||
|
const float max_scale = 64.f;
|
||||||
|
const float min_scale = std::min( Width(), Height() ) / ( 1.1f * ( g_MaxWorldCoord - g_MinWorldCoord ) );
|
||||||
|
f = std::min( max_scale, std::max( min_scale, f ) );
|
||||||
|
if( !float_equal_epsilon( m_fScale, f, float_mid( m_fScale, f ) * 1e-5f ) ){
|
||||||
m_fScale = f;
|
m_fScale = f;
|
||||||
updateProjection();
|
updateProjection();
|
||||||
updateModelview();
|
updateModelview();
|
||||||
XYWnd_Update( *this );
|
XYWnd_Update( *this );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void XYWnd::ZoomIn(){
|
void XYWnd::ZoomIn(){
|
||||||
float max_scale = 64;
|
SetScale( Scale() * 5.0f / 4.0f );
|
||||||
float scale = Scale() * 5.0f / 4.0f;
|
|
||||||
if ( scale > max_scale ) {
|
|
||||||
if ( Scale() != max_scale ) {
|
|
||||||
SetScale( max_scale );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetScale( scale );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: the zoom out factor is 4/5, we could think about customizing it
|
// NOTE: the zoom out factor is 4/5, we could think about customizing it
|
||||||
// we don't go below a zoom factor corresponding to 10% of the max world size
|
// we don't go below a zoom factor corresponding to 10% of the max world size
|
||||||
// (this has to be computed against the window size)
|
// (this has to be computed against the window size)
|
||||||
void XYWnd::ZoomOut(){
|
void XYWnd::ZoomOut(){
|
||||||
float min_scale = std::min( Width(), Height() ) / ( 1.1f * ( g_MaxWorldCoord - g_MinWorldCoord ) );
|
SetScale( Scale() * 4.0f / 5.0f );
|
||||||
float scale = Scale() * 4.0f / 5.0f;
|
|
||||||
if ( scale < min_scale ) {
|
|
||||||
if ( Scale() != min_scale ) {
|
|
||||||
SetScale( min_scale );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetScale( scale );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
|
void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
|
||||||
|
|
@ -2456,9 +2440,6 @@ void XY_ZoomIn(){
|
||||||
g_pParentWnd->ActiveXY()->ZoomIn();
|
g_pParentWnd->ActiveXY()->ZoomIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: the zoom out factor is 4/5, we could think about customizing it
|
|
||||||
// we don't go below a zoom factor corresponding to 10% of the max world size
|
|
||||||
// (this has to be computed against the window size)
|
|
||||||
void XY_ZoomOut(){
|
void XY_ZoomOut(){
|
||||||
g_pParentWnd->ActiveXY()->ZoomOut();
|
g_pParentWnd->ActiveXY()->ZoomOut();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user