Add a voice callback to dynamic menus, along side the text_callback.
From FS#7563. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15042 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3fd073ed4d
commit
5acf091046
6 changed files with 49 additions and 37 deletions
22
apps/menu.c
22
apps/menu.c
|
@ -237,12 +237,22 @@ static void talk_menu_item(const struct menu_item_ex *menu,
|
|||
{
|
||||
if (menu->submenus[sel]->flags&(MENU_DYNAMIC_DESC))
|
||||
{
|
||||
char buffer[80];
|
||||
str = menu->submenus[sel]->menu_get_name_and_icon->
|
||||
list_get_name(sel, menu->submenus[sel]->
|
||||
menu_get_name_and_icon->
|
||||
list_get_name_data, buffer);
|
||||
id = P2ID(str);
|
||||
int (*list_speak_item)(int selected_item, void * data)
|
||||
= menu->submenus[sel]->menu_get_name_and_icon->
|
||||
list_speak_item;
|
||||
if(list_speak_item)
|
||||
list_speak_item(sel, menu->submenus[sel]->
|
||||
menu_get_name_and_icon->
|
||||
list_get_name_data);
|
||||
else
|
||||
{
|
||||
char buffer[80];
|
||||
str = menu->submenus[sel]->menu_get_name_and_icon->
|
||||
list_get_name(sel, menu->submenus[sel]->
|
||||
menu_get_name_and_icon->
|
||||
list_get_name_data, buffer);
|
||||
id = P2ID(str);
|
||||
}
|
||||
}
|
||||
else
|
||||
id = P2ID(menu->submenus[sel]->callback_and_desc->desc);
|
||||
|
|
14
apps/menu.h
14
apps/menu.h
|
@ -90,6 +90,7 @@ struct menu_item_ex {
|
|||
int (*menu_callback)(int action,
|
||||
const struct menu_item_ex *this_item);
|
||||
char *(*list_get_name)(int selected_item, void * data, char *buffer);
|
||||
int (*list_speak_item)(int selected_item, void * data);
|
||||
void *list_get_name_data;
|
||||
int icon_id;
|
||||
} *menu_get_name_and_icon;
|
||||
|
@ -165,9 +166,9 @@ int do_menu(const struct menu_item_ex *menu, int *start_selected);
|
|||
|
||||
/* same as above, except the item name is dynamic */
|
||||
#define MENUITEM_RETURNVALUE_DYNTEXT(name, val, cb, text_callback, \
|
||||
text_cb_data, icon) \
|
||||
voice_callback, text_cb_data, icon) \
|
||||
static const struct menu_get_name_and_icon name##_ \
|
||||
= {cb,text_callback,text_cb_data,icon}; \
|
||||
= {cb,text_callback,voice_callback,text_cb_data,icon}; \
|
||||
static const struct menu_item_ex name = \
|
||||
{ MT_RETURN_VALUE|MENU_DYNAMIC_DESC, { .value = val}, \
|
||||
{.menu_get_name_and_icon = & name##_}};
|
||||
|
@ -187,10 +188,11 @@ int do_menu(const struct menu_item_ex *menu, int *start_selected);
|
|||
{ .function = & name##__}, {.callback_and_desc = & name##_}};
|
||||
|
||||
/* As above, except the text is dynamic */
|
||||
#define MENUITEM_FUNCTION_DYNTEXT(name, flags, func, param, \
|
||||
text_callback, text_cb_data, callback, icon) \
|
||||
static const struct menu_get_name_and_icon name##_ \
|
||||
= {callback,text_callback,text_cb_data,icon}; \
|
||||
#define MENUITEM_FUNCTION_DYNTEXT(name, flags, func, param, \
|
||||
text_callback, voice_callback, \
|
||||
text_cb_data, callback, icon) \
|
||||
static const struct menu_get_name_and_icon name##_ \
|
||||
= {callback,text_callback,voice_callback,text_cb_data,icon}; \
|
||||
static const struct menu_func name##__ = {{(void*)func}, param}; \
|
||||
static const struct menu_item_ex name = \
|
||||
{ MT_FUNCTION_CALL|MENU_DYNAMIC_DESC|flags, \
|
||||
|
|
|
@ -145,21 +145,21 @@ MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, dsp_set_coefs_callback)
|
|||
MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, dsp_set_coefs_callback);
|
||||
MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, dsp_set_coefs_callback);
|
||||
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM, do_option, (void*)&gain_0,
|
||||
gainitem_get_name, &global_settings.eq_band0_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_1, MENU_FUNC_USEPARAM, do_option, (void*)&gain_1,
|
||||
gainitem_get_name, &global_settings.eq_band1_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_2, MENU_FUNC_USEPARAM, do_option, (void*)&gain_2,
|
||||
gainitem_get_name, &global_settings.eq_band2_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_3, MENU_FUNC_USEPARAM, do_option, (void*)&gain_3,
|
||||
gainitem_get_name, &global_settings.eq_band3_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_4, MENU_FUNC_USEPARAM, do_option, (void*)&gain_4,
|
||||
gainitem_get_name, &global_settings.eq_band4_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM, do_option,
|
||||
(void*)&gain_0, gainitem_get_name, NULL, &global_settings.eq_band0_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_1, MENU_FUNC_USEPARAM, do_option,
|
||||
(void*)&gain_1, gainitem_get_name, NULL, &global_settings.eq_band1_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_2, MENU_FUNC_USEPARAM, do_option,
|
||||
(void*)&gain_2, gainitem_get_name, NULL, &global_settings.eq_band2_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_3, MENU_FUNC_USEPARAM, do_option,
|
||||
(void*)&gain_3, gainitem_get_name, NULL, &global_settings.eq_band3_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION_DYNTEXT(gain_item_4, MENU_FUNC_USEPARAM, do_option,
|
||||
(void*)&gain_4, gainitem_get_name, NULL, &global_settings.eq_band4_cutoff,
|
||||
NULL, Icon_NOICON);
|
||||
|
||||
MAKE_MENU(gain_menu, ID2P(LANG_EQUALIZER_GAIN), NULL, Icon_NOICON, &gain_item_0,
|
||||
&gain_item_1, &gain_item_2, &gain_item_3, &gain_item_4);
|
||||
|
@ -195,15 +195,15 @@ int do_center_band_menu(void* param)
|
|||
}
|
||||
MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL,
|
||||
Icon_EQ, &cutoff_0, &q_0, &gain_0);
|
||||
MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM,
|
||||
do_center_band_menu, (void*)1,
|
||||
centerband_get_name, (void*)1, NULL, Icon_EQ);
|
||||
MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM,
|
||||
do_center_band_menu, (void*)1,
|
||||
centerband_get_name, NULL, (void*)1, NULL, Icon_EQ);
|
||||
MENUITEM_FUNCTION_DYNTEXT(band_2_menu, MENU_FUNC_USEPARAM,
|
||||
do_center_band_menu, (void*)2,
|
||||
centerband_get_name, (void*)2, NULL, Icon_EQ);
|
||||
do_center_band_menu, (void*)2,
|
||||
centerband_get_name, NULL, (void*)2, NULL, Icon_EQ);
|
||||
MENUITEM_FUNCTION_DYNTEXT(band_3_menu, MENU_FUNC_USEPARAM,
|
||||
do_center_band_menu, (void*)3,
|
||||
centerband_get_name, (void*)3, NULL, Icon_EQ);
|
||||
do_center_band_menu, (void*)3,
|
||||
centerband_get_name, NULL, (void*)3, NULL, Icon_EQ);
|
||||
MAKE_MENU(band_4_menu, ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), NULL,
|
||||
Icon_EQ, &cutoff_4, &q_4, &gain_4);
|
||||
|
||||
|
|
|
@ -1001,7 +1001,7 @@ static int ratingitem_callback(int action,const struct menu_item_ex *this_item)
|
|||
return action;
|
||||
}
|
||||
MENUITEM_FUNCTION_DYNTEXT(rating_item, 0, set_rating_inline,
|
||||
NULL, rating_name, NULL,
|
||||
NULL, rating_name, NULL, NULL,
|
||||
ratingitem_callback, Icon_Questionmark);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1333,7 +1333,7 @@ static int toggle_radio_mode(void)
|
|||
}
|
||||
MENUITEM_FUNCTION_DYNTEXT(radio_mode_item, 0,
|
||||
toggle_radio_mode, NULL,
|
||||
get_mode_text, NULL, NULL, Icon_NOICON);
|
||||
get_mode_text, NULL, NULL, NULL, Icon_NOICON);
|
||||
#endif
|
||||
|
||||
static int scan_presets(void)
|
||||
|
|
|
@ -362,7 +362,7 @@ char *get_wps_item_name(int selected_item, void * data, char *buffer)
|
|||
return ID2P(LANG_RESUME_PLAYBACK);
|
||||
}
|
||||
MENUITEM_RETURNVALUE_DYNTEXT(wps_item, GO_TO_WPS, NULL, get_wps_item_name,
|
||||
NULL, Icon_Playback_menu);
|
||||
NULL, NULL, Icon_Playback_menu);
|
||||
#ifdef HAVE_RECORDING
|
||||
MENUITEM_RETURNVALUE(rec, ID2P(LANG_RECORDING), GO_TO_RECSCREEN,
|
||||
NULL, Icon_Recording);
|
||||
|
|
Loading…
Reference in a new issue