summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-01 13:29:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-01 13:29:30 +0000
commit57e2fb1f3769a8be74c25217a360fb27d48822bb (patch)
tree79bcd10f9592107b9fc40cc3ad0e5805e55d109a /firmware
parent7769ad2982ce958e0c3df66cd3011c0c6aa6221e (diff)
downloadrockbox-57e2fb1f3769a8be74c25217a360fb27d48822bb.tar.gz
rockbox-57e2fb1f3769a8be74c25217a360fb27d48822bb.zip
Markus Braun's progressbar and slidebar code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1510 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd.c138
-rw-r--r--firmware/drivers/lcd.h11
2 files changed, 149 insertions, 0 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c
index 5a08b55930..5e86647280 100644
--- a/firmware/drivers/lcd.c
+++ b/firmware/drivers/lcd.c
@@ -1051,6 +1051,144 @@ void lcd_getfontsize(unsigned int font, int *width, int *height)
}
}
+/*
+ * Print a progress bar
+ */
+void lcd_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;i<height;i++) {
+ DRAW_PIXEL(x,(y+i));
+ DRAW_PIXEL((x+width-1),(y+i));
+ }
+
+ /* clear edge pixels */
+ CLEAR_PIXEL(x,y);
+ CLEAR_PIXEL((x+width-1),y);
+ CLEAR_PIXEL(x,(y+height-1));
+ CLEAR_PIXEL((x+width-1),(y+height-1));
+
+ /* clear pixels in progress bar */
+ for(i=1;i<=width-2;i++) {
+ for(j=1;j<=height-2;j++) {
+ CLEAR_PIXEL((x+i),(y+j));
+ CLEAR_PIXEL((x+i),(y+j));
+ }
+ }
+
+ /* draw bar */
+ pos=percent;
+ if(pos<0)
+ pos=0;
+ if(pos>100)
+ pos=100;
+
+ switch (direction)
+ {
+ case BAR_RIGHT:
+ pos=(width-2)*pos/100;
+ for(i=1;i<=pos;i++)
+ for(j=1;j<height-1;j++)
+ DRAW_PIXEL((x+i),(y+j));
+ break;
+ case BAR_LEFT:
+ pos=(width-2)*(100-pos)/100;
+ for(i=pos+1;i<=width-2;i++)
+ for(j=1;j<height-1;j++)
+ DRAW_PIXEL((x+i),(y+j));
+ break;
+ case BAR_DOWN:
+ pos=(height-2)*pos/100;
+ for(i=1;i<=pos;i++)
+ for(j=1;j<width-1;j++)
+ DRAW_PIXEL((x+j),(y+i));
+ break;
+ case BAR_UP:
+ pos=(height-2)*(100-pos)/100;
+ for(i=pos+1;i<=height-2;i++)
+ for(j=1;j<width-1;j++)
+ DRAW_PIXEL((x+j),(y+i));
+ break;
+ }
+
+}
+
+
+/*
+ * Print a slidebar bar
+ */
+void lcd_slidebar(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;i<height;i++) {
+ DRAW_PIXEL(x,(y+i));
+ DRAW_PIXEL((x+width-1),(y+i));
+ }
+
+ /* clear edge pixels */
+ CLEAR_PIXEL(x,y);
+ CLEAR_PIXEL((x+width-1),y);
+ CLEAR_PIXEL(x,(y+height-1));
+ CLEAR_PIXEL((x+width-1),(y+height-1));
+
+ /* clear pixels in progress bar */
+ for(i=1;i<=width-2;i++)
+ for(j=1;j<=height-2;j++) {
+ CLEAR_PIXEL((x+i),(y+j));
+ CLEAR_PIXEL((x+i),(y+j));
+ }
+
+ /* draw point */
+ pos=percent;
+ if(pos<0)
+ pos=0;
+ if(pos>100)
+ pos=100;
+
+ switch (direction)
+ {
+ case BAR_RIGHT:
+ pos=(width-height-1)*pos/100;
+ break;
+ case BAR_LEFT:
+ pos=(width-height-1)*(100-pos)/100;
+ break;
+ case BAR_DOWN:
+ pos=(height-width-1)*pos/100;
+ break;
+ case BAR_UP:
+ pos=(height-width-1)*(100-pos)/100;
+ break;
+ }
+
+ if(direction == BAR_LEFT || direction == BAR_RIGHT)
+ for(i=1;i<height;i++)
+ for(j=1;j<height;j++)
+ DRAW_PIXEL((x+pos+i),(y+j));
+ else
+ for(i=1;i<width;i++)
+ for(j=1;j<width;j++)
+ DRAW_PIXEL((x+i),(y+pos+j));
+}
+
#else
/* no LCD defined, no code to use */
#endif
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h
index 581ec3461d..c985cb067d 100644
--- a/firmware/drivers/lcd.h
+++ b/firmware/drivers/lcd.h
@@ -74,6 +74,15 @@ extern void lcd_double_height (bool on);
#define LCD_WIDTH 112 /* Display width in pixels */
#define LCD_HEIGHT 64 /* Display height in pixels */
+/* Directions for progressbar and scrollbar */
+enum
+{
+ BAR_RIGHT = 0,
+ BAR_LEFT,
+ BAR_DOWN,
+ BAR_UP
+};
+
extern void lcd_putsxy(int x, int y, unsigned char *string, int font);
extern void lcd_setfont(int font);
extern void lcd_getfontsize(unsigned int font, int *width, int *height);
@@ -88,6 +97,8 @@ extern void lcd_drawline( int x1, int y1, int x2, int y2 );
extern void lcd_clearline( int x1, int y1, int x2, int y2 );
extern void lcd_drawpixel(int x, int y);
extern void lcd_clearpixel(int x, int y);
+extern void lcd_progressbar(int x, int y, int width, int height, int percent, int direction);
+extern void lcd_slidebar(int x, int y, int width, int height, int percent, int direction);
#endif /* CHARCELLS / BITMAP */