1
0
Fork 0
forked from len0rd/rockbox

Removed progressbar() and slidebar()

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4854 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2004-07-08 13:14:44 +00:00
parent e7bb8c0428
commit 2441061764
7 changed files with 24 additions and 121 deletions

View file

@ -151,7 +151,6 @@ bool dbg_mpeg_thread(void)
{ {
char buf[32]; char buf[32];
int button; int button;
int percent;
struct mpeg_debug d; struct mpeg_debug d;
lcd_setmargins(0, 0); lcd_setmargins(0, 0);
@ -182,11 +181,13 @@ bool dbg_mpeg_thread(void)
snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space); snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
lcd_puts(0, 5, buf); lcd_puts(0, 5, buf);
percent = d.playable_space * 100 / d.mp3buflen; /* Playable space left */
progressbar(0, 6*8, 112, 4, percent, Grow_Right); scrollbar(0, 6*8, 112, 4, d.mp3buflen, 0,
d.playable_space, HORIZONTAL);
percent = d.low_watermark_level * 100 / d.mp3buflen; /* Show the watermark limit */
progressbar(0, 6*8+4, 112, 4, percent, Grow_Right); scrollbar(0, 6*8+4, 112, 4, d.mp3buflen, 0,
d.low_watermark_level, HORIZONTAL);
snprintf(buf, sizeof(buf), "wm: %x - %x", snprintf(buf, sizeof(buf), "wm: %x - %x",
d.low_watermark_level, d.lowest_watermark_level); d.low_watermark_level, d.lowest_watermark_level);

View file

@ -107,8 +107,6 @@ static struct plugin_api rockbox_api = {
lcd_getstringsize, lcd_getstringsize,
lcd_update, lcd_update,
lcd_update_rect, lcd_update_rect,
progressbar,
slidebar,
scrollbar, scrollbar,
#ifndef SIMULATOR #ifndef SIMULATOR
lcd_roll, lcd_roll,

View file

@ -45,6 +45,9 @@
#include "settings.h" #include "settings.h"
#include "thread.h" #include "thread.h"
#include "playlist.h" #include "playlist.h"
#ifdef HAVE_LCD_BITMAP
#include "widgets.h"
#endif
#ifdef PLUGIN #ifdef PLUGIN
#if defined(DEBUG) || defined(SIMULATOR) #if defined(DEBUG) || defined(SIMULATOR)
@ -132,10 +135,6 @@ struct plugin_api {
int (*lcd_getstringsize)(unsigned char *str, int *w, int *h); int (*lcd_getstringsize)(unsigned char *str, int *w, int *h);
void (*lcd_update)(void); void (*lcd_update)(void);
void (*lcd_update_rect)(int x, int y, int width, int height); 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, void (*scrollbar)(int x, int y, int width, int height, int items,
int min_shown, int max_shown, int orientation); int min_shown, int max_shown, int orientation);
#ifndef SIMULATOR #ifndef SIMULATOR

View file

@ -1607,8 +1607,8 @@ int wait_for_button(void)
void cb_progess(int current, int total) void cb_progess(int current, int total)
{ {
rb->yield(); /* be nice to the other threads */ rb->yield(); /* be nice to the other threads */
rb->progressbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, rb->scrollbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, 0, total,
current*100/total, 0 /*Grow_Right*/); current, HORIZONTAL);
rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8);
} }

View file

@ -225,7 +225,6 @@ void DrawPosition(int pos, int total)
{ {
int w,h; int w,h;
int sec; // estimated seconds int sec; // estimated seconds
int percent;
/* print the estimated position */ /* print the estimated position */
@ -239,8 +238,7 @@ void DrawPosition(int pos, int total)
/* draw a slider over the rest of the line */ /* draw a slider over the rest of the line */
rb->lcd_getstringsize(gPrint, &w, &h); rb->lcd_getstringsize(gPrint, &w, &h);
w++; w++;
percent = pos/(total/100); rb->scrollbar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, 0, total, pos, HORIZONTAL);
rb->slidebar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, percent, Grow_Right);
if (gPlay.state == paused) // we have to draw ourselves if (gPlay.state == paused) // we have to draw ourselves
rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8);

View file

@ -23,7 +23,7 @@
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* Valid dimensions return true, invalid false */ /* 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) || if((x < 0) || (x + width > LCD_WIDTH) ||
(y < 0) || (y + height > LCD_HEIGHT)) (y < 0) || (y + height > LCD_HEIGHT))
@ -34,107 +34,6 @@ bool valid_dimensions(int x, int y, int width, int height)
return true; 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 * 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)) if (!valid_dimensions(x, y, width, height))
return; 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 */ /* min should be min */
if(min_shown < max_shown) { if(min_shown < max_shown) {

View file

@ -35,8 +35,6 @@ enum {
HORIZONTAL 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 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); extern void checkbox(int x, int y, int width, int height, bool checked);
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */