diff --git a/masonry/src/widget/image.rs b/masonry/src/widget/image.rs index c518cc220..e6a83dd84 100644 --- a/masonry/src/widget/image.rs +++ b/masonry/src/widget/image.rs @@ -81,17 +81,16 @@ impl Widget for Image { // If either the width or height is constrained calculate a value so that the image fits // in the size exactly. If it is unconstrained by both width and height take the size of // the image. - let max = bc.max(); let image_size = Size::new(self.image_data.width as f64, self.image_data.height as f64); - let size = if bc.is_width_bounded() && !bc.is_height_bounded() { - let ratio = max.width / image_size.width; - Size::new(max.width, ratio * image_size.height) - } else if bc.is_height_bounded() && !bc.is_width_bounded() { - let ratio = max.height / image_size.height; - Size::new(ratio * image_size.width, max.height) - } else { - bc.constrain(image_size) - }; + if image_size.is_empty() { + let size = bc.min(); + trace!("Computed size: {}", size); + return size; + } + // This size logic has NOT been carefully considered + // TODO: Carefully consider it + let size = + bc.constrain_aspect_ratio(image_size.height / image_size.width, image_size.width); trace!("Computed size: {}", size); size }