summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-05-15 06:58:36 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-05-15 06:58:36 +0000
commit3e5b38945ce91fec163d252fb83e4b3c52cbbc15 (patch)
tree432d25ede2866864a25ea8d1313946c1dbdf827c /apps/gui
parent6450de3eae5a05bf6539e0b02ba1055364424cd4 (diff)
downloadrockbox-3e5b38945ce91fec163d252fb83e4b3c52cbbc15.zip
rockbox-3e5b38945ce91fec163d252fb83e4b3c52cbbc15.tar.gz
rockbox-3e5b38945ce91fec163d252fb83e4b3c52cbbc15.tar.bz2
rockbox-3e5b38945ce91fec163d252fb83e4b3c52cbbc15.tar.xz
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
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/option_select.c35
-rw-r--r--apps/gui/option_select.h6
2 files changed, 30 insertions, 11 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 8798ea1..c3c2cb3 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -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)
{
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
index 866b8cf..16465cf 100644
--- a/apps/gui/option_select.h
+++ b/apps/gui/option_select.h
@@ -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);