diff --git a/Makefile.common b/Makefile.common index 672184043a..941c602e78 100644 --- a/Makefile.common +++ b/Makefile.common @@ -767,7 +767,6 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/widgets/menu_input_dialog.o \ menu/widgets/menu_input_bind_dialog.o \ menu/widgets/menu_entry.o \ - menu/widgets/menu_list.o \ menu/widgets/menu_osk.o \ menu/menu_cbs.o \ menu/cbs/menu_cbs_ok.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 602764cf15..1fdcaf5e63 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1136,7 +1136,6 @@ MENU #include "../menu/widgets/menu_dialog.c" #include "../menu/widgets/menu_input_dialog.c" #include "../menu/widgets/menu_input_bind_dialog.c" -#include "../menu/widgets/menu_list.c" #include "../menu/widgets/menu_osk.c" #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 28e534e5ef..0e38ca4097 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -24,13 +24,12 @@ #include "../menu_content.h" #include "../menu_driver.h" +#include "../menu_entries.h" #include "../menu_cbs.h" #include "../menu_input.h" #include "../menu_setting.h" #include "../menu_shader.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 48e8eed6e6..be933169de 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -24,13 +24,12 @@ #include "../menu_content.h" #include "../menu_driver.h" +#include "../menu_entries.h" #include "../menu_cbs.h" #include "../menu_input.h" #include "../menu_setting.h" #include "../menu_shader.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 eb94c82740..995e55070b 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -45,8 +45,8 @@ #include "../../core_info.h" #include "../../core.h" +#include "../menu_entries.h" #include "../widgets/menu_entry.h" -#include "../widgets/menu_list.h" #include "../widgets/menu_input_dialog.h" #include "../widgets/menu_osk.h" #include "../widgets/menu_filebrowser.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6750719740..05698cf332 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -51,14 +51,14 @@ #include "../frontend/drivers/platform_unix.h" #endif +#include "menu_cbs.h" #include "menu_content.h" #include "menu_driver.h" +#include "menu_entries.h" #include "menu_shader.h" #include "menu_networking.h" #include "widgets/menu_dialog.h" -#include "widgets/menu_list.h" #include "widgets/menu_filebrowser.h" -#include "menu_cbs.h" #include "../audio/audio_driver.h" #include "../configuration.h" diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5dbe22b948..b0f9b3b2f1 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -39,8 +39,8 @@ #include "menu_driver.h" #include "menu_cbs.h" #include "menu_event.h" +#include "menu_entries.h" #include "widgets/menu_dialog.h" -#include "widgets/menu_list.h" #include "menu_shader.h" #include "../config.def.h" diff --git a/menu/menu_entries.c b/menu/menu_entries.c index d0aeb5f5fc..ff893aad4d 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -23,8 +23,6 @@ #include "menu_driver.h" #include "menu_cbs.h" -#include "widgets/menu_list.h" - #include "../core.h" #include "../retroarch.h" #include "../version.h" @@ -36,6 +34,197 @@ static size_t menu_entries_begin = 0; static rarch_setting_t *menu_entries_list_settings = NULL; static menu_list_t *menu_entries_list = NULL; +struct menu_list +{ + size_t menu_stack_size; + size_t selection_buf_size; + file_list_t **menu_stack; + file_list_t **selection_buf; +}; + +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*)malloc(sizeof(*list)); + + if (!list) + return NULL; + + list->menu_stack_size = 1; + list->selection_buf_size = 1; + list->selection_buf = NULL; + list->menu_stack = (file_list_t**) + calloc(list->menu_stack_size, sizeof(*list->menu_stack)); + + if (!list->menu_stack) + goto error; + + list->selection_buf = (file_list_t**) + calloc(list->selection_buf_size, sizeof(*list->selection_buf)); + + if (!list->selection_buf) + goto error; + + 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 file_list_t *menu_list_get(menu_list_t *list, unsigned idx) +{ + if (!list) + return NULL; + return list->menu_stack[idx]; +} + +static file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx) +{ + if (!list) + return NULL; + return list->selection_buf[idx]; +} + +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]); +} + +static int menu_list_flush_stack_type(const char *needle, const char *label, + unsigned type, unsigned final_type) +{ + return needle ? !string_is_equal(needle, label) : (type != final_type); +} + +static bool menu_list_pop_stack(menu_list_t *list, + size_t idx, size_t *directory_ptr, bool animate) +{ + menu_ctx_list_t list_info; + bool refresh = false; + file_list_t *menu_list = menu_list_get(list, (unsigned)idx); + if (!list) + return false; + + if (menu_list_get_stack_size(list, idx) <= 1) + return false; + + list_info.type = MENU_LIST_PLAIN; + list_info.action = 0; + + if (animate) + menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + + if (menu_list->size != 0) + { + menu_ctx_list_t list_info; + + list_info.list = menu_list; + list_info.idx = menu_list->size - 1; + list_info.list_size = menu_list->size - 1; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); + } + + file_list_pop(menu_list, directory_ptr); + menu_driver_ctl(RARCH_MENU_CTL_LIST_SET_SELECTION, menu_list); + if (animate) + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + + return true; +} + +static void menu_list_flush_stack(menu_list_t *list, + size_t idx, const char *needle, unsigned final_type) +{ + bool refresh = false; + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + size_t entry_idx = 0; + file_list_t *menu_list = menu_list_get(list, (unsigned)idx); + if (!list) + return; + + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + file_list_get_last(menu_list, + &path, &label, &type, &entry_idx); + + while (menu_list_flush_stack_type( + needle, label, type, final_type) != 0) + { + size_t new_selection_ptr = menu_navigation_get_selection(); + + if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) + break; + + menu_navigation_set_selection(new_selection_ptr); + + menu_list = menu_list_get(list, (unsigned)idx); + + file_list_get_last(menu_list, + &path, &label, &type, &entry_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) diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 48679b825e..c669f9b2af 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -22,7 +22,7 @@ #include #include -#include "widgets/menu_list.h" +#include #include "menu_setting.h" #include "menu_displaylist.h" @@ -52,6 +52,31 @@ enum menu_entries_ctl_state MENU_ENTRIES_CTL_SHOW_BACK }; +enum menu_list_type +{ + MENU_LIST_PLAIN = 0, + MENU_LIST_HORIZONTAL, + MENU_LIST_TABS +}; + +typedef struct menu_list menu_list_t; + +typedef struct menu_ctx_list +{ + enum menu_list_type type; + const char *path; + char *fullpath; + const char *label; + unsigned entry_type; + unsigned action; + size_t idx; + size_t selection; + size_t size; + size_t list_size; + void *entry; + file_list_t *list; +} menu_ctx_list_t; + typedef struct menu_file_list_cbs { enum msg_hash_enums enum_idx; diff --git a/menu/menu_networking.c b/menu/menu_networking.c index a67cd554eb..e6f5cd7527 100644 --- a/menu/menu_networking.c +++ b/menu/menu_networking.c @@ -33,7 +33,6 @@ #include "menu_networking.h" #include "menu_cbs.h" #include "menu_entries.h" -#include "widgets/menu_list.h" #include "../core_info.h" #include "../configuration.h" diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c deleted file mode 100644 index 4357e3f0b6..0000000000 --- a/menu/widgets/menu_list.c +++ /dev/null @@ -1,212 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - 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 "menu_list.h" - -#include "../menu_driver.h" - -struct menu_list -{ - size_t menu_stack_size; - size_t selection_buf_size; - file_list_t **menu_stack; - file_list_t **selection_buf; -}; - -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*)malloc(sizeof(*list)); - - if (!list) - return NULL; - - list->menu_stack_size = 1; - list->selection_buf_size = 1; - list->selection_buf = NULL; - list->menu_stack = (file_list_t**) - calloc(list->menu_stack_size, sizeof(*list->menu_stack)); - - if (!list->menu_stack) - goto error; - - list->selection_buf = (file_list_t**) - calloc(list->selection_buf_size, sizeof(*list->selection_buf)); - - if (!list->selection_buf) - goto error; - - 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]); -} - -static int menu_list_flush_stack_type(const char *needle, const char *label, - unsigned type, unsigned final_type) -{ - return needle ? !string_is_equal(needle, label) : (type != final_type); -} - -void menu_list_flush_stack(menu_list_t *list, - size_t idx, const char *needle, unsigned final_type) -{ - bool refresh = false; - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - size_t entry_idx = 0; - file_list_t *menu_list = menu_list_get(list, (unsigned)idx); - if (!list) - return; - - menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - file_list_get_last(menu_list, - &path, &label, &type, &entry_idx); - - while (menu_list_flush_stack_type( - needle, label, type, final_type) != 0) - { - size_t new_selection_ptr = menu_navigation_get_selection(); - - if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) - break; - - menu_navigation_set_selection(new_selection_ptr); - - menu_list = menu_list_get(list, (unsigned)idx); - - file_list_get_last(menu_list, - &path, &label, &type, &entry_idx); - } -} - -bool menu_list_pop_stack(menu_list_t *list, - size_t idx, size_t *directory_ptr, bool animate) -{ - menu_ctx_list_t list_info; - bool refresh = false; - file_list_t *menu_list = menu_list_get(list, (unsigned)idx); - if (!list) - return false; - - if (menu_list_get_stack_size(list, idx) <= 1) - return false; - - list_info.type = MENU_LIST_PLAIN; - list_info.action = 0; - - if (animate) - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); - - if (menu_list->size != 0) - { - menu_ctx_list_t list_info; - - list_info.list = menu_list; - list_info.idx = menu_list->size - 1; - list_info.list_size = menu_list->size - 1; - - menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); - } - - file_list_pop(menu_list, directory_ptr); - menu_driver_ctl(RARCH_MENU_CTL_LIST_SET_SELECTION, menu_list); - if (animate) - menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - - return true; -} diff --git a/menu/widgets/menu_list.h b/menu/widgets/menu_list.h deleted file mode 100644 index dc11a65783..0000000000 --- a/menu/widgets/menu_list.h +++ /dev/null @@ -1,75 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - 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 - -RETRO_BEGIN_DECLS - -enum menu_list_type -{ - MENU_LIST_PLAIN = 0, - MENU_LIST_HORIZONTAL, - MENU_LIST_TABS -}; - -typedef struct menu_ctx_list -{ - enum menu_list_type type; - const char *path; - char *fullpath; - const char *label; - unsigned entry_type; - unsigned action; - size_t idx; - size_t selection; - size_t size; - size_t list_size; - void *entry; - file_list_t *list; -} 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); - -void menu_list_flush_stack(menu_list_t *list, - size_t idx, const char *needle, unsigned final_type); - -bool menu_list_pop_stack(menu_list_t *list, - size_t idx, size_t *directory_ptr, bool animate); - -RETRO_END_DECLS - -#endif