From 244106176447effe0330ef194ad93ccaadf589ff Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 8 Jul 2004 13:14:44 +0000 Subject: Removed progressbar() and slidebar() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4854 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 11 ++--- apps/plugin.c | 2 - apps/plugin.h | 7 ++- apps/plugins/jpeg.c | 4 +- apps/plugins/video.c | 4 +- apps/recorder/widgets.c | 115 +++++------------------------------------------- apps/recorder/widgets.h | 2 - 7 files changed, 24 insertions(+), 121 deletions(-) (limited to 'apps') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 0b4be9d72d..e7c2923f55 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -151,7 +151,6 @@ bool dbg_mpeg_thread(void) { char buf[32]; int button; - int percent; struct mpeg_debug d; lcd_setmargins(0, 0); @@ -182,11 +181,13 @@ bool dbg_mpeg_thread(void) snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space); lcd_puts(0, 5, buf); - percent = d.playable_space * 100 / d.mp3buflen; - progressbar(0, 6*8, 112, 4, percent, Grow_Right); + /* Playable space left */ + scrollbar(0, 6*8, 112, 4, d.mp3buflen, 0, + d.playable_space, HORIZONTAL); - percent = d.low_watermark_level * 100 / d.mp3buflen; - progressbar(0, 6*8+4, 112, 4, percent, Grow_Right); + /* Show the watermark limit */ + scrollbar(0, 6*8+4, 112, 4, d.mp3buflen, 0, + d.low_watermark_level, HORIZONTAL); snprintf(buf, sizeof(buf), "wm: %x - %x", d.low_watermark_level, d.lowest_watermark_level); diff --git a/apps/plugin.c b/apps/plugin.c index bc7707db55..79c3b39315 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -107,8 +107,6 @@ static struct plugin_api rockbox_api = { lcd_getstringsize, lcd_update, lcd_update_rect, - progressbar, - slidebar, scrollbar, #ifndef SIMULATOR lcd_roll, diff --git a/apps/plugin.h b/apps/plugin.h index 79851661e5..0e3451f698 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -45,6 +45,9 @@ #include "settings.h" #include "thread.h" #include "playlist.h" +#ifdef HAVE_LCD_BITMAP +#include "widgets.h" +#endif #ifdef PLUGIN #if defined(DEBUG) || defined(SIMULATOR) @@ -132,10 +135,6 @@ struct plugin_api { int (*lcd_getstringsize)(unsigned char *str, int *w, int *h); void (*lcd_update)(void); void (*lcd_update_rect)(int x, int y, int width, int height); - void (*progressbar)(int x, int y, int width, int height, - int percent, int direction); - void (*slidebar)(int x, int y, int width, int height, - int percent, int direction); void (*scrollbar)(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation); #ifndef SIMULATOR diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index ed21222653..312fd82ce6 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c @@ -1607,8 +1607,8 @@ int wait_for_button(void) void cb_progess(int current, int total) { rb->yield(); /* be nice to the other threads */ - rb->progressbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, - current*100/total, 0 /*Grow_Right*/); + rb->scrollbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, 0, total, + current, HORIZONTAL); rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); } diff --git a/apps/plugins/video.c b/apps/plugins/video.c index 27bb736813..eec600b90f 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c @@ -225,7 +225,6 @@ void DrawPosition(int pos, int total) { int w,h; int sec; // estimated seconds - int percent; /* print the estimated position */ @@ -239,8 +238,7 @@ void DrawPosition(int pos, int total) /* draw a slider over the rest of the line */ rb->lcd_getstringsize(gPrint, &w, &h); w++; - percent = pos/(total/100); - rb->slidebar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, percent, Grow_Right); + rb->scrollbar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, 0, total, pos, HORIZONTAL); if (gPlay.state == paused) // we have to draw ourselves rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c index 4008d2b4c2..7ac647024a 100644 --- a/apps/recorder/widgets.c +++ b/apps/recorder/widgets.c @@ -23,7 +23,7 @@ #ifdef HAVE_LCD_BITMAP /* Valid dimensions return true, invalid false */ -bool valid_dimensions(int x, int y, int width, int height) +static bool valid_dimensions(int x, int y, int width, int height) { if((x < 0) || (x + width > LCD_WIDTH) || (y < 0) || (y + height > LCD_HEIGHT)) @@ -34,107 +34,6 @@ bool valid_dimensions(int x, int y, int width, int height) return true; } -void init_bar(int x, int y, int width, int height) -{ - /* draw box */ - lcd_drawrect(x, y, width, height); - - /* clear edge pixels */ - lcd_clearpixel(x, y); - lcd_clearpixel((x + width - 1), y); - lcd_clearpixel(x, (y + height - 1)); - lcd_clearpixel((x + width - 1), (y + height - 1)); - - /* clear pixels in progress bar */ - lcd_clearrect(x + 1, y + 1, width - 2, height - 2); -} - -/* - * Print a progress bar - */ -void progressbar(int x, int y, int width, int height, int percent, - int direction) -{ - int pos; - - /* check position and dimensions */ - if (!valid_dimensions(x, y, width, height)) - return; - - init_bar(x, y, width, height); - - /* draw bar */ - pos = percent; - if(pos < 0) - pos = 0; - if(pos > 100) - pos = 100; - - switch (direction) - { - case Grow_Right: - pos=(width - 2) * pos / 100; - lcd_fillrect(x + 1, y + 1, pos, height - 2); - break; - case Grow_Left: - pos=(width - 2) * (100 - pos) / 100; - lcd_fillrect(x + pos, y + 1, width - 1 - pos, height - 2); - break; - case Grow_Down: - pos=(height - 2) * pos / 100; - lcd_fillrect(x + 1, y + 1, width - 2, pos); - break; - case Grow_Up: - pos=(height - 2) * (100 - pos) / 100; - lcd_fillrect(x + 1, y + pos, width - 2, height - 1 - pos); - break; - } -} - - -/* - * Print a slidebar bar - */ -void slidebar(int x, int y, int width, int height, int percent, int direction) -{ - int pos; - - /* check position and dimensions */ - if (!valid_dimensions(x, y, width, height)) - return; - - init_bar(x, y, width, height); - - /* draw knob */ - pos = percent; - if(pos < 0) - pos = 0; - if(pos > 100) - pos = 100; - - switch (direction) - { - case Grow_Right: - pos = (width - height) * pos / 100; - break; - case Grow_Left: - pos=(width - height) * (100 - pos) / 100; - break; - case Grow_Down: - pos=(height - width) * pos / 100; - break; - case Grow_Up: - pos=(height - width) * (100 - pos) / 100; - break; - } - - if(direction == Grow_Left || direction == Grow_Right) - lcd_fillrect(x + pos + 1, y + 1, height - 2, height - 2); - else - lcd_fillrect(x + 1, y + pos + 1, width - 2, width - 2); -} - - /* * Print a scroll bar */ @@ -150,7 +49,17 @@ void scrollbar(int x, int y, int width, int height, int items, int min_shown, if (!valid_dimensions(x, y, width, height)) return; - init_bar(x, y, width, height); + /* draw box */ + lcd_drawrect(x, y, width, height); + + /* clear edge pixels */ + lcd_clearpixel(x, y); + lcd_clearpixel((x + width - 1), y); + lcd_clearpixel(x, (y + height - 1)); + lcd_clearpixel((x + width - 1), (y + height - 1)); + + /* clear pixels in progress bar */ + lcd_clearrect(x + 1, y + 1, width - 2, height - 2); /* min should be min */ if(min_shown < max_shown) { diff --git a/apps/recorder/widgets.h b/apps/recorder/widgets.h index de8e78520f..44d849b628 100644 --- a/apps/recorder/widgets.h +++ b/apps/recorder/widgets.h @@ -35,8 +35,6 @@ enum { HORIZONTAL }; -extern void progressbar(int x, int y, int width, int height, int percent, int direction); -extern void slidebar(int x, int y, int width, int height, int percent, int direction); extern void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation); extern void checkbox(int x, int y, int width, int height, bool checked); #endif /* HAVE_LCD_BITMAP */ -- cgit v1.2.3