diff --git a/bin/assets/ui/uitheme/uitheme_progressbar_normal_m.png b/bin/assets/ui/uitheme/uitheme_progressbar_normal_m.png index d7659f5a2..3c0b2bfef 100644 Binary files a/bin/assets/ui/uitheme/uitheme_progressbar_normal_m.png and b/bin/assets/ui/uitheme/uitheme_progressbar_normal_m.png differ diff --git a/bin/assets/ui/uitheme2x.eta b/bin/assets/ui/uitheme2x.eta index de5075c80..1888d5eea 100644 Binary files a/bin/assets/ui/uitheme2x.eta and b/bin/assets/ui/uitheme2x.eta differ diff --git a/bin/assets/ui/uitheme2x.png b/bin/assets/ui/uitheme2x.png index 4fb1ba44e..cdf7c8613 100644 Binary files a/bin/assets/ui/uitheme2x.png and b/bin/assets/ui/uitheme2x.png differ diff --git a/bin/assets/ui/uitheme2x/uitheme2x_progressbar_normal_m.png b/bin/assets/ui/uitheme2x/uitheme2x_progressbar_normal_m.png index a1f7cc7a2..cfc4b3d16 100644 Binary files a/bin/assets/ui/uitheme2x/uitheme2x_progressbar_normal_m.png and b/bin/assets/ui/uitheme2x/uitheme2x_progressbar_normal_m.png differ diff --git a/include/eepp/ui/uiprogressbar.hpp b/include/eepp/ui/uiprogressbar.hpp index b57eda5c0..7af7263af 100644 --- a/include/eepp/ui/uiprogressbar.hpp +++ b/include/eepp/ui/uiprogressbar.hpp @@ -29,6 +29,8 @@ class EE_API UIProgressBar : public UIComplexControl { UIProgressBar( const UIProgressBar::CreateParams& Params ); + UIProgressBar(); + virtual ~UIProgressBar(); virtual Uint32 getType() const; @@ -55,9 +57,9 @@ class EE_API UIProgressBar : public UIComplexControl { const bool& getVerticalExpand() const; - void setFillerMargin( const Rectf& margin ); + void setFillerPadding( const Rectf& margin ); - const Rectf& getFillerMargin() const; + const Rectf& getFillerPadding() const; void setDisplayPercent( const bool& displayPercent ); @@ -68,7 +70,7 @@ class EE_API UIProgressBar : public UIComplexControl { protected: bool mVerticalExpand; Vector2f mSpeed; - Rectf mFillerMargin; + Rectf mFillerPadding; bool mDisplayPercent; Float mProgress; diff --git a/src/eepp/graphics/textureatlasloader.cpp b/src/eepp/graphics/textureatlasloader.cpp index 7fc41a25a..f6fcbf332 100644 --- a/src/eepp/graphics/textureatlasloader.cpp +++ b/src/eepp/graphics/textureatlasloader.cpp @@ -368,15 +368,21 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: Int32 x, y, c; Int32 NeedUpdate = 0; + EE_PIXEL_DENSITY pixelDensity = PD_MDPI; FileSystem::dirPathAddSlashAtEnd( ImagesPath ); Uint32 z; Uint32 totalSubTextures = 0; - for ( z = 0; z < mTempAtlass.size(); z++ ) + for ( z = 0; z < mTempAtlass.size(); z++ ) { totalSubTextures += mTempAtlass[z].Texture.SubTextureCount; + if ( mTempAtlass[z].Texture.SubTextureCount > 0 ) { + pixelDensity = (EE_PIXEL_DENSITY)mTempAtlass[z].SubTextures[0].PixelDensity; + } + } + Uint32 totalImages = 0; std::vector PathFiles = FileSystem::filesGetInPath( ImagesPath ); @@ -434,7 +440,7 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: std::string tapath( FileSystem::fileRemoveExtension( TextureAtlasPath ) + "." + Image::saveTypeToExtension( mTexGrHdr.Format ) ); if ( 2 == NeedUpdate ) { - TexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, PD_MDPI, 0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_POW_OF_TWO ), mTexGrHdr.PixelBorder, mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_ALLOW_FLIPPING ); + TexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, pixelDensity, 0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_POW_OF_TWO ), mTexGrHdr.PixelBorder, mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_ALLOW_FLIPPING ); tp.addTexturesPath( ImagesPath ); diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index b4a8c5719..29921e836 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -6,7 +6,7 @@ UIProgressBar::UIProgressBar( const UIProgressBar::CreateParams& Params ) : UIComplexControl( Params ), mVerticalExpand( Params.VerticalExpand ), mSpeed( Params.MovementSpeed ), - mFillerMargin( Params.FillerMargin ), + mFillerPadding( Params.FillerMargin ), mDisplayPercent( Params.DisplayPercent ), mProgress( 0.f ), mTotalSteps( 100.f ), @@ -26,6 +26,28 @@ UIProgressBar::UIProgressBar( const UIProgressBar::CreateParams& Params ) : applyDefaultTheme(); } +UIProgressBar::UIProgressBar() : + UIComplexControl(), + mVerticalExpand( true ), + mSpeed( 64.f, 0.f ), + mFillerPadding(), + mDisplayPercent( false ), + mProgress( 0.f ), + mTotalSteps( 100.f ), + mParallax( NULL ) +{ + setFlags( UI_AUTO_PADDING | UI_AUTO_SIZE ); + + mTextBox = eeNew( UITextBox, () ); + mTextBox->setHorizontalAlign( UI_HALIGN_CENTER ); + mTextBox->setParent( this ); + mTextBox->setEnabled( false ); + + updateTextBox(); + + applyDefaultTheme(); +} + UIProgressBar::~UIProgressBar() { eeSAFE_DELETE( mParallax ); } @@ -45,7 +67,7 @@ void UIProgressBar::draw() { ColorA C( mParallax->getColor() ); C.Alpha = (Uint8)mAlpha; - Rectf fillerMargin = PixelDensity::dpToPx( mFillerMargin ); + Rectf fillerMargin = PixelDensity::dpToPx( mFillerPadding ); mParallax->setColor( C ); mParallax->setPosition( Vector2f( mScreenPos.x + fillerMargin.Left, mScreenPos.y + fillerMargin.Top ) ); @@ -76,9 +98,16 @@ void UIProgressBar::setTheme( UITheme * Theme ) { if ( Height > mRealSize.getHeight() ) Height = mRealSize.getHeight(); - Rectf fillerMargin = PixelDensity::dpToPx( mFillerMargin ); + if ( mFlags & UI_AUTO_PADDING ) { + Float meH = (Float)getSkinSize().getHeight(); + Float otH = (Float)tSkin->getSize().getHeight(); + Float res = Math::roundUp( ( meH - otH ) * 0.5f ); + mFillerPadding = Rectf( res, res, res, res ); + } - mParallax = eeNew( ScrollParallax, ( tSubTexture, Vector2f( mScreenPos.x + fillerMargin.Left, mScreenPos.y + fillerMargin.Top ), Sizef( ( ( mRealSize.getWidth() - fillerMargin.Left - fillerMargin.Right ) * mProgress ) / mTotalSteps, Height - fillerMargin.Top - fillerMargin.Bottom ), mSpeed ) ); + Rectf fillerPadding = PixelDensity::dpToPx( mFillerPadding ); + + mParallax = eeNew( ScrollParallax, ( tSubTexture, Vector2f( mScreenPos.x + fillerPadding.Left, mScreenPos.y + fillerPadding.Top ), Sizef( ( ( mRealSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) / mTotalSteps, Height - fillerPadding.Top - fillerPadding.Bottom ), mSpeed ) ); } } } @@ -101,9 +130,9 @@ void UIProgressBar::onSizeChange() { if ( Height > mRealSize.getHeight() ) Height = mRealSize.getHeight(); - Rectf fillerMargin = PixelDensity::dpToPx( mFillerMargin ); + Rectf fillerPadding = PixelDensity::dpToPx( mFillerPadding ); - mParallax->setSize( Sizef( ( ( mRealSize.getWidth() - fillerMargin.Left - fillerMargin.Right ) * mProgress ) / mTotalSteps, Height - fillerMargin.Top - fillerMargin.Bottom ) ); + mParallax->setSize( Sizef( ( ( mRealSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) / mTotalSteps, Height - fillerPadding.Top - fillerPadding.Bottom ) ); } updateTextBox(); @@ -135,7 +164,7 @@ void UIProgressBar::setMovementSpeed( const Vector2f& Speed ) { mSpeed = Speed; if ( NULL != mParallax ) - mParallax->setSpeed( mSpeed ); + mParallax->setSpeed( PixelDensity::dpToPx( mSpeed ) ); } const Vector2f& UIProgressBar::getMovementSpeed() const { @@ -154,15 +183,15 @@ const bool& UIProgressBar::getVerticalExpand() const { return mVerticalExpand; } -void UIProgressBar::setFillerMargin( const Rectf& margin ) { - mFillerMargin = margin; +void UIProgressBar::setFillerPadding( const Rectf& margin ) { + mFillerPadding = margin; onPositionChange(); onSizeChange(); } -const Rectf& UIProgressBar::getFillerMargin() const { - return mFillerMargin; +const Rectf& UIProgressBar::getFillerPadding() const { + return mFillerPadding; } void UIProgressBar::setDisplayPercent( const bool& DisplayPercent ) { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index cccd7c976..b6cbca0ed 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -638,8 +638,13 @@ void EETest::createNewUI() { listBox->setPosition( 50, 360 )->setSize( 200, 160 ); listBox->addListBoxItems( str ); + UIProgressBar * progressBar = eeNew( UIProgressBar, () ); + progressBar->setPosition( 50, 540 )->setSize( 200, 26 ); + progressBar->setProgress( 60.f ); + progressBar->setDisplayPercent( true ); + UISprite * sprite = eeNew( UISprite, () ); - sprite->setPosition( 50, 540 ); + sprite->setPosition( 50, 600 ); sprite->setSprite( &SP ); UIScrollBar * scrollBar = eeNew( UIScrollBar, () );