Calculate and return correct width in CGUI::GenerateText

Reviewed By: bb
Differential Revision: https://code.wildfiregames.com/D836
This was SVN commit r21142.
This commit is contained in:
s0600204 2018-02-07 20:47:10 +00:00
parent cacbdf7b1a
commit d01cb88ac4
2 changed files with 5 additions and 8 deletions

View File

@ -746,8 +746,6 @@ SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const
// Append X value.
x += Feedback2.m_Size.cx;
Text.m_Size.cx = std::max(Text.m_Size.cx, x+BufferZone);
// The first word overrides the width limit, what we
// do, in those cases, are just drawing that word even
// though it'll extend the object.
@ -783,10 +781,11 @@ SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const
}
// Reset X
x = 0.f;
x = BufferZone;
// Update height of all
Text.m_Size.cy = std::max(Text.m_Size.cy, y+BufferZone);
// Update dimensions
Text.m_Size.cx = std::max(Text.m_Size.cx, line_width + BufferZone);
Text.m_Size.cy = std::max(Text.m_Size.cy, y + BufferZone);
FirstLine = false;

View File

@ -97,9 +97,7 @@ void CTooltip::SetupText()
GUI<CPos>::GetSetting(this, "offset", offset);
GUI<EVAlign>::GetSetting(this, "anchor", anchor);
// TODO: Calculate the actual width of the wrapped text and use that.
// (m_Size.cx is >max_width if the text wraps, which is not helpful)
float textwidth = std::min(m_GeneratedTexts[0]->m_Size.cx, (float)max_width);
float textwidth = m_GeneratedTexts[0]->m_Size.cx;
float textheight = m_GeneratedTexts[0]->m_Size.cy;
CClientArea size;