diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index b25f811e..5cfe4790 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -489,7 +489,7 @@ protected: BitmapFontPtr m_font; public: - void resizeToText() { setSize(getTextSize()); } + void resizeToText(); void clearText() { setText(""); } void setText(std::string text, bool dontFireLuaCall = false); diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index f1007be8..2eb19835 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -56,6 +56,15 @@ void UIWidget::updateText() m_textMustRecache = true; } +void UIWidget::resizeToText() +{ + auto textSize = getTextSize(); + textSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.bottom); + textSize += m_textOffset.toSize(); + + setSize(textSize); +} + void UIWidget::parseTextStyle(const OTMLNodePtr& styleNode) { for(const OTMLNodePtr& node : styleNode->children()) {