Merge pull request #6365 from Tatsuya79/patch-3

Fix MaterialUI scaling bug in long lists, lower res devices.
This commit is contained in:
Twinaphex 2018-03-07 16:07:16 +01:00 committed by GitHub
commit 1bccf5cf27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1846,21 +1846,31 @@ static bool materialui_load_image(void *userdata, void *data, enum menu_image_ty
/* Compute the scroll value depending on the highlighted entry */ /* Compute the scroll value depending on the highlighted entry */
static float materialui_get_scroll(materialui_handle_t *mui) static float materialui_get_scroll(materialui_handle_t *mui)
{ {
unsigned width, height, half = 0; unsigned i, width, height = 0;
size_t selection = menu_navigation_get_selection(); float half, sum = 0;
size_t selection = menu_navigation_get_selection();
file_list_t *list = menu_entries_get_selection_buf_ptr(0);
if (!mui) if (!mui)
return 0; return 0;
video_driver_get_size(&width, &height); video_driver_get_size(&width, &height);
if (mui->line_height) half = height / 2;
half = (height / mui->line_height) / 3;
if (selection < half) for (i = 0; i < selection; i++)
{
materialui_node_t *node = (materialui_node_t*)
file_list_get_userdata_at_offset(list, i);
if (node)
sum += node->line_height;
}
if (sum < half)
return 0; return 0;
return ((selection + 2 - half) * mui->line_height); return sum - half;
} }
/* The navigation pointer has been updated (for example by pressing up or down /* The navigation pointer has been updated (for example by pressing up or down