const raid in option_select

add table settings and fix int settings with negative step in option_select_next_val
bump plugin API and sort newer functions


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17520 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2008-05-15 06:58:36 +00:00
parent 6450de3eae
commit 3e5b38945c
4 changed files with 73 additions and 53 deletions

View file

@ -43,7 +43,7 @@
#define ASCENDING_INT_SETTINGS
#endif
static int selection_to_val(struct settings_list *setting, int selection);
static int selection_to_val(const struct settings_list *setting, int selection);
static const char *unit_strings[] =
{
@ -60,7 +60,7 @@ static const char *unit_strings[] =
/* these two vars are needed so arbitrary values can be added to the
TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
static int table_setting_oldval = 0, table_setting_array_position = 0;
char *option_get_valuestring(struct settings_list *setting,
char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var)
{
@ -215,7 +215,7 @@ static int option_talk(int selected_item, void * data)
}
#ifdef HAVE_QUICKSCREEN /* only the quickscreen uses this so far */
void option_select_next_val(struct settings_list *setting,
void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply)
{
int val = 0;
@ -230,15 +230,18 @@ void option_select_next_val(struct settings_list *setting,
else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{
struct int_setting *info = (struct int_setting *)setting->int_setting;
int step = info->step;
if (step < 0)
step = -step;
if (!previous)
{
val = *value + info->step;
val = *value + step;
if (val > info->max)
val = info->min;
}
else
{
val = *value - info->step;
val = *value - step;
if (val < info->min)
val = info->max;
}
@ -283,11 +286,27 @@ void option_select_next_val(struct settings_list *setting,
if (apply && info->option_callback)
info->option_callback(*(int*)value);
}
else if ((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING)
{
const struct table_setting *tbl_info = setting->table_setting;
int i, add;
add = previous?tbl_info->count-1:1;
for (i=0; i<tbl_info->count;i++)
{
if ((*value == tbl_info->values[i]) ||
(settings->flags&F_ALLOW_ARBITRARY_VALS &&
*value < tbl_info->values[i]))
{
val = tbl_info->values[(i+add)%tbl_info->count];
break;
}
}
}
*value = val;
}
#endif
static int selection_to_val(struct settings_list *setting, int selection)
static int selection_to_val(const struct settings_list *setting, int selection)
{
int min = 0, max = 0, step = 1;
if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) ||
@ -354,7 +373,7 @@ static void bool_funcwrapper(int value)
boolfunction(false);
}
static void val_to_selection(struct settings_list *setting, int oldvalue,
static void val_to_selection(const struct settings_list *setting, int oldvalue,
int *nb_items, int *selected,
void (**function)(int))
{
@ -430,7 +449,7 @@ static void val_to_selection(struct settings_list *setting, int oldvalue,
}
}
bool option_screen(struct settings_list *setting,
bool option_screen(const struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title)
{

View file

@ -23,14 +23,14 @@
#include "screen_access.h"
#include "settings.h"
bool option_screen(struct settings_list *setting,
bool option_screen(const struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title);
void option_select_next_val(struct settings_list *setting,
void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply);
char *option_get_valuestring(struct settings_list *setting,
char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var);
void option_talk_value(const struct settings_list *setting, int value, bool enqueue);

View file

@ -128,6 +128,9 @@ static const struct plugin_api rockbox_api = {
#endif /* LCD_DEPTH */
lcd_puts_style,
lcd_puts_scroll_style,
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display,
#endif /* HAVE_LCD_INVERT */
bidi_l2v,
font_get_bits,
font_load,
@ -141,6 +144,9 @@ static const struct plugin_api rockbox_api = {
backlight_on,
backlight_off,
backlight_set_timeout,
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness,
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#if CONFIG_CHARGING
backlight_set_timeout_plugged,
@ -215,11 +221,26 @@ static const struct plugin_api rockbox_api = {
button_get,
button_get_w_tmo,
button_status,
#ifdef HAVE_BUTTON_DATA
button_get_data,
#endif
button_clear_queue,
button_queue_count,
#ifdef HAS_BUTTON_HOLD
button_hold,
#endif
#ifdef HAVE_TOUCHPAD
touchpad_set_mode,
#endif
#ifdef HAVE_BUTTON_LIGHT
buttonlight_set_timeout,
buttonlight_off,
buttonlight_on,
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
buttonlight_set_brightness,
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* HAVE_BUTTON_LIGHT */
/* file */
(open_func)PREFIX(open),
@ -578,26 +599,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness,
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display,
#endif /* HAVE_LCD_INVERT */
#ifdef HAVE_BUTTON_DATA
button_get_data,
#endif /* HAVE_BUTTON_DATA */
#ifdef HAVE_TOUCHPAD
touchpad_set_mode,
#endif /* HAVE_TOUCHPAD */
#ifdef HAVE_BUTTON_LIGHT
buttonlight_set_timeout,
buttonlight_off,
buttonlight_on,
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
buttonlight_set_brightness,
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* HAVE_BUTTON_LIGHT */
};
int plugin_load(const char* plugin, const void* parameter)

View file

@ -212,6 +212,9 @@ struct plugin_api {
void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
int style);
#ifdef HAVE_LCD_INVERT
void (*lcd_set_invert_display)(bool yesno);
#endif /* HAVE_LCD_INVERT */
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
@ -232,6 +235,9 @@ struct plugin_api {
void (*backlight_on)(void);
void (*backlight_off)(void);
void (*backlight_set_timeout)(int index);
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
void (*backlight_set_brightness)(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#if CONFIG_CHARGING
void (*backlight_set_timeout_plugged)(int index);
@ -311,12 +317,26 @@ struct plugin_api {
/* button */
long (*button_get)(bool block);
long (*button_get_w_tmo)(int ticks);
#ifdef HAVE_BUTTON_DATA
intptr_t (*button_get_data)(void);
#endif
#ifdef HAVE_TOUCHPAD
void (*touchpad_set_mode)(enum touchpad_mode);
#endif
int (*button_status)(void);
void (*button_clear_queue)(void);
int (*button_queue_count)(void);
#ifdef HAS_BUTTON_HOLD
bool (*button_hold)(void);
#endif
#ifdef HAVE_BUTTON_LIGHT
void (*buttonlight_set_timeout)(int value);
void (*buttonlight_off)(void);
void (*buttonlight_on)(void);
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
void (*buttonlight_set_brightness)(int val);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* HAVE_BUTTON_LIGHT */
/* file */
int (*PREFIX(open))(const char* pathname, int flags);
@ -569,7 +589,7 @@ struct plugin_api {
/* options */
const struct settings_list* (*find_setting)(const void* variable, int *id);
bool (*option_screen)(struct settings_list *setting,
bool (*option_screen)(const struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title);
bool (*set_option)(const char* string, const void* variable,
@ -725,26 +745,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
void (*backlight_set_brightness)(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_LCD_INVERT
void (*lcd_set_invert_display)(bool yesno);
#endif /* HAVE_LCD_INVERT */
#ifdef HAVE_BUTTON_DATA
intptr_t (*button_get_data)(void);
#endif /* HAVE_BUTTON_DATA */
#ifdef HAVE_TOUCHPAD
void (*touchpad_set_mode)(enum touchpad_mode);
#endif /* HAVE_TOUCHPAD */
#ifdef HAVE_BUTTON_LIGHT
void (*buttonlight_set_timeout)(int value);
void (*buttonlight_off)(void);
void (*buttonlight_on)(void);
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
void (*buttonlight_set_brightness)(int val);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* HAVE_BUTTON_LIGHT */
};
/* plugin header */