1
0
Fork 0
forked from len0rd/rockbox

Add setting for disabling wrap-around lists

Allows user to decide whether scrolling lists will wrap around
to the opposite end after the first or last item has been reached.

Change-Id: I22156812cf4c857ddc4b6c48c1cef013b1985260
This commit is contained in:
Christian Soffke 2021-10-21 23:11:32 +02:00 committed by William Wilgus
parent 30a23fdd6d
commit fbf83dc4ce
9 changed files with 73 additions and 7 deletions

View file

@ -686,7 +686,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
switch (wrap)
{
case LIST_WRAP_ON:
gui_synclist_limit_scroll(lists, false);
gui_synclist_limit_scroll(lists, !global_settings.list_wraparound);
break;
case LIST_WRAP_OFF:
gui_synclist_limit_scroll(lists, true);
@ -697,7 +697,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
action == ACTION_LISTTREE_PGUP ||
action == ACTION_LISTTREE_PGDOWN)
gui_synclist_limit_scroll(lists, true);
else gui_synclist_limit_scroll(lists, false);
else gui_synclist_limit_scroll(lists, !global_settings.list_wraparound);
break;
};
@ -911,7 +911,7 @@ bool simplelist_show_list(struct simplelist_info *info)
struct gui_synclist lists;
int action, old_line_count = simplelist_line_count;
list_get_name *getname;
int wrap = LIST_WRAP_UNLESS_HELD;
int wrap = global_settings.list_wraparound ? LIST_WRAP_UNLESS_HELD : LIST_WRAP_OFF;
if (info->get_name)
getname = info->get_name;
else

View file

@ -16122,3 +16122,17 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_LIST_WRAPAROUND
desc: in Settings
user: core
<source>
*: "List Wraparound"
</source>
<dest>
*: "List Wraparound"
</dest>
<voice>
*: "List Wraparound"
</voice>
</phrase>

View file

@ -351,6 +351,22 @@ MENUITEM_SETTING(offset_out_of_view, &global_settings.offset_out_of_view,
MENUITEM_SETTING(screen_scroll_step, &global_settings.screen_scroll_step, NULL);
MENUITEM_SETTING(scroll_paginated, &global_settings.scroll_paginated, NULL);
static int listwraparound_callback(int action,
const struct menu_item_ex *this_item,
struct gui_synclist *this_list)
{
(void)this_item;
switch (action)
{
case ACTION_EXIT_MENUITEM:
gui_synclist_limit_scroll(this_list, !global_settings.list_wraparound);
break;
}
return action;
}
MENUITEM_SETTING(list_wraparound, &global_settings.list_wraparound, listwraparound_callback);
MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
&scroll_speed, &scroll_delay,
&scroll_step,
@ -360,6 +376,7 @@ MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
#endif
&offset_out_of_view, &screen_scroll_step,
&scroll_paginated,
&list_wraparound,
#ifndef HAVE_WHEEL_ACCELERATION
&list_accel_start_delay, &list_accel_wait
#endif

View file

@ -3370,7 +3370,7 @@ static void select_next_track(void)
pf_tracks.sel++;
if (pf_tracks.sel==(pf_tracks.list_visible+pf_tracks.list_start))
pf_tracks.list_start++;
} else {
} else if (rb->global_settings->list_wraparound) {
/* Rollover */
pf_tracks.sel = 0;
pf_tracks.list_start = 0;
@ -3382,7 +3382,7 @@ static void select_prev_track(void)
if (pf_tracks.sel > 0 ) {
if (pf_tracks.sel==pf_tracks.list_start) pf_tracks.list_start--;
pf_tracks.sel--;
} else {
} else if (rb->global_settings->list_wraparound) {
/* Rolllover */
pf_tracks.sel = pf_tracks.count - 1;
pf_tracks.list_start = pf_tracks.count - pf_tracks.list_visible;

View file

@ -1215,16 +1215,18 @@ static void kbd_move_cursor(struct edit_state *state, int dir)
{
state->changed = CHANGED_CURSOR;
}
else if (state->editpos > state->len_utf8)
else if (global_settings.list_wraparound && state->editpos > state->len_utf8)
{
state->editpos = 0;
if (global_settings.talk_menu) beep_play(1000, 150, 1500);
}
else if (state->editpos < 0)
else if (global_settings.list_wraparound && state->editpos < 0)
{
state->editpos = state->len_utf8;
if (global_settings.talk_menu) beep_play(1000, 150, 1500);
}
else if (!global_settings.list_wraparound)
state->editpos -= dir;
}
static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
@ -1235,12 +1237,22 @@ static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
pm->x += dir;
if (pm->x < 0)
{
if (!global_settings.list_wraparound && pm->page == 0)
{
pm->x = 0;
return;
}
if (--pm->page < 0)
pm->page = pm->pages - 1;
pm->x = pm->max_chars - 1;
}
else if (pm->x >= pm->max_chars)
{
if (!global_settings.list_wraparound && pm->page == pm->pages - 1)
{
pm->x = pm->max_chars - 1;
return;
}
if (++pm->page >= pm->pages)
pm->page = 0;
pm->x = 0;
@ -1261,6 +1273,22 @@ static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
#endif /* HAVE_MORSE_INPUT */
pm->y += dir;
if (!global_settings.list_wraparound)
{
if (pm->y >= pm->lines)
{
pm->y = pm->lines;
pm->line_edit = true;
}
else if (pm->y < 0)
pm->y = 0;
else if (pm->line_edit)
pm->line_edit = false;
return;
}
if (pm->line_edit)
{
pm->y = (dir > 0 ? 0 : pm->lines - 1);

View file

@ -530,6 +530,7 @@ struct user_settings
bool browse_current; /* 1=goto current song,
0=goto previous location */
bool scroll_paginated; /* 0=dont 1=do */
bool list_wraparound; /* wrap around to opposite end of list when scrolling */
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 */

View file

@ -1220,6 +1220,8 @@ const struct settings_list settings[] = {
gui_list_screen_scroll_step),
OFFON_SETTING(0,scroll_paginated,LANG_SCROLL_PAGINATED,
false,"scroll paginated",NULL),
OFFON_SETTING(0,list_wraparound,LANG_LIST_WRAPAROUND,
true,"list wraparound",NULL),
#ifdef HAVE_LCD_COLOR
{F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.fg_color,-1,

View file

@ -64,6 +64,7 @@
Screen Scrolls Out Of View & on, off & N/A\\
bidir limit & 0 to 200 & \% screen\\
scroll paginated & on, off & N/A\\
list wraparound & on, off & N/A\\
hold\_lr\_for\_scroll\_in\_list & on, off & N/A\\
show path in browser & off, current directory, full path & N/A\\
contrast & 0 to 63 & N/A\\

View file

@ -207,6 +207,9 @@
When set to \setting{Yes} scrolling vertically on pages that surpass the
screen size will page up/down instead of simply changing lines. This can be
useful on slow displays.
\item[List Wraparound.]
When set to \setting{Yes}, scrolling will wrap around back to the opposite
end of a list after the first or last item has been reached.
\nopt{scrollwheel}{
\item[List Acceleration Start Delay.]
This setting enables the acceleration of scroll speed in lists when