From 0991c1942ee6f09d40a6224702ce2bf88921a54f Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 17 Apr 2008 12:27:09 +0000 Subject: Added smooth progress changes into progressbars. --- ChangeLog | 5 +++++ src/gui/progressbar.cpp | 11 ++++++++--- src/gui/progressbar.h | 2 +- 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 + + * src/gui/progressbar.h, src/gui/progressbar.cpp: Added smooth + changes in progressbar. + 2008-04-16 David Athay * 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; -- cgit v1.2.3-70-g09d2