From 81f496fff5b6ca7cb289d60aaa8bcb2f9c035d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=C2=ADn=20Lucas=20Golini?= Date: Mon, 27 Feb 2017 04:24:42 -0300 Subject: [PATCH] Small fix. --HG-- branch : dev --- src/eepp/ui/uipushbutton.cpp | 8 +++++++- src/test/eetest.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index a4daf2d7e..aa9cb10e2 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -61,6 +61,8 @@ UIPushButton::UIPushButton() : mTextBox( NULL ), mIconSpace( 0 ) { + setFlags( UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER ); + mIcon = eeNew( UIGfx, () ); mIcon->setParent( this ); mIcon->setFlags( UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER ); @@ -91,7 +93,11 @@ bool UIPushButton::isType( const Uint32& type ) const { return UIPushButton::getType() == type ? true : UIComplexControl::isType( type ); } -void UIPushButton::onSizeChange() { +void UIPushButton::onSizeChange() { + if ( ( mFlags & UI_AUTO_SIZE ) && NULL != getSkin() && 0 == mSize.getHeight() ) { + setInternalHeight( getSkinSize().getHeight() ); + } + if ( NULL != mTextBox ) { mTextBox->setSize( mSize ); mTextBox->setPosition( 0, 0 ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index b6cbca0ed..ef0e6e21d 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -639,10 +639,15 @@ void EETest::createNewUI() { listBox->addListBoxItems( str ); UIProgressBar * progressBar = eeNew( UIProgressBar, () ); - progressBar->setPosition( 50, 540 )->setSize( 200, 26 ); + progressBar->setPosition( 50, 530 )->setSize( 200, 26 ); progressBar->setProgress( 60.f ); progressBar->setDisplayPercent( true ); + UIPushButton * pushButton = eeNew( UIPushButton, () ); + pushButton->setPosition( 50, 560 )->setSize( 200, 0 ); + pushButton->setText( "PushButton" ); + pushButton->setIcon( mTheme->getIconByName( "ok" ) ); + UISprite * sprite = eeNew( UISprite, () ); sprite->setPosition( 50, 600 ); sprite->setSprite( &SP );