aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 8224087..9a811a9 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -281,7 +281,6 @@ namespace QuickMedia {
//item_background.setFillColor(front_color);
//item_background.setOutlineThickness(1.0f);
//item_background.setOutlineColor(sf::Color(13, 15, 17));
- image_fallback.setSize(thumbnail_fallback_size);
item_background_shadow.setFillColor(line_seperator_color);
num_visible_items = 0;
last_item_fully_visible = true;
@@ -579,11 +578,16 @@ namespace QuickMedia {
// 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.setSize(sf::Vector2f(width_ratio * image_size.x, height_ratio * image_size.y));
} else if(!item->thumbnail_url.empty()) {
+ sf::Vector2f content_size(thumbnail_resize_target_size.x, thumbnail_resize_target_size.y);
+ if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0)
+ content_size = sf::Vector2f(item->thumbnail_size.x, item->thumbnail_size.y);
+ image_fallback.setSize(content_size);
+
if(thumbnail_mask_shader && item->thumbnail_mask_type == ThumbnailMaskType::CIRCLE) {
// TODO: Use the mask shader instead, but a vertex shader is also needed for that to pass the vertex coordinates since
// shapes dont have texture coordinates.
// TODO: Cache circle shape
- sf::CircleShape circle_shape(image_fallback.getSize().x * 0.5f);
+ sf::CircleShape circle_shape(content_size.x * 0.5f);
circle_shape.setFillColor(sf::Color::White);
circle_shape.setPosition(item_pos + sf::Vector2f(image_padding_x, padding_y));
window.draw(circle_shape);
@@ -591,10 +595,7 @@ namespace QuickMedia {
image_fallback.setPosition(item_pos + sf::Vector2f(image_padding_x, padding_y));
window.draw(image_fallback);
}
- float image_width = image_fallback.getSize().x;
- if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0)
- image_width = item->thumbnail_size.x;
- text_offset_x += image_padding_x + image_width;
+ text_offset_x += image_padding_x + content_size.x;
}
}
@@ -699,7 +700,7 @@ namespace QuickMedia {
item_height += item->description_text->getHeight() - 2.0f;
}
if(draw_thumbnails && !item->thumbnail_url.empty()) {
- float image_height = image_fallback.getSize().y;
+ float image_height = thumbnail_resize_target_size.y;
if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0)
image_height = item->thumbnail_size.y;
@@ -718,7 +719,10 @@ namespace QuickMedia {
item_thumbnail->referenced = true;
if(!item->thumbnail_url.empty() && item_thumbnail->loading_state == LoadingState::NOT_LOADED) {
- async_image_loader.load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, thumbnail_resize_target_size, program->is_tor_enabled(), item_thumbnail);
+ sf::Vector2i resize_size = thumbnail_resize_target_size;
+ if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0)
+ resize_size = item->thumbnail_size;
+ async_image_loader.load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, resize_size, program->is_tor_enabled(), item_thumbnail);
}
if(item_thumbnail->loading_state == LoadingState::FINISHED_LOADING && item_thumbnail->image->getSize().x > 0 && item_thumbnail->image->getSize().y > 0) {