ch |= (3 << 16);
text.insert(text.begin() + m_iCursorPos, ch);
}
- changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+ changed |= m_label.SetMaxRect(m_posX, m_posY, GetMaxWidth(), m_height);
changed |= m_label.SetStyledText(text, colors);
}
else
if (m_bHasPath)
label = ShortenPath(label);
- changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+ changed |= m_label.SetMaxRect(m_posX, m_posY, GetMaxWidth(), m_height);
changed |= m_label.SetText(label);
}
if (changed)
float CGUILabelControl::GetWidth() const
{
if (m_minWidth && m_minWidth != m_width)
- {
- float maxWidth = m_width ? m_width : m_label.GetTextWidth();
- return CLAMP(m_label.GetTextWidth(), m_minWidth, maxWidth);
- }
+ return CLAMP(m_label.GetTextWidth(), m_minWidth, GetMaxWidth());
return m_width;
}
bool UpdateColors();
CStdString ShortenPath(const CStdString &path);
+ /*! \brief Return the maximum width of this label control.
+ \return Return the width of the control if available, else the width of the current text.
+ */
+ float GetMaxWidth() const { return m_width ? m_width : m_label.GetTextWidth(); }
+
CGUILabel m_label;
bool m_bHasPath;