Represent alignment as a float; eliminates selects. (I havn't

yet decided whether these should be -1.0 ... +1.0, indicating
"fully left aligned" and "fully right aligned", or 0.0 ... 1.0,
indicating "anchor to this fractional position in m_size".
It may become the latter.)
This commit is contained in:
Glenn Maynard
2007-03-01 02:19:49 +00:00
parent f6b792490a
commit be4efcd0c2
5 changed files with 40 additions and 73 deletions
+6 -17
View File
@@ -72,8 +72,8 @@ void Actor::InitState()
m_start.Init();
m_current.Init();
m_HorizAlign = HorizAlign_Center;
m_VertAlign = VertAlign_Middle;
m_fHorizAlign = 0.0f;
m_fVertAlign = 0.0f;
m_Effect = no_effect;
m_fSecsIntoEffect = 0;
@@ -166,8 +166,8 @@ Actor::Actor( const Actor &cpy ):
CPY( m_bFirstUpdate );
CPY( m_HorizAlign );
CPY( m_VertAlign );
CPY( m_fHorizAlign );
CPY( m_fVertAlign );
CPY( m_Effect );
CPY( m_fSecsIntoEffect );
@@ -730,19 +730,8 @@ void Actor::ScaleTo( const RectF &rect, StretchType st )
break;
}
switch( m_HorizAlign )
{
case HorizAlign_Left: SetX( rect.left ); break;
case HorizAlign_Center: SetX( rect.left + rect_width/2 ); break;
case HorizAlign_Right: SetX( rect.left + rect_width ); break;
}
switch( m_VertAlign )
{
case VertAlign_Top: SetY( rect.top ); break;
case VertAlign_Middle: SetY( rect.top + rect_height/2 ); break;
case VertAlign_Bottom: SetY( rect.top + rect_height ); break;
}
SetX( rect.left + rect_width * SCALE( m_fHorizAlign, -1.0f, +1.0f, 0.0f, 1.0f ) );
SetY( rect.top + rect_height * SCALE( m_fVertAlign, -1.0f, +1.0f, 0.0f, 1.0f ) );
SetZoom( fNewZoom );
}