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
This commit is contained in:
Roman Artiukhin 2024-02-29 17:05:19 +02:00
parent cff56c8e8c
commit b918ec531b

View file

@ -219,10 +219,15 @@ static int option_talk(int selected_item, void * data)
void option_select_next_val(const struct settings_list *setting, void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply) bool previous, bool apply)
{ {
bool repeated = get_action_statuscode(NULL) & ACTION_REPEAT;
int val = 0; int val = 0;
int *value = setting->setting; int *value = setting->setting;
if (HASFLAG(setting, F_BOOL_SETTING)) if (HASFLAG(setting, F_BOOL_SETTING))
{ {
if (repeated)
return;
*(bool*)value = !*(bool*)value; *(bool*)value = !*(bool*)value;
if (apply && setting->bool_setting->option_callback) if (apply && setting->bool_setting->option_callback)
setting->bool_setting->option_callback(*(bool*)value); 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; val = *value + info->step;
if (neg_step ? (val < info->max) : (val > info->max)) if (neg_step ? (val < info->max) : (val > info->max))
val = info->min; val = repeated ? *value : info->min;
} }
else else
{ {
val = *value - info->step; val = *value - info->step;
if (neg_step ? (val > info->min) : (val < info->min)) if (neg_step ? (val > info->min) : (val < info->min))
val = info->max; val = repeated ? *value : info->max;
} }
*value = val; *value = val;
if (apply && info->option_callback) if (apply && info->option_callback)
@ -258,13 +263,13 @@ void option_select_next_val(const struct settings_list *setting,
{ {
val = *value + steps; val = *value + steps;
if (val >= max) if (val >= max)
val = min; val = repeated ? *value : min;
} }
else else
{ {
val = *value - steps; val = *value - steps;
if (val < min) if (val < min)
val = max; val = repeated ? *value : max;
} }
*value = val; *value = val;
if (apply) if (apply)
@ -277,13 +282,13 @@ void option_select_next_val(const struct settings_list *setting,
{ {
val = *value + 1; val = *value + 1;
if (val >= info->count) if (val >= info->count)
val = 0; val = repeated ? *value : 0;
} }
else else
{ {
val = *value - 1; val = *value - 1;
if (val < 0) if (val < 0)
val = info->count-1; val = repeated ? *value : info->count-1;
} }
*value = val; *value = val;
if (apply && info->option_callback) 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 && (settings->flags&F_ALLOW_ARBITRARY_VALS &&
*value < tbl_info->values[i])) *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; break;
} }
} }