aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-16 05:58:48 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-16 05:58:48 +0200
commit9908a7dc298cc9c20a99e3423bdb531b86a7eb56 (patch)
treeea36441e54db04304e73a32975741d110e86fb53 /src/Body.cpp
parentcde1537e9a0f57169814687a17f458132a130a37 (diff)
fix body height not clamping to image height, fix rounded rectangle shader border
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp14
1 files changed, 4 insertions, 10 deletions
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<ThumbnailData> 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