diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/gui/progressbar.cpp | 38 | ||||
-rw-r--r-- | src/gui/progressbar.h | 18 |
3 files changed, 47 insertions, 11 deletions
@@ -9,6 +9,8 @@ * src/net/accountserver/account.h, src/net/accountserver/account.cpp, src/net/protocol.h: Made it work nicely with the server. * src/protocol.h: Generic return values were incomplete client-side. + * src/gui/progressbar.h, src/gui/progressbar.cpp: Made smooth color + changing and smooth progress optional. 2008-04-25 David Athay <ko2fan@gmail.com> 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; |