1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Aidan MacDonald 2021-11-21 16:30:38 +00:00
parent a3684e090e
commit dcac2c616f
8 changed files with 99 additions and 35 deletions

View file

@ -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;
}
}

View file

@ -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],