summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-11-21 16:30:38 +0000
committerAidan MacDonald <amachronic@protonmail.com>2021-12-11 01:13:22 +0000
commitdcac2c616f7e87ac3f444ecc3893107f7a91ef22 (patch)
tree23685350f1eae00285e2e5f9230cdbda1328bb66 /apps
parenta3684e090ea637168c2542c7b4eaade756de3fe3 (diff)
downloadrockbox-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')
-rw-r--r--apps/gui/option_select.c62
-rw-r--r--apps/gui/option_select.h9
-rw-r--r--apps/lang/english.lang44
-rw-r--r--apps/menus/display_menu.c2
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_list.c9
6 files changed, 92 insertions, 35 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],
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 333527c71c..bb992f65c1 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -16149,4 +16149,46 @@
<voice>
*: "Show Shutdown Message"
</voice>
-</phrase> \ No newline at end of file
+</phrase>
+<phrase>
+ id: LANG_LIST_ORDER
+ desc: in Settings
+ user: core
+ <source>
+ *: "List Order"
+ </source>
+ <dest>
+ *: "List Order"
+ </dest>
+ <voice>
+ *: "List Order"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_ASCENDING
+ desc: in Settings
+ user: core
+ <source>
+ *: "Ascending"
+ </source>
+ <dest>
+ *: "Ascending"
+ </dest>
+ <voice>
+ *: "Ascending"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_DESCENDING
+ desc: in Settings
+ user: core
+ <source>
+ *: "Descending"
+ </source>
+ <dest>
+ *: "Descending"
+ </dest>
+ <voice>
+ *: "Descending"
+ </voice>
+</phrase>
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index 7a4d81284a..ea3fdc0858 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -366,6 +366,7 @@ static int listwraparound_callback(int action,
}
MENUITEM_SETTING(list_wraparound, &global_settings.list_wraparound, listwraparound_callback);
+MENUITEM_SETTING(list_order, &global_settings.list_order, NULL);
MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
&scroll_speed, &scroll_delay,
@@ -377,6 +378,7 @@ MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
&offset_out_of_view, &screen_scroll_step,
&scroll_paginated,
&list_wraparound,
+ &list_order,
#ifndef HAVE_WHEEL_ACCELERATION
&list_accel_start_delay, &list_accel_wait
#endif
diff --git a/apps/settings.h b/apps/settings.h
index 4374cc720b..79b47f6a0f 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -531,6 +531,7 @@ struct user_settings
0=goto previous location */
bool scroll_paginated; /* 0=dont 1=do */
bool list_wraparound; /* wrap around to opposite end of list when scrolling */
+ int list_order; /* order for numeric lists (ascending or descending) */
int scroll_speed; /* long texts scrolling speed: 1-30 */
int bidir_limit; /* bidir scroll length limit */
int scroll_delay; /* delay (in 1/10s) before starting scroll */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index d8702148ba..f93b3c272a 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1216,6 +1216,15 @@ const struct settings_list settings[] = {
false,"scroll paginated",NULL),
OFFON_SETTING(0,list_wraparound,LANG_LIST_WRAPAROUND,
true,"list wraparound",NULL),
+ CHOICE_SETTING(0, list_order, LANG_LIST_ORDER,
+#if defined(HAVE_SCROLLWHEEL) && !defined(FIIO_M3K)
+ 1,
+#else
+ 0,
+#endif
+ /* values are defined by the enum in option_select.h */
+ "list order", "descending,ascending",
+ NULL, 2, ID2P(LANG_DESCENDING), ID2P(LANG_ASCENDING)),
#ifdef HAVE_LCD_COLOR
{F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.fg_color,-1,