Previously, alignment had to be implemented by each actor, so it was

only ever supported by Sprite and BitmapText.  Handle it globally, using
m_size.  This way, an actor only needs to set m_size to support alignment.

This means alignment can be set for non-drawing ActorFrames, if a size
is set explicitly.  This allows stretching from the border of a frame
without playing games with extra nested frames.  "setsize,100,100;valign,4;zoomx,.5"

This adds an extra matrix multiply.  This will only happen for actors
actually set to non-centered alignment, which is the exception.

BitmapText still overrides this behavior a bit.  Alignment for text
does two things: changes the alignment of the bounding box vs. the
X/Y position (the generic behavior), and changes the alignment of
the text within the bounding box.
This commit is contained in:
Glenn Maynard
2007-03-01 04:29:05 +00:00
parent be4efcd0c2
commit c371d9f26b
5 changed files with 34 additions and 32 deletions
+4 -8
View File
@@ -188,12 +188,8 @@ void BitmapText::BuildChars()
/* There's padding between every line: */
m_size.y += iPadding * int(m_wTextLines.size()-1);
RageVector2 center = m_size;
// center.x *= m_fHorizAlign*-0.5f;
center.y *= m_fVertAlign*-0.5f;
// the top position of the first row of characters
int iY = lrintf(center.y - m_size.y/2.0f);
int iY = lrintf(-m_size.y/2.0f);
for( unsigned i=0; i<m_wTextLines.size(); i++ ) // foreach line
{
@@ -203,9 +199,9 @@ void BitmapText::BuildChars()
if( m_pFont->IsRightToLeft() )
reverse( sLine.begin(), sLine.end() );
const int iLineWidth = m_iLineWidths[i];
float fCenterX = iLineWidth * m_fHorizAlign * -0.5f;
int iX = lrintf(fCenterX - iLineWidth/2.0f);
float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, -m_size.x/2.0f, +m_size.x/2.0f - iLineWidth );
int iX = lrintf( fX );
for( unsigned i = 0; i < sLine.size(); ++i )
{