From b918ec531b6d67534f3565be2338723459f994c6 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Thu, 29 Feb 2024 17:05:19 +0200 Subject: 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 --- apps/gui/option_select.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'apps/gui') 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; } } -- cgit v1.2.3