summaryrefslogtreecommitdiff
path: root/apps/gui/option_select.c
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/gui/option_select.c
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/gui/option_select.c')
-rw-r--r--apps/gui/option_select.c62
1 files changed, 33 insertions, 29 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 }