summaryrefslogtreecommitdiff
path: root/src/gui/progressbar.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-10 23:04:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-10 23:04:39 +0000
commit34a718bbd2573477cb600cfa422c5669b1b9d6b2 (patch)
treee618e678162fa2f086b3d116006de0efafc1fcd9 /src/gui/progressbar.cpp
parent7550a006a6dfd185b3e970dbbb21ff053df75e0d (diff)
downloadmana-client-34a718bbd2573477cb600cfa422c5669b1b9d6b2.tar.gz
mana-client-34a718bbd2573477cb600cfa422c5669b1b9d6b2.tar.bz2
mana-client-34a718bbd2573477cb600cfa422c5669b1b9d6b2.tar.xz
mana-client-34a718bbd2573477cb600cfa422c5669b1b9d6b2.zip
Fixed progress bars in OpenGL mode, now uses Guichan's fillRectangle.
Diffstat (limited to 'src/gui/progressbar.cpp')
-rw-r--r--src/gui/progressbar.cpp40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index d19ed52d..d939b3b5 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -26,7 +26,7 @@
#include "../resources/resourcemanager.h"
ProgressBar::ProgressBar(float progress, int x, int y, int width, int height,
- unsigned char red, unsigned green, unsigned char blue):
+ int red, int green, int blue):
gcn::Widget(),
red(red), green(green), blue(blue)
{
@@ -50,19 +50,10 @@ ProgressBar::ProgressBar(float progress, int x, int y, int width, int height,
dTopRightBorder = dBorders->getSubImage(7, 0, 4, 4);
dBottomRightBorder = dBorders->getSubImage(7, 15, 4, 4);
dBottomLeftBorder = dBorders->getSubImage(0, 15, 4, 4);
-
- colorBar = Image::create(getWidth() - 8, getHeight() - 8);
- if (colorBar) {
- colorBar->fillWithColor(red, green, blue);
- colorBar->setAlpha(0.7f);
- }
}
ProgressBar::~ProgressBar()
{
- if (colorBar) {
- delete colorBar;
- }
}
void ProgressBar::draw(gcn::Graphics *graphics)
@@ -70,7 +61,6 @@ void ProgressBar::draw(gcn::Graphics *graphics)
int absx, absy;
getAbsolutePosition(absx, absy);
- // We're drawing the bar itself first
// Background
dBackground->drawPattern(screen,
absx + 4, absy + 4,
@@ -91,15 +81,19 @@ void ProgressBar::draw(gcn::Graphics *graphics)
dRightBorder->drawPattern(screen, absx + getWidth() - 4, absy + 4,
4, getHeight() - 8);
- if (colorBar) {
- colorBar->draw(screen, 0, 0, absx + 4, absy + 4,
- (int)(progress * float(getWidth() - 4)), getHeight() - 8);
+ // The bar
+ if (progress > 0) {
+ graphics->setColor(gcn::Color(red, green, blue, 200));
+ graphics->fillRectangle(gcn::Rectangle(4, 4,
+ (int)(progress * (getWidth() - 8)), getHeight() - 8));
}
}
void ProgressBar::setProgress(float progress)
{
- this->progress = progress;
+ if (progress < 0.0f) this->progress = 0.0;
+ else if (progress > 1.0f) this->progress = 1.0;
+ else this->progress = progress;
}
float ProgressBar::getProgress()
@@ -107,17 +101,9 @@ float ProgressBar::getProgress()
return progress;
}
-void ProgressBar::setColor(
- unsigned char newRed, unsigned char newGreen, unsigned char newBlue)
+void ProgressBar::setColor(int red, int green, int blue)
{
- if (red != newRed || green != newGreen || blue != newBlue)
- {
- red = newRed;
- green = newGreen;
- blue = newBlue;
- if (colorBar) {
- colorBar->fillWithColor(red, green, blue);
- colorBar->setAlpha(0.7f);
- }
- }
+ this->red = red;
+ this->green = green;
+ this->blue = blue;
}