From c9c7aea1847a8eda406f4f629b61af6cd7d4a555 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 20 Oct 2016 15:57:35 +0200 Subject: [PATCH] Create sublabel callbacks --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/cbs/menu_cbs_sublabel.c | 75 ++++++++++++++++++++++++++++++++++++ menu/menu_cbs.c | 4 ++ menu/menu_cbs.h | 3 ++ menu/menu_entries.h | 6 +++ menu/widgets/menu_entry.c | 7 ++++ 7 files changed, 97 insertions(+) create mode 100644 menu/cbs/menu_cbs_sublabel.c diff --git a/Makefile.common b/Makefile.common index b04e7e22dc..c9ecaff208 100644 --- a/Makefile.common +++ b/Makefile.common @@ -542,6 +542,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/cbs/menu_cbs_scan.o \ menu/cbs/menu_cbs_get_value.o \ menu/cbs/menu_cbs_label.o \ + menu/cbs/menu_cbs_sublabel.o \ menu/cbs/menu_cbs_title.o \ menu/cbs/menu_cbs_up.o \ menu/cbs/menu_cbs_down.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 12fcb024ba..93aa374a0e 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -927,6 +927,7 @@ MENU #include "../menu/cbs/menu_cbs_scan.c" #include "../menu/cbs/menu_cbs_get_value.c" #include "../menu/cbs/menu_cbs_label.c" +#include "../menu/cbs/menu_cbs_sublabel.c" #include "../menu/cbs/menu_cbs_up.c" #include "../menu/cbs/menu_cbs_down.c" #include "../menu/cbs/menu_cbs_contentlist_switch.c" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c new file mode 100644 index 0000000000..1c64ae447e --- /dev/null +++ b/menu/cbs/menu_cbs_sublabel.c @@ -0,0 +1,75 @@ +/* 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 "../menu_driver.h" +#include "../menu_cbs.h" +#include "../menu_navigation.h" +#include "../../file_path_special.h" + +#ifndef BIND_ACTION_SUBLABEL +#define BIND_ACTION_SUBLABEL(cbs, name) \ + cbs->action_sublabel = name; \ + cbs->action_sublabel_ident = #name; +#endif + +static int action_bind_sublabel_generic( + file_list_t *list, + unsigned type, unsigned i, + const char *label, const char *path, + char *s, size_t len) +{ + return 0; +} + +#if 0 +static int action_bind_sublabel_information( + file_list_t *list, + unsigned type, unsigned i, + const char *label, const char *path, + char *s, size_t len) +{ + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INFORMATION), len); + return 0; +} +#endif + +int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx) +{ + if (!cbs) + return -1; + + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_generic); + + if (cbs->enum_idx != MSG_UNKNOWN) + { + switch (cbs->enum_idx) + { +#if 0 + case MENU_ENUM_LABEL_INFORMATION: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_information); + break; +#endif + default: + case MSG_UNKNOWN: + break; + } + } + + return -1; +} diff --git a/menu/menu_cbs.c b/menu/menu_cbs.c index 8698d29b8a..1546145a43 100644 --- a/menu/menu_cbs.c +++ b/menu/menu_cbs.c @@ -130,6 +130,10 @@ void menu_cbs_init(void *data, menu_cbs_init_log(repr_label, "LABEL", cbs->action_label_ident); + menu_cbs_init_bind_sublabel(cbs, path, label, type, idx); + + menu_cbs_init_log(repr_label, "SUBLABEL", cbs->action_sublabel_ident); + bind_info.cbs = cbs; bind_info.path = path; bind_info.label = label; diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index aff7aaec07..6963772151 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -160,6 +160,9 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, int menu_cbs_init_bind_label(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx); +int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx); + int menu_cbs_init_bind_up(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx); diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 7a0832c619..f3015c2297 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -111,6 +111,12 @@ typedef struct menu_file_list_cbs char *s, size_t len); const char *action_label_ident; + int (*action_sublabel)(file_list_t *list, + unsigned type, unsigned i, + const char *label, const char *path, + char *s, size_t len); + const char *action_sublabel_ident; + int (*action_down)(unsigned type, const char *label); const char *action_down_ident; diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c index f5a368efc4..bdb367d383 100644 --- a/menu/widgets/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -430,6 +430,13 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, label, path, entry->rich_label, sizeof(entry->rich_label)); + + if (cbs->action_sublabel) + cbs->action_sublabel(list, + entry->type, i, + label, path, + entry->sublabel, + sizeof(entry->sublabel)); } entry->idx = i;