mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
(XUI) Move file list code to XUI
This commit is contained in:
parent
9bc6e99104
commit
dcebbf0202
4
driver.h
4
driver.h
@ -501,6 +501,10 @@ typedef struct menu_ctx_driver
|
||||
void (*navigation_set_last)(void *);
|
||||
void (*navigation_descend_alphabet)(void *, size_t *);
|
||||
void (*navigation_ascend_alphabet)(void *, size_t *);
|
||||
void (*list_insert)(void *, const char *, size_t);
|
||||
void (*list_delete)(void *, size_t);
|
||||
void (*list_clear)(void *);
|
||||
void (*list_set_selection)(void *);
|
||||
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
|
@ -732,5 +732,9 @@ const menu_ctx_driver_t menu_ctx_lakka = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"lakka",
|
||||
};
|
||||
|
@ -624,5 +624,9 @@ const menu_ctx_driver_t menu_ctx_rgui = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"rgui",
|
||||
};
|
||||
|
@ -485,5 +485,9 @@ const menu_ctx_driver_t menu_ctx_rmenu = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"rmenu",
|
||||
};
|
||||
|
@ -674,6 +674,34 @@ static void rmenu_xui_navigation_alphabet(void *data, size_t *ptr_out)
|
||||
XuiListSetCurSelVisible(m_menulist, *ptr_out);
|
||||
}
|
||||
|
||||
static void rmenu_xui_list_insert(void *data, const char *path, size_t list_size)
|
||||
{
|
||||
(void)data;
|
||||
wchar_t buf[PATH_MAX];
|
||||
|
||||
XuiListInsertItems(m_menulist, list_size, 1);
|
||||
mbstowcs(buf, path, sizeof(buf) / sizeof(wchar_t));
|
||||
XuiListSetText(m_menulist, list_size, buf);
|
||||
}
|
||||
|
||||
static void rmenu_xui_list_delete(void *data, size_t list_size)
|
||||
{
|
||||
(void)data;
|
||||
XuiListDeleteItems(m_menulist, 0, list_size);
|
||||
}
|
||||
|
||||
static void rmenu_xui_list_clear(void *data)
|
||||
{
|
||||
(void)data;
|
||||
XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist));
|
||||
}
|
||||
|
||||
static void rmenu_xui_list_set_selection(void *data)
|
||||
{
|
||||
file_list_t *list = (file_list_t*)data;
|
||||
XuiListSetCurSel(m_menulist, list->list[list->size].directory_ptr);
|
||||
}
|
||||
|
||||
const menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
||||
NULL,
|
||||
rmenu_xui_render_messagebox,
|
||||
@ -693,5 +721,9 @@ const menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
||||
rmenu_xui_navigation_set_visible,
|
||||
rmenu_xui_navigation_alphabet,
|
||||
rmenu_xui_navigation_alphabet,
|
||||
rmenu_xui_list_insert,
|
||||
rmenu_xui_list_delete,
|
||||
rmenu_xui_list_clear,
|
||||
rmenu_xui_list_set_selection,
|
||||
"rmenu_xui",
|
||||
};
|
||||
|
@ -17,11 +17,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "file_list.h"
|
||||
#include "../../driver.h"
|
||||
#include "../../compat/strcasestr.h"
|
||||
#include "../../msvc/msvc_compat.h"
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
#include <xui.h>
|
||||
#endif
|
||||
|
||||
struct item_file
|
||||
{
|
||||
@ -31,10 +29,6 @@ struct item_file
|
||||
size_t directory_ptr;
|
||||
};
|
||||
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
extern HXUIOBJ m_menulist;
|
||||
#endif
|
||||
|
||||
void file_list_push(file_list_t *list,
|
||||
const char *path, unsigned type, size_t directory_ptr)
|
||||
{
|
||||
@ -48,12 +42,8 @@ void file_list_push(file_list_t *list,
|
||||
list->list = (struct item_file*)realloc(list->list, list->capacity * sizeof(struct item_file));
|
||||
}
|
||||
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
wchar_t buf[PATH_MAX];
|
||||
XuiListInsertItems(m_menulist, list->size, 1);
|
||||
mbstowcs(buf, path, sizeof(buf) / sizeof(wchar_t));
|
||||
XuiListSetText(m_menulist, list->size, buf);
|
||||
#endif
|
||||
if (driver.menu_ctx && driver.menu_ctx->list_insert)
|
||||
driver.menu_ctx->list_insert(list, path, list->size);
|
||||
|
||||
list->list[list->size].path = strdup(path);
|
||||
list->list[list->size].alt = NULL;
|
||||
@ -67,9 +57,8 @@ void file_list_pop(file_list_t *list, size_t *directory_ptr)
|
||||
{
|
||||
if (!(list->size == 0))
|
||||
{
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
XuiListDeleteItems(m_menulist, 0, list->size);
|
||||
#endif
|
||||
if (driver.menu_ctx && driver.menu_ctx->list_delete)
|
||||
driver.menu_ctx->list_delete(list, list->size);
|
||||
free(list->list[--list->size].path);
|
||||
}
|
||||
|
||||
@ -77,9 +66,9 @@ void file_list_pop(file_list_t *list, size_t *directory_ptr)
|
||||
{
|
||||
*directory_ptr = list->list[list->size].directory_ptr;
|
||||
}
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
XuiListSetCurSel(m_menulist, list->list[list->size].directory_ptr);
|
||||
#endif
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->list_set_selection)
|
||||
driver.menu_ctx->list_set_selection(list);
|
||||
}
|
||||
|
||||
void file_list_free(file_list_t *list)
|
||||
@ -99,9 +88,9 @@ void file_list_clear(file_list_t *list)
|
||||
free(list->list[i].path);
|
||||
free(list->list[i].alt);
|
||||
}
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist));
|
||||
#endif
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->list_clear)
|
||||
driver.menu_ctx->list_clear(list);
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user