Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/bookmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ static int select_bookmark(const char* bookmark_file_name,
= (strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0);

gui_synclist_init(&list, &get_bookmark_info,
(void*) bookmarks, false, 2, NULL);
(void*) bookmarks, false, 2, NULL, false);

if(global_settings.talk_menu)
gui_synclist_set_voice_callback(&list, bookmark_list_voice_cb);
Expand Down
2 changes: 1 addition & 1 deletion apps/cuesheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void browse_cuesheet(struct cuesheet *cue)
title[sizeof(title) - 2] = '~'; /* give indication of truncation */


gui_synclist_init(&lists, list_get_name_cb, cue, false, 2, NULL);
gui_synclist_init(&lists, list_get_name_cb, cue, false, 2, NULL, false);
gui_synclist_set_nb_items(&lists, 2*cue->track_count);
gui_synclist_set_title(&lists, title, 0);

Expand Down
1 change: 1 addition & 0 deletions apps/filetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define FILE_ATTR_OPX 0x1400 /* open plugins shortcut */
#define FILE_ATTR_LOG 0x1500 /* log file */
#define FILE_ATTR_MASK 0xFF00 /* which bits tree.c uses for file types */
#define FILE_ATTR_MULTISELECTION 0x40000000 /* is file a part of a multiselection ? */

long tree_get_filetype_voiceclip(int attr);

Expand Down
9 changes: 5 additions & 4 deletions apps/gui/bitmap/list-skinned.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static bool skinlist_is_configured(enum screen_type screen,
struct gui_synclist *list)
{
return (listcfg[screen] != NULL) &&
(!list || (list && list->selected_size == 1));
(!list || (list && (list->selected_size == 1 || list->multiple_selection_force_single_entry_scroll)));
}
static int current_drawing_line;
static int offset_to_item(int offset, bool wrap)
Expand Down Expand Up @@ -214,7 +214,8 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
display->set_background(parent->bg_pattern);
#endif
display->clear_viewport();
current_item = list->selected_item;
int selected_item = list->selected_item;
current_item = selected_item;
current_nbitems = list->nb_items;
needs_scrollbar[screen] = list->nb_items > display_lines;

Expand All @@ -225,7 +226,7 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
if (list_start_item+cur_line+1 > list->nb_items)
break;
current_drawing_line = list_start_item+cur_line;
is_selected = list_start_item+cur_line == list->selected_item;
is_selected = list_start_item+cur_line == selected_item;

for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree);
viewport;
Expand Down Expand Up @@ -315,6 +316,6 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
}
else
display->update_viewport();
current_drawing_line = list->selected_item;
current_drawing_line = selected_item;
return true;
}
19 changes: 15 additions & 4 deletions apps/gui/bitmap/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,16 @@ void list_draw(struct screen *display, struct gui_synclist *list)
const int nb_lines = list_get_nb_lines(list, screen);

linedes.height = list->line_height[screen];
linedes.nlines = list->selected_size;
int selected_item = list->selected_item;
int selected_size = list->selected_size;
if (selected_size <= 0)
{
selected_item += selected_size;
while (selected_item < 0)
selected_item += list->nb_items;
selected_size = ((- selected_size) + 1);
}
linedes.nlines = selected_size;
#if LCD_DEPTH > 1
/* XXX: Do we want to support the separator on remote displays? */
if (display->screen_type == SCREEN_MAIN)
Expand Down Expand Up @@ -388,8 +397,8 @@ void list_draw(struct screen *display, struct gui_synclist *list)
/* don't draw it during scrolling */
list->scroll_mode == SCROLL_NONE &&
#endif
i >= list->selected_item
&& i < list->selected_item + list->selected_size)
((i >= selected_item && i < selected_item + selected_size) ||
(i < (selected_item + selected_size - list->nb_items))))
{/* The selected item must be displayed scrolling */
#ifdef HAVE_LCD_COLOR
if (list->selection_color)
Expand Down Expand Up @@ -451,7 +460,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
#endif
linedes.style = style;
linedes.scroll = is_selected ? true : list->scroll_all;
linedes.line = i % list->selected_size;
linedes.line = i % selected_size;
icon = list->callback_get_item_icon ?
list->callback_get_item_icon(i, list->data) : Icon_NOICON;

Expand Down Expand Up @@ -484,6 +493,8 @@ void list_draw(struct screen *display, struct gui_synclist *list)

#if defined(HAVE_TOUCHSCREEN)
/* This needs to be fixed if we ever get more than 1 touchscreen on a target. */
/* FIXME: Multiple selection (with multiple_selection_force_single_entry_scroll)
is not coded (yet) for touchscreen devices */

static void do_touch_scroll(struct gui_synclist *gui_list, int new_y_pos)
{
Expand Down
90 changes: 58 additions & 32 deletions apps/gui/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ void gui_synclist_init(struct gui_synclist * gui_list,
list_get_name callback_get_item_name,
void * data,
bool scroll_all,
int selected_size, struct viewport list_parent[NB_SCREENS]
int selected_size, struct viewport list_parent[NB_SCREENS],
bool multiple_selection_force_single_entry_scroll
)
{
gui_list->callback_get_item_icon = NULL;
gui_list->callback_get_item_name = callback_get_item_name;
gui_list->callback_speak_item = NULL;
gui_list->callback_draw_item = NULL;
gui_list->multiple_selection_force_single_entry_scroll = multiple_selection_force_single_entry_scroll;
gui_list->nb_items = 0;
gui_list->selected_item = 0;
gui_list->min_index_forbid_limit = 0;
gui_list->end_index_forbid_limit = 0;
gui_synclist_init_display_settings(gui_list);
#ifdef HAVE_TOUCHSCREEN
gui_list->y_pos = 0;
Expand Down Expand Up @@ -256,30 +260,34 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
int nb_lines = list_get_nb_lines(gui_list, screen);
int bottom = MAX(0, gui_list->nb_items - nb_lines);
int new_start_item = gui_list->start_item[screen];
int difference = gui_list->selected_item - gui_list->start_item[screen];
const int scroll_limit_up = (nb_lines < gui_list->selected_size+2 ? 0:1);
const int scroll_limit_down = (scroll_limit_up+gui_list->selected_size);

if (gui_list->selected_size >= nb_lines)
int selected_item = gui_list->selected_item;
int selected_size = gui_list->selected_size;
if (gui_list->multiple_selection_force_single_entry_scroll)
selected_size = 1;
int difference = selected_item - gui_list->start_item[screen];
const int scroll_limit_up = (nb_lines < selected_size + 2 ? 0:1);
const int scroll_limit_down = (scroll_limit_up+selected_size);

if (selected_size >= nb_lines)
{
new_start_item = gui_list->selected_item;
new_start_item = selected_item;
}
else if (gui_list->scroll_paginated)
{
nb_lines -= nb_lines%gui_list->selected_size;
nb_lines -= nb_lines%selected_size;
if (difference < 0 || difference >= nb_lines)
{
new_start_item = gui_list->selected_item -
(gui_list->selected_item%nb_lines);
new_start_item = selected_item -
(selected_item%nb_lines);
}
}
else if (difference <= scroll_limit_up) /* list moved up */
{
new_start_item = gui_list->selected_item - scroll_limit_up;
new_start_item = selected_item - scroll_limit_up;
}
else if (difference > nb_lines - scroll_limit_down) /* list moved down */
{
new_start_item = gui_list->selected_item + scroll_limit_down - nb_lines;
new_start_item = selected_item + scroll_limit_down - nb_lines;
}
if (new_start_item < 0)
gui_list->start_item[screen] = 0;
Expand Down Expand Up @@ -389,22 +397,31 @@ void gui_synclist_select_item(struct gui_synclist * gui_list, int item_number)
static void gui_list_select_at_offset(struct gui_synclist * gui_list,
int offset, bool allow_wrap)
{
if (gui_list->selected_size > 1)
int selected_item = gui_list->selected_item;
int selected_size = gui_list->selected_size;
int max_index = gui_list->nb_items - gui_list->end_index_forbid_limit;
if (max_index < gui_list->min_index_forbid_limit)
max_index = gui_list->min_index_forbid_limit;
if (gui_list->multiple_selection_force_single_entry_scroll)
selected_size = 1;
else if (selected_size > 1)
offset *= selected_size;

int new_selection = selected_item + offset;
int remain = (max_index - selected_size);
if (remain < gui_list->min_index_forbid_limit)
remain = gui_list->min_index_forbid_limit;
else if (remain > max_index)
remain = max_index;

if (new_selection >= max_index)
{
offset *= gui_list->selected_size;
}

int new_selection = gui_list->selected_item + offset;
int remain = (gui_list->nb_items - gui_list->selected_size);

if (new_selection >= gui_list->nb_items)
{
new_selection = allow_wrap ? 0 : remain;
new_selection = (allow_wrap ? gui_list->min_index_forbid_limit : remain);
edge_beep(gui_list, allow_wrap);
}
else if (new_selection < 0)
else if (new_selection < gui_list->min_index_forbid_limit)
{
new_selection = allow_wrap ? remain : 0;
new_selection = (allow_wrap ? remain : gui_list->min_index_forbid_limit);
edge_beep(gui_list, allow_wrap);
}

Expand Down Expand Up @@ -517,7 +534,7 @@ static void gui_synclist_select_next_page(struct gui_synclist * lists,
bool allow_wrap)
{
int nb_lines = list_get_nb_lines(lists, screen);
if (lists->selected_size > 1)
if (lists->selected_size > 1 && !lists->multiple_selection_force_single_entry_scroll)
nb_lines = MAX(1, nb_lines/lists->selected_size);

gui_list_select_at_offset(lists, nb_lines, allow_wrap);
Expand All @@ -528,7 +545,7 @@ static void gui_synclist_select_previous_page(struct gui_synclist * lists,
bool allow_wrap)
{
int nb_lines = list_get_nb_lines(lists, screen);
if (lists->selected_size > 1)
if (lists->selected_size > 1 && !lists->multiple_selection_force_single_entry_scroll)
nb_lines = MAX(1, nb_lines/lists->selected_size);

gui_list_select_at_offset(lists, -nb_lines, allow_wrap);
Expand Down Expand Up @@ -578,8 +595,11 @@ bool gui_synclist_keyclick_callback(int action, void* data)
if (action == ACTION_STD_PREV && !lists->wraparound)
return false;
}
int selected_size = lists->selected_size;
if (lists->multiple_selection_force_single_entry_scroll)
selected_size = 1;

if (lists->selected_item == lists->nb_items - lists->selected_size)
if (lists->selected_item == lists->nb_items - selected_size)
{
if (action == ACTION_STD_NEXTREPEAT)
return false;
Expand Down Expand Up @@ -709,6 +729,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
#ifndef HAVE_WHEEL_ACCELERATION
if (button_queue_count() < FRAMEDROP_TRIGGER)
#endif
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
yield();
*actionptr = ACTION_STD_PREV;
Expand All @@ -722,14 +743,16 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
#ifndef HAVE_WHEEL_ACCELERATION
if (button_queue_count() < FRAMEDROP_TRIGGER)
#endif
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
yield();
*actionptr = ACTION_STD_NEXT;
return true;

case ACTION_TREE_PGRIGHT:
gui_synclist_scroll_right(lists);
gui_synclist_draw(lists);
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
yield();
return true;
case ACTION_TREE_ROOT_INIT:
Expand All @@ -755,7 +778,8 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
return false;
}
gui_synclist_scroll_left(lists);
gui_synclist_draw(lists);
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
pgleft_allow_cancel = false; /* stop ACTION_TREE_PAGE_LEFT
skipping to root */
yield();
Expand All @@ -772,7 +796,8 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
#endif
SCREEN_MAIN;
gui_synclist_select_previous_page(lists, screen, false);
gui_synclist_draw(lists);
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
yield();
*actionptr = ACTION_STD_NEXT;
}
Expand All @@ -787,7 +812,8 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
#endif
SCREEN_MAIN;
gui_synclist_select_next_page(lists, screen, false);
gui_synclist_draw(lists);
if (!lists->multiple_selection_force_single_entry_scroll)
gui_synclist_draw(lists);
yield();
*actionptr = ACTION_STD_PREV;
}
Expand Down Expand Up @@ -938,7 +964,7 @@ bool simplelist_show_list(struct simplelist_info *info)
}

gui_synclist_init(&lists, getname, info->callback_data,
info->scroll_all, info->selection_size, NULL);
info->scroll_all, info->selection_size, NULL, false);

if (info->title)
gui_synclist_set_title(&lists, info->title, info->title_icon);
Expand Down
7 changes: 5 additions & 2 deletions apps/gui/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ struct gui_synclist
bool scroll_all;
int nb_items;
int selected_item;

int min_index_forbid_limit; /* don't let the user scroll under it */
int end_index_forbid_limit; /* don't let the user scroll past (number_items-this var) */
int start_item[NB_SCREENS]; /* the item that is displayed at the top of the screen */
/* the number of lines that are selected at the same time */
int selected_size;
bool multiple_selection_force_single_entry_scroll;
/* the number of pixels each line occupies (including optional padding on touchscreen */
int line_height[NB_SCREENS];
int offset_position[NB_SCREENS]; /* the list's screen scroll placement in pixels */
Expand Down Expand Up @@ -199,7 +201,8 @@ extern void gui_synclist_init(
void * data,
bool scroll_all,
int selected_size,
struct viewport parent[NB_SCREENS] /* NOTE: new screens should NOT set this to NULL */
struct viewport parent[NB_SCREENS], /* NOTE: new screens should NOT set this to NULL */
bool multiple_selection_force_single_entry_scroll
);
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
Expand Down
2 changes: 1 addition & 1 deletion apps/gui/option_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bool option_screen(const struct settings_list *setting,
else return false; /* only int/bools can go here */
push_current_activity(ACTIVITY_OPTIONSELECT);
gui_synclist_init(&lists, value_setting_get_name_cb,
(void*)setting, false, 1, parent);
(void*)setting, false, 1, parent, false);
if (setting->lang_id == -1)
{
title = setting_get_cfgvals(setting);
Expand Down
4 changes: 2 additions & 2 deletions apps/gui/wps.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ long gui_wps_show(void)
theme_enabled = false;
gwps_leave_wps(theme_enabled);
onplay(state->id3->path,
FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION);
FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION, false);
if (!audio_status())
{
/* re-enable theme since we're returning to SBS */
Expand All @@ -820,7 +820,7 @@ long gui_wps_show(void)
{
gwps_leave_wps(true);
int retval = onplay(state->id3->path,
FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION);
FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION, false);
/* if music is stopped in the context menu we want to exit the wps */
if (retval == ONPLAY_MAINMENU
|| !audio_status())
Expand Down
Loading