summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--manual/appendix/config_file_options.tex1
-rwxr-xr-xmanual/configure_rockbox/display_options.tex6
8 files changed, 99 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)
334 else if ((setting->flags & F_T_SOUND) == F_T_SOUND) 334 else if ((setting->flags & F_T_SOUND) == F_T_SOUND)
335 { 335 {
336 int setting_id = setting->sound_setting->setting; 336 int setting_id = setting->sound_setting->setting;
337#ifndef ASCENDING_INT_SETTINGS 337 if(global_settings.list_order == LIST_ORDER_DESCENDING)
338 step = sound_steps(setting_id); 338 {
339 max = (setting_id == SOUND_VOLUME) ? 339 step = sound_steps(setting_id);
340 global_settings.volume_limit : sound_max(setting_id); 340 max = (setting_id == SOUND_VOLUME) ?
341 /* min = sound_min(setting_id); */ 341 global_settings.volume_limit : sound_max(setting_id);
342#else 342 /* min = sound_min(setting_id); */
343 step = -sound_steps(setting_id); 343 }
344 /* min = sound_max(setting_id); */ 344 else
345 max = sound_min(setting_id); 345 {
346#endif 346 step = -sound_steps(setting_id);
347 /* min = sound_max(setting_id); */
348 max = sound_min(setting_id);
349 }
347 } 350 }
348 else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) 351 else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
349 { 352 {
350 const struct int_setting *info = setting->int_setting; 353 const struct int_setting *info = setting->int_setting;
351#ifndef ASCENDING_INT_SETTINGS 354 if(global_settings.list_order == LIST_ORDER_DESCENDING)
352 /* min = info->min; */ 355 {
353 max = info->max; 356 /* min = info->min; */
354 step = info->step; 357 max = info->max;
355#else 358 step = info->step;
356 max = info->min; 359 }
357 /* min = info->max; */ 360 else
358 step = -info->step; 361 {
359#endif 362 max = info->min;
363 /* min = info->max; */
364 step = -info->step;
365 }
360 } 366 }
361 return max- (selection * step); 367 return max- (selection * step);
362} 368}
@@ -424,11 +430,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue,
424 int max = (setting_id == SOUND_VOLUME) ? 430 int max = (setting_id == SOUND_VOLUME) ?
425 global_settings.volume_limit : sound_max(setting_id); 431 global_settings.volume_limit : sound_max(setting_id);
426 *nb_items = (max-min)/steps + 1; 432 *nb_items = (max-min)/steps + 1;
427#ifndef ASCENDING_INT_SETTINGS 433 if (global_settings.list_order == LIST_ORDER_DESCENDING)
428 *selected = (max - oldvalue) / steps; 434 *selected = (max - oldvalue) / steps;
429#else 435 else
430 *selected = (oldvalue - min) / steps; 436 *selected = (oldvalue - min) / steps;
431#endif
432 *function = sound_get_fn(setting_id); 437 *function = sound_get_fn(setting_id);
433 } 438 }
434 else 439 else
@@ -439,11 +444,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue,
439 min = info->min; 444 min = info->min;
440 step = info->step; 445 step = info->step;
441 *nb_items = (max-min)/step + 1; 446 *nb_items = (max-min)/step + 1;
442#ifndef ASCENDING_INT_SETTINGS 447 if(global_settings.list_order == LIST_ORDER_DESCENDING)
443 *selected = (max - oldvalue) / step; 448 *selected = (max - oldvalue) / step;
444#else 449 else
445 *selected = (oldvalue - min) / step; 450 *selected = (oldvalue - min) / step;
446#endif
447 *function = info->option_callback; 451 *function = info->option_callback;
448 } 452 }
449 } 453 }
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 @@
25#include "screen_access.h" 25#include "screen_access.h"
26#include "settings.h" 26#include "settings.h"
27 27
28#if defined (HAVE_SCROLLWHEEL) && !defined(FIIO_M3K) 28enum {
29/* Define this if your target makes sense to have 29 LIST_ORDER_DESCENDING = 0,
30 smaller values at the top of the list increasing down the list */ 30 LIST_ORDER_ASCENDING = 1,
31#define ASCENDING_INT_SETTINGS 31};
32#endif
33 32
34bool option_screen(const struct settings_list *setting, 33bool option_screen(const struct settings_list *setting,
35 struct viewport parent[NB_SCREENS], 34 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 @@
16149 <voice> 16149 <voice>
16150 *: "Show Shutdown Message" 16150 *: "Show Shutdown Message"
16151 </voice> 16151 </voice>
16152</phrase> \ No newline at end of file 16152</phrase>
16153<phrase>
16154 id: LANG_LIST_ORDER
16155 desc: in Settings
16156 user: core
16157 <source>
16158 *: "List Order"
16159 </source>
16160 <dest>
16161 *: "List Order"
16162 </dest>
16163 <voice>
16164 *: "List Order"
16165 </voice>
16166</phrase>
16167<phrase>
16168 id: LANG_ASCENDING
16169 desc: in Settings
16170 user: core
16171 <source>
16172 *: "Ascending"
16173 </source>
16174 <dest>
16175 *: "Ascending"
16176 </dest>
16177 <voice>
16178 *: "Ascending"
16179 </voice>
16180</phrase>
16181<phrase>
16182 id: LANG_DESCENDING
16183 desc: in Settings
16184 user: core
16185 <source>
16186 *: "Descending"
16187 </source>
16188 <dest>
16189 *: "Descending"
16190 </dest>
16191 <voice>
16192 *: "Descending"
16193 </voice>
16194</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,
366} 366}
367 367
368MENUITEM_SETTING(list_wraparound, &global_settings.list_wraparound, listwraparound_callback); 368MENUITEM_SETTING(list_wraparound, &global_settings.list_wraparound, listwraparound_callback);
369MENUITEM_SETTING(list_order, &global_settings.list_order, NULL);
369 370
370MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON, 371MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
371 &scroll_speed, &scroll_delay, 372 &scroll_speed, &scroll_delay,
@@ -377,6 +378,7 @@ MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
377 &offset_out_of_view, &screen_scroll_step, 378 &offset_out_of_view, &screen_scroll_step,
378 &scroll_paginated, 379 &scroll_paginated,
379 &list_wraparound, 380 &list_wraparound,
381 &list_order,
380#ifndef HAVE_WHEEL_ACCELERATION 382#ifndef HAVE_WHEEL_ACCELERATION
381 &list_accel_start_delay, &list_accel_wait 383 &list_accel_start_delay, &list_accel_wait
382#endif 384#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
531 0=goto previous location */ 531 0=goto previous location */
532 bool scroll_paginated; /* 0=dont 1=do */ 532 bool scroll_paginated; /* 0=dont 1=do */
533 bool list_wraparound; /* wrap around to opposite end of list when scrolling */ 533 bool list_wraparound; /* wrap around to opposite end of list when scrolling */
534 int list_order; /* order for numeric lists (ascending or descending) */
534 int scroll_speed; /* long texts scrolling speed: 1-30 */ 535 int scroll_speed; /* long texts scrolling speed: 1-30 */
535 int bidir_limit; /* bidir scroll length limit */ 536 int bidir_limit; /* bidir scroll length limit */
536 int scroll_delay; /* delay (in 1/10s) before starting scroll */ 537 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[] = {
1216 false,"scroll paginated",NULL), 1216 false,"scroll paginated",NULL),
1217 OFFON_SETTING(0,list_wraparound,LANG_LIST_WRAPAROUND, 1217 OFFON_SETTING(0,list_wraparound,LANG_LIST_WRAPAROUND,
1218 true,"list wraparound",NULL), 1218 true,"list wraparound",NULL),
1219 CHOICE_SETTING(0, list_order, LANG_LIST_ORDER,
1220#if defined(HAVE_SCROLLWHEEL) && !defined(FIIO_M3K)
1221 1,
1222#else
1223 0,
1224#endif
1225 /* values are defined by the enum in option_select.h */
1226 "list order", "descending,ascending",
1227 NULL, 2, ID2P(LANG_DESCENDING), ID2P(LANG_ASCENDING)),
1219#ifdef HAVE_LCD_COLOR 1228#ifdef HAVE_LCD_COLOR
1220 1229
1221 {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.fg_color,-1, 1230 {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.fg_color,-1,
diff --git a/manual/appendix/config_file_options.tex b/manual/appendix/config_file_options.tex
index 5cf5b1b0f7..257a3bc48e 100644
--- a/manual/appendix/config_file_options.tex
+++ b/manual/appendix/config_file_options.tex
@@ -65,6 +65,7 @@
65 bidir limit & 0 to 200 & \% screen\\ 65 bidir limit & 0 to 200 & \% screen\\
66 scroll paginated & on, off & N/A\\ 66 scroll paginated & on, off & N/A\\
67 list wraparound & on, off & N/A\\ 67 list wraparound & on, off & N/A\\
68 list order & ascending, descending & N/A\\
68 hold\_lr\_for\_scroll\_in\_list & on, off & N/A\\ 69 hold\_lr\_for\_scroll\_in\_list & on, off & N/A\\
69 show path in browser & off, current directory, full path & N/A\\ 70 show path in browser & off, current directory, full path & N/A\\
70 contrast & 0 to 63 & N/A\\ 71 contrast & 0 to 63 & N/A\\
diff --git a/manual/configure_rockbox/display_options.tex b/manual/configure_rockbox/display_options.tex
index ee594d676a..5b4692b9ba 100755
--- a/manual/configure_rockbox/display_options.tex
+++ b/manual/configure_rockbox/display_options.tex
@@ -210,6 +210,12 @@
210 \item[List Wraparound.] 210 \item[List Wraparound.]
211 When set to \setting{Yes}, scrolling will wrap around back to the opposite 211 When set to \setting{Yes}, scrolling will wrap around back to the opposite
212 end of a list after the first or last item has been reached. 212 end of a list after the first or last item has been reached.
213 \item[List Order.]
214 When set to \setting{Ascending}, numeric lists such as brightness and
215 volume will be sorted with the smallest value at the top of the list and
216 values increasing down the list. When set to \setting{Descending}, the
217 order is reversed -- the largest value is sorted at the top and values
218 will decrease down the list.
213 \nopt{scrollwheel}{ 219 \nopt{scrollwheel}{
214 \item[List Acceleration Start Delay.] 220 \item[List Acceleration Start Delay.]
215 This setting enables the acceleration of scroll speed in lists when 221 This setting enables the acceleration of scroll speed in lists when