summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c11
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h7
-rw-r--r--apps/plugins/jpeg.c4
-rw-r--r--apps/plugins/video.c4
-rw-r--r--apps/recorder/widgets.c115
-rw-r--r--apps/recorder/widgets.h2
7 files changed, 24 insertions, 121 deletions
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)
151{ 151{
152 char buf[32]; 152 char buf[32];
153 int button; 153 int button;
154 int percent;
155 struct mpeg_debug d; 154 struct mpeg_debug d;
156 155
157 lcd_setmargins(0, 0); 156 lcd_setmargins(0, 0);
@@ -182,11 +181,13 @@ bool dbg_mpeg_thread(void)
182 snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space); 181 snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
183 lcd_puts(0, 5, buf); 182 lcd_puts(0, 5, buf);
184 183
185 percent = d.playable_space * 100 / d.mp3buflen; 184 /* Playable space left */
186 progressbar(0, 6*8, 112, 4, percent, Grow_Right); 185 scrollbar(0, 6*8, 112, 4, d.mp3buflen, 0,
186 d.playable_space, HORIZONTAL);
187 187
188 percent = d.low_watermark_level * 100 / d.mp3buflen; 188 /* Show the watermark limit */
189 progressbar(0, 6*8+4, 112, 4, percent, Grow_Right); 189 scrollbar(0, 6*8+4, 112, 4, d.mp3buflen, 0,
190 d.low_watermark_level, HORIZONTAL);
190 191
191 snprintf(buf, sizeof(buf), "wm: %x - %x", 192 snprintf(buf, sizeof(buf), "wm: %x - %x",
192 d.low_watermark_level, d.lowest_watermark_level); 193 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 = {
107 lcd_getstringsize, 107 lcd_getstringsize,
108 lcd_update, 108 lcd_update,
109 lcd_update_rect, 109 lcd_update_rect,
110 progressbar,
111 slidebar,
112 scrollbar, 110 scrollbar,
113#ifndef SIMULATOR 111#ifndef SIMULATOR
114 lcd_roll, 112 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 @@
45#include "settings.h" 45#include "settings.h"
46#include "thread.h" 46#include "thread.h"
47#include "playlist.h" 47#include "playlist.h"
48#ifdef HAVE_LCD_BITMAP
49#include "widgets.h"
50#endif
48 51
49#ifdef PLUGIN 52#ifdef PLUGIN
50#if defined(DEBUG) || defined(SIMULATOR) 53#if defined(DEBUG) || defined(SIMULATOR)
@@ -132,10 +135,6 @@ struct plugin_api {
132 int (*lcd_getstringsize)(unsigned char *str, int *w, int *h); 135 int (*lcd_getstringsize)(unsigned char *str, int *w, int *h);
133 void (*lcd_update)(void); 136 void (*lcd_update)(void);
134 void (*lcd_update_rect)(int x, int y, int width, int height); 137 void (*lcd_update_rect)(int x, int y, int width, int height);
135 void (*progressbar)(int x, int y, int width, int height,
136 int percent, int direction);
137 void (*slidebar)(int x, int y, int width, int height,
138 int percent, int direction);
139 void (*scrollbar)(int x, int y, int width, int height, int items, 138 void (*scrollbar)(int x, int y, int width, int height, int items,
140 int min_shown, int max_shown, int orientation); 139 int min_shown, int max_shown, int orientation);
141#ifndef SIMULATOR 140#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)
1607void cb_progess(int current, int total) 1607void cb_progess(int current, int total)
1608{ 1608{
1609 rb->yield(); /* be nice to the other threads */ 1609 rb->yield(); /* be nice to the other threads */
1610 rb->progressbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, 1610 rb->scrollbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, 0, total,
1611 current*100/total, 0 /*Grow_Right*/); 1611 current, HORIZONTAL);
1612 rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); 1612 rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8);
1613} 1613}
1614 1614
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)
225{ 225{
226 int w,h; 226 int w,h;
227 int sec; // estimated seconds 227 int sec; // estimated seconds
228 int percent;
229 228
230 229
231 /* print the estimated position */ 230 /* print the estimated position */
@@ -239,8 +238,7 @@ void DrawPosition(int pos, int total)
239 /* draw a slider over the rest of the line */ 238 /* draw a slider over the rest of the line */
240 rb->lcd_getstringsize(gPrint, &w, &h); 239 rb->lcd_getstringsize(gPrint, &w, &h);
241 w++; 240 w++;
242 percent = pos/(total/100); 241 rb->scrollbar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, 0, total, pos, HORIZONTAL);
243 rb->slidebar(w, LCD_HEIGHT-7, LCD_WIDTH-w, 7, percent, Grow_Right);
244 242
245 if (gPlay.state == paused) // we have to draw ourselves 243 if (gPlay.state == paused) // we have to draw ourselves
246 rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); 244 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 @@
23#ifdef HAVE_LCD_BITMAP 23#ifdef HAVE_LCD_BITMAP
24 24
25/* Valid dimensions return true, invalid false */ 25/* Valid dimensions return true, invalid false */
26bool valid_dimensions(int x, int y, int width, int height) 26static bool valid_dimensions(int x, int y, int width, int height)
27{ 27{
28 if((x < 0) || (x + width > LCD_WIDTH) || 28 if((x < 0) || (x + width > LCD_WIDTH) ||
29 (y < 0) || (y + height > LCD_HEIGHT)) 29 (y < 0) || (y + height > LCD_HEIGHT))
@@ -34,107 +34,6 @@ bool valid_dimensions(int x, int y, int width, int height)
34 return true; 34 return true;
35} 35}
36 36
37void init_bar(int x, int y, int width, int height)
38{
39 /* draw box */
40 lcd_drawrect(x, y, width, height);
41
42 /* clear edge pixels */
43 lcd_clearpixel(x, y);
44 lcd_clearpixel((x + width - 1), y);
45 lcd_clearpixel(x, (y + height - 1));
46 lcd_clearpixel((x + width - 1), (y + height - 1));
47
48 /* clear pixels in progress bar */
49 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
50}
51
52/*
53 * Print a progress bar
54 */
55void progressbar(int x, int y, int width, int height, int percent,
56 int direction)
57{
58 int pos;
59
60 /* check position and dimensions */
61 if (!valid_dimensions(x, y, width, height))
62 return;
63
64 init_bar(x, y, width, height);
65
66 /* draw bar */
67 pos = percent;
68 if(pos < 0)
69 pos = 0;
70 if(pos > 100)
71 pos = 100;
72
73 switch (direction)
74 {
75 case Grow_Right:
76 pos=(width - 2) * pos / 100;
77 lcd_fillrect(x + 1, y + 1, pos, height - 2);
78 break;
79 case Grow_Left:
80 pos=(width - 2) * (100 - pos) / 100;
81 lcd_fillrect(x + pos, y + 1, width - 1 - pos, height - 2);
82 break;
83 case Grow_Down:
84 pos=(height - 2) * pos / 100;
85 lcd_fillrect(x + 1, y + 1, width - 2, pos);
86 break;
87 case Grow_Up:
88 pos=(height - 2) * (100 - pos) / 100;
89 lcd_fillrect(x + 1, y + pos, width - 2, height - 1 - pos);
90 break;
91 }
92}
93
94
95/*
96 * Print a slidebar bar
97 */
98void slidebar(int x, int y, int width, int height, int percent, int direction)
99{
100 int pos;
101
102 /* check position and dimensions */
103 if (!valid_dimensions(x, y, width, height))
104 return;
105
106 init_bar(x, y, width, height);
107
108 /* draw knob */
109 pos = percent;
110 if(pos < 0)
111 pos = 0;
112 if(pos > 100)
113 pos = 100;
114
115 switch (direction)
116 {
117 case Grow_Right:
118 pos = (width - height) * pos / 100;
119 break;
120 case Grow_Left:
121 pos=(width - height) * (100 - pos) / 100;
122 break;
123 case Grow_Down:
124 pos=(height - width) * pos / 100;
125 break;
126 case Grow_Up:
127 pos=(height - width) * (100 - pos) / 100;
128 break;
129 }
130
131 if(direction == Grow_Left || direction == Grow_Right)
132 lcd_fillrect(x + pos + 1, y + 1, height - 2, height - 2);
133 else
134 lcd_fillrect(x + 1, y + pos + 1, width - 2, width - 2);
135}
136
137
138/* 37/*
139 * Print a scroll bar 38 * Print a scroll bar
140 */ 39 */
@@ -150,7 +49,17 @@ void scrollbar(int x, int y, int width, int height, int items, int min_shown,
150 if (!valid_dimensions(x, y, width, height)) 49 if (!valid_dimensions(x, y, width, height))
151 return; 50 return;
152 51
153 init_bar(x, y, width, height); 52 /* draw box */
53 lcd_drawrect(x, y, width, height);
54
55 /* clear edge pixels */
56 lcd_clearpixel(x, y);
57 lcd_clearpixel((x + width - 1), y);
58 lcd_clearpixel(x, (y + height - 1));
59 lcd_clearpixel((x + width - 1), (y + height - 1));
60
61 /* clear pixels in progress bar */
62 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
154 63
155 /* min should be min */ 64 /* min should be min */
156 if(min_shown < max_shown) { 65 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 {
35 HORIZONTAL 35 HORIZONTAL
36}; 36};
37 37
38extern void progressbar(int x, int y, int width, int height, int percent, int direction);
39extern void slidebar(int x, int y, int width, int height, int percent, int direction);
40extern void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation); 38extern void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation);
41extern void checkbox(int x, int y, int width, int height, bool checked); 39extern void checkbox(int x, int y, int width, int height, bool checked);
42#endif /* HAVE_LCD_BITMAP */ 40#endif /* HAVE_LCD_BITMAP */