From 9908a7dc298cc9c20a99e3423bdb531b86a7eb56 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 16 Jun 2021 05:58:48 +0200 Subject: fix body height not clamping to image height, fix rounded rectangle shader border --- src/Body.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 4ab90f3..67c5c8e 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -735,7 +735,7 @@ namespace QuickMedia { // TODO: Move up where scroll is limited? then we wont delay this by 1 frame creating a small scroll overflow only in the opposite direction of attach side. // Also take |selected_scrolled| into consideration // Limit scroll in the opposide direction of attach side, since the scroll is already limited for the attach side above (with a simple check) - if(!rendering_card_view) { + if(!rendering_card_view && (body_size_changed || is_touch_enabled())) { if(attach_side == AttachSide::TOP) { if(top_cut_off && !bottom_cut_off && body_total_height > (size.y - body_spacing[body_theme].body_padding_vertical)) page_scroll = -(body_total_height - (size.y - body_spacing[body_theme].body_padding_vertical)); @@ -1489,12 +1489,10 @@ namespace QuickMedia { const bool rendering_card_view = card_view && card_view_enabled; sf::Vector2i content_size = get_item_thumbnail_size(item); - float image_height = 0.0f; float text_offset_x = body_spacing[body_theme].padding_x; if(draw_thumbnails && load_texture && !item->thumbnail_url.empty() && !merge_with_previous) { std::shared_ptr item_thumbnail = AsyncImageLoader::get_instance().get_thumbnail(item->thumbnail_url, item->thumbnail_is_local, content_size); content_size = clamp_to_size_x(content_size, sf::Vector2i(width - (rendering_card_view ? 0.0f : body_spacing[body_theme].image_padding_x * 2.0f), content_size.y)); - image_height = content_size.y; if(item_thumbnail && item_thumbnail->loading_state == LoadingState::FINISHED_LOADING && item_thumbnail->image->getSize().x > 0 && item_thumbnail->image->getSize().y > 0) { if(!item_thumbnail->texture.loadFromImage(*item_thumbnail->image)) @@ -1509,17 +1507,13 @@ namespace QuickMedia { auto image_size = item_thumbnail->texture.getSize(); sf::Vector2f image_size_f(image_size.x, image_size.y); auto new_image_size = clamp_to_size(image_size_f, to_vec2f(content_size)); - image_height = new_image_size.y; text_offset_x += body_spacing[body_theme].image_padding_x + new_image_size.x; + item->loaded_image_height = new_image_size.y; } else { text_offset_x += body_spacing[body_theme].image_padding_x + content_size.x; + if(item->loaded_image_height < 0.1f) + item->loaded_image_height = content_size.y; } - - // TODO: This wont work if the image has changed to a different image (for example if the image is a local image and it has been overwritten). - if(body_size_changed) - item->loaded_image_height = image_height; - else - item->loaded_image_height = std::max(item->loaded_image_height, image_height); } else if(item->thumbnail_size.x > 0) { text_offset_x += body_spacing[body_theme].image_padding_x + content_size.x; // TODO: Fix. This makes the body item have incorrect position when loading and if the item is merge_with_previous? and has an embedded item -- cgit v1.2.3