diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-21 16:30:38 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-12-11 01:13:22 +0000 |
commit | dcac2c616f7e87ac3f444ecc3893107f7a91ef22 (patch) | |
tree | 23685350f1eae00285e2e5f9230cdbda1328bb66 /apps/gui | |
parent | a3684e090ea637168c2542c7b4eaade756de3fe3 (diff) | |
download | rockbox-dcac2c616f7e87ac3f444ecc3893107f7a91ef22.tar.gz rockbox-dcac2c616f7e87ac3f444ecc3893107f7a91ef22.zip |
Add setting for numeric list sort order
The sort order of numeric lists can now be changed with the
new "List Order" setting. It defaults to ascending for most
scrollwheel targets and descending for all others, matching
the old hardcoded behavior.
Change-Id: I4866f04ec5995158edf9e40badf7f661b3ddea81
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/option_select.c | 62 | ||||
-rw-r--r-- | apps/gui/option_select.h | 9 |
2 files changed, 37 insertions, 34 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 9f1f0a64e3..7068fee510 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -334,29 +334,35 @@ static int selection_to_val(const struct settings_list *setting, int selection) else if ((setting->flags & F_T_SOUND) == F_T_SOUND) { int setting_id = setting->sound_setting->setting; -#ifndef ASCENDING_INT_SETTINGS - step = sound_steps(setting_id); - max = (setting_id == SOUND_VOLUME) ? - global_settings.volume_limit : sound_max(setting_id); - /* min = sound_min(setting_id); */ -#else - step = -sound_steps(setting_id); - /* min = sound_max(setting_id); */ - max = sound_min(setting_id); -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + { + step = sound_steps(setting_id); + max = (setting_id == SOUND_VOLUME) ? + global_settings.volume_limit : sound_max(setting_id); + /* min = sound_min(setting_id); */ + } + else + { + step = -sound_steps(setting_id); + /* min = sound_max(setting_id); */ + max = sound_min(setting_id); + } } else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) { const struct int_setting *info = setting->int_setting; -#ifndef ASCENDING_INT_SETTINGS - /* min = info->min; */ - max = info->max; - step = info->step; -#else - max = info->min; - /* min = info->max; */ - step = -info->step; -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + { + /* min = info->min; */ + max = info->max; + step = info->step; + } + else + { + max = info->min; + /* min = info->max; */ + step = -info->step; + } } return max- (selection * step); } @@ -424,11 +430,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue, int max = (setting_id == SOUND_VOLUME) ? global_settings.volume_limit : sound_max(setting_id); *nb_items = (max-min)/steps + 1; -#ifndef ASCENDING_INT_SETTINGS - *selected = (max - oldvalue) / steps; -#else - *selected = (oldvalue - min) / steps; -#endif + if (global_settings.list_order == LIST_ORDER_DESCENDING) + *selected = (max - oldvalue) / steps; + else + *selected = (oldvalue - min) / steps; *function = sound_get_fn(setting_id); } else @@ -439,11 +444,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue, min = info->min; step = info->step; *nb_items = (max-min)/step + 1; -#ifndef ASCENDING_INT_SETTINGS - *selected = (max - oldvalue) / step; -#else - *selected = (oldvalue - min) / step; -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + *selected = (max - oldvalue) / step; + else + *selected = (oldvalue - min) / step; *function = info->option_callback; } } diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index 476e7b81bd..104e86f64d 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h @@ -25,11 +25,10 @@ #include "screen_access.h" #include "settings.h" -#if defined (HAVE_SCROLLWHEEL) && !defined(FIIO_M3K) -/* Define this if your target makes sense to have - smaller values at the top of the list increasing down the list */ -#define ASCENDING_INT_SETTINGS -#endif +enum { + LIST_ORDER_DESCENDING = 0, + LIST_ORDER_ASCENDING = 1, +}; bool option_screen(const struct settings_list *setting, struct viewport parent[NB_SCREENS], |