File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -193,16 +193,11 @@ impl<T: Data> Widget<T> for Image {
193193 // in the size exactly. If it is unconstrained by both width and height take the size of
194194 // the image.
195195 let max = bc. max ( ) ;
196+ let min = bc. min ( ) ;
196197 let image_size = self . image_data . size ( ) ;
197- let size = if bc. is_width_bounded ( ) && !bc. is_height_bounded ( ) {
198- let ratio = max. width / image_size. width ;
199- Size :: new ( max. width , ratio * image_size. height )
200- } else if bc. is_height_bounded ( ) && !bc. is_width_bounded ( ) {
201- let ratio = max. height / image_size. height ;
202- Size :: new ( ratio * image_size. width , max. height )
203- } else {
204- bc. constrain ( self . image_data . size ( ) )
205- } ;
198+ let width = image_size. width . max ( min. width ) . min ( max. width ) ;
199+ let height = image_size. height . max ( min. height ) . min ( max. height ) ;
200+ let size = Size :: new ( width, height) ;
206201 trace ! ( "Computed size: {}" , size) ;
207202 size
208203 }
You can’t perform that action at this time.
0 commit comments