summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-10 14:51:28 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-10 14:52:11 -0700
commit6c7bf198fa165c971565f069081c603f068014b1 (patch)
tree28056d3d94f9e8ae3477c39102e4cd5c1bd71267 /src/gui/widgets
parent7ec3ae46caf310cf83ece9e90e8e0f668179144b (diff)
downloadmana-client-6c7bf198fa165c971565f069081c603f068014b1.tar.gz
mana-client-6c7bf198fa165c971565f069081c603f068014b1.tar.bz2
mana-client-6c7bf198fa165c971565f069081c603f068014b1.tar.xz
mana-client-6c7bf198fa165c971565f069081c603f068014b1.zip
Improve look and utility of the SkillDialog
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/progressbar.cpp61
-rw-r--r--src/gui/widgets/progressbar.h8
2 files changed, 47 insertions, 22 deletions
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index cb064899..98c31873 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -141,31 +141,14 @@ void ProgressBar::draw(gcn::Graphics *graphics)
{
updateAlpha();
- static_cast<Graphics*>(graphics)->
- drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
-
mColor.a = (int) (mAlpha * 255);
- // The bar
- if (mProgress > 0)
- {
- graphics->setColor(mColor);
- graphics->fillRectangle(gcn::Rectangle(4, 4,
- (int) (mProgress * (getWidth() - 8)),
- getHeight() - 8));
- }
-
- // The label
- if (!mText.empty())
- {
- const int textX = getWidth() / 2;
- const int textY = (getHeight() - boldFont->getHeight()) / 2;
+ gcn::Rectangle rect = getDimension();
+ rect.x = 0;
+ rect.y = 0;
- TextRenderer::renderText(graphics, mText, textX, textY,
- gcn::Graphics::CENTER,
- guiPalette->getColor(Palette::PROGRESS_BAR),
- gui->getFont(), true, false);
- }
+ render(static_cast<Graphics*>(graphics), rect, mColor,
+ mProgress, mText);
}
void ProgressBar::setProgress(float progress)
@@ -184,3 +167,37 @@ void ProgressBar::setColor(const gcn::Color &color)
if (!mSmoothColorChange)
mColor = color;
}
+
+void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area,
+ const gcn::Color &color, float progress,
+ const std::string &text)
+{
+ gcn::Font *oldFont = graphics->getFont();
+ gcn::Color oldColor = graphics->getColor();
+
+ graphics->drawImageRect(area, mBorder);
+
+ // The bar
+ if (progress > 0)
+ {
+ graphics->setColor(color);
+ graphics->fillRectangle(gcn::Rectangle(area.x + 4, area.y + 4,
+ (int) (progress * (area.width - 8)),
+ area.height - 8));
+ }
+
+ // The label
+ if (!text.empty())
+ {
+ const int textX = area.x + area.width / 2;
+ const int textY = area.y + (area.height - boldFont->getHeight()) / 2;
+
+ TextRenderer::renderText(graphics, text, textX, textY,
+ gcn::Graphics::CENTER,
+ guiPalette->getColor(Palette::PROGRESS_BAR),
+ gui->getFont(), true, false);
+ }
+
+ graphics->setFont(oldFont);
+ graphics->setColor(oldColor);
+}
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 4a314690..daa872a1 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -26,6 +26,7 @@
#include <string>
+class Graphics;
class ImageRect;
/**
@@ -112,6 +113,13 @@ class ProgressBar : public gcn::Widget
void setSmoothColorChange(bool smoothColorChange)
{ mSmoothColorChange = smoothColorChange; }
+ /**
+ * Renders a progressbar with the given properties.
+ */
+ static void render(Graphics *graphics, const gcn::Rectangle &area,
+ const gcn::Color &color, float progress,
+ const std::string &text = "");
+
private:
float mProgress, mProgressToGo;
bool mSmoothProgress;