Bug in guiControl.cc
by Claude-Alain Fournier · in Torque Game Engine · 04/05/2005 (2:06 am) · 5 replies
I consider this a bug. When your text height is bigger than the control extent Y then the start.y value is wrong.
So I did that small correction (in bold) so the text show anyway.
I found that when my main menu button had their text disappearing when using smaller screen size.
So I did that small correction (in bold) so the text show anyway.
I found that when my main menu button had their text disappearing when using smaller screen size.
void GuiControl::renderJustifiedText(Point2I offset, Point2I extent, const char *text)
{
GFont *font = mProfile->mFont;
S32 textWidth = font->getStrWidth(text);
Point2I start;
// align the horizontal
switch( mProfile->mAlignment )
{
case GuiControlProfile::RightJustify:
start.set( extent.x - textWidth, 0 );
break;
case GuiControlProfile::CenterJustify:
start.set( ( extent.x - textWidth) / 2, 0 );
break;
default:
// GuiControlProfile::LeftJustify
start.set( 0, 0 );
break;
}
// If the text is longer then the box size, (it'll get clipped) so
// force Left Justify
if( textWidth > extent.x )
start.set( 0, 0 );
// center the vertical
[b] if(font->getHeight() > extent.y)
start.y = 0 - ((font->getHeight() - extent.y) / 2) ;
else[/b]
start.y = ( extent.y - font->getHeight() ) / 2;
dglDrawText( font, start + offset, text, mProfile->mFontColors );
}
#2
04/05/2005 (1:22 pm)
AutoSizeHeight was not solving the problem.
#3
04/06/2005 (11:41 am)
This is on my list of fixes to review. Thank you.
#4
04/07/2005 (9:40 am)
By the way my correction center the text verticaly in the control which suit my own requirement. But may be you want to set start.y = 0; instead to keep consistent with your implementation.
#5
08/02/2005 (5:24 pm)
For now, the centering thing seems good. I've committed this (#31). I'd welcome feedback on centered vs. not vs. GuiControlProfile setting.
Torque 3D Owner Jacob