summaryrefslogtreecommitdiff
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
parent34e6d6c9c6d13623b9adf00ff19081770c4d9f24 (diff)
downloadmana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.gz
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.bz2
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.tar.xz
mana-0991c1942ee6f09d40a6224702ce2bf88921a54f.zip
Added smooth progress changes into progressbars.
-rw-r--r--ChangeLog5
-rw-r--r--src/gui/progressbar.cpp11
-rw-r--r--src/gui/progressbar.h2
3 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4fb64c22..b09a4c2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;