Standardise and improve playlist display

This commit is contained in:
jdgleaver 2019-02-22 15:20:59 +00:00
parent d2f73e3f33
commit 4a26e4bc97
6 changed files with 154 additions and 194 deletions

View File

@ -710,9 +710,8 @@ static const bool playlist_sort_alphabetical = true;
/* File format to use when writing playlists to disk */
static const bool playlist_use_old_format = false;
/* Show currently associated core next to each playlist entry
* (RGUI only) */
static const bool playlist_show_core_name = true;
/* Always show currently associated core next to each playlist entry */
static const bool playlist_show_core_name = false;
static const bool playlist_show_sublabels = false;

View File

@ -1501,7 +1501,6 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("rgui_background_filler_thickness_enable", &settings->bools.menu_rgui_background_filler_thickness_enable, true, true, false);
SETTING_BOOL("rgui_border_filler_thickness_enable", &settings->bools.menu_rgui_border_filler_thickness_enable, true, true, false);
SETTING_BOOL("rgui_border_filler_enable", &settings->bools.menu_rgui_border_filler_enable, true, true, false);
SETTING_BOOL("playlist_show_core_name", &settings->bools.playlist_show_core_name, true, playlist_show_core_name, false);
#endif
#ifdef HAVE_XMB
SETTING_BOOL("xmb_shadows_enable", &settings->bools.menu_xmb_shadows_enable, true, xmb_shadows_enable, false);
@ -1576,7 +1575,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("playlist_use_old_format", &settings->bools.playlist_use_old_format, true, playlist_use_old_format, false);
SETTING_BOOL("content_runtime_log", &settings->bools.content_runtime_log, true, content_runtime_log, false);
SETTING_BOOL("playlist_show_sublabels", &settings->bools.playlist_show_sublabels, true, playlist_show_sublabels, false);
SETTING_BOOL("playlist_show_core_name", &settings->bools.playlist_show_core_name, true, playlist_show_core_name, false);
SETTING_BOOL("playlist_sort_alphabetical", &settings->bools.playlist_sort_alphabetical, true, playlist_sort_alphabetical, false);
*size = count;

View File

@ -8240,7 +8240,7 @@ MSG_HASH(
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_CORE_NAME,
"Show associated cores in playlists"
"Always show associated cores in playlists"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_CORE_NAME,

View File

@ -1637,15 +1637,6 @@ static void rgui_render(void *data, bool is_idle)
char title_buf[255];
unsigned timedate_x = RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE - RGUI_TERM_START_X(fb_width);
unsigned core_name_len = ((timedate_x - RGUI_TERM_START_X(fb_width)) / FONT_WIDTH_STRIDE) - 3;
bool show_playlist_labels = !settings->bools.playlist_show_core_name && rgui->is_playlist;
playlist_t *playlist = NULL;
/* Get cached playlist, if required */
if (show_playlist_labels)
{
playlist = playlist_get_cached();
show_playlist_labels = show_playlist_labels && playlist;
}
/* Print title */
title_buf[0] = '\0';
@ -1685,7 +1676,6 @@ static void rgui_render(void *data, bool is_idle)
size_t entry_title_buf_len = 0;
bool has_value = false;
bool entry_selected = menu_entry_is_currently_selected((unsigned)i);
bool show_playlist_label = show_playlist_labels;
size_t selection = menu_navigation_get_selection();
if (i > (selection + 100))
@ -1696,54 +1686,20 @@ static void rgui_render(void *data, bool is_idle)
entry_title_buf[0] = '\0';
type_str_buf[0] = '\0';
/* Get playlist label for current entry, if required */
if (show_playlist_label)
{
/* Ensure that we fallback to the normal entry label if
* any of the following playlist access fails... */
show_playlist_label = false;
/* Get current entry */
menu_entry_t entry;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)i, NULL, true);
if (i < playlist_get_size(playlist))
{
const char *playlist_label = NULL;
playlist_get_index(playlist, i, NULL, &playlist_label, NULL, NULL, NULL, NULL);
/* Read entry parameters */
entry_spacing = menu_entry_get_spacing(&entry);
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
entry_path = menu_entry_get_rich_label(&entry);
if (!string_is_empty(playlist_label))
{
entry_path = strdup(playlist_label);
show_playlist_label = true;
}
}
}
/* Determine whether entry has a value component */
has_value = !string_is_empty(entry_value);
if (show_playlist_label)
{
/* We are using the current playlist label as the entry title
* > We already have entry_path
* > entry_spacing is irrelevant (set to zero)
* > entry_value is irrelevant
* > has_value is false */
entry_spacing = 0;
has_value = false;
}
else
{
/* Either this is not a playlist entry, or we are ignoring
* playlists - extract all required info from entry itself */
menu_entry_t entry;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)i, NULL, true);
/* Read entry parameters */
entry_spacing = menu_entry_get_spacing(&entry);
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
entry_path = menu_entry_get_rich_label(&entry);
/* Determine whether entry has a value component */
has_value = !string_is_empty(entry_value);
menu_entry_free(&entry);
}
menu_entry_free(&entry);
/* Format entry title string */
entry_title_max_len = RGUI_TERM_WIDTH(fb_width) - (1 + 2);

View File

@ -99,6 +99,20 @@ static char new_lbl_entry[4096] = {0};
static char new_entry[4096] = {0};
static enum msg_hash_enums new_type = MSG_UNKNOWN;
/* Spacers used for '<content> - <core name>' labels
* in playlists */
#define PL_LABEL_SPACER_DEFAULT " | "
#define PL_LABEL_SPACER_RGUI " | "
#if defined(__APPLE__)
/* UTF-8 support is currently broken on Apple devices... */
#define PL_LABEL_SPACER_OZONE " | "
#else
/* <EM SPACE><BULLET><EM SPACE>
* UCN equivalent: "\u2003\u2022\u2003" */
#define PL_LABEL_SPACER_OZONE "\xE2\x80\x83\xE2\x80\xA2\xE2\x80\x83"
#endif
#define PL_LABEL_SPACER_MAXLEN 37
#ifdef HAVE_NETWORKING
/* HACK - we have to find some way to pass state inbetween
* function pointer callback functions that don't necessarily
@ -1304,7 +1318,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
}
static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
playlist_t *playlist, const char *path_playlist, bool is_history)
playlist_t *playlist, const char *path_playlist, bool is_collection)
{
unsigned i;
size_t selection = menu_navigation_get_selection();
@ -1312,41 +1326,45 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
settings_t *settings = config_get_ptr();
bool is_rgui = string_is_equal(settings->arrays.menu_driver, "rgui");
bool get_runtime = string_is_equal(path_playlist, "history") && g_defaults.content_runtime && settings->bools.content_runtime_log;
char label_spacer[PL_LABEL_SPACER_MAXLEN];
label_spacer[0] = '\0';
if (list_size == 0)
goto error;
/* Get spacer for menu entry labels (<content><spacer><core>) */
if (is_rgui)
strlcpy(label_spacer, PL_LABEL_SPACER_RGUI, sizeof(label_spacer));
else if (string_is_equal(settings->arrays.menu_driver, "ozone"))
strlcpy(label_spacer, PL_LABEL_SPACER_OZONE, sizeof(label_spacer));
else
strlcpy(label_spacer, PL_LABEL_SPACER_DEFAULT, sizeof(label_spacer));
/* Inform menu driver of current system name */
if (!string_is_empty(info->path))
{
size_t lpl_basename_size = PATH_MAX_LENGTH * sizeof(char);
char *lpl_basename = (char*)malloc(lpl_basename_size);
char lpl_basename[PATH_MAX_LENGTH];
lpl_basename[0] = '\0';
fill_pathname_base_noext(lpl_basename, info->path, lpl_basename_size);
menu_driver_set_thumbnail_system(lpl_basename, lpl_basename_size);
free(lpl_basename);
fill_pathname_base_noext(lpl_basename, info->path, sizeof(lpl_basename));
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
}
/* preallocate the file list */
/* Preallocate the file list */
file_list_reserve(info->list, list_size);
for (i = 0; i < list_size; i++)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *path_copy = (char*)malloc(path_size);
char *fill_buf = (char*)malloc(path_size);
const char *core_path = NULL;
const char *core_name = NULL;
char menu_entry_label[PATH_MAX_LENGTH];
const char *path = NULL;
const char *label = NULL;
const char *core_path = NULL;
const char *core_name = NULL;
fill_buf[0] = path_copy[0] = '\0';
if (!string_is_empty(info->path))
strlcpy(path_copy, info->path, path_size);
path = path_copy;
menu_entry_label[0] = '\0';
/* Read playlist entry */
playlist_get_index(playlist, i,
&path, &label, &core_path, &core_name, NULL, NULL);
@ -1379,69 +1397,66 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
}
}
if (core_name)
strlcpy(fill_buf, core_name, path_size);
/* Note: this condition is never met when using RGUI,
* since 'is_history' is always set to 'true'.
* But if it ever were then we must ensure that thumbnail
* updates are omitted (since this functionality is
* handled elsewhere). */
if (!is_history && i == selection && !string_is_empty(label) && !is_rgui)
/* If this is a standard collection (not a history list or
* favourites), trigger thumbnail update for current selection.
* Note: Thumbnail updates must be omitted when using RGUI,
* since this functionality is handled elsewhere... */
if (i == selection)
{
char *content_basename = strdup(label);
menu_driver_set_thumbnail_content(content_basename, strlen(content_basename) + 1);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL);
free(content_basename);
if (is_collection && !string_is_empty(label) && !is_rgui)
{
char *content_basename = strdup(label);
/* Note: If menu_driver_set_thumbnail_content() accepted a const pointer,
* we could save a string duplication here... */
menu_driver_set_thumbnail_content(content_basename, strlen(content_basename) + 1);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL);
free(content_basename);
}
}
if (path)
if (!string_is_empty(path))
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *path_short = (char*)malloc(path_size);
/* Standard playlist entry
* > Base menu entry label is always playlist label
* > If playlist label is NULL, fallback to playlist entry file name
* > If playlist sublabels are enabled, no further additions
* are required
* > If playlist sublabels are disabled:
* > If this is *not* a standard collection (i.e. a history list or
* favourites) *or* 'show core name' is enabled, add currently
* associated core (if set) */
path_short[0] = '\0';
if (string_is_empty(label))
fill_short_pathname_representation(menu_entry_label, path, sizeof(menu_entry_label));
else
strlcpy(menu_entry_label, label, sizeof(menu_entry_label));
fill_short_pathname_representation(path_short, path,
path_size);
strlcpy(fill_buf,
(!string_is_empty(label)) ? label : path_short,
path_size);
if (!string_is_empty(core_name))
if (!settings->bools.playlist_show_sublabels)
{
if (!string_is_equal(core_name,
file_path_str(FILE_PATH_DETECT)))
if (!is_collection || settings->bools.playlist_show_core_name)
{
char *tmp = (char*)malloc(path_size);
tmp[0] = '\0';
snprintf(tmp, path_size, " (%s)", core_name);
strlcat(fill_buf, tmp, path_size);
free(tmp);
if (!string_is_empty(core_name) && !string_is_equal(core_name, file_path_str(FILE_PATH_DETECT)))
{
strlcat(menu_entry_label, label_spacer, sizeof(menu_entry_label));
strlcat(menu_entry_label, core_name, sizeof(menu_entry_label));
}
}
}
free(path_short);
menu_entries_append_enum(info->list, menu_entry_label, path,
MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_RPL_ENTRY, 0, i);
}
else
{
if (core_name)
strlcpy(menu_entry_label, core_name, sizeof(menu_entry_label));
menu_entries_append_enum(info->list, menu_entry_label, path_playlist,
MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_PLAYLIST_ENTRY, 0, i);
}
if (!path)
menu_entries_append_enum(info->list, fill_buf, path_playlist,
MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_PLAYLIST_ENTRY, 0, i);
else if (is_history)
menu_entries_append_enum(info->list, fill_buf,
path, MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_RPL_ENTRY, 0, i);
else
menu_entries_append_enum(info->list, label,
path, MENU_ENUM_LABEL_PLAYLIST_ENTRY, FILE_TYPE_RPL_ENTRY, 0, i);
info->count++;
free(path_copy);
free(fill_buf);
}
return 0;
@ -2585,7 +2600,6 @@ static int menu_displaylist_parse_horizontal_list(
{
menu_ctx_list_t list_info;
menu_ctx_list_t list_horiz_info;
bool is_historylist = false;
playlist_t *playlist = NULL;
struct item_file *item = NULL;
@ -2617,10 +2631,6 @@ static int menu_displaylist_parse_horizontal_list(
fill_pathname_base_noext(lpl_basename, item->path, sizeof(lpl_basename));
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
/* Note: Redundant, since this function is never used for history lists... */
if (string_is_equal(lpl_basename, "content_history"))
is_historylist = true;
fill_pathname_join(
path_playlist,
settings->paths.directory_playlist,
@ -2633,15 +2643,12 @@ static int menu_displaylist_parse_horizontal_list(
if (playlist)
{
/* Note: If this function were used for history lists, then history
* lists would be sorted alphabetically. This is incorrect behaviour.
* Fortunately it never happens... */
if (sort)
playlist_qsort(playlist);
menu_displaylist_parse_playlist(info,
playlist,
msg_hash_to_str(MENU_ENUM_LABEL_COLLECTION), is_historylist);
msg_hash_to_str(MENU_ENUM_LABEL_COLLECTION), true);
}
return 0;
@ -4167,6 +4174,7 @@ static void menu_displaylist_parse_playlist_generic(
menu_displaylist_info_t *info,
const char *playlist_name,
const char *playlist_path,
bool is_collection,
bool sort,
int *ret)
{
@ -4182,7 +4190,7 @@ static void menu_displaylist_parse_playlist_generic(
playlist_qsort(playlist);
*ret = menu_displaylist_parse_playlist(info,
playlist, playlist_name, true);
playlist, playlist_name, is_collection);
}
}
@ -4849,7 +4857,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
playlist_qsort(playlist);
ret = menu_displaylist_parse_playlist(info,
playlist, path_playlist, false);
playlist, path_playlist, true);
}
if (ret == 0)
@ -4870,7 +4878,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu, info,
"history",
settings->paths.path_content_history,
false,
false, /* Not a collection */
false, /* Do not sort */
&ret);
else
{
@ -4895,6 +4904,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu_displaylist_parse_playlist_generic(menu, info,
"favorites",
settings->paths.path_content_favorites,
false, /* Not a conventional collection */
settings->bools.playlist_sort_alphabetical,
&ret);
@ -4924,7 +4934,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu_displaylist_parse_playlist_generic(menu, info,
"music_history",
settings->paths.path_content_music_history,
false,
false, /* Not a collection */
false, /* Do not sort */
&ret);
if (info->count == 0)
@ -4956,7 +4967,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu_displaylist_parse_playlist_generic(menu, info,
"video_history",
settings->paths.path_content_video_history,
false,
false, /* Not a collection */
false, /* Do not sort */
&ret);
count++;
}
@ -5319,41 +5331,36 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
info->need_push = true;
break;
case DISPLAYLIST_PLAYLIST_SETTINGS_LIST:
{
settings_t *settings = config_get_ptr();
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_HISTORY_LIST_ENABLE,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE,
PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_ENTRY_RENAME,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_ENTRY_REMOVE,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SORT_ALPHABETICAL,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_USE_OLD_FORMAT,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS,
PARSE_ONLY_BOOL, false);
if (string_is_equal(settings->arrays.menu_driver, "rgui"))
{
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SHOW_CORE_NAME,
PARSE_ONLY_BOOL, false);
}
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_HISTORY_LIST_ENABLE,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE,
PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_ENTRY_RENAME,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_ENTRY_REMOVE,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SORT_ALPHABETICAL,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_USE_OLD_FORMAT,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS,
PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_PLAYLIST_SHOW_CORE_NAME,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_playlist_associations(info);
info->need_push = true;
menu_displaylist_parse_playlist_associations(info);
info->need_push = true;
}
break;
case DISPLAYLIST_INPUT_HOTKEY_BINDS_LIST:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
@ -8139,6 +8146,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu_displaylist_parse_playlist_generic(menu, info,
path_basename(info->path),
info->path,
true, /* Is a collection */
settings->bools.playlist_sort_alphabetical,
&ret);
ret = 0; /* Why do we do this...? */
@ -8161,7 +8169,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
menu_displaylist_parse_playlist_generic(menu, info,
"images_history",
settings->paths.path_content_image_history,
false,
false, /* Not a collection */
false, /* Do not sort */
&ret);
count++;
}

View File

@ -9853,24 +9853,21 @@ static bool setting_append_list(
SD_FLAG_NONE
);
if (string_is_equal(settings->arrays.menu_driver, "rgui"))
{
CONFIG_BOOL(
list, list_info,
&settings->bools.playlist_show_core_name,
MENU_ENUM_LABEL_PLAYLIST_SHOW_CORE_NAME,
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_CORE_NAME,
playlist_show_core_name,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
}
CONFIG_BOOL(
list, list_info,
&settings->bools.playlist_show_core_name,
MENU_ENUM_LABEL_PLAYLIST_SHOW_CORE_NAME,
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_CORE_NAME,
playlist_show_core_name,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
END_SUB_GROUP(list, list_info, parent_group);