From 85e936b8a33879b8c84c22cd8ac9471a95b24701 Mon Sep 17 00:00:00 2001 From: Markus Braun Date: Wed, 28 Aug 2002 14:24:59 +0000 Subject: No longer use the *_PIXEL macros. Added a scrollbar with sizable knob for directory browsing etc. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2040 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/widgets.c | 202 +++++++++++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 81 deletions(-) (limited to 'apps/recorder') diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c index 1c3f0b1a10..dae9e58b32 100644 --- a/apps/recorder/widgets.c +++ b/apps/recorder/widgets.c @@ -27,69 +27,45 @@ void progressbar(int x, int y, int width, int height, int percent, int direction) { int pos; - int i,j; - /* draw horizontal lines */ - for(i=x+1;i<=x+width-2;i++) { - DRAW_PIXEL(i,y); - DRAW_PIXEL(i,(y+height-1)); - } - - /* draw vertical lines */ - for(i=1;i100) - pos=100; + pos = percent; + if(pos < 0) + pos = 0; + if(pos > 100) + pos = 100; switch (direction) { case Grow_Right: - pos=(width-2)*pos/100; - for(i=1;i<=pos;i++) - for(j=1;j100) - pos=100; + /* draw knob */ + pos = percent; + if(pos < 0) + pos = 0; + if(pos > 100) + pos = 100; switch (direction) { case Grow_Right: - pos=(width-height-1)*pos/100; + pos = (width - height) * pos / 100; break; case Grow_Left: - pos=(width-height-1)*(100-pos)/100; + pos=(width - height) * (100 - pos) / 100; break; case Grow_Down: - pos=(height-width-1)*pos/100; + pos=(height - width) * pos / 100; break; case Grow_Up: - pos=(height-width-1)*(100-pos)/100; + pos=(height - width) * (100 - pos) / 100; break; } if(direction == Grow_Left || direction == Grow_Right) - for(i=1;i items) + min = items; + + if(max < 0) + max = 0; + if(max > items) + max = items; + + /* calc start and end of the knob */ + if(items > 0 && items > (max - min)) { + if(orientation == VERTICAL) { + size = (height - 2) * (max - min) / items; + start = (height - 2 - size) * min / (items - (max - min)); + } + else { + size = (width - 2) * (max - min) / items; + start = (width - 2 - size) * min / (items - (max - min)); + } + } + else { /* if null draw a full bar */ + start = 0; + if(orientation == VERTICAL) + size = (height - 2); + else + size = (width - 2); + } + + /* knob has a width */ + if(size != 0) { + if(orientation == VERTICAL) + lcd_fillrect(x + 1, y + start + 1, width - 2, size); + else + lcd_fillrect(x + start + 1, y + 1, size, height - 2); + } + else { /* width of knob is null */ + if(orientation == VERTICAL) { + start = (height - 2 - 1) * min / items; + lcd_fillrect(x + 1, y + start + 1, width - 2, 1); + } + else { + start = (width - 2 - 1) * min / items; + lcd_fillrect(x + start + 1, y + 1, 1, height - 2); + } + } } #endif -- cgit v1.2.3