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.zip
rockbox-77936e6ec5c2d71f605df855ed24677c307b1bc7.tar.gz
rockbox-77936e6ec5c2d71f605df855ed24677c307b1bc7.tar.bz2
rockbox-77936e6ec5c2d71f605df855ed24677c307b1bc7.tar.xz
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 f944354..d1f0736 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -42,9 +42,13 @@
struct menu {
int top;
int cursor;
- struct menu_items* items;
+ struct menu_item* items;
int itemcount;
int (*callback)(int, int);
+#ifdef HAVE_LCD_BITMAP
+ bool use_buttonbar; /* true if a buttonbar is defined */
+ char *buttonbar[3];
+#endif
};
#define MAX_MENUS 5
@@ -132,12 +136,22 @@ void menu_draw(int m)
#ifdef HAVE_LCD_BITMAP
int fw, fh;
int menu_lines;
+ int height = LCD_HEIGHT;
+
lcd_setfont(FONT_UI);
lcd_getstringsize("A", &fw, &fh);
if (global_settings.statusbar)
- menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh;
- else
- menu_lines = LCD_HEIGHT/fh;
+ height -= STATUSBAR_HEIGHT;
+
+ if(global_settings.buttonbar && menus[m].use_buttonbar) {
+ buttonbar_set(menus[m].buttonbar[0],
+ menus[m].buttonbar[1],
+ menus[m].buttonbar[2]);
+ height -= BUTTONBAR_HEIGHT;
+ }
+
+ menu_lines = height / fh;
+
#else
int menu_lines = MENU_LINES;
#endif
@@ -170,10 +184,14 @@ void menu_draw(int m)
#ifdef HAVE_LCD_BITMAP
if (global_settings.scrollbar && menus[m].itemcount > menu_lines)
scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
- LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top,
+ height, menus[m].itemcount, menus[m].top,
menus[m].top + menu_lines, VERTICAL);
+
+ if(global_settings.buttonbar && menus[m].use_buttonbar)
+ buttonbar_draw();
#endif
status_draw(true);
+
lcd_update();
}
@@ -187,12 +205,17 @@ static void put_cursor(int m, int target)
#ifdef HAVE_LCD_BITMAP
int fw, fh;
int menu_lines;
+ int height = LCD_HEIGHT;
+
lcd_setfont(FONT_UI);
lcd_getstringsize("A", &fw, &fh);
- if (global_settings.statusbar)
- menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh;
- else
- menu_lines = LCD_HEIGHT/fh;
+ if(global_settings.statusbar)
+ height -= STATUSBAR_HEIGHT;
+
+ if(global_settings.buttonbar && menus[m].use_buttonbar)
+ height -= BUTTONBAR_HEIGHT;
+
+ menu_lines = height / fh;
#else
int menu_lines = MENU_LINES;
#endif
@@ -226,7 +249,8 @@ static void put_cursor(int m, int target)
}
-int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int))
+int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
+ char *button1, char *button2, char *button3)
{
int i;
@@ -245,7 +269,20 @@ int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int))
menus[i].top = 0;
menus[i].cursor = 0;
menus[i].callback = callback;
+#ifdef HAVE_LCD_BITMAP
+ menus[i].buttonbar[0] = button1;
+ menus[i].buttonbar[1] = button2;
+ menus[i].buttonbar[2] = button3;
+ if(button1 || button2 || button3)
+ menus[i].use_buttonbar = true;
+ else
+ menus[i].use_buttonbar = false;
+#else
+ (void)button1;
+ (void)button2;
+ (void)button3;
+#endif
return i;
}
@@ -262,12 +299,21 @@ int menu_show(int m)
#ifdef HAVE_LCD_BITMAP
int fw, fh;
int menu_lines;
+ int height = LCD_HEIGHT;
+
lcd_setfont(FONT_UI);
lcd_getstringsize("A", &fw, &fh);
if (global_settings.statusbar)
- menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh;
- else
- menu_lines = LCD_HEIGHT/fh;
+ height -= STATUSBAR_HEIGHT;
+
+ if(global_settings.buttonbar && menus[m].use_buttonbar) {
+ buttonbar_set(menus[m].buttonbar[0],
+ menus[m].buttonbar[1],
+ menus[m].buttonbar[2]);
+ height -= BUTTONBAR_HEIGHT;
+ }
+
+ menu_lines = height / fh;
#endif
menu_draw(m);
@@ -439,7 +485,7 @@ int menu_count(int menu)
bool menu_moveup(int menu)
{
- struct menu_items swap;
+ struct menu_item swap;
/* can't be the first item ! */
if( menus[menu].cursor == 0)
@@ -460,7 +506,7 @@ bool menu_moveup(int menu)
bool menu_movedown(int menu)
{
- struct menu_items swap;
+ struct menu_item swap;
/* can't be the last item ! */
if( menus[menu].cursor == menus[menu].itemcount - 1)