(XMB) Add optional thumbnail scaling

This commit is contained in:
jdgleaver 2019-06-07 16:38:17 +01:00
parent 03c45f2ec8
commit cfaaa5eeff
10 changed files with 121 additions and 40 deletions

View File

@ -827,6 +827,8 @@ static const unsigned menu_timedate_style = 5;
static const bool xmb_vertical_thumbnails = false;
static const unsigned xmb_thumbnail_scale_factor = 100;
#ifdef IOS
static const bool ui_companion_start_on_boot = false;
#else

View File

@ -1777,6 +1777,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
SETTING_UINT("menu_font_color_red", &settings->uints.menu_font_color_red, true, menu_font_color_red, false);
SETTING_UINT("menu_font_color_green", &settings->uints.menu_font_color_green, true, menu_font_color_green, false);
SETTING_UINT("menu_font_color_blue", &settings->uints.menu_font_color_blue, true, menu_font_color_blue, false);
SETTING_UINT("menu_xmb_thumbnail_scale_factor", &settings->uints.menu_xmb_thumbnail_scale_factor, true, xmb_thumbnail_scale_factor, false);
#endif
SETTING_UINT("materialui_menu_color_theme", &settings->uints.menu_materialui_color_theme, true, MATERIALUI_THEME_BLUE, false);
SETTING_UINT("menu_shader_pipeline", &settings->uints.menu_xmb_shader_pipeline, true, menu_shader_pipeline, false);

View File

@ -473,6 +473,7 @@ typedef struct settings
unsigned menu_xmb_alpha_factor;
unsigned menu_xmb_theme;
unsigned menu_xmb_color_theme;
unsigned menu_xmb_thumbnail_scale_factor;
unsigned menu_materialui_color_theme;
unsigned menu_ozone_color_theme;
unsigned menu_font_color_red;

View File

@ -1151,6 +1151,8 @@ MSG_HASH(MENU_ENUM_LABEL_LEFT_THUMBNAILS,
"left thumbnails")
MSG_HASH(MENU_ENUM_LABEL_XMB_VERTICAL_THUMBNAILS,
"xmb_vertical_thumbnails")
MSG_HASH(MENU_ENUM_LABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR,
"menu_xmb_thumbnail_scale_factor")
MSG_HASH(MENU_ENUM_LABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD,
"menu_thumbnail_upscale_threshold")
MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER,

View File

@ -3034,6 +3034,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_XMB_VERTICAL_THUMBNAILS,
"Thumbnails Vertical Disposition"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MENU_XMB_THUMBNAIL_SCALE_FACTOR,
"Thumbnail Scale Factor"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR,
"Reduce thumbnail display size by scaling maximum allowed width."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MENU_THUMBNAIL_UPSCALE_THRESHOLD,
"Thumbnail Upscaling Threshold"

View File

@ -440,6 +440,7 @@ default_sublabel_macro(action_bind_sublabel_xmb_layout,
default_sublabel_macro(action_bind_sublabel_xmb_icon_theme, MENU_ENUM_SUBLABEL_XMB_THEME)
default_sublabel_macro(action_bind_sublabel_xmb_shadows_enable, MENU_ENUM_SUBLABEL_XMB_SHADOWS_ENABLE)
default_sublabel_macro(action_bind_sublabel_xmb_vertical_thumbnails, MENU_ENUM_SUBLABEL_XMB_VERTICAL_THUMBNAILS)
default_sublabel_macro(action_bind_sublabel_menu_xmb_thumbnail_scale_factor, MENU_ENUM_SUBLABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR)
default_sublabel_macro(action_bind_sublabel_menu_color_theme, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_COLOR_THEME)
default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME)
default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR)
@ -1466,6 +1467,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_XMB_VERTICAL_THUMBNAILS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_vertical_thumbnails);
break;
case MENU_ENUM_LABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_thumbnail_scale_factor);
break;
case MENU_ENUM_LABEL_XMB_LAYOUT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_layout);
break;

View File

@ -2942,7 +2942,15 @@ static int xmb_draw_item(
&& xmb->left_thumbnail
&& settings->bools.menu_xmb_vertical_thumbnails)
)
{
ticker_limit = 40 * scale_mod[1];
/* Can increase text length if thumbnail is downscaled */
if (settings->uints.menu_xmb_thumbnail_scale_factor < 100)
ticker_limit +=
(unsigned)((1.0f - ((float)settings->uints.menu_xmb_thumbnail_scale_factor / 100.0f)) *
15.0f * scale_mod[1]);
}
else
ticker_limit = 70 * scale_mod[2];
}
@ -3401,6 +3409,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
unsigned height = video_info->height;
const float under_thumb_margin = 0.96;
float scale_factor = 0.0f;
float thumbnail_scale_factor = 0.0f;
float pseudo_font_length = 0.0f;
xmb_handle_t *xmb = (xmb_handle_t*)data;
settings_t *settings = config_get_ptr();
@ -3411,6 +3420,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
return;
scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100);
thumbnail_scale_factor = ((float)settings->uints.menu_xmb_thumbnail_scale_factor / 100.0f);
pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4;
msg[0] = '\0';
@ -3484,15 +3494,50 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
/* Save State thumbnail, right side */
if (xmb->savestate_thumbnail)
{
float thumb_width = 0.0f;
float thumb_height = 0.0f;
float thumb_max_width = (float)width - (xmb->icon_size / 6)
- (xmb->margins_screen_left * scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
/* Limit thumbnail width */
if (xmb->savestate_thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
thumb_width = (xmb->savestate_thumbnail_width * scale_mod[4]) *
(thumb_max_width_scaled / (xmb->savestate_thumbnail_width * scale_mod[4]));
thumb_height = (xmb->savestate_thumbnail_height * scale_mod[4]) *
(thumb_max_width_scaled / (xmb->savestate_thumbnail_width * scale_mod[4]));
}
else
{
thumb_width = xmb->savestate_thumbnail_width * scale_mod[4];
thumb_height = xmb->savestate_thumbnail_height * scale_mod[4];
}
/* Limit thumbnail height to screen height + margin. */
if (xmb->margins_screen_top + xmb->icon_size + thumb_height >=
((float)height * under_thumb_margin))
{
thumb_width = thumb_width *
((((float)height * under_thumb_margin) -
xmb->margins_screen_top - xmb->icon_size) /
thumb_height);
thumb_height = thumb_height *
((((float)height * under_thumb_margin) -
xmb->margins_screen_top - xmb->icon_size) /
thumb_height);
}
xmb_draw_thumbnail(video_info,
xmb, &coord_white[0], width, height,
xmb->margins_screen_left * scale_mod[5] +
xmb->icon_spacing_horizontal + pseudo_font_length,
xmb->margins_screen_top + xmb->icon_size +
xmb->savestate_thumbnail_height * scale_mod[4],
xmb->savestate_thumbnail_width * scale_mod[4],
xmb->savestate_thumbnail_height * scale_mod[4],
(float)width - (xmb->icon_size / 6) - thumb_max_width +
((thumb_max_width - thumb_width) / 2),
xmb->margins_screen_top + xmb->icon_size + thumb_height,
thumb_width, thumb_height,
xmb->savestate_thumbnail);
}
/* This is used for hiding thumbnails when going into sub-levels in the
* Quick Menu as well as when selecting "Information" for a playlist entry.
@ -3522,6 +3567,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float thumb_max_width = (float)width - (xmb->icon_size / 6)
- (xmb->margins_screen_left * scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
#ifdef XMB_DEBUG
RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n",
@ -3529,12 +3575,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->thumbnail_width * scale_mod[4] > thumb_max_width)
if (xmb->thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
thumb_width = (xmb->thumbnail_width * scale_mod[4]) *
(thumb_max_width / (xmb->thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->thumbnail_width * scale_mod[4]));
thumb_height = (xmb->thumbnail_height * scale_mod[4]) *
(thumb_max_width / (xmb->thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->thumbnail_width * scale_mod[4]));
}
else
{
@ -3584,7 +3630,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float left_thumb_width = 0.0f;
float left_thumb_height = 0.0f;
float thumb_max_width = xmb->icon_size * 3.4;
float thumb_max_width = xmb->icon_size * 3.4;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
float y_offset_factor = !(xmb->depth == 1) ? 2.1 : 1;
float thumb_max_height = ((float)height - (96.0 * scale_factor)) -
xmb->margins_screen_top -
(xmb->icon_size * y_offset_factor);
#ifdef XMB_DEBUG
RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n",
@ -3592,12 +3643,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width)
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
left_thumb_width = (xmb->left_thumbnail_width * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
left_thumb_height = (xmb->left_thumbnail_height * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
}
else
{
@ -3606,30 +3657,21 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
}
/* Limit left thumbnail height to screen height + margin. */
if (xmb->margins_screen_top + xmb->icon_size *
(!(xmb->depth == 1)? 2.1 : 1) +
left_thumb_height >=
((float)height - (96.0 * scale_factor)))
if (left_thumb_height >= thumb_max_height)
{
left_thumb_width = left_thumb_width *
((((float)height - (96.0 * scale_factor))
- xmb->margins_screen_top -
(xmb->icon_size * (!(xmb->depth == 1)? 2.1 : 1))) /
left_thumb_height);
(thumb_max_height / left_thumb_height);
left_thumb_height = left_thumb_height *
((((float)height - (96.0 * scale_factor))
- xmb->margins_screen_top -
(xmb->icon_size * (!(xmb->depth == 1)? 2.1 : 1))) /
left_thumb_height);
left_thumb_height = thumb_max_height;
}
xmb_draw_thumbnail(video_info,
xmb, &coord_white[0], width, height,
(xmb->icon_size / 6) +
((thumb_max_width - left_thumb_width) / 2),
xmb->margins_screen_top + xmb->icon_size *
(!(xmb->depth == 1)? 2.1 : 1) + left_thumb_height,
xmb->margins_screen_top + (xmb->icon_size * y_offset_factor) +
left_thumb_height + (!(xmb->depth == 1) ?
(1.0f - thumbnail_scale_factor) * 0.5f * (thumb_max_height - left_thumb_height) : 0),
left_thumb_width, left_thumb_height,
xmb->left_thumbnail);
}
@ -3656,6 +3698,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float thumb_max_width = (float)width - (xmb->icon_size / 6)
- (xmb->margins_screen_left * scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
#ifdef XMB_DEBUG
RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n",
@ -3663,12 +3706,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width)
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
left_thumb_width = (xmb->left_thumbnail_width * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
left_thumb_height = (xmb->left_thumbnail_height * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
}
else
{
@ -3717,6 +3760,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float left_thumb_width = 0.0f;
float left_thumb_height = 0.0f;
float thumb_max_width = xmb->icon_size * 2.4;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
#ifdef XMB_DEBUG
RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n",
@ -3724,12 +3768,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->left_thumbnail_width > thumb_max_width)
if (xmb->left_thumbnail_width > thumb_max_width_scaled)
{
left_thumb_width = xmb->left_thumbnail_width *
(thumb_max_width / xmb->left_thumbnail_width);
(thumb_max_width_scaled / xmb->left_thumbnail_width);
left_thumb_height = xmb->left_thumbnail_height *
(thumb_max_width / xmb->left_thumbnail_width);
(thumb_max_width_scaled / xmb->left_thumbnail_width);
}
else
{
@ -3960,6 +4004,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float thumb_max_width = (float)width - (xmb->icon_size / 6) -
(xmb->margins_screen_left * scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
#ifdef XMB_DEBUG
RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n",
@ -3967,12 +4012,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->thumbnail_width * scale_mod[4] > thumb_max_width)
if (xmb->thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
thumb_width = (xmb->thumbnail_width * scale_mod[4]) *
(thumb_max_width / (xmb->thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->thumbnail_width * scale_mod[4]));
thumb_height = (xmb->thumbnail_height * scale_mod[4]) *
(thumb_max_width / (xmb->thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->thumbnail_width * scale_mod[4]));
}
else
{
@ -4022,6 +4067,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
float thumb_max_width = (float)width - (xmb->icon_size / 6) -
(xmb->margins_screen_left * scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
float thumb_max_width_scaled = thumb_max_width * thumbnail_scale_factor;
#ifdef XMB_DEBUG
RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n",
@ -4029,12 +4075,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width)
if (xmb->left_thumbnail_width * scale_mod[4] > thumb_max_width_scaled)
{
left_thumb_width = (xmb->left_thumbnail_width * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
left_thumb_height = (xmb->left_thumbnail_height * scale_mod[4]) *
(thumb_max_width / (xmb->left_thumbnail_width * scale_mod[4]));
(thumb_max_width_scaled / (xmb->left_thumbnail_width * scale_mod[4]));
}
else
{

View File

@ -4462,6 +4462,7 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
{MENU_ENUM_LABEL_THUMBNAILS, PARSE_ONLY_UINT },
{MENU_ENUM_LABEL_LEFT_THUMBNAILS, PARSE_ONLY_UINT },
{MENU_ENUM_LABEL_XMB_VERTICAL_THUMBNAILS, PARSE_ONLY_BOOL },
{MENU_ENUM_LABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR, PARSE_ONLY_UINT },
{MENU_ENUM_LABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD, PARSE_ONLY_UINT },
{MENU_ENUM_LABEL_MENU_RGUI_SWAP_THUMBNAILS, PARSE_ONLY_BOOL },
{MENU_ENUM_LABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER, PARSE_ONLY_UINT },

View File

@ -12287,6 +12287,21 @@ static bool setting_append_list(
general_write_handler,
general_read_handler,
SD_FLAG_NONE);
CONFIG_UINT(
list, list_info,
&settings->uints.menu_xmb_thumbnail_scale_factor,
MENU_ENUM_LABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR,
MENU_ENUM_LABEL_VALUE_MENU_XMB_THUMBNAIL_SCALE_FACTOR,
xmb_thumbnail_scale_factor,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
(*list)[list_info->index - 1].offset_by = 30;
menu_settings_list_current_add_range(list, list_info, (*list)[list_info->index - 1].offset_by, 100, 1, true, true);
}
if (string_is_equal(settings->arrays.menu_driver, "xmb") || string_is_equal(settings->arrays.menu_driver, "ozone"))

View File

@ -936,6 +936,7 @@ enum msg_hash_enums
MENU_LABEL(LEFT_THUMBNAILS_RGUI),
MENU_LABEL(LEFT_THUMBNAILS_OZONE),
MENU_LABEL(XMB_VERTICAL_THUMBNAILS),
MENU_LABEL(MENU_XMB_THUMBNAIL_SCALE_FACTOR),
MENU_LABEL(MENU_THUMBNAIL_UPSCALE_THRESHOLD),
MENU_LABEL(MENU_RGUI_INLINE_THUMBNAILS),
MENU_LABEL(MENU_RGUI_SWAP_THUMBNAILS),