From 661c3406a928bad14102a09219774884f9e1db91 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 13 Oct 2006 04:16:49 +0000 Subject: Added inner fill option to normal scrollbar and foreground only option. Added a left-pointing cursor for using pointer. Updated color picker and now sliders look very good on color, grayscale and mono screens when using bar selector. Some misc. changes for appearance. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11210 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/scrollbar.c | 134 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 42 deletions(-) (limited to 'apps/gui/scrollbar.c') diff --git a/apps/gui/scrollbar.c b/apps/gui/scrollbar.c index 4cf92f4b47..f7dead566e 100644 --- a/apps/gui/scrollbar.c +++ b/apps/gui/scrollbar.c @@ -26,27 +26,14 @@ void gui_scrollbar_draw(struct screen * screen, int x, int y, int width, int height, int items, int min_shown, int max_shown, - enum orientation orientation) + unsigned flags) { - int min; - int max; - int inner_len; - int start; - int size; - - /* draw box */ - screen->drawrect(x, y, width, height); - - screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - - /* clear edge pixels */ - screen->drawpixel(x, y); - screen->drawpixel((x + width - 1), y); - screen->drawpixel(x, (y + height - 1)); - screen->drawpixel((x + width - 1), (y + height - 1)); - - /* clear pixels in progress bar */ - screen->fillrect(x + 1, y + 1, width - 2, height - 2); + int inner_x, inner_y, inner_wd, inner_ht, inner_len; + int min, max, range; + int start, size; +#ifdef HAVE_LCD_COLOR + int infill; +#endif /* min should be min */ if(min_shown < max_shown) { @@ -69,10 +56,17 @@ void gui_scrollbar_draw(struct screen * screen, int x, int y, if(max > items) max = items; - if (orientation == VERTICAL) - inner_len = height - 2; + range = max - min; + + inner_x = x + 1; + inner_y = y + 1; + inner_wd = width - 2; + inner_ht = height - 2; + + if (flags & HORIZONTAL) + inner_len = inner_wd; else - inner_len = width - 2; + inner_len = inner_ht; /* avoid overflows */ while (items > (INT_MAX / inner_len)) { @@ -82,31 +76,87 @@ void gui_scrollbar_draw(struct screen * screen, int x, int y, } /* calc start and end of the knob */ - if (items > 0 && items > (max - min)) { - size = inner_len * (max - min) / items; + if (items > 0 && items > range) { + size = inner_len * range / items; if (size == 0) { /* width of knob is null */ size = 1; start = (inner_len - 1) * min / items; } else { - start = (inner_len - size) * min / (items - (max - min)); + start = (inner_len - size) * min / (items - range); } } else { /* if null draw full bar */ size = inner_len; start = 0; } + /* draw box */ +#ifdef HAVE_LCD_COLOR + /* must avoid corners if case of (flags & FOREGROUND) */ + screen->hline(inner_x, x + inner_wd, y); + screen->hline(inner_x, x + inner_wd, y + height - 1); + screen->vline(x, inner_y, y + inner_ht); + screen->vline(x + width - 1, inner_y, y + inner_ht); +#else + screen->drawrect(x, y, width, height); +#endif + + screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); + +#ifdef HAVE_LCD_COLOR + infill = flags & (screen->depth > 1 ? INNER_FILL_MASK : INNER_FILL); + + if (!(flags & FOREGROUND)) + { +#endif + /* clear corner pixels */ + screen->drawpixel(x, y); + screen->drawpixel(x + width - 1, y); + screen->drawpixel(x, y + height - 1); + screen->drawpixel(x + width - 1, y + height - 1); + +#ifdef HAVE_LCD_COLOR + if (infill != INNER_BGFILL) + infill = INNER_FILL; + } + + if (infill == INNER_FILL) +#endif + { + /* clear pixels in progress bar */ + screen->fillrect(inner_x, inner_y, inner_wd, inner_ht); + } + screen->set_drawmode(DRMODE_SOLID); - if(orientation == VERTICAL) - screen->fillrect(x + 1, y + start + 1, width - 2, size); +#ifdef HAVE_LCD_COLOR + if (infill == INNER_BGFILL) + { + /* fill inner area with current background color */ + unsigned fg = screen->get_foreground(); + screen->set_foreground(screen->get_background()); + screen->fillrect(inner_x, inner_y, inner_wd, inner_ht); + screen->set_foreground(fg); + } +#endif + + if (flags & HORIZONTAL) + { + inner_x += start; + inner_wd = size; + } else - screen->fillrect(x + start + 1, y + 1, size, height - 2); + { + inner_y += start; + inner_ht = size; + } + + screen->fillrect(inner_x, inner_y, inner_wd, inner_ht); } void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap bm, int x, int y, int width, int height, int items, int min_shown, int max_shown, - enum orientation orientation) + unsigned flags) { int min; int max; @@ -140,7 +190,7 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap bm, int x, if(max > items) max = items; - if (orientation == VERTICAL) + if (flags & VERTICAL) inner_len = height; else inner_len = width; @@ -168,27 +218,27 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap bm, int x, screen->set_drawmode(DRMODE_SOLID); - if(orientation == VERTICAL) { + if (flags & HORIZONTAL) { #if LCD_DEPTH > 1 if (bm.format == FORMAT_MONO) #endif - screen->mono_bitmap_part(bm.data, 0, 0, - bm.width, x, y + start, width, size); + screen->mono_bitmap_part(bm.data, 0, 0, + bm.width, x + start, y, size, height); #if LCD_DEPTH > 1 - else - screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, - bm.width, x, y + start, width, size); -#endif + else + screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, + bm.width, x + start, y, size, height); +#endif } else { #if LCD_DEPTH > 1 if (bm.format == FORMAT_MONO) #endif - screen->mono_bitmap_part(bm.data, 0, 0, - bm.width, x + start, y, size, height); + screen->mono_bitmap_part(bm.data, 0, 0, + bm.width, x, y + start, width, size); #if LCD_DEPTH > 1 else - screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, - bm.width, x + start, y, size, height); + screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, + bm.width, x, y + start, width, size); #endif } } -- cgit v1.2.3