forked from 0ad/0ad
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:
parent
cacbdf7b1a
commit
d01cb88ac4
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user