From 0711d865e21311b625941f1e4618bb0c83410ed5 Mon Sep 17 00:00:00 2001 From: Karolis K Date: Fri, 11 May 2018 20:28:17 +0300 Subject: [PATCH] Thumbnail overlay for videos in AssetLib --- editor/icons/icon_play_overlay.svg | 4 ++++ editor/plugins/asset_library_editor_plugin.cpp | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 editor/icons/icon_play_overlay.svg diff --git a/editor/icons/icon_play_overlay.svg b/editor/icons/icon_play_overlay.svg new file mode 100644 index 00000000000..eff33f1b6b4 --- /dev/null +++ b/editor/icons/icon_play_overlay.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 05833704d10..c9a7433e2d7 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -170,7 +170,23 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { - preview_images[i].button->set_icon(p_image); + if (preview_images[i].is_video) { + Ref overlay = get_icon("PlayOverlay", "EditorIcons")->get_data(); + Ref thumbnail = p_image->get_data(); + Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); + + thumbnail->lock(); + thumbnail->blend_rect(overlay, overlay->get_used_rect(), overlay_pos); + thumbnail->unlock(); + + Ref tex; + tex.instance(); + tex->create_from_image(thumbnail); + + preview_images[i].button->set_icon(tex); + } else { + preview_images[i].button->set_icon(p_image); + } break; } }