From c43822d1027db7a12f37c822d77e6fe644fab0de Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Thu, 3 Nov 2005 11:56:21 +0000 Subject: Fixed a bug whith the multi-screen menus : when entering / leaving a menu, the selected item was not voiced git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7739 a1c6a512-1295-4272-9138-f99709370657 --- apps/menu.c | 39 +++++++++++++++++++++------------------ apps/menu.h | 1 + 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/menu.c b/apps/menu.c index 90a3c89d75..83826e33f9 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -125,9 +125,9 @@ int menu_show(int m) int key; gui_synclist_draw(&(menus[m].synclist)); + menu_talk_selected(m); while (!exit) { key = button_get_w_tmo(HZ/2); - /* * "short-circuit" the default keypresses by running the * callback function @@ -137,17 +137,9 @@ int menu_show(int m) */ if( menus[m].callback != NULL ) key = menus[m].callback(key, m); + /* If moved, "say" the entry under the cursor */ if(gui_synclist_do_button(&(menus[m].synclist), key)) - { - /* If moved, "say" the entry under the cursor */ - if(global_settings.talk_menu) - { - int selected=gui_synclist_get_sel_pos(&(menus[m].synclist)); - int voice_id = P2ID(menus[m].items[selected].desc); - if (voice_id >= 0) /* valid ID given? */ - talk_id(voice_id, false); /* say it */ - } - } + menu_talk_selected(m); switch( key ) { case MENU_ENTER: #ifdef MENU_ENTER2 @@ -265,7 +257,7 @@ void menu_insert(int menu, int position, char *desc, bool (*function) (void)) } /* - * Property function - return the "count" of menu items in "menu" + * Property function - return the "count" of menu items in "menu" */ int menu_count(int menu) @@ -309,7 +301,7 @@ bool menu_movedown(int menu) if( selected == nb_items - 1) return false; - /* use a temporary variable to do the swap */ + /* use a temporary variable to do the swap */ swap = menus[menu].items[selected + 1]; menus[menu].items[selected + 1] = menus[menu].items[selected]; menus[menu].items[selected] = swap; @@ -327,6 +319,22 @@ void menu_set_cursor(int menu, int position) gui_synclist_select_item(&(menus[menu].synclist), position); } +void menu_talk_selected(int m) +{ + if(global_settings.talk_menu) + { + int selected=gui_synclist_get_sel_pos(&(menus[m].synclist)); + int voice_id = P2ID(menus[m].items[selected].desc); + if (voice_id >= 0) /* valid ID given? */ + talk_id(voice_id, false); /* say it */ + } +} + +void menu_draw(int m) +{ + gui_synclist_draw(&(menus[m].synclist)); +} + /* count in letter positions, NOT pixels */ void put_cursorxy(int x, int y, bool on) { @@ -364,8 +372,3 @@ void put_cursorxy(int x, int y, bool on) #endif } } - -void menu_draw(int m) -{ - gui_synclist_draw(&(menus[m].synclist)); -} diff --git a/apps/menu.h b/apps/menu.h index 08cd70fcda..c163e35ccc 100644 --- a/apps/menu.h +++ b/apps/menu.h @@ -96,5 +96,6 @@ bool menu_movedown(int menu); void menu_draw(int menu); void menu_insert(int menu, int position, char *desc, bool (*function) (void)); void menu_set_cursor(int menu, int position); +void menu_talk_selected(int m); #endif /* End __MENU_H__ */ -- cgit v1.2.3