diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2008-04-26 00:13:11 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2008-04-26 00:13:11 +0000 |
commit | a6731dd30a4ab7b2b19af18295293c13895b664d (patch) | |
tree | 44a6bd6b34e9995298d19a44b6019ab3235b7563 /src/gui | |
parent | ba366046e31523664b2deab4d48d9962aa8bac7e (diff) | |
download | mana-a6731dd30a4ab7b2b19af18295293c13895b664d.tar.gz mana-a6731dd30a4ab7b2b19af18295293c13895b664d.tar.bz2 mana-a6731dd30a4ab7b2b19af18295293c13895b664d.tar.xz mana-a6731dd30a4ab7b2b19af18295293c13895b664d.zip |
Made smooth color changing and smooth progress optional.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/progressbar.cpp | 38 | ||||
-rw-r--r-- | src/gui/progressbar.h | 18 |
2 files changed, 45 insertions, 11 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 07b01eef..90a85478 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -39,6 +39,8 @@ ProgressBar::ProgressBar(float progress, mRedToGo(red), mGreenToGo(green), mBlueToGo(blue) { mProgressToGo = mProgress = 0.0f; + mSmoothProgress = mSmoothColorChange = true; + setProgress(progress); setWidth(width); setHeight(height); @@ -82,17 +84,31 @@ ProgressBar::~ProgressBar() void ProgressBar::logic() { - // Smoothly changing the color for a nicer effect. - if (mRedToGo > mRed) mRed++; - if (mRedToGo < mRed) mRed--; - if (mGreenToGo > mGreen) mGreen++; - 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; + if (mSmoothColorChange) + { + // Smoothly changing the color for a nicer effect. + if (mRedToGo > mRed) mRed++; + if (mRedToGo < mRed) mRed--; + if (mGreenToGo > mGreen) mGreen++; + if (mGreenToGo < mGreen) mGreen--; + if (mBlueToGo > mBlue) mBlue++; + if (mBlueToGo < mBlue) mBlue--; + } + else + { + mRed = mRedToGo; + mGreen = mGreenToGo; + mBlue = mBlueToGo; + } + + if (mSmoothProgress) + { + // Smoothly showing the progressbar changes. + if (mProgressToGo > mProgress) mProgress = mProgress + 0.005f; + if (mProgressToGo < mProgress) mProgress = mProgress - 0.005f; + } + else + mProgress = mProgressToGo; } void diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index eb0795fa..ddabbb77 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -98,10 +98,28 @@ class ProgressBar : public gcn::Widget { Uint8 getBlue() { return mBlue; } + /** + * Set wether the progress is moved smoothly + */ + void + setSmoothProgress(bool smoothProgress) + { mSmoothProgress = smoothProgress; } + + /** + * Set wether the color changing is made smoothly + */ + void + setSmoothColorChange(bool smoothColorChange) + { mSmoothColorChange = smoothColorChange; } + + private: float mProgress, mProgressToGo; + bool mSmoothProgress; + Uint8 mRed, mGreen, mBlue; Uint8 mRedToGo, mGreenToGo, mBlueToGo; + bool mSmoothColorChange; static ImageRect mBorder; static int mInstances; |