summaryrefslogtreecommitdiff
path: root/src/gui/progressbar.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2008-04-17 12:27:09 +0000
committerYohann Ferreira <bertram@cegetel.net>2008-04-17 12:27:09 +0000
commit0991c1942ee6f09d40a6224702ce2bf88921a54f (patch)
tree629a57773166036cb630700188b1a33922653d77 /src/gui/progressbar.cpp
parent34e6d6c9c6d13623b9adf00ff19081770c4d9f24 (diff)
downloadmana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.gz
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.bz2
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.xz
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.zip
Added smooth progress changes into progressbars.
Diffstat (limited to 'src/gui/progressbar.cpp')
-rw-r--r--src/gui/progressbar.cpp11
1 files changed, 8 insertions, 3 deletions
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