Give all menus using the old API a nice title and icons (except plugins)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13068 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-04-08 05:52:47 +00:00
parent 1e0ae1be63
commit 21b415df56
6 changed files with 40 additions and 10 deletions

View file

@ -2390,7 +2390,7 @@ bool debug_menu(void)
}; };
m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
NULL, NULL, NULL); "Debug Menu", NULL, NULL);
result = menu_run(m); result = menu_run(m);
menu_exit(m); menu_exit(m);

View file

@ -10727,3 +10727,17 @@
*: "" *: ""
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_ONPLAY_MENU_TITLE
desc: title for the onplay menus
user:
<source>
*: "Context Menu"
</source>
<dest>
*: "Context Menu"
</dest>
<voice>
*: "Context Menu"
</voice>
</phrase>

View file

@ -61,6 +61,7 @@
/* needed for the old menu system */ /* needed for the old menu system */
struct menu { struct menu {
struct menu_item* items; struct menu_item* items;
char *title;
int count; int count;
int (*callback)(int, int); int (*callback)(int, int);
int current_selection; int current_selection;
@ -659,9 +660,6 @@ static int menu_find_free(void)
int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int), int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
const char *button1, const char *button2, const char *button3) const char *button1, const char *button2, const char *button3)
{ {
(void)button1;
(void)button2;
(void)button3;
int menu=menu_find_free(); int menu=menu_find_free();
if(menu==-1)/* Out of menus */ if(menu==-1)/* Out of menus */
return -1; return -1;
@ -669,6 +667,9 @@ int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, in
menus[menu].count = count; menus[menu].count = count;
menus[menu].callback = callback; menus[menu].callback = callback;
menus[menu].current_selection = 0; menus[menu].current_selection = 0;
if ((button2 == NULL) && (button3 == NULL))
menus[menu].title = button1;
else menus[menu].title = NULL;
return menu; return menu;
} }
@ -702,6 +703,14 @@ static char* oldmenuwrapper_getname(int selected_item,
unsigned char* desc = menus[(intptr_t)data].items[selected_item].desc; unsigned char* desc = menus[(intptr_t)data].items[selected_item].desc;
return P2STR(desc); return P2STR(desc);
} }
#ifdef HAVE_LCD_BITMAP
static void oldmenu_get_icon(int selected_item, void * data, ICON * icon)
{
*icon = bitmap_icons_6x8[Icon_Menu_functioncall];
}
#endif
static void init_oldmenu(const struct menu_item_ex *menu, static void init_oldmenu(const struct menu_item_ex *menu,
struct gui_synclist *lists, int selected, bool callback) struct gui_synclist *lists, int selected, bool callback)
{ {
@ -711,6 +720,11 @@ static void init_oldmenu(const struct menu_item_ex *menu,
gui_synclist_set_nb_items(lists, MENU_GET_COUNT(menu->flags)); gui_synclist_set_nb_items(lists, MENU_GET_COUNT(menu->flags));
gui_synclist_limit_scroll(lists, true); gui_synclist_limit_scroll(lists, true);
gui_synclist_select_item(lists, selected); gui_synclist_select_item(lists, selected);
#ifdef HAVE_LCD_BITMAP
gui_synclist_set_title(lists, menus[menu->value].title,
bitmap_icons_6x8[Icon_Submenu_Entered]);
gui_synclist_set_icon_callback(lists, oldmenu_get_icon);
#endif
} }
static void menu_talk_selected(int m) static void menu_talk_selected(int m)
@ -729,7 +743,7 @@ int menu_show(int m)
{ {
oldmenuwrapper_callback, oldmenuwrapper_callback,
oldmenuwrapper_getname, oldmenuwrapper_getname,
(void*)(intptr_t)m, Icon_NOICON (void*)(intptr_t)m, Icon_Submenu
}; };
menu.flags = (MENU_TYPE_MASK&MT_OLD_MENU) | MENU_DYNAMIC_DESC | menu.flags = (MENU_TYPE_MASK&MT_OLD_MENU) | MENU_DYNAMIC_DESC |

View file

@ -189,6 +189,7 @@ struct menu_item {
bool (*function) (void); /* return true if USB was connected */ bool (*function) (void); /* return true if USB was connected */
}; };
/* if button2 == button3 == NULL, button1 is the menu title */
int menu_init(const struct menu_item* mitems, int count, int menu_init(const struct menu_item* mitems, int count,
int (*callback)(int, int), int (*callback)(int, int),
const char *button1, const char *button2, const char *button3); const char *button1, const char *button2, const char *button3);

View file

@ -107,7 +107,7 @@ static bool bookmark_menu(void)
} }
} }
m=menu_init( items, i, NULL, NULL, NULL, NULL ); m=menu_init( items, i, NULL, str(LANG_BOOKMARK_MENU), NULL, NULL );
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_set_param(true); status_set_param(true);
@ -256,7 +256,7 @@ static bool cat_playlist_options(void)
i++; i++;
} }
m = menu_init( items, i, NULL, NULL, NULL, NULL ); m = menu_init( items, i, NULL, str(LANG_CATALOG), NULL, NULL );
result = menu_show(m); result = menu_show(m);
if(result >= 0) if(result >= 0)
ret = items[result].function(); ret = items[result].function();
@ -373,7 +373,7 @@ static bool playlist_options(void)
} }
} }
m = menu_init( items, i, NULL, NULL, NULL, NULL ); m = menu_init( items, i, NULL, str(LANG_PLAYLIST_MENU), NULL, NULL );
result = menu_show(m); result = menu_show(m);
if (result >= 0 && result < pstart) if (result >= 0 && result < pstart)
ret = items[result].function(); ret = items[result].function();
@ -1048,7 +1048,8 @@ int onplay(char* file, int attr, int from)
/* DIY menu handling, since we want to exit after selection */ /* DIY menu handling, since we want to exit after selection */
if (i) if (i)
{ {
m = menu_init( items, i, onplay_callback, NULL, NULL, NULL ); m = menu_init( items, i, onplay_callback,
str(LANG_ONPLAY_MENU_TITLE), NULL, NULL );
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
do do
{ {

View file

@ -440,7 +440,7 @@ static int onplay_menu(int index)
items[i].desc = ID2P(LANG_CATALOG_ADD_TO_NEW); items[i].desc = ID2P(LANG_CATALOG_ADD_TO_NEW);
i++; i++;
m = menu_init(items, i, NULL, NULL, NULL, NULL); m = menu_init(items, i, NULL, str(LANG_PLAYLIST_MENU), NULL, NULL);
result = menu_show(m); result = menu_show(m);
if (result == MENU_ATTACHED_USB) if (result == MENU_ATTACHED_USB)
{ {