From 42131ce1eb8dcdfa1b7ef01a56d4b63d998d8e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=C2=ADn=20Lucas=20Golini?= Date: Tue, 28 Feb 2017 18:07:40 -0300 Subject: [PATCH] UITextBox set as auto size if no size is set when the text is being set. --HG-- branch : dev --- src/eepp/ui/uicommondialog.cpp | 1 - src/eepp/ui/uiprogressbar.cpp | 2 +- src/eepp/ui/uitextbox.cpp | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uicommondialog.cpp index defeaf546..7fe392e39 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uicommondialog.cpp @@ -40,7 +40,6 @@ UICommonDialog::UICommonDialog( const UICommonDialog::CreateParams& Params ) : } UITextBox * lookIn = UITextBox::New(); - lookIn->setFlags( UI_AUTO_SIZE ); lookIn->setParent( getContainer() ); lookIn->setPosition( 6, 13 ); lookIn->setVisible( true ); diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 592c0a3bc..0e739aa6e 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -189,8 +189,8 @@ const bool& UIProgressBar::getDisplayPercent() const { void UIProgressBar::updateTextBox() { mTextBox->setVisible( mStyleConfig.displayPercent ); - mTextBox->setSize( mSize ); mTextBox->setText( String::toStr( (Int32)( ( mProgress / mTotalSteps ) * 100.f ) ) + "%" ); + mTextBox->center(); } UITextBox * UIProgressBar::getTextBox() const { diff --git a/src/eepp/ui/uitextbox.cpp b/src/eepp/ui/uitextbox.cpp index 192ea8285..01e9e418c 100644 --- a/src/eepp/ui/uitextbox.cpp +++ b/src/eepp/ui/uitextbox.cpp @@ -111,6 +111,10 @@ void UITextBox::setText( const String& text ) { mTextCache->setText( text ); } + if ( mSize == Sizei::Zero ) { + setFlags( UI_AUTO_SIZE ); + } + autoShrink(); autoSize(); autoAlign(); @@ -168,7 +172,7 @@ void UITextBox::shrinkText( const Uint32& MaxWidth ) { } void UITextBox::autoSize() { - if ( mFlags & UI_AUTO_SIZE ) { + if ( ( mFlags & UI_AUTO_SIZE ) ) { setPixelsSize( Sizei( (int)mTextCache->getTextWidth(), (int)mTextCache->getTextHeight() ) ); } }