summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Artiukhin <bahusdrive@gmail.com>2024-02-29 17:05:19 +0200
committerRoman Artiukhin <bahusdrive@gmail.com>2024-07-29 18:20:39 +0300
commitb918ec531b6d67534f3565be2338723459f994c6 (patch)
treed069dde9c795cffb8a168fd37cb1fe3323a710d2
parentcff56c8e8cd966e9a78e45fba658927bbdc25b59 (diff)
downloadrockbox-b918ec531b.tar.gz
rockbox-b918ec531b.zip
QuickScreen: stop for first/last entry on repeated actions
Stops on first/last setting value when you switch quick setting using long button press. Useful for long settings list (like Skip Length). Change-Id: Id7ddae4f70554e7f523661e5f0e09f5e4d5d32fd
-rw-r--r--apps/gui/option_select.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 6d1d2df370..65f2a0491d 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -219,10 +219,15 @@ static int option_talk(int selected_item, void * data)
void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply)
{
+ bool repeated = get_action_statuscode(NULL) & ACTION_REPEAT;
+
int val = 0;
int *value = setting->setting;
if (HASFLAG(setting, F_BOOL_SETTING))
{
+ if (repeated)
+ return;
+
*(bool*)value = !*(bool*)value;
if (apply && setting->bool_setting->option_callback)
setting->bool_setting->option_callback(*(bool*)value);
@@ -236,13 +241,13 @@ void option_select_next_val(const struct settings_list *setting,
{
val = *value + info->step;
if (neg_step ? (val < info->max) : (val > info->max))
- val = info->min;
+ val = repeated ? *value : info->min;
}
else
{
val = *value - info->step;
if (neg_step ? (val > info->min) : (val < info->min))
- val = info->max;
+ val = repeated ? *value : info->max;
}
*value = val;
if (apply && info->option_callback)
@@ -258,13 +263,13 @@ void option_select_next_val(const struct settings_list *setting,
{
val = *value + steps;
if (val >= max)
- val = min;
+ val = repeated ? *value : min;
}
else
{
val = *value - steps;
if (val < min)
- val = max;
+ val = repeated ? *value : max;
}
*value = val;
if (apply)
@@ -277,13 +282,13 @@ void option_select_next_val(const struct settings_list *setting,
{
val = *value + 1;
if (val >= info->count)
- val = 0;
+ val = repeated ? *value : 0;
}
else
{
val = *value - 1;
if (val < 0)
- val = info->count-1;
+ val = repeated ? *value : info->count-1;
}
*value = val;
if (apply && info->option_callback)
@@ -300,7 +305,11 @@ void option_select_next_val(const struct settings_list *setting,
(settings->flags&F_ALLOW_ARBITRARY_VALS &&
*value < tbl_info->values[i]))
{
- val = tbl_info->values[(i+add)%tbl_info->count];
+ int index = (i+add)%tbl_info->count;
+ if (repeated && ((i == 0 && previous) || (!previous && i == tbl_info->count -1)))
+ val = *value;
+ else
+ val = tbl_info->values[index];
break;
}
}