From 4b7414b3f6869f2bdeb097e4f997498bae9f0aee Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 30 Mar 2013 17:44:20 +0100 Subject: New box rendering of all widgets. Minor tweaks still missing. --- plugingui/progressbar.cc | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'plugingui/progressbar.cc') 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 -- cgit v1.2.3