diff --git a/Makefile.common b/Makefile.common
index 262f92cc68..b18a87f367 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -511,6 +511,7 @@ ifeq ($(HAVE_MENU_COMMON), 1)
menu/menu_setting.o \
menu/menu_shader.o \
menu/widgets/menu_popup.o \
+ menu/widgets/menu_list.o \
menu/menu_cbs.o \
menu/cbs/menu_cbs_ok.o \
menu/cbs/menu_cbs_cancel.o \
diff --git a/griffin/griffin.c b/griffin/griffin.c
index 871467abfd..ecff6a10c5 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -894,6 +894,7 @@ MENU
#include "../menu/menu_cbs.c"
#include "../menu/menu_content.c"
#include "../menu/widgets/menu_popup.c"
+#include "../menu/widgets/menu_list.c"
#include "../menu/cbs/menu_cbs_ok.c"
#include "../menu/cbs/menu_cbs_cancel.c"
#include "../menu/cbs/menu_cbs_select.c"
diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c
index 4312602f51..299149ff05 100644
--- a/menu/cbs/menu_cbs_left.c
+++ b/menu/cbs/menu_cbs_left.c
@@ -30,6 +30,8 @@
#include "../menu_shader.h"
#include "../menu_navigation.h"
+#include "../widgets/menu_list.h"
+
#include "../../configuration.h"
#include "../../core.h"
#include "../../core_info.h"
diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c
index 47b252569a..1bf35e2d85 100644
--- a/menu/cbs/menu_cbs_right.c
+++ b/menu/cbs/menu_cbs_right.c
@@ -30,6 +30,8 @@
#include "../menu_shader.h"
#include "../menu_navigation.h"
+#include "../widgets/menu_list.h"
+
#include "../../configuration.h"
#include "../../core.h"
#include "../../core_info.h"
diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c
index a5efe33358..13172bee3a 100644
--- a/menu/drivers/xmb.c
+++ b/menu/drivers/xmb.c
@@ -42,6 +42,8 @@
#include "../menu_display.h"
#include "../menu_navigation.h"
+#include "../widgets/menu_list.h"
+
#include "../menu_cbs.h"
#include "../../frontend/frontend_driver.h"
diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c
index 7a876f2f1d..9f53dad062 100644
--- a/menu/menu_displaylist.c
+++ b/menu/menu_displaylist.c
@@ -45,6 +45,7 @@
#include "menu_driver.h"
#include "menu_navigation.h"
#include "widgets/menu_popup.h"
+#include "widgets/menu_list.h"
#include "menu_cbs.h"
#include "../configuration.h"
diff --git a/menu/menu_driver.c b/menu/menu_driver.c
index 75ed0853bd..23bb3507c7 100644
--- a/menu/menu_driver.c
+++ b/menu/menu_driver.c
@@ -30,6 +30,7 @@
#include "menu_display.h"
#include "menu_navigation.h"
#include "widgets/menu_popup.h"
+#include "widgets/menu_list.h"
#include "menu_shader.h"
#include "../config.def.h"
diff --git a/menu/menu_driver.h b/menu/menu_driver.h
index 33f277156c..21a0ea83a5 100644
--- a/menu/menu_driver.h
+++ b/menu/menu_driver.h
@@ -284,20 +284,6 @@ typedef struct menu_ctx_load_image
enum menu_image_type type;
} menu_ctx_load_image_t;
-typedef struct menu_ctx_list
-{
- file_list_t *list;
- size_t list_size;
- const char *path;
- const char *label;
- size_t idx;
- enum menu_list_type type;
- unsigned action;
- size_t selection;
- size_t size;
- void *entry;
-} menu_ctx_list_t;
-
typedef struct menu_ctx_displaylist
{
menu_displaylist_info_t *info;
diff --git a/menu/menu_entries.c b/menu/menu_entries.c
index a44d7c1a69..7db963b2d5 100644
--- a/menu/menu_entries.c
+++ b/menu/menu_entries.c
@@ -24,107 +24,13 @@
#include "menu_cbs.h"
#include "menu_navigation.h"
+#include "widgets/menu_list.h"
+
#include "../core.h"
#include "../configuration.h"
#include "../runloop.h"
#include "../version.h"
-struct menu_list
-{
- file_list_t **menu_stack;
- size_t menu_stack_size;
- file_list_t **selection_buf;
- size_t selection_buf_size;
-};
-
-static void menu_list_free_list(file_list_t *list)
-{
- unsigned i;
-
- for (i = 0; i < list->size; i++)
- {
- menu_ctx_list_t list_info;
-
- list_info.list = list;
- list_info.idx = i;
- list_info.list_size = list->size;
-
- menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info);
- }
-
- file_list_free(list);
-}
-
-static void menu_list_free(menu_list_t *menu_list)
-{
- unsigned i;
- if (!menu_list)
- return;
-
- for (i = 0; i < menu_list->menu_stack_size; i++)
- {
- if (!menu_list->menu_stack[i])
- continue;
-
- menu_list_free_list(menu_list->menu_stack[i]);
- menu_list->menu_stack[i] = NULL;
- }
- for (i = 0; i < menu_list->selection_buf_size; i++)
- {
- if (!menu_list->selection_buf[i])
- continue;
-
- menu_list_free_list(menu_list->selection_buf[i]);
- menu_list->selection_buf[i] = NULL;
- }
-
- free(menu_list->menu_stack);
- free(menu_list->selection_buf);
-
- free(menu_list);
-}
-
-static menu_list_t *menu_list_new(void)
-{
- unsigned i;
- menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list));
-
- if (!list)
- return NULL;
-
- list->menu_stack = (file_list_t**)calloc(1, sizeof(*list->menu_stack));
-
- if (!list->menu_stack)
- goto error;
-
- list->selection_buf = (file_list_t**)calloc(1, sizeof(*list->selection_buf));
-
- if (!list->selection_buf)
- goto error;
-
- list->menu_stack_size = 1;
- list->selection_buf_size = 1;
-
- for (i = 0; i < list->menu_stack_size; i++)
- list->menu_stack[i] = (file_list_t*)calloc(1, sizeof(*list->menu_stack[i]));
-
- for (i = 0; i < list->selection_buf_size; i++)
- list->selection_buf[i] = (file_list_t*)calloc(1, sizeof(*list->selection_buf[i]));
-
- return list;
-
-error:
- menu_list_free(list);
- return NULL;
-}
-
-static size_t menu_list_get_stack_size(menu_list_t *list, size_t idx)
-{
- if (!list)
- return 0;
- return file_list_get_size(list->menu_stack[idx]);
-}
-
void menu_entries_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx, const char **alt)
@@ -168,12 +74,10 @@ static bool menu_list_pop_stack(menu_list_t *list,
{
menu_ctx_list_t list_info;
bool refresh = false;
- file_list_t *menu_list = NULL;
+ file_list_t *menu_list = menu_list_get(list, idx);
if (!list)
return false;
- menu_list = list->menu_stack[idx];
-
if (menu_list_get_stack_size(list, idx) <= 1)
return false;
@@ -210,11 +114,12 @@ static void menu_list_flush_stack(menu_list_t *list,
const char *label = NULL;
unsigned type = 0;
size_t entry_idx = 0;
+ file_list_t *menu_list = menu_list_get(list, idx);
if (!list)
return;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
- menu_entries_get_last(list->menu_stack[idx],
+ menu_entries_get_last(menu_list,
&path, &label, &type, &entry_idx);
while (menu_entries_flush_stack_type(
@@ -231,7 +136,9 @@ static void menu_list_flush_stack(menu_list_t *list,
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION,
&new_selection_ptr);
- menu_entries_get_last(list->menu_stack[idx],
+ menu_list = menu_list_get(list, idx);
+
+ menu_entries_get_last(menu_list,
&path, &label, &type, &entry_idx);
}
}
@@ -479,7 +386,7 @@ file_list_t *menu_entries_get_menu_stack_ptr(size_t idx)
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
if (!menu_list)
return NULL;
- return menu_list->menu_stack[idx];
+ return menu_list_get(menu_list, idx);
}
file_list_t *menu_entries_get_selection_buf_ptr(size_t idx)
@@ -488,7 +395,7 @@ file_list_t *menu_entries_get_selection_buf_ptr(size_t idx)
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
if (!menu_list)
return NULL;
- return menu_list->selection_buf[idx];
+ return menu_list_get_selection(menu_list, idx);
}
static bool menu_entries_init(void)
@@ -622,7 +529,7 @@ menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void)
if (!menu_list)
return NULL;
return (menu_file_list_cbs_t*)file_list_get_last_actiondata(
- menu_list->menu_stack[0]);
+ menu_list_get(menu_list, 0));
}
void menu_entries_get_last_stack(const char **path, const char **label,
@@ -634,7 +541,7 @@ void menu_entries_get_last_stack(const char **path, const char **label,
if (!menu_list)
return;
- menu_entries_get_last(menu_list->menu_stack[0],
+ menu_entries_get_last(menu_list_get(menu_list, 0),
path, label, file_type, entry_idx);
cbs = menu_entries_get_last_stack_actiondata();
if (cbs)
@@ -672,7 +579,7 @@ size_t menu_entries_get_size(void)
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
if (!menu_list)
return 0;
- return file_list_get_size(menu_list->selection_buf[0]);
+ return file_list_get_size(menu_list_get_selection(menu_list, 0));
}
rarch_setting_t *menu_entries_get_setting(uint32_t i)
diff --git a/menu/menu_entries.h b/menu/menu_entries.h
index d1a4a1cb5b..f2ae7f0ab3 100644
--- a/menu/menu_entries.h
+++ b/menu/menu_entries.h
@@ -130,9 +130,6 @@ typedef struct menu_file_list_cbs
} menu_file_list_cbs_t;
-
-typedef struct menu_list menu_list_t;
-
size_t menu_entries_get_end(void);
void menu_entries_get(size_t i, menu_entry_t *entry);
diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c
new file mode 100644
index 0000000000..c2a6d0b34d
--- /dev/null
+++ b/menu/widgets/menu_list.c
@@ -0,0 +1,134 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2011-2016 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#include
+
+#include
+#include
+#include
+
+#include "menu_list.h"
+
+#include "../menu_driver.h"
+
+struct menu_list
+{
+ file_list_t **menu_stack;
+ size_t menu_stack_size;
+ file_list_t **selection_buf;
+ size_t selection_buf_size;
+};
+
+void menu_list_free_list(file_list_t *list)
+{
+ unsigned i;
+
+ for (i = 0; i < list->size; i++)
+ {
+ menu_ctx_list_t list_info;
+
+ list_info.list = list;
+ list_info.idx = i;
+ list_info.list_size = list->size;
+
+ menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info);
+ }
+
+ file_list_free(list);
+}
+
+void menu_list_free(menu_list_t *menu_list)
+{
+ unsigned i;
+ if (!menu_list)
+ return;
+
+ for (i = 0; i < menu_list->menu_stack_size; i++)
+ {
+ if (!menu_list->menu_stack[i])
+ continue;
+
+ menu_list_free_list(menu_list->menu_stack[i]);
+ menu_list->menu_stack[i] = NULL;
+ }
+ for (i = 0; i < menu_list->selection_buf_size; i++)
+ {
+ if (!menu_list->selection_buf[i])
+ continue;
+
+ menu_list_free_list(menu_list->selection_buf[i]);
+ menu_list->selection_buf[i] = NULL;
+ }
+
+ free(menu_list->menu_stack);
+ free(menu_list->selection_buf);
+
+ free(menu_list);
+}
+
+menu_list_t *menu_list_new(void)
+{
+ unsigned i;
+ menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list));
+
+ if (!list)
+ return NULL;
+
+ list->menu_stack = (file_list_t**)calloc(1, sizeof(*list->menu_stack));
+
+ if (!list->menu_stack)
+ goto error;
+
+ list->selection_buf = (file_list_t**)calloc(1, sizeof(*list->selection_buf));
+
+ if (!list->selection_buf)
+ goto error;
+
+ list->menu_stack_size = 1;
+ list->selection_buf_size = 1;
+
+ for (i = 0; i < list->menu_stack_size; i++)
+ list->menu_stack[i] = (file_list_t*)calloc(1, sizeof(*list->menu_stack[i]));
+
+ for (i = 0; i < list->selection_buf_size; i++)
+ list->selection_buf[i] = (file_list_t*)calloc(1, sizeof(*list->selection_buf[i]));
+
+ return list;
+
+error:
+ menu_list_free(list);
+ return NULL;
+}
+
+file_list_t *menu_list_get(menu_list_t *list, unsigned idx)
+{
+ if (!list)
+ return NULL;
+ return list->menu_stack[idx];
+}
+
+file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx)
+{
+ if (!list)
+ return NULL;
+ return list->selection_buf[idx];
+}
+
+size_t menu_list_get_stack_size(menu_list_t *list, size_t idx)
+{
+ if (!list)
+ return 0;
+ return file_list_get_size(list->menu_stack[idx]);
+}
diff --git a/menu/widgets/menu_list.h b/menu/widgets/menu_list.h
new file mode 100644
index 0000000000..e47ea87ce6
--- /dev/null
+++ b/menu/widgets/menu_list.h
@@ -0,0 +1,62 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2016 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef _MENU_WIDGETS_LIST_H
+#define _MENU_WIDGETS_LIST_H
+
+#include
+#include
+
+#include
+
+#include
+#include
+
+#include "../menu_entries.h"
+
+RETRO_BEGIN_DECLS
+
+typedef struct menu_ctx_list
+{
+ file_list_t *list;
+ size_t list_size;
+ const char *path;
+ const char *label;
+ size_t idx;
+ enum menu_list_type type;
+ unsigned action;
+ size_t selection;
+ size_t size;
+ void *entry;
+} menu_ctx_list_t;
+
+typedef struct menu_list menu_list_t;
+
+void menu_list_free_list(file_list_t *list);
+
+void menu_list_free(menu_list_t *menu_list);
+
+menu_list_t *menu_list_new(void);
+
+file_list_t *menu_list_get(menu_list_t *list, unsigned idx);
+
+file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx);
+
+size_t menu_list_get_stack_size(menu_list_t *list, size_t idx);
+
+RETRO_END_DECLS
+
+#endif