enable text-auto-resize for width

master
Eduardo Bart 12 년 전
부모 2c53d0b1dc
커밋 1d2f6c7e9f

@ -18,5 +18,6 @@ Panel
text-align: center
text-auto-resize: true
width: 120
padding: 2
color: #ffffff
font: verdana-11px-monochrome

@ -1318,8 +1318,6 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
{
callLuaField("onGeometryChange", oldRect, newRect);
if(m_textWrap && oldRect.size() != newRect.size())
updateText();
@ -1328,6 +1326,8 @@ void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
if(!child->isAnchored())
child->bindRectToParent();
}
callLuaField("onGeometryChange", oldRect, newRect);
}
void UIWidget::onLayoutUpdate()

@ -41,20 +41,14 @@ void UIWidget::updateText()
m_drawText = m_text;
// update rect size
if(!m_rect.isValid()) {
Size textSize = getTextSize();
Size newSize = getSize();
if(newSize.width() <= 0)
newSize.setWidth(textSize.width());
if(newSize.height() <= 0)
newSize.setHeight(textSize.height());
setSize(newSize);
} else if(m_textAutoResize) {
Size textSize = getTextSize();
if(!m_rect.isValid() || m_textAutoResize) {
Size textBoxSize = getTextSize();
textBoxSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.left);
Size size = getSize();
if(textSize.width() > size.width())
size.setWidth(textSize.width());
size.setHeight(textSize.height());
if(size.width() <= 0 || (m_textAutoResize && !m_textWrap))
size.setWidth(textBoxSize.width());
if(size.height() <= 0 || m_textAutoResize)
size.setHeight(textBoxSize.height());
setSize(size);
}

불러오는 중...
취소
저장