Allow settings to have a different title in the setting screen than they
have in the menu. Fixes the scroll speed/step settings git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12572 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
02a871780f
commit
97090863a6
3 changed files with 37 additions and 13 deletions
27
apps/menu.c
27
apps/menu.c
|
@ -334,12 +334,12 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer)
|
|||
|
||||
menu = menu->submenus[selected_item];
|
||||
|
||||
if (menu->flags&MENU_DYNAMIC_DESC)
|
||||
if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT))
|
||||
return menu->menu_get_name_and_icon->list_get_name(selected_item,
|
||||
menu->menu_get_name_and_icon->list_get_name_data, buffer);
|
||||
|
||||
type = (menu->flags&MENU_TYPE_MASK);
|
||||
if (type == MT_SETTING)
|
||||
if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
|
||||
{
|
||||
const struct settings_list *v
|
||||
= find_setting(menu->variable, NULL);
|
||||
|
@ -353,7 +353,7 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer)
|
|||
static void menu_get_icon(int selected_item, void * data, ICON * icon)
|
||||
{
|
||||
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
|
||||
int menu_icon;
|
||||
int menu_icon = Icon_NOICON;
|
||||
selected_item = get_menu_selection(selected_item, menu);
|
||||
|
||||
menu = menu->submenus[selected_item];
|
||||
|
@ -365,6 +365,7 @@ static void menu_get_icon(int selected_item, void * data, ICON * icon)
|
|||
switch (menu->flags&MENU_TYPE_MASK)
|
||||
{
|
||||
case MT_SETTING:
|
||||
case MT_SETTING_W_TEXT:
|
||||
*icon = bitmap_icons_6x8[Icon_Menu_setting];
|
||||
break;
|
||||
case MT_MENU:
|
||||
|
@ -438,12 +439,14 @@ static void talk_menu_item(const struct menu_item_ex *menu,
|
|||
struct gui_synclist *lists)
|
||||
{
|
||||
int id = -1;
|
||||
int type;
|
||||
if (global_settings.talk_menu)
|
||||
{
|
||||
int sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu);
|
||||
if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)
|
||||
{
|
||||
if ((menu->submenus[sel]->flags&MENU_TYPE_MASK) == MT_SETTING)
|
||||
type = menu->submenus[sel]->flags&MENU_TYPE_MASK;
|
||||
if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
|
||||
talk_setting(menu->submenus[sel]->variable);
|
||||
else
|
||||
{
|
||||
|
@ -463,8 +466,14 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
|
|||
temp->variable,
|
||||
&setting_id);
|
||||
bool ret_val = false;
|
||||
unsigned char *title;
|
||||
if (setting)
|
||||
{
|
||||
if ((temp->flags&MENU_TYPE_MASK) == MT_SETTING_W_TEXT)
|
||||
title = temp->callback_and_desc->desc;
|
||||
else
|
||||
title = ID2P(setting->lang_id);
|
||||
|
||||
if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING)
|
||||
{
|
||||
bool temp_var, *var;
|
||||
|
@ -478,7 +487,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
|
|||
{
|
||||
var = (bool*)setting->setting;
|
||||
}
|
||||
set_bool_options(str(setting->lang_id),var,
|
||||
set_bool_options(P2STR(title), var,
|
||||
STR(setting->bool_setting->lang_yes),
|
||||
STR(setting->bool_setting->lang_no),
|
||||
setting->bool_setting->option_callback);
|
||||
|
@ -489,7 +498,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
|
|||
}
|
||||
else if (setting->flags&F_T_SOUND)
|
||||
{
|
||||
set_sound(str(setting->lang_id), setting->setting,
|
||||
set_sound(P2STR(title), setting->setting,
|
||||
setting->sound_setting->setting);
|
||||
}
|
||||
else /* other setting, must be an INT type */
|
||||
|
@ -519,8 +528,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
|
|||
min = setting->int_setting->min;
|
||||
step = setting->int_setting->step;
|
||||
}
|
||||
set_int_ex(str(setting->lang_id),
|
||||
NULL,
|
||||
set_int_ex(P2STR(title), NULL,
|
||||
setting->int_setting->unit,var,
|
||||
setting->int_setting->option_callback,
|
||||
step, min, max,
|
||||
|
@ -561,7 +569,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
|
|||
j++;
|
||||
}
|
||||
}
|
||||
set_option(str(setting->lang_id), var, INT,
|
||||
set_option(P2STR(title), var, INT,
|
||||
options,j,
|
||||
setting->
|
||||
choice_setting->option_callback);
|
||||
|
@ -721,6 +729,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
|
|||
temp->func_with_param->param);
|
||||
break;
|
||||
case MT_SETTING:
|
||||
case MT_SETTING_W_TEXT:
|
||||
{
|
||||
if (do_setting_from_menu(temp))
|
||||
init_menu_lists(menu, &lists, 0, true);
|
||||
|
|
11
apps/menu.h
11
apps/menu.h
|
@ -60,6 +60,9 @@ void menu_talk_selected(int m);
|
|||
enum menu_item_type {
|
||||
MT_MENU = 0,
|
||||
MT_SETTING,
|
||||
MT_SETTING_W_TEXT, /* same as setting, but uses different
|
||||
text for the setting title,
|
||||
ID2P() or "literal" for the str param */
|
||||
MT_FUNCTION_CALL, /* used when the standard code wont work */
|
||||
MT_FUNCTION_WITH_PARAM,
|
||||
MT_RETURN_ID, /* returns the position of the selected item (starting at 0)*/
|
||||
|
@ -134,6 +137,14 @@ bool do_setting_from_menu(const struct menu_item_ex *temp);
|
|||
static const struct menu_item_ex name = \
|
||||
{MT_SETTING, {.variable = (void*)var},{callback}};
|
||||
|
||||
/* Use this for settings which have a differnt title in their
|
||||
setting screen than in the menu (e.g scroll options */
|
||||
#define MENUITEM_SETTING_W_TEXT(name, var, str, callback ) \
|
||||
static const struct menu_callback_with_desc name##__ = {callback,str, Icon_NOICON};\
|
||||
static const struct menu_item_ex name = \
|
||||
{MT_SETTING_W_TEXT|MENU_HAS_DESC, {.variable = (void*)var }, \
|
||||
{.callback_and_desc = & name##__}};
|
||||
|
||||
/* Use this To create a list of NON-XLATABLE (for the time being) Strings
|
||||
When the user enters this list and selects one, the menu will exits
|
||||
and its return value will be the index of the chosen item */
|
||||
|
|
|
@ -279,16 +279,20 @@ MAKE_MENU(lcd_remote_settings, ID2P(LANG_LCD_REMOTE_MENU),
|
|||
|
||||
/***********************************/
|
||||
/* SCROLL MENU */
|
||||
MENUITEM_SETTING(scroll_speed, &global_settings.scroll_speed, NULL);
|
||||
MENUITEM_SETTING_W_TEXT(scroll_speed, &global_settings.scroll_speed,
|
||||
ID2P(LANG_SCROLL), NULL);
|
||||
MENUITEM_SETTING(scroll_delay, &global_settings.scroll_delay, NULL);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
MENUITEM_SETTING(scroll_step, &global_settings.scroll_step, NULL);
|
||||
MENUITEM_SETTING_W_TEXT(scroll_step, &global_settings.scroll_step,
|
||||
ID2P(LANG_SCROLL_STEP_EXAMPLE), NULL);
|
||||
#endif
|
||||
MENUITEM_SETTING(bidir_limit, &global_settings.bidir_limit, NULL);
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
MENUITEM_SETTING(remote_scroll_speed, &global_settings.remote_scroll_speed, NULL);
|
||||
MENUITEM_SETTING_W_TEXT(remote_scroll_speed, &global_settings.remote_scroll_speed,
|
||||
ID2P(LANG_SCROLL), NULL);
|
||||
MENUITEM_SETTING(remote_scroll_delay, &global_settings.remote_scroll_delay, NULL);
|
||||
MENUITEM_SETTING(remote_scroll_step, &global_settings.remote_scroll_step, NULL);
|
||||
MENUITEM_SETTING_W_TEXT(remote_scroll_step, &global_settings.remote_scroll_step,
|
||||
ID2P(LANG_SCROLL_STEP_EXAMPLE), NULL);
|
||||
MENUITEM_SETTING(remote_bidir_limit, &global_settings.remote_bidir_limit, NULL);
|
||||
MAKE_MENU(remote_scroll_sets, ID2P(LANG_REMOTE_SCROLL_SETS), 0, Icon_NOICON,
|
||||
&remote_scroll_speed, &remote_scroll_delay,
|
||||
|
|
Loading…
Reference in a new issue