Skip to content

Commit

Permalink
Constrain to max bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
fishrockz committed Nov 1, 2021
1 parent 94ad9c6 commit 853603c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion druid/src/widget/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ impl<T: Data> Widget<T> for Image {
let affine = self.fill.affine_to_fill(max, image_size).as_coeffs();
// The first and forth elements of the affine are the x and y scale factor.
// So just multiply them by the original size to get the ideal area based on `self.fill`.
let size = Size::new(affine[0] * image_size.width, affine[3] * image_size.height);
let mut width = affine[0] * image_size.width;
let mut height = affine[3] * image_size.height;
width = width.min(max.width);
height = height.min(max.height);
let size = Size::new(width, height);
trace!("Computed size: {}", size);
size
}
Expand Down

0 comments on commit 853603c

Please sign in to comment.