diff --git a/ee.linux.cbp b/ee.linux.cbp
index 133be051f..97ff86adb 100644
--- a/ee.linux.cbp
+++ b/ee.linux.cbp
@@ -524,6 +524,8 @@
+
+
diff --git a/src/ee.h b/src/ee.h
index 77c6eba0f..5ea80e674 100755
--- a/src/ee.h
+++ b/src/ee.h
@@ -158,5 +158,6 @@
#include "ui/cuislider.hpp"
#include "ui/cuispinbox.hpp"
#include "ui/cuiscrollbar.hpp"
+ #include "ui/cuiprogressbar.hpp"
using namespace EE::UI;
#endif
diff --git a/src/graphics/cscrollparallax.cpp b/src/graphics/cscrollparallax.cpp
index f1bdebb9a..1b65c9992 100755
--- a/src/graphics/cscrollparallax.cpp
+++ b/src/graphics/cscrollparallax.cpp
@@ -2,104 +2,157 @@
namespace EE { namespace Graphics {
-cScrollParallax::cScrollParallax() {
- TF = cTextureFactory::instance();
+cScrollParallax::cScrollParallax() :
+ mShape( NULL ),
+ mBlend( ALPHA_NORMAL ),
+ mColor( 0xFFFFFFFF )
+{
}
cScrollParallax::~cScrollParallax() {}
-cScrollParallax::cScrollParallax( const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_PRE_BLEND_FUNC& Effect ) {
- TF = cTextureFactory::instance();
- Create( TexId, DestX, DestY, DestWidth, DestHeight, SrcRECT, Color, Alpha, Effect );
+cScrollParallax::cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color, const EE_PRE_BLEND_FUNC& Blend ) {
+ Create( Shape, DestX, DestY, DestWidth, DestHeight, Speed, Color, Blend );
}
-bool cScrollParallax::Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_PRE_BLEND_FUNC& Effect ) {
- cTexture * Tex = TF->GetTexture( TexId );
+cShape * cScrollParallax::Shape() const {
+ return mShape;
+}
- if ( NULL == Tex )
- return false;
+void cScrollParallax::Shape( cShape * shape ) {
+ mShape = shape;
- mSrcRECT = SrcRECT;
+ SetShape();
+}
- if ( mSrcRECT.Bottom == 0 && mSrcRECT.Right == 0 ) {
- mSrcRECT.Left = 0;
- mSrcRECT.Top = 0;
- mSrcRECT.Right = (Int32)Tex->Width();
- mSrcRECT.Bottom = (Int32)Tex->Height();
+void cScrollParallax::SetShape() {
+ if ( NULL != mShape ) {
+ mRect = mShape->SrcRect();
+ mRealSize = eeVector2f( mShape->RealSize().Width(), mShape->RealSize().Height() );
+
+ mTiles.x = ( (Int32)mSize.Width() / mShape->RealSize().Width() ) + 1;
+ mTiles.y = ( (Int32)mSize.Height() / mShape->RealSize().Height() ) + 1;
}
+}
- mWidth = static_cast ( mSrcRECT.Right - mSrcRECT.Left );
- mHeight = static_cast ( mSrcRECT.Bottom - mSrcRECT.Top );
+void cScrollParallax::SetAABB() {
+ mAABB = eeRectf( mInitPos.x, mInitPos.y, mInitPos.x + mSize.Width(), mInitPos.y + mSize.Height() );
+}
- mTilerWidth = DestWidth + DestX;
- mTilerHeight = DestHeight + DestY;
+bool cScrollParallax::Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color, const EE_PRE_BLEND_FUNC& Blend ) {
+ mShape = Shape;
+ mPos = eeVector2f( DestX, DestY );
+ mSize = eeSizef( DestWidth, DestHeight );
+ mInitPos = mPos;
+ mSpeed = Speed;
+ mColor = Color;
+ mBlend = Blend;
- if (DestX <= mTilerWidth) mPomSx = DestX;
- if (DestY <= mTilerHeight) mPomSy = DestY;
-
- mX = (Int16) ( ( mTilerWidth - mPomSx ) / mWidth ) + 1;
- mY = (Int16) ( ( mTilerHeight - mPomSy ) / mHeight ) + 1;
-
- mSpr.CreateStatic( TexId, mWidth, mHeight, 0, 0, mSrcRECT );
-
- mSpr.Color( Color );
- mSpr.Alpha( Alpha );
- mSpr.SetRenderAlphas( Effect );
+ SetAABB();
+ SetShape();
return true;
}
-void cScrollParallax::Draw( const eeFloat& XDirVel, const eeFloat& YDirVel ) {
- Int16 tX, tY;
- eeFloat tPomSx, tPomSy, tWidth, tHeight;
- eeRectf tSrcRECT( (eeFloat)mSrcRECT.Left, (eeFloat)mSrcRECT.Top, (eeFloat)mSrcRECT.Right, (eeFloat)mSrcRECT.Bottom );
+void cScrollParallax::Size( const eeFloat& DestWidth, const eeFloat& DestHeight ) {
+ mSize = eeSizef( DestWidth, DestHeight );
- mSx = mSx + XDirVel;
- if (mSx > mWidth) mSx = 0;
- if (mSx < -mWidth) mSx = 0;
+ SetShape();
+ SetAABB();
+}
- mSy = mSy + YDirVel;
- if (mSy > mHeight) mSy = 0;
- if (mSy < -mHeight) mSy = 0;
+void cScrollParallax::Position( const eeVector2f& Pos ) {
+ eeVector2f Diff = mPos - mInitPos;
- for (tY = -1; tY <= mY; tY++ ) {
- for (tX = -1; tX <= mX; tX++) {
- tPomSx = mPomSx + ( (eeFloat)tX * mWidth ) + mSx;
- tPomSy = mPomSy + ( (eeFloat)tY * mHeight ) + mSy;
+ mInitPos = Pos;
- if ( (tPomSx + mWidth) > mPomSx && (tPomSy + mHeight) > mPomSy && tPomSx < mTilerWidth && tPomSy < mTilerHeight ) {
- tWidth = mWidth;
- tHeight = mHeight;
+ mPos = Pos + Diff;
- if ( tPomSy + mHeight > mTilerHeight && tPomSy < mTilerHeight ) {
- tSrcRECT.Bottom = tSrcRECT.Bottom - ((tPomSy + mHeight) - mTilerHeight);
- tHeight = tSrcRECT.Bottom - tSrcRECT.Top;
+ SetAABB();
+}
+
+const eeSizef& cScrollParallax::Size() const {
+ return mSize;
+}
+
+const eeVector2f& cScrollParallax::Position() const {
+ return mInitPos;
+}
+
+void cScrollParallax::Draw() {
+ if ( NULL != mShape && mAABB.Left != mAABB.Right && mAABB.Top != mAABB.Bottom ) {
+ mPos += ( ( mSpeed * (eeFloat)mElapsed.Elapsed() ) / 1000.f );
+
+ if ( mPos.x > mAABB.Left + mRealSize.Width() || mPos.x < mAABB.Left - mRealSize.Width() )
+ mPos.x = mAABB.Left;
+
+ if ( mPos.y > mAABB.Top + mRealSize.Height() || mPos.y < mAABB.Top - mRealSize.Height() )
+ mPos.y = mAABB.Top;
+
+ eeVector2f Pos = mPos;
+
+ Pos.x = (eeFloat)(Int32)Pos.x;
+ Pos.y = (eeFloat)(Int32)Pos.y;
+
+ if ( mSpeed.x > 0.f )
+ Pos.x -= mRealSize.Width();
+
+ if ( mSpeed.y > 0.f )
+ Pos.y -= mRealSize.Height();
+
+ for ( Int32 y = -1; y < mTiles.y; y++ ) {
+ for ( Int32 x = -1; x < mTiles.x; x++ ) {
+ eeRecti Rect = mRect;
+ eeRectf AABB( Pos.x, Pos.y, Pos.x + mRealSize.Width(), Pos.y + mRealSize.Height() );
+
+ if ( AABB.Intersect( mAABB ) ) {
+ if ( Pos.x < mAABB.Left ) {
+ Rect.Left += ( mAABB.Left - Pos.x );
+ AABB.Left = mAABB.Left;
+ }
+
+ if ( Pos.x + mRealSize.Width() > mAABB.Right ) {
+ Rect.Right -= ( ( Pos.x + mRealSize.Width() ) - mAABB.Right );
+ }
+
+ if ( Pos.y < mAABB.Top ) {
+ Rect.Top += ( mAABB.Top - Pos.y );
+ AABB.Top = mAABB.Top;
+ }
+
+ if ( Pos.y + mRealSize.Height() > mAABB.Bottom ) {
+ Rect.Bottom -= ( ( Pos.y + mRealSize.Height() ) - mAABB.Bottom );
+ }
+
+ mShape->SrcRect( Rect );
+ mShape->ResetDestWidthAndHeight();
+
+ if ( !( Rect.Right == 0 || Rect.Bottom == 0 ) )
+ mShape->Draw( AABB.Left, AABB.Top, mColor, 0.f, 1.f, mBlend );
}
- if ( tPomSx < mPomSx ) {
- tSrcRECT.Left = tSrcRECT.Left + mPomSx - tPomSx;
- tPomSx = mPomSx;
- tWidth = tSrcRECT.Right - tSrcRECT.Left;
- }
-
- if ( (tPomSx + mWidth) > mTilerWidth && tPomSx < mTilerWidth ) {
- tSrcRECT.Right = tSrcRECT.Right - ((tPomSx + mWidth) - mTilerWidth);
- tWidth = tSrcRECT.Right - tSrcRECT.Left;
- }
-
- if (tPomSy < mPomSy) {
- tSrcRECT.Top = tSrcRECT.Top + mPomSy - tPomSy;
- tPomSy = mPomSy;
- tHeight = tSrcRECT.Bottom - tSrcRECT.Top;
- }
-
- mSpr.UpdateSize( tWidth, tHeight );
- mSpr.UpdateSprRECT( eeRecti( (Int32)tSrcRECT.Left, (Int32)tSrcRECT.Top, (Int32)tSrcRECT.Right, (Int32)tSrcRECT.Bottom ) );
- mSpr.UpdatePos( tPomSx, tPomSy );
- mSpr.Draw();
+ Pos.x += mRealSize.Width();
}
+
+ Pos.x = (eeFloat)(Int32)mPos.x;
+
+ if ( mSpeed.x > 0.f )
+ Pos.x -= mRealSize.Width();
+
+ Pos.y += mRealSize.Height();
}
+
+ mShape->SrcRect( mRect );
+ mShape->ResetDestWidthAndHeight();
}
}
+void cScrollParallax::Speed( const eeVector2f& speed ) {
+ mSpeed = speed;
+}
+
+const eeVector2f& cScrollParallax::Speed() const {
+ return mSpeed;
+}
+
}}
diff --git a/src/graphics/cscrollparallax.hpp b/src/graphics/cscrollparallax.hpp
index 3d28db875..80a09f860 100755
--- a/src/graphics/cscrollparallax.hpp
+++ b/src/graphics/cscrollparallax.hpp
@@ -3,8 +3,7 @@
#include "base.hpp"
#include "ctexture.hpp"
-#include "ctexturefactory.hpp"
-#include "csprite.hpp"
+#include "cshape.hpp"
namespace EE { namespace Graphics {
@@ -14,50 +13,84 @@ class EE_API cScrollParallax {
~cScrollParallax();
/** Constructor that create's the Scroll Parallax */
- cScrollParallax(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL);
+ cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL );
/** Create's the Scroll Parallax
- * @param TexId The Internal Texture Id
+ * @param Shape The Shape to Draw
* @param DestX The X position
* @param DestY The Y position
* @param DestWidth The Width of the Parallax
* @param DestHeight The Height of the Parallax
- * @param SrcRECT The Texture source eeRectf to render ( default render all the texture )
+ * @param Speed Speed of movement ( in Pixels Per Second )
* @param Color The Texture Color
- * @param Alpha The Texture Alpha
* @param Effect The Blend Mode ( default ALPHA_NORMAL )
* @return True if success
*/
- bool Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL);
-
- /** Set the Alpha */
- void Alpha( const Uint8& Alpha ) { mSpr.Alpha( Alpha ); }
-
- /** Get the Alpha */
- eeFloat Alpha() const { return mSpr.Alpha(); }
+ bool Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL );
/** Set the Color */
- void Color( const eeRGBA& Color ) { mSpr.Color( Color ); }
+ void Color( const eeRGBA& Color ) { mColor = Color; }
/** Get the color */
- eeRGBA Color() const { return mSpr.Color(); }
+ eeRGBA Color() const { return mColor; }
/** Set the Blend Mode */
- void SetRenderAlphas( const EE_PRE_BLEND_FUNC& Effect ) { mSpr.SetRenderAlphas( Effect ); }
+ void BlendMode( const EE_PRE_BLEND_FUNC& Blend ) { mBlend = Blend; }
+
+ /** @return The Blend Mode */
+ const EE_PRE_BLEND_FUNC& BlendMode() const { return mBlend; }
/** Draw the Scroll Parallax
* @param XDirVel X Direction Speed to move the parallax.
* @param YDirVel Y Direction Speed to move the parallax.
*/
- void Draw( const eeFloat& XDirVel, const eeFloat& YDirVel );
+ void Draw();
+
+ /** Change the size of the current parallax
+ * @param DestWidth The Width of the Parallax
+ * @param DestHeight The Height of the Parallax
+ */
+ void Size( const eeFloat& DestWidth, const eeFloat& DestHeight );
+
+ /** @return Size */
+ const eeSizef& Size() const;
+
+ /** Change the Parallax position
+ * @param Pos New Position
+ */
+ void Position( const eeVector2f& Pos );
+
+ /** @return Position */
+ const eeVector2f& Position() const;
+
+ /** @return Shape */
+ cShape * Shape() const;
+
+ /** Set Shape */
+ void Shape( cShape * shape );
+
+ /** Set the parallax speed */
+ void Speed( const eeVector2f& speed );
+
+ /** @return The parallax speed */
+ const eeVector2f& Speed() const;
private:
- cTextureFactory * TF;
-
- cSprite mSpr;
- eeRecti mSrcRECT;
-
- Int16 mX, mY;
- eeFloat mPomSx, mPomSy, mWidth, mHeight, mTilerWidth, mTilerHeight, mSx, mSy;
+ cShape * mShape;
+ EE_PRE_BLEND_FUNC mBlend;
+ eeColorA mColor;
+ eeVector2f mInitPos;
+ eeVector2f mPos;
+ eeVector2f mSpeed;
+ eeSizef mSize;
+ eeRecti mRect;
+ cTimeElapsed mElapsed;
+ eeVector2i mTiles;
+ eeRectf mAABB;
+ eeSizef mRealSize;
+
+ void SetShape();
+
+ void SetAABB();
};
}}
diff --git a/src/graphics/ctexture.cpp b/src/graphics/ctexture.cpp
index 8a90351a9..bdecf83ac 100755
--- a/src/graphics/ctexture.cpp
+++ b/src/graphics/ctexture.cpp
@@ -172,7 +172,7 @@ bool cTexture::Unlock( const bool& KeepData, const bool& Modified ) {
NTexId = SOIL_create_OGL_texture( reinterpret_cast(&mPixels[0]), &width, &height, mChannels, mTexture, flags );
- SetTextureFilter(mFilter);
+ TextureFilter(mFilter);
if ( PreviousTexture != (GLint)mTexture )
glBindTexture(GL_TEXTURE_2D, PreviousTexture);
@@ -224,7 +224,7 @@ bool cTexture::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Form
return Res;
}
-void cTexture::SetTextureFilter(const EE_TEX_FILTER& filter) {
+void cTexture::TextureFilter(const EE_TEX_FILTER& filter) {
if (mTexture) {
if ( mFilter != filter ) {
mFilter = filter;
@@ -248,6 +248,10 @@ void cTexture::SetTextureFilter(const EE_TEX_FILTER& filter) {
}
}
+const EE_TEX_FILTER& cTexture::TextureFilter() const {
+ return mFilter;
+}
+
void cTexture::ReplaceColor( const eeColorA& ColorKey, const eeColorA& NewColor ) {
Lock();
diff --git a/src/graphics/ctexture.hpp b/src/graphics/ctexture.hpp
index 3cc6f9ef2..69a040034 100755
--- a/src/graphics/ctexture.hpp
+++ b/src/graphics/ctexture.hpp
@@ -89,7 +89,9 @@ class EE_API cTexture : public cImage {
const Uint8* GetPixelsPtr();
/** Set the Texture Filter Mode */
- void SetTextureFilter(const EE_TEX_FILTER& filter);
+ void TextureFilter( const EE_TEX_FILTER& filter );
+
+ const EE_TEX_FILTER& TextureFilter() const;
/** Save the Texture to a new File */
bool SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format );
diff --git a/src/test/ee.cpp b/src/test/ee.cpp
index c951f68b1..eb36519a1 100644
--- a/src/test/ee.cpp
+++ b/src/test/ee.cpp
@@ -200,6 +200,7 @@ class cEETest : private cThread {
cUIScrollBar * mScrollBar;
cUITextBox * mTextBoxValue;
cUISlider * mSlider;
+ cUIProgressBar * mProgressBar;
};
void cEETest::CreateAquaTextureAtlas() {
@@ -378,7 +379,7 @@ void cEETest::CreateUI() {
C->Enabled( true );
C->Pos( 320, 240 );
C->DragEnable( true );
- C->StartRotation( 0.f, 360.f, 2500.f );
+ //C->StartRotation( 0.f, 360.f, 2500.f );
Params.Flags &= ~UI_CLIP_ENABLE;
Params.Background.Corners(0);
@@ -511,6 +512,17 @@ void cEETest::CreateUI() {
mScrollBar->Enabled( true );
mScrollBar->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cEETest::OnValueChange ) );
+ cUIProgressBar::CreateParams PBParams;
+ PBParams.Parent( C );
+ PBParams.PosSet( 20, 197 );
+ PBParams.Size = eeSize( 150, 16 );
+ PBParams.DisplayPercent = true;
+ PBParams.Font = TTF;
+ mProgressBar = eeNew( cUIProgressBar, ( PBParams ) );
+ mProgressBar->Visible( true );
+ mProgressBar->Enabled( true );
+ mProgressBar->TextBox()->Padding( eeRectf( 0, -1, 0, 0 ) );
+
TextParams.PosSet( 20, 5 );
mTextBoxValue = eeNew( cUITextBox, ( TextParams ) );
mTextBoxValue->Visible( true );
@@ -523,7 +535,7 @@ void cEETest::CreateUI() {
/*
cTextureGroupLoader tgl( MyPath + "data/aqua.etg" );
TF->GetByName( "data/aqua.png" )->ClampMode( EE_CLAMP_REPEAT );
- TF->GetByName( "data/aqua.png" )->SetTextureFilter( TEX_FILTER_NEAREST );
+ TF->GetByName( "data/aqua.png" )->TextureFilter( TEX_FILTER_NEAREST );
cUIThemeManager::instance()->Add( cUITheme::LoadFromShapeGroup( cShapeGroupManager::instance()->GetByName( "aqua" ), "aqua", "aqua" ) );
*/
cUIManager::instance()->SetTheme( "aqua" );
@@ -533,6 +545,8 @@ void cEETest::CreateUI() {
void cEETest::OnValueChange( const cUIEvent * Event ) {
mTextBoxValue->Text( L"Scroll Value:\n" + toWStr( mScrollBar->Value() ) );
+
+ mProgressBar->Progress( mScrollBar->Value() * 100.f );
}
void cEETest::ButtonClick( const cUIEvent * Event ) {
diff --git a/src/ui/cuicheckbox.cpp b/src/ui/cuicheckbox.cpp
index b560fa350..7cc455e94 100644
--- a/src/ui/cuicheckbox.cpp
+++ b/src/ui/cuicheckbox.cpp
@@ -60,6 +60,13 @@ void cUICheckBox::SetTheme( cUITheme * Theme ) {
Padding( eeRectf(0,0,0,0) );
}
+void cUICheckBox::OnSizeChange() {
+ cUITextBox::OnSizeChange();
+
+ mActiveButton->CenterVertical();
+ mInactiveButton->CenterVertical();
+}
+
Uint32 cUICheckBox::OnMessage( const cUIMessage * Msg ) {
switch ( Msg->Msg() ) {
case cUIMessage::MsgClick: {
diff --git a/src/ui/cuicheckbox.hpp b/src/ui/cuicheckbox.hpp
index e800bd560..ded3547a9 100644
--- a/src/ui/cuicheckbox.hpp
+++ b/src/ui/cuicheckbox.hpp
@@ -31,7 +31,9 @@ class EE_API cUICheckBox : public cUITextBox {
cUIControlAnim * mActiveButton;
cUIControlAnim * mInactiveButton;
bool mActive;
-
+
+ virtual void OnSizeChange();
+
void SwitchState();
};
diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp
index 89fd6dab8..6c31e5551 100644
--- a/src/ui/cuicontrol.cpp
+++ b/src/ui/cuicontrol.cpp
@@ -860,7 +860,10 @@ void cUIControl::UpdateScreenPos() {
}
cUISkin * cUIControl::GetSkin() {
- return mSkinState->GetSkin();
+ if ( NULL != mSkinState )
+ return mSkinState->GetSkin();
+
+ return NULL;
}
void cUIControl::WriteCtrlFlag( const Uint32& Pos, const Uint32& Val ) {
diff --git a/src/ui/cuiprogressbar.cpp b/src/ui/cuiprogressbar.cpp
new file mode 100644
index 000000000..4171a27a1
--- /dev/null
+++ b/src/ui/cuiprogressbar.cpp
@@ -0,0 +1,158 @@
+#include "cuiprogressbar.hpp"
+
+namespace EE { namespace UI {
+
+cUIProgressBar::cUIProgressBar( const cUIProgressBar::CreateParams& Params ) :
+ cUIControlAnim( Params ),
+ mVerticalExpand( Params.VerticalExpand ),
+ mSpeed( Params.MovementSpeed ),
+ mFillerMargin( Params.FillerMargin ),
+ mDisplayPercent( Params.DisplayPercent ),
+ mProgress( 0.f ),
+ mTotalSteps( 100.f ),
+ mParallax( NULL )
+{
+ cUITextBox::CreateParams TxtBoxParams = Params;
+
+ TxtBoxParams.Parent( this );
+ TxtBoxParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER;
+ TxtBoxParams.PosSet( 0, 0 );
+
+ mTextBox = eeNew( cUITextBox, ( TxtBoxParams ) );
+ mTextBox->Enabled( false );
+
+ UpdateTextBox();
+}
+
+cUIProgressBar::~cUIProgressBar() {
+ eeSAFE_DELETE( mParallax );
+}
+
+void cUIProgressBar::Draw() {
+ cUIControlAnim::Draw();
+
+ if ( NULL != mParallax ) {
+ mParallax->Position( eeVector2f( mScreenPos.x + mFillerMargin.Left, mScreenPos.y + mFillerMargin.Top ) );
+ mParallax->Draw();
+ }
+}
+
+void cUIProgressBar::SetTheme( cUITheme * Theme ) {
+ cUIControl::SetTheme( Theme, "progressbar" );
+
+ cUISkin * tSkin = Theme->GetByName( Theme->Abbr() + "_progressbar_filler" );
+
+ if ( tSkin ) {
+ cShape * tShape = tSkin->GetShape( cUISkinState::StateNormal );
+
+ if ( NULL != tShape ) {
+ eeSAFE_DELETE( mParallax );
+
+ eeFloat Height = mSize.Height();
+
+ if ( !mVerticalExpand )
+ Height = tShape->RealSize().Height();
+
+ mParallax = eeNew( cScrollParallax, ( tShape, mScreenPos.x + mFillerMargin.Left, mScreenPos.y + mFillerMargin.Top, ( ( mSize.Width() - mFillerMargin.Left - mFillerMargin.Right ) * mProgress ) / mTotalSteps, Height - mFillerMargin.Top - mFillerMargin.Bottom, mSpeed ) );
+ }
+ }
+}
+
+Uint32 cUIProgressBar::OnValueChange() {
+ cUIControlAnim::OnValueChange();
+
+ OnSizeChange();
+
+ return 1;
+}
+
+void cUIProgressBar::OnSizeChange() {
+ if ( NULL != mParallax ) {
+ eeFloat Height = mSize.Height();
+
+ if ( !mVerticalExpand && mParallax->Shape() )
+ Height = mParallax->Shape()->RealSize().Height();
+
+ mParallax->Size( ( ( mSize.Width() - mFillerMargin.Left - mFillerMargin.Right ) * mProgress ) / mTotalSteps, Height - mFillerMargin.Top - mFillerMargin.Bottom );
+ }
+
+ UpdateTextBox();
+}
+
+void cUIProgressBar::Progress( eeFloat Val ) {
+ mProgress = Val;
+
+ OnValueChange();
+ UpdateTextBox();
+}
+
+const eeFloat& cUIProgressBar::Progress() const {
+ return mProgress;
+}
+
+void cUIProgressBar::TotalSteps( const eeFloat& Steps ) {
+ mTotalSteps = Steps;
+
+ OnSizeChange();
+ UpdateTextBox();
+}
+
+const eeFloat& cUIProgressBar::TotalSteps() const {
+ return mTotalSteps;
+}
+
+void cUIProgressBar::MovementSpeed( const eeVector2f& Speed ) {
+ mSpeed = Speed;
+
+ if ( NULL != mParallax )
+ mParallax->Speed( mSpeed );
+}
+
+const eeVector2f& cUIProgressBar::MovementSpeed() const {
+ return mSpeed;
+}
+
+void cUIProgressBar::VerticalExpand( const bool& VerticalExpand ) {
+ if ( VerticalExpand != mVerticalExpand ) {
+ mVerticalExpand = VerticalExpand;
+
+ OnSizeChange();
+ }
+}
+
+const bool& cUIProgressBar::VerticalExpand() const {
+ return mVerticalExpand;
+}
+
+void cUIProgressBar::FillerMargin( const eeRectf& margin ) {
+ mFillerMargin = margin;
+
+ OnPosChange();
+ OnSizeChange();
+}
+
+const eeRectf& cUIProgressBar::FillerMargin() const {
+ return mFillerMargin;
+}
+
+void cUIProgressBar::DisplayPercent( const bool& DisplayPercent ) {
+ mDisplayPercent = DisplayPercent;
+
+ UpdateTextBox();
+}
+
+const bool& cUIProgressBar::DisplayPercent() const {
+ return mDisplayPercent;
+}
+
+void cUIProgressBar::UpdateTextBox() {
+ mTextBox->Visible( mDisplayPercent );
+ mTextBox->Size( mSize );
+ mTextBox->Text( toWStr( (Int32)( ( mProgress / mTotalSteps ) * 100.f ) ) + L"%" );
+}
+
+cUITextBox * cUIProgressBar::TextBox() const {
+ return mTextBox;
+}
+
+}}
diff --git a/src/ui/cuiprogressbar.hpp b/src/ui/cuiprogressbar.hpp
new file mode 100644
index 000000000..7458291c3
--- /dev/null
+++ b/src/ui/cuiprogressbar.hpp
@@ -0,0 +1,87 @@
+#ifndef EE_UICPROGRESSBAR_HPP
+#define EE_UICPROGRESSBAR_HPP
+
+#include "cuicontrolanim.hpp"
+#include "cuitextbox.hpp"
+#include "../graphics/cscrollparallax.hpp"
+
+namespace EE { namespace UI {
+
+class cUIProgressBar : public cUIControlAnim {
+ public:
+ class CreateParams : public cUITextBox::CreateParams {
+ public:
+ inline CreateParams() :
+ cUITextBox::CreateParams(),
+ DisplayPercent( false ),
+ VerticalExpand( false ),
+ MovementSpeed( 64.f, 0.f )
+ {
+ }
+
+ inline ~CreateParams() {}
+
+ bool DisplayPercent;
+ bool VerticalExpand;
+ eeVector2f MovementSpeed;
+ eeRectf FillerMargin;
+ };
+
+ cUIProgressBar( const cUIProgressBar::CreateParams& Params );
+
+ ~cUIProgressBar();
+
+ virtual void SetTheme( cUITheme * Theme );
+
+ virtual void Progress( eeFloat Val );
+
+ const eeFloat& Progress() const;
+
+ virtual void TotalSteps( const eeFloat& Steps );
+
+ const eeFloat& TotalSteps() const;
+
+ virtual void Draw();
+
+ void MovementSpeed( const eeVector2f& Speed );
+
+ const eeVector2f& MovementSpeed() const;
+
+ void VerticalExpand( const bool& VerticalExpand );
+
+ const bool& VerticalExpand() const;
+
+ void FillerMargin( const eeRectf& margin );
+
+ const eeRectf& FillerMargin() const;
+
+ void DisplayPercent( const bool& DisplayPercent );
+
+ const bool& DisplayPercent() const;
+
+ cUITextBox * TextBox() const;
+ protected:
+ bool mVerticalExpand;
+ eeVector2f mSpeed;
+ eeRectf mFillerMargin;
+ bool mDisplayPercent;
+
+ eeFloat mProgress;
+ eeFloat mTotalSteps;
+
+ cScrollParallax * mParallax;
+
+ cUITextBox * mTextBox;
+
+ virtual Uint32 OnValueChange();
+
+ virtual void OnSizeChange();
+
+ void UpdateTextBox();
+
+};
+
+}}
+
+#endif
+
diff --git a/src/ui/cuiradiobutton.cpp b/src/ui/cuiradiobutton.cpp
index 3611adbc7..de98e454e 100644
--- a/src/ui/cuiradiobutton.cpp
+++ b/src/ui/cuiradiobutton.cpp
@@ -64,6 +64,13 @@ void cUIRadioButton::SetTheme( cUITheme * Theme ) {
Padding( eeRectf(0,0,0,0) );
}
+void cUIRadioButton::OnSizeChange() {
+ cUITextBox::OnSizeChange();
+
+ mActiveButton->CenterVertical();
+ mInactiveButton->CenterVertical();
+}
+
Uint32 cUIRadioButton::OnMessage( const cUIMessage * Msg ) {
switch ( Msg->Msg() ) {
case cUIMessage::MsgClick: {
diff --git a/src/ui/cuiradiobutton.hpp b/src/ui/cuiradiobutton.hpp
index b01202813..93aec1cbf 100644
--- a/src/ui/cuiradiobutton.hpp
+++ b/src/ui/cuiradiobutton.hpp
@@ -31,6 +31,8 @@ class EE_API cUIRadioButton : public cUITextBox {
cUIControlAnim * mActiveButton;
cUIControlAnim * mInactiveButton;
bool mActive;
+
+ virtual void OnSizeChange();
void SwitchState();
diff --git a/src/ui/cuiscrollbar.cpp b/src/ui/cuiscrollbar.cpp
index 91952a112..d65f52063 100644
--- a/src/ui/cuiscrollbar.cpp
+++ b/src/ui/cuiscrollbar.cpp
@@ -89,6 +89,10 @@ void cUIScrollBar::SetTheme( cUITheme * Theme ) {
mSlider->AdjustChilds();
}
+void cUIScrollBar::OnSizeChange() {
+ AdjustChilds();
+}
+
void cUIScrollBar::AdjustChilds() {
mBtnUp->Pos( 0, 0 );
diff --git a/src/ui/cuiscrollbar.hpp b/src/ui/cuiscrollbar.hpp
index 816e7a79e..79201afbe 100644
--- a/src/ui/cuiscrollbar.hpp
+++ b/src/ui/cuiscrollbar.hpp
@@ -51,6 +51,8 @@ class cUIScrollBar : public cUIControlAnim {
cUIControlAnim * mBtnUp;
cUIControlAnim * mBtnDown;
+ virtual void OnSizeChange();
+
void AdjustChilds();
void ManageClick( const Uint32& Flags );
diff --git a/src/ui/cuislider.cpp b/src/ui/cuislider.cpp
index 24afbe853..f650de962 100644
--- a/src/ui/cuislider.cpp
+++ b/src/ui/cuislider.cpp
@@ -70,6 +70,10 @@ void cUISlider::SetTheme( cUITheme * Theme ) {
Value( mValue );
}
+void cUISlider::OnSizeChange() {
+ AdjustChilds();
+}
+
void cUISlider::AdjustChilds() {
cShape * tShape = NULL;
cUISkin * tSkin = NULL;
diff --git a/src/ui/cuislider.hpp b/src/ui/cuislider.hpp
index 1864c026e..0fcd315c8 100644
--- a/src/ui/cuislider.hpp
+++ b/src/ui/cuislider.hpp
@@ -72,6 +72,8 @@ class EE_API cUISlider : public cUIControlAnim {
eeFloat mClickStep;
bool mOnPosChange;
+
+ virtual void OnSizeChange();
void FixSliderPos();
diff --git a/src/ui/cuitextbox.hpp b/src/ui/cuitextbox.hpp
index 9ff62c887..764efca16 100644
--- a/src/ui/cuitextbox.hpp
+++ b/src/ui/cuitextbox.hpp
@@ -9,8 +9,10 @@ class EE_API cUITextBox : public cUIControlAnim {
public:
class CreateParams : public cUIControl::CreateParams {
public:
- inline CreateParams() : cUIControl::CreateParams() {
- Font = NULL;
+ inline CreateParams() :
+ cUIControl::CreateParams(),
+ Font( NULL )
+ {
}
inline ~CreateParams() {}
diff --git a/src/ui/cuitheme.cpp b/src/ui/cuitheme.cpp
index b28c23574..ab5113d81 100644
--- a/src/ui/cuitheme.cpp
+++ b/src/ui/cuitheme.cpp
@@ -38,7 +38,9 @@ static const char * UI_THEME_ELEMENTS[] = {
"vscrollbar_bg",
"vscrollbar_button",
"vscrollbar_btnup",
- "vscrollbar_btndown"
+ "vscrollbar_btndown",
+ "progressbar",
+ "progressbar_filler"
};
cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) {
diff --git a/src/utils/size.hpp b/src/utils/size.hpp
index 76ae4e653..a02c8ed7c 100644
--- a/src/utils/size.hpp
+++ b/src/utils/size.hpp
@@ -63,7 +63,8 @@ void tSize::Height( const T& height ) {
}
typedef tSize eeSize;
+typedef tSize eeSizef;
}}
-#endif
+#endif