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 #define ASCENDING_INT_SETTINGS
#endif #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[] = 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 /* 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 */ TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
static int table_setting_oldval = 0, table_setting_array_position = 0; 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, char *buffer, int buf_len,
intptr_t temp_var) 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 */ #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) bool previous, bool apply)
{ {
int val = 0; 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) else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{ {
struct int_setting *info = (struct int_setting *)setting->int_setting; struct int_setting *info = (struct int_setting *)setting->int_setting;
int step = info->step;
if (step < 0)
step = -step;
if (!previous) if (!previous)
{ {
val = *value + info->step; val = *value + step;
if (val > info->max) if (val > info->max)
val = info->min; val = info->min;
} }
else else
{ {
val = *value - info->step; val = *value - step;
if (val < info->min) if (val < info->min)
val = info->max; val = info->max;
} }
@ -283,11 +286,27 @@ void option_select_next_val(struct settings_list *setting,
if (apply && info->option_callback) if (apply && info->option_callback)
info->option_callback(*(int*)value); 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; *value = val;
} }
#endif #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; int min = 0, max = 0, step = 1;
if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) || if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) ||
@ -354,7 +373,7 @@ static void bool_funcwrapper(int value)
boolfunction(false); 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, int *nb_items, int *selected,
void (**function)(int)) 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], struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title) bool use_temp_var, unsigned char* option_title)
{ {

View file

@ -23,14 +23,14 @@
#include "screen_access.h" #include "screen_access.h"
#include "settings.h" #include "settings.h"
bool option_screen(struct settings_list *setting, bool option_screen(const struct settings_list *setting,
struct viewport parent[NB_SCREENS], struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title); 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); 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, char *buffer, int buf_len,
intptr_t temp_var); intptr_t temp_var);
void option_talk_value(const struct settings_list *setting, int value, bool enqueue); 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 */ #endif /* LCD_DEPTH */
lcd_puts_style, lcd_puts_style,
lcd_puts_scroll_style, lcd_puts_scroll_style,
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display,
#endif /* HAVE_LCD_INVERT */
bidi_l2v, bidi_l2v,
font_get_bits, font_get_bits,
font_load, font_load,
@ -141,6 +144,9 @@ static const struct plugin_api rockbox_api = {
backlight_on, backlight_on,
backlight_off, backlight_off,
backlight_set_timeout, backlight_set_timeout,
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness,
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#if CONFIG_CHARGING #if CONFIG_CHARGING
backlight_set_timeout_plugged, backlight_set_timeout_plugged,
@ -215,11 +221,26 @@ static const struct plugin_api rockbox_api = {
button_get, button_get,
button_get_w_tmo, button_get_w_tmo,
button_status, button_status,
#ifdef HAVE_BUTTON_DATA
button_get_data,
#endif
button_clear_queue, button_clear_queue,
button_queue_count, button_queue_count,
#ifdef HAS_BUTTON_HOLD #ifdef HAS_BUTTON_HOLD
button_hold, button_hold,
#endif #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 */ /* file */
(open_func)PREFIX(open), (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 /* new stuff at the end, sort into place next time
the API gets incompatible */ 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) 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_style)(int x, int y, const unsigned char *str, int style);
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string, void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
int style); 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 ); unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); 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_on)(void);
void (*backlight_off)(void); void (*backlight_off)(void);
void (*backlight_set_timeout)(int index); void (*backlight_set_timeout)(int index);
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
void (*backlight_set_brightness)(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#if CONFIG_CHARGING #if CONFIG_CHARGING
void (*backlight_set_timeout_plugged)(int index); void (*backlight_set_timeout_plugged)(int index);
@ -311,12 +317,26 @@ struct plugin_api {
/* button */ /* button */
long (*button_get)(bool block); long (*button_get)(bool block);
long (*button_get_w_tmo)(int ticks); 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); int (*button_status)(void);
void (*button_clear_queue)(void); void (*button_clear_queue)(void);
int (*button_queue_count)(void); int (*button_queue_count)(void);
#ifdef HAS_BUTTON_HOLD #ifdef HAS_BUTTON_HOLD
bool (*button_hold)(void); bool (*button_hold)(void);
#endif #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 */ /* file */
int (*PREFIX(open))(const char* pathname, int flags); int (*PREFIX(open))(const char* pathname, int flags);
@ -569,7 +589,7 @@ struct plugin_api {
/* options */ /* options */
const struct settings_list* (*find_setting)(const void* variable, int *id); 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], struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title); bool use_temp_var, unsigned char* option_title);
bool (*set_option)(const char* string, const void* variable, 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 /* new stuff at the end, sort into place next time
the API gets incompatible */ 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 */ /* plugin header */