commit
3f70099f01
|
@ -71,6 +71,18 @@ void *file_list_get_actiondata_at_offset(const file_list_t *list,
|
||||||
*/
|
*/
|
||||||
void file_list_free(file_list_t *list);
|
void file_list_free(file_list_t *list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief makes the list big enough to contain at least nitems
|
||||||
|
*
|
||||||
|
* This function will not change the capacity if nitems is smaller
|
||||||
|
* than the current capacity.
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @param nitems
|
||||||
|
* @return whether or not the operation succeeded
|
||||||
|
*/
|
||||||
|
bool file_list_reserve(file_list_t *list, size_t nitems);
|
||||||
|
|
||||||
bool file_list_append(file_list_t *userdata, const char *path,
|
bool file_list_append(file_list_t *userdata, const char *path,
|
||||||
const char *label, unsigned type, size_t current_directory_ptr,
|
const char *label, unsigned type, size_t current_directory_ptr,
|
||||||
size_t entry_index);
|
size_t entry_index);
|
||||||
|
|
|
@ -29,28 +29,25 @@
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <compat/strcasestr.h>
|
#include <compat/strcasestr.h>
|
||||||
|
|
||||||
/**
|
bool file_list_reserve(file_list_t *list, size_t nitems)
|
||||||
* file_list_capacity:
|
|
||||||
* @list : pointer to file list
|
|
||||||
* @cap : new capacity for file list.
|
|
||||||
*
|
|
||||||
* Change maximum capacity of file list's size.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
static struct item_file *realloc_file_list_capacity(file_list_t *list, size_t cap)
|
|
||||||
{
|
{
|
||||||
struct item_file *new_data = (struct item_file*)realloc(list->list,
|
const size_t item_size = sizeof(struct item_file);
|
||||||
cap * sizeof(struct item_file));
|
struct item_file *new_data;
|
||||||
|
|
||||||
if (!new_data)
|
if (nitems < list->capacity || nitems > (size_t)-1/item_size)
|
||||||
return NULL;
|
return false;
|
||||||
|
|
||||||
if (cap > list->capacity)
|
new_data = (struct item_file*)realloc(list->list, nitems * item_size);
|
||||||
memset(&new_data[list->capacity], 0,
|
|
||||||
sizeof(*new_data) * (cap - list->capacity));
|
|
||||||
|
|
||||||
return new_data;
|
if (new_data)
|
||||||
|
{
|
||||||
|
memset(&new_data[list->capacity], 0, item_size * (nitems - list->capacity));
|
||||||
|
|
||||||
|
list->list = new_data;
|
||||||
|
list->capacity = nitems;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_data != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void file_list_add(file_list_t *list, unsigned idx,
|
static void file_list_add(file_list_t *list, unsigned idx,
|
||||||
|
@ -78,16 +75,8 @@ static void file_list_add(file_list_t *list, unsigned idx,
|
||||||
static bool file_list_expand_if_needed(file_list_t *list)
|
static bool file_list_expand_if_needed(file_list_t *list)
|
||||||
{
|
{
|
||||||
if (list->size >= list->capacity)
|
if (list->size >= list->capacity)
|
||||||
{
|
return file_list_reserve(list, list->capacity * 2 + 1);
|
||||||
size_t new_capacity = list->capacity * 2 + 1;
|
|
||||||
struct item_file *items = realloc_file_list_capacity(
|
|
||||||
list, new_capacity);
|
|
||||||
|
|
||||||
if (!items)
|
|
||||||
return false;
|
|
||||||
list->list = items;
|
|
||||||
list->capacity = new_capacity;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,6 @@ enum
|
||||||
|
|
||||||
typedef struct xmb_handle
|
typedef struct xmb_handle
|
||||||
{
|
{
|
||||||
file_list_t *menu_stack_old;
|
|
||||||
file_list_t *selection_buf_old;
|
file_list_t *selection_buf_old;
|
||||||
file_list_t *horizontal_list;
|
file_list_t *horizontal_list;
|
||||||
size_t selection_ptr_old;
|
size_t selection_ptr_old;
|
||||||
|
@ -2297,7 +2296,7 @@ static void xmb_draw_items(
|
||||||
video_frame_info_t *video_info,
|
video_frame_info_t *video_info,
|
||||||
menu_display_frame_info_t menu_disp_info,
|
menu_display_frame_info_t menu_disp_info,
|
||||||
xmb_handle_t *xmb,
|
xmb_handle_t *xmb,
|
||||||
file_list_t *list, file_list_t *stack,
|
file_list_t *list,
|
||||||
size_t current, size_t cat_selection_ptr, float *color,
|
size_t current, size_t cat_selection_ptr, float *color,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
|
@ -2809,7 +2808,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||||
unsigned height = video_info->height;
|
unsigned height = video_info->height;
|
||||||
bool render_background = false;
|
bool render_background = false;
|
||||||
file_list_t *selection_buf = NULL;
|
file_list_t *selection_buf = NULL;
|
||||||
file_list_t *menu_stack = NULL;
|
|
||||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||||
|
|
||||||
if (!xmb)
|
if (!xmb)
|
||||||
|
@ -3086,7 +3084,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||||
menu_disp_info,
|
menu_disp_info,
|
||||||
xmb,
|
xmb,
|
||||||
xmb->selection_buf_old,
|
xmb->selection_buf_old,
|
||||||
xmb->menu_stack_old,
|
|
||||||
xmb->selection_ptr_old,
|
xmb->selection_ptr_old,
|
||||||
(xmb_list_get_size(xmb, MENU_LIST_PLAIN) > 1)
|
(xmb_list_get_size(xmb, MENU_LIST_PLAIN) > 1)
|
||||||
? xmb->categories.selection_ptr : xmb->categories.selection_ptr_old,
|
? xmb->categories.selection_ptr : xmb->categories.selection_ptr_old,
|
||||||
|
@ -3095,14 +3092,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||||
height);
|
height);
|
||||||
|
|
||||||
selection_buf = menu_entries_get_selection_buf_ptr(0);
|
selection_buf = menu_entries_get_selection_buf_ptr(0);
|
||||||
menu_stack = menu_entries_get_menu_stack_ptr(0);
|
|
||||||
|
|
||||||
xmb_draw_items(
|
xmb_draw_items(
|
||||||
video_info,
|
video_info,
|
||||||
menu_disp_info,
|
menu_disp_info,
|
||||||
xmb,
|
xmb,
|
||||||
selection_buf,
|
selection_buf,
|
||||||
menu_stack,
|
|
||||||
selection,
|
selection,
|
||||||
xmb->categories.selection_ptr,
|
xmb->categories.selection_ptr,
|
||||||
&item_color[0],
|
&item_color[0],
|
||||||
|
@ -3431,11 +3426,6 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
|
||||||
|
|
||||||
*userdata = xmb;
|
*userdata = xmb;
|
||||||
|
|
||||||
xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
|
||||||
|
|
||||||
if (!xmb->menu_stack_old)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
||||||
|
|
||||||
if (!xmb->selection_buf_old)
|
if (!xmb->selection_buf_old)
|
||||||
|
@ -3503,9 +3493,6 @@ error:
|
||||||
|
|
||||||
if (xmb)
|
if (xmb)
|
||||||
{
|
{
|
||||||
if (xmb->menu_stack_old)
|
|
||||||
free(xmb->menu_stack_old);
|
|
||||||
xmb->menu_stack_old = NULL;
|
|
||||||
if (xmb->selection_buf_old)
|
if (xmb->selection_buf_old)
|
||||||
free(xmb->selection_buf_old);
|
free(xmb->selection_buf_old);
|
||||||
xmb->selection_buf_old = NULL;
|
xmb->selection_buf_old = NULL;
|
||||||
|
@ -3525,12 +3512,6 @@ static void xmb_free(void *data)
|
||||||
|
|
||||||
if (xmb)
|
if (xmb)
|
||||||
{
|
{
|
||||||
if (xmb->menu_stack_old)
|
|
||||||
{
|
|
||||||
xmb_free_list_nodes(xmb->menu_stack_old, false);
|
|
||||||
file_list_free(xmb->menu_stack_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmb->selection_buf_old)
|
if (xmb->selection_buf_old)
|
||||||
{
|
{
|
||||||
xmb_free_list_nodes(xmb->selection_buf_old, false);
|
xmb_free_list_nodes(xmb->selection_buf_old, false);
|
||||||
|
@ -3543,7 +3524,6 @@ static void xmb_free(void *data)
|
||||||
file_list_free(xmb->horizontal_list);
|
file_list_free(xmb->horizontal_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmb->menu_stack_old = NULL;
|
|
||||||
xmb->selection_buf_old = NULL;
|
xmb->selection_buf_old = NULL;
|
||||||
xmb->horizontal_list = NULL;
|
xmb->horizontal_list = NULL;
|
||||||
|
|
||||||
|
@ -3931,35 +3911,47 @@ static void xmb_list_free(file_list_t *list, size_t a, size_t b)
|
||||||
xmb_list_clear(list);
|
xmb_list_clear(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst)
|
static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst,
|
||||||
|
size_t first, size_t last)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i, j = 0;
|
||||||
menu_animation_ctx_tag tag = (uintptr_t)dst;
|
menu_animation_ctx_tag tag = (uintptr_t)dst;
|
||||||
size_t size = dst->size;
|
|
||||||
|
|
||||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||||
|
|
||||||
/* use true here because file_list_copy() doesn't free actiondata */
|
/* use true here because file_list_copy() doesn't free actiondata */
|
||||||
xmb_free_list_nodes(dst, true);
|
xmb_free_list_nodes(dst, true);
|
||||||
file_list_copy(src, dst);
|
|
||||||
|
|
||||||
size = dst->size;
|
file_list_clear(dst);
|
||||||
|
file_list_reserve(dst, (last + 1) - first);
|
||||||
|
|
||||||
for (i = 0; i < size; ++i)
|
for (i = first; i <= last; ++i)
|
||||||
{
|
{
|
||||||
void *src_udata = menu_entries_get_userdata_at_offset(src, i);
|
struct item_file *d = &dst->list[j];
|
||||||
void *src_adata = (void*)menu_entries_get_actiondata_at_offset(src, i);
|
struct item_file *s = &src->list[i];
|
||||||
|
|
||||||
|
void *src_udata = s->userdata;
|
||||||
|
void *src_adata = s->actiondata;
|
||||||
|
|
||||||
|
*d = *s;
|
||||||
|
d->alt = string_is_empty(d->alt) ? NULL : strdup(d->alt);
|
||||||
|
d->path = string_is_empty(d->path) ? NULL : strdup(d->path);
|
||||||
|
d->label = string_is_empty(d->label) ? NULL : strdup(d->label);
|
||||||
|
|
||||||
if (src_udata)
|
if (src_udata)
|
||||||
file_list_set_userdata(dst, i, (xmb_node_t*)xmb_copy_node(src_udata));
|
file_list_set_userdata(dst, j, (xmb_node_t*)xmb_copy_node(src_udata));
|
||||||
|
|
||||||
if (src_adata)
|
if (src_adata)
|
||||||
{
|
{
|
||||||
void *data = malloc(sizeof(menu_file_list_cbs_t));
|
void *data = malloc(sizeof(menu_file_list_cbs_t));
|
||||||
memcpy(data, src_adata, sizeof(menu_file_list_cbs_t));
|
memcpy(data, src_adata, sizeof(menu_file_list_cbs_t));
|
||||||
file_list_set_actiondata(dst, i, data);
|
file_list_set_actiondata(dst, j, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dst->size = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action)
|
static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action)
|
||||||
|
@ -3974,19 +3966,30 @@ static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action
|
||||||
if (!xmb)
|
if (!xmb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check whether to enable the horizontal animation. */
|
|
||||||
if (settings->bools.menu_horizontal_animation)
|
|
||||||
{
|
|
||||||
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old);
|
|
||||||
xmb_list_deep_copy(menu_stack, xmb->menu_stack_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: this shouldn't be happening at all */
|
/* FIXME: this shouldn't be happening at all */
|
||||||
if (selection >= xmb->selection_buf_old->size)
|
if (selection >= xmb->selection_buf_old->size)
|
||||||
selection = xmb->selection_buf_old->size ? xmb->selection_buf_old->size - 1 : 0;
|
selection = xmb->selection_buf_old->size ? xmb->selection_buf_old->size - 1 : 0;
|
||||||
|
|
||||||
xmb->selection_ptr_old = selection;
|
xmb->selection_ptr_old = selection;
|
||||||
|
|
||||||
|
/* Check whether to enable the horizontal animation. */
|
||||||
|
if (settings->bools.menu_horizontal_animation)
|
||||||
|
{
|
||||||
|
unsigned first = 0, last = 0;
|
||||||
|
unsigned height = 0;
|
||||||
|
video_driver_get_size(NULL, &height);
|
||||||
|
|
||||||
|
xmb_calculate_visible_range(xmb, height, selection_buf->size,
|
||||||
|
xmb->selection_ptr_old, &first, &last);
|
||||||
|
|
||||||
|
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old, first, last);
|
||||||
|
|
||||||
|
xmb->selection_ptr_old -= first;
|
||||||
|
last -= first;
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
|
list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
|
||||||
+ xmb->system_tab_end;
|
+ xmb->system_tab_end;
|
||||||
|
|
||||||
|
|
|
@ -1550,6 +1550,9 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
|
||||||
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
|
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prealocate the file list */
|
||||||
|
file_list_reserve(info->list, list_size);
|
||||||
|
|
||||||
for (i = 0; i < list_size; i++)
|
for (i = 0; i < list_size; i++)
|
||||||
{
|
{
|
||||||
char fill_buf[PATH_MAX_LENGTH];
|
char fill_buf[PATH_MAX_LENGTH];
|
||||||
|
|
Loading…
Reference in New Issue