summaryrefslogtreecommitdiff
path: root/plugingui/progressbar.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-30 17:44:20 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-30 17:44:20 +0100
commit4b7414b3f6869f2bdeb097e4f997498bae9f0aee (patch)
tree53e9741d7d40f1ff6f77d47fc308b18168dca330 /plugingui/progressbar.cc
parenta1fba9ba11a13f94c524f2ac78206b3fdfb3be74 (diff)
New box rendering of all widgets. Minor tweaks still missing.
Diffstat (limited to 'plugingui/progressbar.cc')
-rw-r--r--plugingui/progressbar.cc43
1 files changed, 37 insertions, 6 deletions
diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc
index d7048a4..3b821bb 100644
--- a/plugingui/progressbar.cc
+++ b/plugingui/progressbar.cc
@@ -30,7 +30,32 @@
GUI::ProgressBar::ProgressBar(GUI::Widget *parent) : GUI::Widget(parent)
{
- _progress = 0;
+ bar_bg.left = new Image(":progress_back_l.png");
+ bar_bg.right = new Image(":progress_back_r.png");
+ bar_bg.center = new Image(":progress_back_c.png");
+
+ bar_blue.left = new Image(":progress_front_blue_l.png");
+ bar_blue.right = new Image(":progress_front_blue_r.png");
+ bar_blue.center = new Image(":progress_front_blue_c.png");
+
+ bar_red.left = new Image(":progress_front_red_l.png");
+ bar_red.right = new Image(":progress_front_red_r.png");
+ bar_red.center = new Image(":progress_front_red_c.png");
+
+ bar_green.left = new Image(":progress_front_green_l.png");
+ bar_green.right = new Image(":progress_front_green_r.png");
+ bar_green.center = new Image(":progress_front_green_c.png");
+
+ state = blue;
+ _progress = .5;
+}
+
+void GUI::ProgressBar::setState(GUI::ProgressBar::state_t state)
+{
+ if(this->state != state) {
+ this->state = state;
+ repaintEvent(NULL);
+ }
}
float GUI::ProgressBar::progress()
@@ -48,15 +73,21 @@ void GUI::ProgressBar::repaintEvent(GUI::RepaintEvent *e)
{
Painter p(this);
- int max = width() - 1;
+ int max = width() * _progress;
p.clear();
- p.setColour(Colour(0, 0, 1, 0.3));
- p.drawFilledRectangle(1, 1, max * _progress - 2, height() - 1);
+ int brd = 4;
+ p.drawBar(0, 0, &bar_bg, width(), height());
- p.setColour(Colour(1));
- p.drawRectangle(0,0,max,height()-1);
+ GUI::Painter::Bar *b = NULL;
+ switch(state) {
+ case red: b = &bar_red; break;
+ case green: b = &bar_green; break;
+ case blue: b = &bar_blue; break;
+ default: break;
+ }
+ if(b) p.drawBar(brd, 0, b, max - 2*brd, height());
}
#ifdef TEST_PROGRESSBAR