forked from len0rd/rockbox
a minor bit of code policing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3928 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8afb858804
commit
7a38db572e
1 changed files with 33 additions and 60 deletions
|
@ -21,26 +21,21 @@
|
||||||
#include "widgets.h"
|
#include "widgets.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
/*
|
|
||||||
* Print a progress bar
|
/* Valid dimensions return true, invalid false */
|
||||||
*/
|
bool valid_dimensions(int x, int y, int width, int height)
|
||||||
void progressbar(int x, int y, int width, int height, int percent, int direction)
|
|
||||||
{
|
{
|
||||||
int pos;
|
if((x < 0) || (x + width > LCD_WIDTH) ||
|
||||||
|
(y < 0) || (y + height > LCD_HEIGHT))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* check position and dimensions */
|
return true;
|
||||||
if(x < 0)
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
if(y < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(x + width > LCD_WIDTH)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(y + height > LCD_HEIGHT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
void init_bar(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
/* draw box */
|
/* draw box */
|
||||||
lcd_drawrect(x, y, width, height);
|
lcd_drawrect(x, y, width, height);
|
||||||
|
|
||||||
|
@ -52,6 +47,21 @@ void progressbar(int x, int y, int width, int height, int percent, int direction
|
||||||
|
|
||||||
/* clear pixels in progress bar */
|
/* clear pixels in progress bar */
|
||||||
lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
|
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 */
|
/* draw bar */
|
||||||
pos = percent;
|
pos = percent;
|
||||||
|
@ -90,29 +100,10 @@ void slidebar(int x, int y, int width, int height, int percent, int direction)
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
/* check position and dimensions */
|
/* check position and dimensions */
|
||||||
if(x < 0)
|
if (!valid_dimensions(x, y, width, height))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(y < 0)
|
init_bar(x, y, width, height);
|
||||||
return;
|
|
||||||
|
|
||||||
if(x + width > LCD_WIDTH)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(y + height > LCD_HEIGHT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
/* draw knob */
|
/* draw knob */
|
||||||
pos = percent;
|
pos = percent;
|
||||||
|
@ -147,7 +138,8 @@ void slidebar(int x, int y, int width, int height, int percent, int direction)
|
||||||
/*
|
/*
|
||||||
* Print a scroll bar
|
* Print a scroll bar
|
||||||
*/
|
*/
|
||||||
void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation)
|
void scrollbar(int x, int y, int width, int height, int items, int min_shown,
|
||||||
|
int max_shown, int orientation)
|
||||||
{
|
{
|
||||||
int min;
|
int min;
|
||||||
int max;
|
int max;
|
||||||
|
@ -155,29 +147,10 @@ void scrollbar(int x, int y, int width, int height, int items, int min_shown, in
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
/* check position and dimensions */
|
/* check position and dimensions */
|
||||||
if(x < 0)
|
if (!valid_dimensions(x, y, width, height))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(y < 0)
|
init_bar(x, y, width, height);
|
||||||
return;
|
|
||||||
|
|
||||||
if(x + width > LCD_WIDTH)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(y + height > LCD_HEIGHT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* 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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue