diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-02-17 19:18:19 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-02-17 19:18:34 +0100 |
commit | 02e029ed40f801e0710b09062069e7083cd30b93 (patch) | |
tree | b3bd567ad0c03074064d62d32a876920aa58fab4 /src/Body.cpp | |
parent | d4cd63129ae5dff8fd69525424e0f8cb9ae1a905 (diff) |
Add local anime tracking. Check readme for more info about local_anime config
Diffstat (limited to 'src/Body.cpp')
-rw-r--r-- | src/Body.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index 4681410..6fdb285 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -13,8 +13,8 @@ #include <mglpp/window/Window.hpp> #include <mglpp/graphics/Shader.hpp> #include <assert.h> -#include <cmath> #include <malloc.h> +#include <cmath> struct BodySpacing { float spacing_y = 0.0f; @@ -954,7 +954,7 @@ namespace QuickMedia { if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0) content_size = clamp_to_size(mgl::vec2i(std::floor(item->thumbnail_size.x * get_config().scale), std::floor(item->thumbnail_size.y * get_config().scale)), thumbnail_max_size_scaled); else - content_size = mgl::vec2i(250 * get_config().scale, 141 * get_config().scale); + content_size = clamp_to_size(mgl::vec2i(250 * get_config().scale, 141 * get_config().scale), thumbnail_max_size_scaled); return content_size; } @@ -1365,6 +1365,7 @@ namespace QuickMedia { const float padding_y = item_thumbnail ? body_spacing[body_theme].padding_y : body_spacing[body_theme].padding_y_text_only; + bool thumbnail_drawn = false; float text_offset_x = body_spacing[body_theme].padding_x; if(item_thumbnail && !merge_with_previous) { // TODO: Verify if this is safe. The thumbnail is being modified in another thread @@ -1390,6 +1391,7 @@ namespace QuickMedia { text_offset_x += body_spacing[body_theme].image_padding_x + new_image_size.x; // We want the next image fallback to have the same size as the successful image rendering, because its likely the image fallback will have the same size (for example thumbnails on youtube) //image_fallback.set_size(mgl::vec2f(width_ratio * image_size.x, height_ratio * image_size.y)); + thumbnail_drawn = true; } else if(!item->thumbnail_url.empty()) { mgl::vec2f content_size = thumbnail_size.to_vec2f(); @@ -1506,6 +1508,17 @@ namespace QuickMedia { window.draw(*item->timestamp_text); } + if(item->extra) { + Widgets widgets; + if(thumbnail_drawn) { + ThumbnailWidget thumbnail; + thumbnail.position = image.get_position(); + thumbnail.size = image.get_texture()->get_size().to_vec2f() * image.get_scale(); + widgets.thumbnail = std::move(thumbnail); + } + item->extra->draw_overlay(window, widgets); + } + if(!content_progress.isObject()) return; @@ -1530,6 +1543,7 @@ namespace QuickMedia { mgl::View new_view = { mgl::vec2i(0, scissor_y), mgl::vec2i(window_size.x, body_size.y) }; window.set_view(new_view); + bool thumbnail_drawn = false; { float image_height = 0.0f; if(item_thumbnail && item_thumbnail->loading_state == LoadingState::APPLIED_TO_TEXTURE && item_thumbnail->texture.is_valid()) { @@ -1552,6 +1566,8 @@ namespace QuickMedia { } else { window.draw(image); } + + thumbnail_drawn = true; } else if(!item->thumbnail_url.empty()) { mgl::vec2f content_size = thumbnail_size.to_vec2f(); mgl::vec2f loading_icon_size(loading_icon.get_texture()->get_size().x, loading_icon.get_texture()->get_size().y); @@ -1563,6 +1579,17 @@ namespace QuickMedia { image_height = content_size.y; } + if(item->extra) { + Widgets widgets; + if(thumbnail_drawn) { + ThumbnailWidget thumbnail; + thumbnail.position = image.get_position(); + thumbnail.size = image.get_texture()->get_size().to_vec2f() * image.get_scale(); + widgets.thumbnail = std::move(thumbnail); + } + item->extra->draw_overlay(window, widgets); + } + const float text_padding = item_thumbnail ? card_image_text_padding : 0.0f; mgl::vec2f text_pos = mgl::vec2f(pos.x, scissor_y + body_spacing[body_theme].body_padding_vertical) + pos_offset + mgl::vec2f(card_padding_x, card_padding_y) + mgl::vec2f(0.0f, image_height + text_padding); |