diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2008-04-17 12:27:09 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2008-04-17 12:27:09 +0000 |
commit | 0991c1942ee6f09d40a6224702ce2bf88921a54f (patch) | |
tree | 629a57773166036cb630700188b1a33922653d77 | |
parent | 34e6d6c9c6d13623b9adf00ff19081770c4d9f24 (diff) | |
download | mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.gz mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.bz2 mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.xz mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.zip |
Added smooth progress changes into progressbars.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/gui/progressbar.cpp | 11 | ||||
-rw-r--r-- | src/gui/progressbar.h | 2 |
3 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2008-04-17 Yohann Ferreira <bertram@cegetel.net> + + * src/gui/progressbar.h, src/gui/progressbar.cpp: Added smooth + changes in progressbar. + 2008-04-16 David Athay <ko2fan@gmail.com> * src/gui/guildlistbox.cpp, src/gui/guildwindow.h, diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 6d18b2f7..07b01eef 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -38,6 +38,7 @@ ProgressBar::ProgressBar(float progress, mRed(red), mGreen(green), mBlue(blue), mRedToGo(red), mGreenToGo(green), mBlueToGo(blue) { + mProgressToGo = mProgress = 0.0f; setProgress(progress); setWidth(width); setHeight(height); @@ -88,6 +89,10 @@ void ProgressBar::logic() if (mGreenToGo < mGreen) mGreen--; if (mBlueToGo > mBlue) mBlue++; if (mBlueToGo < mBlue) mBlue--; + + // Smoothly showing the progressbar changes. + if (mProgressToGo > mProgress) mProgress = mProgress + 0.005f; + if (mProgressToGo < mProgress) mProgress = mProgress - 0.005f; } void @@ -109,9 +114,9 @@ ProgressBar::draw(gcn::Graphics *graphics) void ProgressBar::setProgress(float progress) { - if (progress < 0.0f) mProgress = 0.0; - else if (progress > 1.0f) mProgress = 1.0; - else mProgress = progress; + if (progress < 0.0f) mProgressToGo = 0.0; + else if (progress > 1.0f) mProgressToGo = 1.0; + else mProgressToGo = progress; } void diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index 3e58f14e..eb0795fa 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -99,7 +99,7 @@ class ProgressBar : public gcn::Widget { getBlue() { return mBlue; } private: - float mProgress; + float mProgress, mProgressToGo; Uint8 mRed, mGreen, mBlue; Uint8 mRedToGo, mGreenToGo, mBlueToGo; |