1
0
forked from 0ad/0ad

Unbroke text-alignment buffer-zones. Allowed \n in tooltip text.

This was SVN commit r1585.
This commit is contained in:
Ykkrosh 2004-12-28 12:38:45 +00:00
parent 156ff7cf56
commit aab60e9ab8
3 changed files with 10 additions and 7 deletions

View File

@ -58,7 +58,9 @@ void CButton::SetupText()
CGUIString caption;
GUI<CGUIString>::GetSetting(this, "caption", caption);
*m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, m_CachedActualSize.GetWidth(), 0, this);
float buffer_zone=0.f;
GUI<float>::GetSetting(this, "buffer-zone", buffer_zone);
*m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, m_CachedActualSize.GetWidth(), buffer_zone, this);
CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]);
}

View File

@ -120,6 +120,9 @@ static void ShowTooltip(IGUIObject* obj, CPos pos, CStr& style, CGUI* gui)
if (GUI<CStr>::GetSetting(obj, "tooltip", text) != PS_OK)
debug_warn("Failed to retrieve tooltip text"); // shouldn't fail
// Do some minimal processing ("\n" -> newline, etc)
text.Replace("\\n", "\n"); // TODO: Allow tooltip="\\n" etc
// Set tooltip's caption
if (usedobj->SetSetting("caption", text) != PS_OK)
debug_warn("Failed to set tooltip caption"); // shouldn't fail

View File

@ -80,22 +80,20 @@ void IGUITextOwner::CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUITex
{
EAlign align;
EVAlign valign;
float bz;
GUI<EAlign>::GetSetting(this, "text-align", align);
GUI<EVAlign>::GetSetting(this, "text-valign", valign);
GUI<float>::GetSetting(this, "buffer-zone", bz);
switch (align)
{
case EAlign_Left:
TextPos.x = ObjSize.left + bz;
TextPos.x = ObjSize.left;
break;
case EAlign_Center:
// Round to integer pixel values, else the fonts look awful
TextPos.x = floorf(ObjSize.CenterPoint().x - Text.m_Size.cx/2.f);
break;
case EAlign_Right:
TextPos.x = ObjSize.right - Text.m_Size.cx - bz;
TextPos.x = ObjSize.right - Text.m_Size.cx;
break;
default:
debug_warn("Broken EAlign in CButton::SetupText()");
@ -105,14 +103,14 @@ void IGUITextOwner::CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUITex
switch (valign)
{
case EVAlign_Top:
TextPos.y = ObjSize.top + bz;
TextPos.y = ObjSize.top;
break;
case EVAlign_Center:
// Round to integer pixel values, else the fonts look awful
TextPos.y = floorf(ObjSize.CenterPoint().y - Text.m_Size.cy/2.f);
break;
case EVAlign_Bottom:
TextPos.y = ObjSize.bottom - Text.m_Size.cy - bz;
TextPos.y = ObjSize.bottom - Text.m_Size.cy;
break;
default:
debug_warn("Broken EVAlign in CButton::SetupText()");