summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-07-13 18:43:52 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-07-13 18:43:52 +0000
commit801cd58db50ad29742939144fc799f98232959cc (patch)
tree9c5a83ebd98bde2fec608b1c6649041967dbb1e6 /src
parent2197d2f78937f67326a13ec5485f9ed6fdc4d763 (diff)
downloadmana-801cd58db50ad29742939144fc799f98232959cc.tar.gz
mana-801cd58db50ad29742939144fc799f98232959cc.tar.bz2
mana-801cd58db50ad29742939144fc799f98232959cc.tar.xz
mana-801cd58db50ad29742939144fc799f98232959cc.zip
Adding smooth color changing on progress bars.
Diffstat (limited to 'src')
-rw-r--r--src/gui/progressbar.cpp20
-rw-r--r--src/gui/progressbar.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 47225acd..c8d0194a 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -35,6 +35,9 @@ ProgressBar::ProgressBar(float progress, int x, int y, int width, int height,
setY(y);
setWidth(width);
setHeight(height);
+ redToGo = red;
+ greenToGo = green;
+ blueToGo = blue;
// Load dialog title bar image
ResourceManager *resman = ResourceManager::getInstance();
@@ -82,7 +85,16 @@ void ProgressBar::draw(gcn::Graphics *graphics)
4, getHeight() - 8);
// The bar
- if (progress > 0) {
+ if (progress > 0)
+ {
+ // Smoothly changing the color for a nicer effect.
+ if (redToGo > red ) red++;
+ if (redToGo < red ) red--;
+ if (greenToGo > green ) green++;
+ if (greenToGo < green ) green--;
+ if (blueToGo > blue ) blue++;
+ if (blueToGo < blue ) blue--;
+
graphics->setColor(gcn::Color(red, green, blue, 200));
graphics->fillRectangle(gcn::Rectangle(4, 4,
(int)(progress * (getWidth() - 8)), getHeight() - 8));
@@ -103,7 +115,7 @@ float ProgressBar::getProgress()
void ProgressBar::setColor(int red, int green, int blue)
{
- this->red = red;
- this->green = green;
- this->blue = blue;
+ this->redToGo = red;
+ this->greenToGo = green;
+ this->blueToGo = blue;
}
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index abfbe92d..d39ae0f9 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -93,6 +93,7 @@ class ProgressBar : public gcn::Widget {
private:
float progress;
int red, green, blue;
+ int redToGo, greenToGo, blueToGo;
// Bar Images
Image *dBackground;