diff options
author | Stéphane Doyon <s.doyon@videotron.ca> | 2007-10-21 00:23:23 +0000 |
---|---|---|
committer | Stéphane Doyon <s.doyon@videotron.ca> | 2007-10-21 00:23:23 +0000 |
commit | 4e09b78f8c37cccae61523fbd52588bd06919a28 (patch) | |
tree | e0fbcd8b2d774e85940bd2a48ff7262c2e993d22 /apps | |
parent | 27615a4b6d8c14a580550c14f938bd2076fd2670 (diff) | |
download | rockbox-4e09b78f8c37cccae61523fbd52588bd06919a28.tar.gz rockbox-4e09b78f8c37cccae61523fbd52588bd06919a28.zip |
From FS#7774: use list voice callback in menus.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15234 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/menu.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/apps/menu.c b/apps/menu.c index 55f1938b80..35b2527cce 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -65,6 +65,7 @@ | |||
65 | static struct menu_item_ex *current_submenus_menu; | 65 | static struct menu_item_ex *current_submenus_menu; |
66 | static int current_subitems[MAX_MENU_SUBITEMS]; | 66 | static int current_subitems[MAX_MENU_SUBITEMS]; |
67 | static int current_subitems_count = 0; | 67 | static int current_subitems_count = 0; |
68 | static int talk_menu_item(int selected_item, void *data); | ||
68 | 69 | ||
69 | static void get_menu_callback(const struct menu_item_ex *m, | 70 | static void get_menu_callback(const struct menu_item_ex *m, |
70 | menu_callback_type *menu_callback) | 71 | menu_callback_type *menu_callback) |
@@ -207,6 +208,8 @@ static void init_menu_lists(const struct menu_item_ex *menu, | |||
207 | (void)icon; | 208 | (void)icon; |
208 | gui_synclist_set_icon_callback(lists, NULL); | 209 | gui_synclist_set_icon_callback(lists, NULL); |
209 | #endif | 210 | #endif |
211 | if(global_settings.talk_menu) | ||
212 | gui_synclist_set_voice_callback(lists, talk_menu_item); | ||
210 | gui_synclist_set_nb_items(lists,current_subitems_count); | 213 | gui_synclist_set_nb_items(lists,current_subitems_count); |
211 | gui_synclist_limit_scroll(lists,true); | 214 | gui_synclist_limit_scroll(lists,true); |
212 | gui_synclist_select_item(lists, find_menu_selection(selected)); | 215 | gui_synclist_select_item(lists, find_menu_selection(selected)); |
@@ -215,19 +218,17 @@ static void init_menu_lists(const struct menu_item_ex *menu, | |||
215 | if (callback && menu_callback) | 218 | if (callback && menu_callback) |
216 | menu_callback(ACTION_ENTER_MENUITEM,menu); | 219 | menu_callback(ACTION_ENTER_MENUITEM,menu); |
217 | gui_synclist_draw(lists); | 220 | gui_synclist_draw(lists); |
221 | gui_synclist_speak_item(lists); | ||
218 | } | 222 | } |
219 | 223 | ||
220 | static void talk_menu_item(const struct menu_item_ex *menu, | 224 | static int talk_menu_item(int selected_item, void *data) |
221 | struct gui_synclist *lists) | ||
222 | { | 225 | { |
226 | const struct menu_item_ex *menu = (const struct menu_item_ex *)data; | ||
223 | int id = -1; | 227 | int id = -1; |
224 | int type; | 228 | int type; |
225 | unsigned char *str; | 229 | unsigned char *str; |
226 | int sel; | 230 | int sel = get_menu_selection(selected_item, menu); |
227 | 231 | ||
228 | if (global_settings.talk_menu) | ||
229 | { | ||
230 | sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); | ||
231 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) | 232 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) |
232 | { | 233 | { |
233 | type = menu->submenus[sel]->flags&MENU_TYPE_MASK; | 234 | type = menu->submenus[sel]->flags&MENU_TYPE_MASK; |
@@ -271,7 +272,7 @@ static void talk_menu_item(const struct menu_item_ex *menu, | |||
271 | talk_id(id,false); | 272 | talk_id(id,false); |
272 | } | 273 | } |
273 | } | 274 | } |
274 | } | 275 | return 0; |
275 | } | 276 | } |
276 | #define MAX_OPTIONS 32 | 277 | #define MAX_OPTIONS 32 |
277 | bool do_setting_from_menu(const struct menu_item_ex *temp) | 278 | bool do_setting_from_menu(const struct menu_item_ex *temp) |
@@ -307,7 +308,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
307 | int stack_top = 0; | 308 | int stack_top = 0; |
308 | bool in_stringlist, done = false; | 309 | bool in_stringlist, done = false; |
309 | menu_callback_type menu_callback = NULL; | 310 | menu_callback_type menu_callback = NULL; |
310 | bool talk_item = false; | ||
311 | if (start_menu == NULL) | 311 | if (start_menu == NULL) |
312 | menu = &main_menu_; | 312 | menu = &main_menu_; |
313 | else menu = start_menu; | 313 | else menu = start_menu; |
@@ -320,25 +320,18 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
320 | init_menu_lists(menu,&lists,selected,true); | 320 | init_menu_lists(menu,&lists,selected,true); |
321 | in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID); | 321 | in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID); |
322 | 322 | ||
323 | talk_menu_item(menu, &lists); | ||
324 | |||
325 | /* load the callback, and only reload it if menu changes */ | 323 | /* load the callback, and only reload it if menu changes */ |
326 | get_menu_callback(menu, &menu_callback); | 324 | get_menu_callback(menu, &menu_callback); |
327 | gui_synclist_draw(&lists); | ||
328 | 325 | ||
329 | while (!done) | 326 | while (!done) |
330 | { | 327 | { |
331 | talk_item = false; | ||
332 | redraw_lists = false; | 328 | redraw_lists = false; |
333 | gui_syncstatusbar_draw(&statusbars, true); | 329 | gui_syncstatusbar_draw(&statusbars, true); |
334 | action = get_action(CONTEXT_MAINMENU,HZ); | 330 | action = get_action(CONTEXT_MAINMENU, |
331 | list_do_action_timeout(&lists, HZ)); | ||
335 | /* HZ so the status bar redraws corectly */ | 332 | /* HZ so the status bar redraws corectly */ |
336 | if (action == ACTION_NONE) | ||
337 | { | ||
338 | continue; | ||
339 | } | ||
340 | 333 | ||
341 | if (menu_callback) | 334 | if (action != ACTION_NONE && menu_callback) |
342 | { | 335 | { |
343 | int old_action = action; | 336 | int old_action = action; |
344 | action = menu_callback(action, menu); | 337 | action = menu_callback(action, menu); |
@@ -356,10 +349,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
356 | } | 349 | } |
357 | 350 | ||
358 | if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) | 351 | if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) |
359 | { | ||
360 | talk_menu_item(menu, &lists); | ||
361 | continue; | 352 | continue; |
362 | } | 353 | if (action == ACTION_NONE) |
354 | continue; | ||
363 | 355 | ||
364 | #ifdef HAVE_RECORDING | 356 | #ifdef HAVE_RECORDING |
365 | if (action == ACTION_STD_REC) | 357 | if (action == ACTION_STD_REC) |
@@ -411,7 +403,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
411 | menu_stack_selected_item[stack_top], false); | 403 | menu_stack_selected_item[stack_top], false); |
412 | /* new menu, so reload the callback */ | 404 | /* new menu, so reload the callback */ |
413 | get_menu_callback(menu, &menu_callback); | 405 | get_menu_callback(menu, &menu_callback); |
414 | talk_item = true; | ||
415 | } | 406 | } |
416 | else if (menu != &root_menu_) | 407 | else if (menu != &root_menu_) |
417 | { | 408 | { |
@@ -453,13 +444,11 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
453 | init_menu_lists(temp, &lists, 0, true); | 444 | init_menu_lists(temp, &lists, 0, true); |
454 | redraw_lists = false; /* above does the redraw */ | 445 | redraw_lists = false; /* above does the redraw */ |
455 | menu = temp; | 446 | menu = temp; |
456 | talk_item = true; | ||
457 | } | 447 | } |
458 | break; | 448 | break; |
459 | case MT_FUNCTION_CALL: | 449 | case MT_FUNCTION_CALL: |
460 | { | 450 | { |
461 | int return_value; | 451 | int return_value; |
462 | talk_item = true; | ||
463 | if (temp->flags&MENU_FUNC_USEPARAM) | 452 | if (temp->flags&MENU_FUNC_USEPARAM) |
464 | return_value = temp->function->function_w_param( | 453 | return_value = temp->function->function_w_param( |
465 | temp->function->param); | 454 | temp->function->param); |
@@ -483,7 +472,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
483 | init_menu_lists(menu, &lists, selected, true); | 472 | init_menu_lists(menu, &lists, selected, true); |
484 | redraw_lists = false; /* above does the redraw */ | 473 | redraw_lists = false; /* above does the redraw */ |
485 | } | 474 | } |
486 | talk_item = true; | ||
487 | break; | 475 | break; |
488 | } | 476 | } |
489 | case MT_RETURN_ID: | 477 | case MT_RETURN_ID: |
@@ -500,7 +488,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
500 | menu = temp; | 488 | menu = temp; |
501 | init_menu_lists(menu,&lists,0,false); | 489 | init_menu_lists(menu,&lists,0,false); |
502 | redraw_lists = false; /* above does the redraw */ | 490 | redraw_lists = false; /* above does the redraw */ |
503 | talk_item = true; | ||
504 | in_stringlist = true; | 491 | in_stringlist = true; |
505 | } | 492 | } |
506 | break; | 493 | break; |
@@ -534,11 +521,12 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
534 | ret = MENU_ATTACHED_USB; | 521 | ret = MENU_ATTACHED_USB; |
535 | done = true; | 522 | done = true; |
536 | } | 523 | } |
537 | if (talk_item && !done) | ||
538 | talk_menu_item(menu, &lists); | ||
539 | 524 | ||
540 | if (redraw_lists) | 525 | if (redraw_lists && !done) |
526 | { | ||
541 | gui_synclist_draw(&lists); | 527 | gui_synclist_draw(&lists); |
528 | gui_synclist_speak_item(&lists); | ||
529 | } | ||
542 | } | 530 | } |
543 | if (start_selected) | 531 | if (start_selected) |
544 | { | 532 | { |