Skip to content

Commit 8f3347d

Browse files
authored
GLUI: Limit save state thumbnail size (#17600)
1 parent b5e0142 commit 8f3347d

File tree

1 file changed

+64
-6
lines changed

1 file changed

+64
-6
lines changed

menu/drivers/materialui.c

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,7 @@ static void materialui_update_savestate_thumbnail_image(void *data)
25152515
* > Thumbnail has never been loaded *OR*
25162516
* > Thumbnail path has changed */
25172517
if ( (mui->thumbnails.savestate.status == GFX_THUMBNAIL_STATUS_UNKNOWN)
2518+
|| (mui->thumbnails.savestate.status == GFX_THUMBNAIL_STATUS_PENDING)
25182519
|| !string_is_equal(mui->savestate_thumbnail_file_path,
25192520
mui->prev_savestate_thumbnail_file_path))
25202521
{
@@ -3234,8 +3235,7 @@ static void materialui_compute_entries_box_savestate_list(
32343235
float node_entry_width = (float)width -
32353236
(float)(mui->landscape_optimization.border_width * 2) -
32363237
(float)mui->nav_bar_layout_width -
3237-
(float)mui->thumbnail_width_max -
3238-
(float)(mui->margin * 2) -
3238+
((mui->flags & MUI_FLAG_IS_PORTRAIT) ? 0 : (float)(mui->thumbnail_width_max) + (float)(mui->margin * 2)) -
32393239
(float)(mui->entry_divider_width * (mui->landscape_optimization.enabled ? 2 : 1));
32403240
float node_x = (float)mui->landscape_optimization.border_width +
32413241
(float)(mui->entry_divider_width * (mui->landscape_optimization.enabled ? 2 : 1));
@@ -5833,10 +5833,22 @@ static void materialui_render_selected_entry_aux_savestate_list(
58335833
(int)mui->nav_bar_layout_height - (int)mui->status_bar.height;
58345834
float thumbnail_x = background_x + (float)mui->margin +
58355835
(mui->landscape_optimization.enabled ? mui->entry_divider_width : 0);
5836-
float thumbnail_y = background_y + (float)mui->margin + (background_height - mui->thumbnail_height_max) / 2;
5836+
float thumbnail_y = background_y + (background_height - mui->thumbnail_height_max) / 2;
58375837
gfx_display_t *p_disp = disp_get_ptr();
58385838
settings_t *settings = config_get_ptr();
58395839

5840+
/* Portrait moves thumbnail to bottom and full width */
5841+
if (mui->flags & MUI_FLAG_IS_PORTRAIT)
5842+
{
5843+
background_x = (float)(x_offset + (int)mui->landscape_optimization.border_width);
5844+
background_y = video_height - mui->thumbnail_height_max - (mui->margin * 2) -
5845+
(int)mui->nav_bar_layout_height - (int)mui->status_bar.height;
5846+
background_width = video_width;
5847+
background_height = mui->thumbnail_height_max + (mui->margin * 2);
5848+
thumbnail_x = background_x + (background_width - mui->thumbnail_width_max) / 2;
5849+
thumbnail_y = background_y + (float)mui->margin;
5850+
}
5851+
58405852
/* Sanity check */
58415853
if ( (background_width <= 0)
58425854
|| (background_height <= 0))
@@ -8426,6 +8438,50 @@ static void materialui_set_thumbnail_dimensions(materialui_handle_t *mui)
84268438
mui->thumbnail_width_max =
84278439
(unsigned)(((float)mui->thumbnail_height_max *
84288440
MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f);
8441+
8442+
/* Limit size to half screen width in landscape and full in portrait,
8443+
* and vice versa */
8444+
{
8445+
unsigned usable_width =
8446+
(int)(mui->last_width) -
8447+
(int)(mui->margin * 3) -
8448+
(int)(mui->landscape_optimization.border_width * 2) -
8449+
(int)mui->nav_bar_layout_width;
8450+
8451+
unsigned usable_height =
8452+
(int)mui->last_height - (int)disp_get_ptr()->header_height -
8453+
(int)(mui->margin * 2) - (int)mui->nav_bar_layout_height -
8454+
(int)mui->status_bar.height;
8455+
8456+
if (mui->flags & MUI_FLAG_IS_PORTRAIT)
8457+
{
8458+
unsigned half_height = (usable_height >> 1);
8459+
if (usable_height > half_height)
8460+
usable_height = half_height;
8461+
}
8462+
else
8463+
{
8464+
unsigned half_width = (usable_width >> 1);
8465+
if (usable_width > half_width)
8466+
usable_width = half_width;
8467+
}
8468+
8469+
if (mui->thumbnail_width_max >= usable_width)
8470+
{
8471+
mui->thumbnail_width_max = usable_width;
8472+
mui->thumbnail_height_max =
8473+
(unsigned)(((float)mui->thumbnail_width_max /
8474+
MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f);
8475+
}
8476+
8477+
if (mui->thumbnail_height_max >= usable_height)
8478+
{
8479+
mui->thumbnail_height_max = usable_height;
8480+
mui->thumbnail_width_max =
8481+
(unsigned)(((float)mui->thumbnail_height_max *
8482+
MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f);
8483+
}
8484+
}
84298485
break;
84308486

84318487
case MUI_LIST_VIEW_PLAYLIST:
@@ -10389,13 +10445,14 @@ static int materialui_menu_entry_action(
1038910445
static int materialui_list_push(void *data, void *userdata,
1039010446
menu_displaylist_info_t *info, unsigned type)
1039110447
{
10448+
#if 1
10449+
/* Use common lists for all drivers */
10450+
return -1;
10451+
#else
1039210452
int ret = -1;
1039310453
core_info_list_t *list = NULL;
1039410454
materialui_handle_t *mui = (materialui_handle_t*)userdata;
1039510455

10396-
/* Use common lists for all drivers */
10397-
return ret;
10398-
1039910456
if (!mui)
1040010457
return ret;
1040110458

@@ -10658,6 +10715,7 @@ static int materialui_list_push(void *data, void *userdata,
1065810715
break;
1065910716
}
1066010717
return ret;
10718+
#endif
1066110719
}
1066210720

1066310721
/* Returns the active tab id */

0 commit comments

Comments
 (0)