summaryrefslogtreecommitdiff
path: root/apps/menu.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-03-16 13:44:56 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-03-16 13:44:56 +0000
commit77936e6ec5c2d71f605df855ed24677c307b1bc7 (patch)
treef58c287f2a9f575c764b026116e32787c6c5bc0e /apps/menu.c
parentce0878bd40ea07d126181d1827a235f7c3ee1b00 (diff)
downloadrockbox-77936e6ec5c2d71f605df855ed24677c307b1bc7.tar.gz
rockbox-77936e6ec5c2d71f605df855ed24677c307b1bc7.zip
First shot at a nice little button bar at the bottom of the recorder LCD. Enable Button Bar in the Display settings. Only the dir browser uses it at the moment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4391 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/menu.c')
-rw-r--r--apps/menu.c76
1 files changed, 61 insertions, 15 deletions
diff --git a/apps/menu.c b/apps/menu.c
index f9443548f6..d1f073645b 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -42,9 +42,13 @@
42struct menu { 42struct menu {
43 int top; 43 int top;
44 int cursor; 44 int cursor;
45 struct menu_items* items; 45 struct menu_item* items;
46 int itemcount; 46 int itemcount;
47 int (*callback)(int, int); 47 int (*callback)(int, int);
48#ifdef HAVE_LCD_BITMAP
49 bool use_buttonbar; /* true if a buttonbar is defined */
50 char *buttonbar[3];
51#endif
48}; 52};
49 53
50#define MAX_MENUS 5 54#define MAX_MENUS 5
@@ -132,12 +136,22 @@ void menu_draw(int m)
132#ifdef HAVE_LCD_BITMAP 136#ifdef HAVE_LCD_BITMAP
133 int fw, fh; 137 int fw, fh;
134 int menu_lines; 138 int menu_lines;
139 int height = LCD_HEIGHT;
140
135 lcd_setfont(FONT_UI); 141 lcd_setfont(FONT_UI);
136 lcd_getstringsize("A", &fw, &fh); 142 lcd_getstringsize("A", &fw, &fh);
137 if (global_settings.statusbar) 143 if (global_settings.statusbar)
138 menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; 144 height -= STATUSBAR_HEIGHT;
139 else 145
140 menu_lines = LCD_HEIGHT/fh; 146 if(global_settings.buttonbar && menus[m].use_buttonbar) {
147 buttonbar_set(menus[m].buttonbar[0],
148 menus[m].buttonbar[1],
149 menus[m].buttonbar[2]);
150 height -= BUTTONBAR_HEIGHT;
151 }
152
153 menu_lines = height / fh;
154
141#else 155#else
142 int menu_lines = MENU_LINES; 156 int menu_lines = MENU_LINES;
143#endif 157#endif
@@ -170,10 +184,14 @@ void menu_draw(int m)
170#ifdef HAVE_LCD_BITMAP 184#ifdef HAVE_LCD_BITMAP
171 if (global_settings.scrollbar && menus[m].itemcount > menu_lines) 185 if (global_settings.scrollbar && menus[m].itemcount > menu_lines)
172 scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, 186 scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
173 LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top, 187 height, menus[m].itemcount, menus[m].top,
174 menus[m].top + menu_lines, VERTICAL); 188 menus[m].top + menu_lines, VERTICAL);
189
190 if(global_settings.buttonbar && menus[m].use_buttonbar)
191 buttonbar_draw();
175#endif 192#endif
176 status_draw(true); 193 status_draw(true);
194
177 lcd_update(); 195 lcd_update();
178} 196}
179 197
@@ -187,12 +205,17 @@ static void put_cursor(int m, int target)
187#ifdef HAVE_LCD_BITMAP 205#ifdef HAVE_LCD_BITMAP
188 int fw, fh; 206 int fw, fh;
189 int menu_lines; 207 int menu_lines;
208 int height = LCD_HEIGHT;
209
190 lcd_setfont(FONT_UI); 210 lcd_setfont(FONT_UI);
191 lcd_getstringsize("A", &fw, &fh); 211 lcd_getstringsize("A", &fw, &fh);
192 if (global_settings.statusbar) 212 if(global_settings.statusbar)
193 menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; 213 height -= STATUSBAR_HEIGHT;
194 else 214
195 menu_lines = LCD_HEIGHT/fh; 215 if(global_settings.buttonbar && menus[m].use_buttonbar)
216 height -= BUTTONBAR_HEIGHT;
217
218 menu_lines = height / fh;
196#else 219#else
197 int menu_lines = MENU_LINES; 220 int menu_lines = MENU_LINES;
198#endif 221#endif
@@ -226,7 +249,8 @@ static void put_cursor(int m, int target)
226 249
227} 250}
228 251
229int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int)) 252int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
253 char *button1, char *button2, char *button3)
230{ 254{
231 int i; 255 int i;
232 256
@@ -245,7 +269,20 @@ int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int))
245 menus[i].top = 0; 269 menus[i].top = 0;
246 menus[i].cursor = 0; 270 menus[i].cursor = 0;
247 menus[i].callback = callback; 271 menus[i].callback = callback;
272#ifdef HAVE_LCD_BITMAP
273 menus[i].buttonbar[0] = button1;
274 menus[i].buttonbar[1] = button2;
275 menus[i].buttonbar[2] = button3;
248 276
277 if(button1 || button2 || button3)
278 menus[i].use_buttonbar = true;
279 else
280 menus[i].use_buttonbar = false;
281#else
282 (void)button1;
283 (void)button2;
284 (void)button3;
285#endif
249 return i; 286 return i;
250} 287}
251 288
@@ -262,12 +299,21 @@ int menu_show(int m)
262#ifdef HAVE_LCD_BITMAP 299#ifdef HAVE_LCD_BITMAP
263 int fw, fh; 300 int fw, fh;
264 int menu_lines; 301 int menu_lines;
302 int height = LCD_HEIGHT;
303
265 lcd_setfont(FONT_UI); 304 lcd_setfont(FONT_UI);
266 lcd_getstringsize("A", &fw, &fh); 305 lcd_getstringsize("A", &fw, &fh);
267 if (global_settings.statusbar) 306 if (global_settings.statusbar)
268 menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; 307 height -= STATUSBAR_HEIGHT;
269 else 308
270 menu_lines = LCD_HEIGHT/fh; 309 if(global_settings.buttonbar && menus[m].use_buttonbar) {
310 buttonbar_set(menus[m].buttonbar[0],
311 menus[m].buttonbar[1],
312 menus[m].buttonbar[2]);
313 height -= BUTTONBAR_HEIGHT;
314 }
315
316 menu_lines = height / fh;
271#endif 317#endif
272 318
273 menu_draw(m); 319 menu_draw(m);
@@ -439,7 +485,7 @@ int menu_count(int menu)
439 485
440bool menu_moveup(int menu) 486bool menu_moveup(int menu)
441{ 487{
442 struct menu_items swap; 488 struct menu_item swap;
443 489
444 /* can't be the first item ! */ 490 /* can't be the first item ! */
445 if( menus[menu].cursor == 0) 491 if( menus[menu].cursor == 0)
@@ -460,7 +506,7 @@ bool menu_moveup(int menu)
460 506
461bool menu_movedown(int menu) 507bool menu_movedown(int menu)
462{ 508{
463 struct menu_items swap; 509 struct menu_item swap;
464 510
465 /* can't be the last item ! */ 511 /* can't be the last item ! */
466 if( menus[menu].cursor == menus[menu].itemcount - 1) 512 if( menus[menu].cursor == menus[menu].itemcount - 1)