From 9170bca9b3c27b115094fa80faf0530982635c46 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 25 Nov 2019 13:14:25 +0000 Subject: [PATCH] (Ozone) Use new 'menu_thumbnail' library for loading/rendering thumbnails --- menu/drivers/materialui.c | 3 + menu/drivers/ozone/ozone.c | 217 ++++------------------------- menu/drivers/ozone/ozone.h | 14 +- menu/drivers/ozone/ozone_entries.c | 114 ++++++++------- menu/menu_thumbnail.c | 70 +++++++--- menu/menu_thumbnail.h | 19 ++- 6 files changed, 168 insertions(+), 269 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 8c0d991e07..6313f1610f 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1861,6 +1861,7 @@ static void materialui_draw_thumbnail( menu_thumbnail_draw( video_info, thumbnail, x, y, mui->thumbnail_width_max, mui->thumbnail_height_max, + MENU_THUMBNAIL_ALIGN_CENTRE, mui->transition_alpha, scale_factor); } } @@ -4645,6 +4646,7 @@ static void materialui_render_fullscreen_thumbnails( primary_thumbnail_y, (unsigned)thumbnail_box_width, (unsigned)thumbnail_box_height, + MENU_THUMBNAIL_ALIGN_CENTRE, mui->fullscreen_thumbnail_alpha, 1.0f); } @@ -4673,6 +4675,7 @@ static void materialui_render_fullscreen_thumbnails( secondary_thumbnail_y, (unsigned)thumbnail_box_width, (unsigned)thumbnail_box_height, + MENU_THUMBNAIL_ALIGN_CENTRE, mui->fullscreen_thumbnail_alpha, 1.0f); } diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index b80686f40e..01be16e064 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -391,71 +391,25 @@ static void ozone_update_thumbnail_path(void *data, unsigned i, char pos) static void ozone_update_thumbnail_image(void *data) { - settings_t *settings = config_get_ptr(); - ozone_handle_t *ozone = (ozone_handle_t*)data; - const char *right_thumbnail_path = NULL; - const char *left_thumbnail_path = NULL; - bool supports_rgba = video_driver_supports_rgba(); + ozone_handle_t *ozone = (ozone_handle_t*)data; + size_t selection = menu_navigation_get_selection(); + playlist_t *playlist = playlist_get_cached(); - /* Have to wrap `thumbnails_missing` like this to silence - * brain dead `set but not used` warnings when networking - * is disabled... */ -#ifdef HAVE_NETWORKING - bool thumbnails_missing = false; -#endif + /* Right thumbnail */ + menu_thumbnail_request( + ozone->thumbnail_path_data, + MENU_THUMBNAIL_RIGHT, + playlist, + selection, + &ozone->thumbnails.right); - if (!ozone || !settings) - return; - - if (menu_thumbnail_get_path(ozone->thumbnail_path_data, MENU_THUMBNAIL_RIGHT, &right_thumbnail_path)) - { - if (path_is_valid(right_thumbnail_path)) - task_push_image_load(right_thumbnail_path, - supports_rgba, settings->uints.menu_thumbnail_upscale_threshold, - menu_display_handle_thumbnail_upload, NULL); - else - { - video_driver_texture_unload(&ozone->thumbnail); -#ifdef HAVE_NETWORKING - thumbnails_missing = true; -#endif - } - } - else - video_driver_texture_unload(&ozone->thumbnail); - - if (menu_thumbnail_get_path(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT, &left_thumbnail_path)) - { - if (path_is_valid(left_thumbnail_path)) - task_push_image_load(left_thumbnail_path, - supports_rgba, settings->uints.menu_thumbnail_upscale_threshold, - menu_display_handle_left_thumbnail_upload, NULL); - else - { - video_driver_texture_unload(&ozone->left_thumbnail); -#ifdef HAVE_NETWORKING - thumbnails_missing = true; -#endif - } - } - else - video_driver_texture_unload(&ozone->left_thumbnail); - -#ifdef HAVE_NETWORKING - /* On demand thumbnail downloads */ - if (thumbnails_missing) - { - if (settings->bools.network_on_demand_thumbnails) - { - const char *system = NULL; - - if (menu_thumbnail_get_system(ozone->thumbnail_path_data, &system)) - task_push_pl_entry_thumbnail_download(system, - playlist_get_cached(), (unsigned)menu_navigation_get_selection(), - false, true); - } - } -#endif + /* Left thumbnail */ + menu_thumbnail_request( + ozone->thumbnail_path_data, + MENU_THUMBNAIL_LEFT, + playlist, + selection, + &ozone->thumbnails.left); } static void ozone_refresh_thumbnail_image(void *data, unsigned i) @@ -541,10 +495,6 @@ static void ozone_context_reset(void *data, bool is_threaded) ozone->dimensions.thumbnail_bar_width = ozone->dimensions.sidebar_width_normal - ozone->dimensions.sidebar_entry_icon_size - ozone->dimensions.sidebar_entry_icon_padding; - - ozone->dimensions.thumbnail_width = ozone->dimensions.thumbnail_bar_width - ozone->dimensions.sidebar_entry_icon_padding * 2; - ozone->dimensions.left_thumbnail_width = ozone->dimensions.thumbnail_width; - ozone->dimensions.cursor_size = CURSOR_SIZE * scale; /* Naive font size */ @@ -711,8 +661,8 @@ static void ozone_context_destroy(void *data) video_driver_texture_unload(&ozone->tab_textures[i]); /* Thumbnails */ - video_driver_texture_unload(&ozone->thumbnail); - video_driver_texture_unload(&ozone->left_thumbnail); + menu_thumbnail_reset(&ozone->thumbnails.right); + menu_thumbnail_reset(&ozone->thumbnails.left); video_driver_texture_unload(&menu_display_white_texture); @@ -1385,10 +1335,8 @@ static void ozone_unload_thumbnail_textures(void *data) if (!ozone) return; - if (ozone->thumbnail) - video_driver_texture_unload(&ozone->thumbnail); - if (ozone->left_thumbnail) - video_driver_texture_unload(&ozone->left_thumbnail); + menu_thumbnail_reset(&ozone->thumbnails.right); + menu_thumbnail_reset(&ozone->thumbnails.left); } static void ozone_set_thumbnail_system(void *data, char*s, size_t len) @@ -1851,11 +1799,11 @@ static void ozone_populate_entries(void *data, const char *path, const char *lab } /* Thumbnails */ + ozone_unload_thumbnail_textures(ozone); + if (menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_RIGHT) || menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT)) { - ozone_unload_thumbnail_textures(ozone); - if (ozone->is_playlist) { ozone_set_thumbnail_content(ozone, ""); @@ -2328,123 +2276,6 @@ static int ozone_pointer_up(void *userdata, return 0; } -static bool ozone_load_image(void *userdata, void *data, enum menu_image_type type) -{ - ozone_handle_t *ozone = (ozone_handle_t*) userdata; - unsigned sidebar_height; - unsigned height; - unsigned maximum_height, maximum_width; - float display_aspect_ratio; - - if (!ozone) - return false; - - if (!data) - { - /* If this happens, the image we attempted to load - * was corrupt/incorrectly formatted. If this was a - * thumbnail image, have unload any existing thumbnails - * (otherwise entry with 'corrupt' thumbnail will show - * thumbnail from last selected 'good' entry) */ - if (type == MENU_IMAGE_THUMBNAIL) - { - ozone->dimensions.thumbnail_width = 0.0f; - ozone->dimensions.thumbnail_height = 0.0f; - video_driver_texture_unload(&ozone->thumbnail); - } - else if (type == MENU_IMAGE_LEFT_THUMBNAIL) - { - ozone->dimensions.left_thumbnail_width = 0.0f; - ozone->dimensions.left_thumbnail_height = 0.0f; - video_driver_texture_unload(&ozone->left_thumbnail); - } - - return false; - } - - video_driver_get_size(NULL, &height); - - sidebar_height = height - ozone->dimensions.header_height - 55 - ozone->dimensions.footer_height; - maximum_height = sidebar_height / 2; - maximum_width = ozone->dimensions.thumbnail_bar_width - ozone->dimensions.sidebar_entry_icon_padding * 2; - if (maximum_height > 0) - display_aspect_ratio = (float)maximum_width / (float)maximum_height; - else - display_aspect_ratio = 0.0f; - - switch (type) - { - case MENU_IMAGE_THUMBNAIL: - { - struct texture_image *img = (struct texture_image*)data; - - if (img->width > 0 && img->height > 0 && display_aspect_ratio > 0.0001f) - { - float thumb_aspect_ratio = (float)img->width / (float)img->height; - - if (thumb_aspect_ratio > display_aspect_ratio) - { - ozone->dimensions.thumbnail_width = (float)maximum_width; - ozone->dimensions.thumbnail_height = (float)img->height * (float)maximum_width / (float)img->width; - } - else - { - ozone->dimensions.thumbnail_height = (float)maximum_height; - ozone->dimensions.thumbnail_width = (float)img->width * (float)maximum_height / (float)img->height; - } - - video_driver_texture_unload(&ozone->thumbnail); - video_driver_texture_load(data, - TEXTURE_FILTER_MIPMAP_LINEAR, &ozone->thumbnail); - } - else - { - ozone->dimensions.thumbnail_width = 0.0f; - ozone->dimensions.thumbnail_height = 0.0f; - video_driver_texture_unload(&ozone->thumbnail); - } - - break; - } - case MENU_IMAGE_LEFT_THUMBNAIL: - { - struct texture_image *img = (struct texture_image*)data; - - if (img->width > 0 && img->height > 0 && display_aspect_ratio > 0.0001f) - { - float thumb_aspect_ratio = (float)img->width / (float)img->height; - - if (thumb_aspect_ratio > display_aspect_ratio) - { - ozone->dimensions.left_thumbnail_width = (float)maximum_width; - ozone->dimensions.left_thumbnail_height = (float)img->height * (float)maximum_width / (float)img->width; - } - else - { - ozone->dimensions.left_thumbnail_height = (float)maximum_height; - ozone->dimensions.left_thumbnail_width = (float)img->width * (float)maximum_height / (float)img->height; - } - - video_driver_texture_unload(&ozone->left_thumbnail); - video_driver_texture_load(data, - TEXTURE_FILTER_MIPMAP_LINEAR, &ozone->left_thumbnail); - } - else - { - ozone->dimensions.left_thumbnail_width = 0.0f; - ozone->dimensions.left_thumbnail_height = 0.0f; - video_driver_texture_unload(&ozone->left_thumbnail); - } - - break; - } - default: - break; - } - return true; -} - - menu_ctx_driver_t menu_ctx_ozone = { NULL, /* set_texture */ ozone_messagebox, @@ -2476,7 +2307,7 @@ menu_ctx_driver_t menu_ctx_ozone = { ozone_list_get_entry, NULL, /* list_set_selection */ ozone_list_bind_init, - ozone_load_image, + NULL, "ozone", ozone_environ_cb, ozone_update_thumbnail_path, diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 82d8aa5556..e5da61159c 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -25,6 +25,7 @@ typedef struct ozone_handle ozone_handle_t; #include #include "../../menu_thumbnail_path.h" +#include "../../menu_thumbnail.h" #include "../../menu_driver.h" #include "../../../retroarch.h" @@ -212,11 +213,6 @@ struct ozone_handle int cursor_size; int thumbnail_bar_width; - - float thumbnail_width; /* set at layout time */ - float thumbnail_height; /* set later to thumbnail_width * image aspect ratio */ - float left_thumbnail_width; /* set at layout time */ - float left_thumbnail_height; /* set later to left_thumbnail_width * image aspect ratio */ } dimensions; bool show_cursor; @@ -230,11 +226,13 @@ struct ozone_handle /* Thumbnails data */ bool show_thumbnail_bar; - uintptr_t thumbnail; - uintptr_t left_thumbnail; - menu_thumbnail_path_data_t *thumbnail_path_data; + struct { + menu_thumbnail_t right; + menu_thumbnail_t left; + } thumbnails; + char selection_core_name[255]; char selection_playtime[255]; char selection_lastplayed[255]; diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index e5b54c5ae1..1b057b2825 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -729,12 +729,17 @@ static void ozone_content_metadata_line(video_frame_info_t *video_info, ozone_ha void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_info) { - unsigned sidebar_height = video_info->height - ozone->dimensions.header_height - 55 - ozone->dimensions.footer_height; - unsigned sidebar_width = ozone->dimensions.thumbnail_bar_width; - unsigned x_position = video_info->width - (unsigned) ozone->animations.thumbnail_bar_position; + unsigned sidebar_height = video_info->height - ozone->dimensions.header_height - 55 - ozone->dimensions.footer_height; + unsigned sidebar_width = ozone->dimensions.thumbnail_bar_width; + unsigned x_position = video_info->width - (unsigned) ozone->animations.thumbnail_bar_position; + unsigned thumbnail_width = sidebar_width - (ozone->dimensions.sidebar_entry_icon_padding * 2); + unsigned thumbnail_height = (video_info->height - ozone->dimensions.header_height - 2 - ozone->dimensions.footer_height - (ozone->dimensions.sidebar_entry_icon_padding * 3)) / 2; + int thumbnail_x_position = x_position + ozone->dimensions.sidebar_entry_icon_padding; + int right_thumbnail_y_position = 0; + int left_thumbnail_y_position = 0; - bool thumbnail; - bool left_thumbnail; + bool show_right_thumbnail; + bool show_left_thumbnail; /* Background */ if (!video_info->libretro_running) @@ -745,71 +750,83 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i } /* Thumbnails */ - thumbnail = ozone->thumbnail && - menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_RIGHT); - left_thumbnail = ozone->left_thumbnail && - menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT); + show_right_thumbnail = + (ozone->thumbnails.right.status != MENU_THUMBNAIL_STATUS_MISSING) && + menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_RIGHT); + show_left_thumbnail = + (ozone->thumbnails.left.status != MENU_THUMBNAIL_STATUS_MISSING) && + menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT) && + !ozone->selection_core_is_viewer; /* If user requested "left" thumbnail instead of content metadata - * and no thumbnails are available, show a centered message and + * and no thumbnails are available, show a centred message and * return immediately */ - if (!thumbnail && !left_thumbnail && menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT)) + if (!show_right_thumbnail && !show_left_thumbnail && menu_thumbnail_is_enabled(ozone->thumbnail_path_data, MENU_THUMBNAIL_LEFT)) { ozone_draw_no_thumbnail_available(ozone, video_info, x_position, sidebar_width, 0); return; } /* Top row : thumbnail or no thumbnail available message */ - if (thumbnail) + if (show_right_thumbnail) { - unsigned thumb_x_position = x_position + sidebar_width/2 - ozone->dimensions.thumbnail_width / 2; - unsigned thumb_y_position = video_info->height / 2 - ozone->dimensions.thumbnail_height / 2; + enum menu_thumbnail_alignment alignment = MENU_THUMBNAIL_ALIGN_BOTTOM; - if (!string_is_equal(ozone->selection_core_name, "imageviewer")) - thumb_y_position -= ozone->dimensions.thumbnail_height / 2 + ozone->dimensions.sidebar_entry_icon_padding/2; + /* If this entry is associated with the image viewer + * core, there can be only one thumbnail and no + * content metadata + * > Centre image vertically */ + if (ozone->selection_core_is_viewer) + { + right_thumbnail_y_position = + ozone->dimensions.header_height + + ((thumbnail_height / 2) + + (int)(1.5f * (float)ozone->dimensions.sidebar_entry_icon_padding)); - menu_display_blend_begin(video_info); - ozone_draw_icon(video_info, - ozone->dimensions.thumbnail_width, - ozone->dimensions.thumbnail_height, - ozone->thumbnail, - thumb_x_position, - thumb_y_position, - video_info->width, video_info->height, - 0, 1, - ozone_pure_white - ); - menu_display_blend_end(video_info); + alignment = MENU_THUMBNAIL_ALIGN_CENTRE; + } + else + right_thumbnail_y_position = + ozone->dimensions.header_height + 1 + + ozone->dimensions.sidebar_entry_icon_padding; + + menu_thumbnail_draw( + video_info, + &ozone->thumbnails.right, + (float)thumbnail_x_position, + (float)right_thumbnail_y_position, + thumbnail_width, + thumbnail_height, + alignment, + 1.0f, 1.0f); } else { /* If thumbnails are disabled, we don't know the thumbnail * height but we still need to move it to leave room for the * content metadata panel */ - unsigned height = video_info->height / 4; + unsigned y_offset = thumbnail_height / 2; - ozone_draw_no_thumbnail_available(ozone, video_info, x_position, sidebar_width, - height / 2 + ozone->dimensions.sidebar_entry_icon_padding/2); + ozone_draw_no_thumbnail_available(ozone, video_info, x_position, sidebar_width, y_offset); } /* Bottom row : "left" thumbnail or content metadata */ - if (thumbnail && left_thumbnail) - { - unsigned thumb_x_position = x_position + sidebar_width/2 - ozone->dimensions.left_thumbnail_width / 2; - unsigned thumb_y_position = video_info->height / 2 + ozone->dimensions.sidebar_entry_icon_padding / 2; + left_thumbnail_y_position = + ozone->dimensions.header_height + 1 + + thumbnail_height + + (ozone->dimensions.sidebar_entry_icon_padding * 2); - menu_display_blend_begin(video_info); - ozone_draw_icon(video_info, - ozone->dimensions.left_thumbnail_width, - ozone->dimensions.left_thumbnail_height, - ozone->left_thumbnail, - thumb_x_position, - thumb_y_position, - video_info->width, video_info->height, - 0, 1, - ozone_pure_white - ); - menu_display_blend_end(video_info); + if (show_right_thumbnail && show_left_thumbnail) + { + menu_thumbnail_draw( + video_info, + &ozone->thumbnails.left, + (float)thumbnail_x_position, + (float)left_thumbnail_y_position, + thumbnail_width, + thumbnail_height, + MENU_THUMBNAIL_ALIGN_TOP, + 1.0f, 1.0f); } else if (!ozone->selection_core_is_viewer) { @@ -821,7 +838,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i settings_t *settings = config_get_ptr(); bool scroll_content_metadata = settings->bools.ozone_scroll_content_metadata; bool use_smooth_ticker = settings->bools.menu_ticker_smooth; - unsigned y = video_info->height / 2 + ozone->dimensions.sidebar_entry_icon_padding / 2; + unsigned y = (unsigned)left_thumbnail_y_position; unsigned separator_padding = ozone->dimensions.sidebar_entry_icon_padding*2; unsigned column_x = x_position + separator_padding; @@ -856,7 +873,6 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i } /* Content metadata */ - y += 10; /* Separator */ menu_display_draw_quad(video_info, diff --git a/menu/menu_thumbnail.c b/menu/menu_thumbnail.c index 2dbac7d22b..e7c02e9e71 100644 --- a/menu/menu_thumbnail.c +++ b/menu/menu_thumbnail.c @@ -155,18 +155,23 @@ static void menu_thumbnail_handle_upload( /* Update thumbnail status */ thumbnail_tag->thumbnail->status = MENU_THUMBNAIL_STATUS_AVAILABLE; - /* Trigger 'fade in' animation */ - thumbnail_tag->thumbnail->alpha = 0.0f; + /* Trigger 'fade in' animation, if required */ + if (menu_thumbnail_fade_duration > 0.0f) + { + thumbnail_tag->thumbnail->alpha = 0.0f; - animation_entry.easing_enum = EASING_OUT_QUAD; - animation_entry.tag = (uintptr_t)&thumbnail_tag->thumbnail->alpha; - animation_entry.duration = menu_thumbnail_fade_duration; - animation_entry.target_value = 1.0f; - animation_entry.subject = &thumbnail_tag->thumbnail->alpha; - animation_entry.cb = NULL; - animation_entry.userdata = NULL; + animation_entry.easing_enum = EASING_OUT_QUAD; + animation_entry.tag = (uintptr_t)&thumbnail_tag->thumbnail->alpha; + animation_entry.duration = menu_thumbnail_fade_duration; + animation_entry.target_value = 1.0f; + animation_entry.subject = &thumbnail_tag->thumbnail->alpha; + animation_entry.cb = NULL; + animation_entry.userdata = NULL; - menu_animation_push(&animation_entry); + menu_animation_push(&animation_entry); + } + else + thumbnail_tag->thumbnail->alpha = 1.0f; end: /* Clean up */ @@ -548,15 +553,17 @@ error: return; } -/* Draws specified thumbnail centred (with aspect correct - * scaling) within a rectangle of (width x height) +/* Draws specified thumbnail with specified alignment + * (and aspect correct scaling) within a rectangle of + * (width x height) * NOTE: Setting scale_factor > 1.0f will increase the * size of the thumbnail beyond the limits of the - * (width x height) rectangle (centring + aspect + * (width x height) rectangle (alignment + aspect * correct scaling is preserved). Use with caution */ void menu_thumbnail_draw( video_frame_info_t *video_info, menu_thumbnail_t *thumbnail, float x, float y, unsigned width, unsigned height, + enum menu_thumbnail_alignment alignment, float alpha, float scale_factor) { /* Sanity check */ @@ -631,9 +638,40 @@ void menu_thumbnail_draw( draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline.id = 0; - /* > Ensure thumbnail is centred */ - draw.x = x + ((float)width - draw_width) / 2.0f; - draw.y = (float)video_info->height - y - draw_height - ((float)height - draw_height) / 2.0f; + /* Set thumbnail alignment within bounding box */ + switch (alignment) + { + case MENU_THUMBNAIL_ALIGN_TOP: + /* Centred horizontally */ + draw.x = x + ((float)width - draw_width) / 2.0f; + /* Drawn at top of bounding box */ + draw.y = (float)video_info->height - y - draw_height; + break; + case MENU_THUMBNAIL_ALIGN_BOTTOM: + /* Centred horizontally */ + draw.x = x + ((float)width - draw_width) / 2.0f; + /* Drawn at bottom of bounding box */ + draw.y = (float)video_info->height - y - (float)height; + break; + case MENU_THUMBNAIL_ALIGN_LEFT: + /* Drawn at left side of bounding box */ + draw.x = x; + /* Centred vertically */ + draw.y = (float)video_info->height - y - draw_height - ((float)height - draw_height) / 2.0f; + break; + case MENU_THUMBNAIL_ALIGN_RIGHT: + /* Drawn at right side of bounding box */ + draw.x = x + (float)width - draw_width; + /* Centred vertically */ + draw.y = (float)video_info->height - y - draw_height - ((float)height - draw_height) / 2.0f; + break; + case MENU_THUMBNAIL_ALIGN_CENTRE: + default: + /* Centred both horizontally and vertically */ + draw.x = x + ((float)width - draw_width) / 2.0f; + draw.y = (float)video_info->height - y - draw_height - ((float)height - draw_height) / 2.0f; + break; + } /* Draw thumbnail */ menu_display_draw(&draw, video_info); diff --git a/menu/menu_thumbnail.h b/menu/menu_thumbnail.h index 66d91184db..e0c16122dc 100644 --- a/menu/menu_thumbnail.h +++ b/menu/menu_thumbnail.h @@ -42,6 +42,17 @@ enum menu_thumbnail_status MENU_THUMBNAIL_STATUS_MISSING }; +/* Defines thumbnail alignment within + * menu_thumbnail_draw() bounding box */ +enum menu_thumbnail_alignment +{ + MENU_THUMBNAIL_ALIGN_CENTRE = 0, + MENU_THUMBNAIL_ALIGN_TOP, + MENU_THUMBNAIL_ALIGN_BOTTOM, + MENU_THUMBNAIL_ALIGN_LEFT, + MENU_THUMBNAIL_ALIGN_RIGHT +}; + /* Holds all runtime parameters associated with * an entry thumbnail */ typedef struct @@ -149,15 +160,17 @@ void menu_thumbnail_get_draw_dimensions( unsigned width, unsigned height, float scale_factor, float *draw_width, float *draw_height); -/* Draws specified thumbnail centred (with aspect correct - * scaling) within a rectangle of (width x height) +/* Draws specified thumbnail with specified alignment + * (and aspect correct scaling) within a rectangle of + * (width x height) * NOTE: Setting scale_factor > 1.0f will increase the * size of the thumbnail beyond the limits of the - * (width x height) rectangle (centring + aspect + * (width x height) rectangle (alignment + aspect * correct scaling is preserved). Use with caution */ void menu_thumbnail_draw( video_frame_info_t *video_info, menu_thumbnail_t *thumbnail, float x, float y, unsigned width, unsigned height, + enum menu_thumbnail_alignment alignment, float alpha, float scale_factor); RETRO_END_DECLS