Skip to content

Commit

Permalink
image size uses ObjectFit setting in SizeUp to request the right amou…
Browse files Browse the repository at this point in the history
…nt of space. Fixes #1030
  • Loading branch information
rcoreilly committed Jul 22, 2024
1 parent 47f3107 commit 9f896b3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ func (im *Image) OpenFS(fsys fs.FS, filename string) error {
return nil
}

func (im *Image) SizeUp() {
im.WidgetBase.SizeUp()
if im.Image != nil {
sz := &im.Geom.Size
obj := math32.Vector2FromPoint(im.Image.Bounds().Size())
osz := styles.ObjectSizeFromFit(im.Styles.ObjectFit, obj, sz.Actual.Content)
sz.Actual.Content = osz
sz.setTotalFromContent(&sz.Actual)
}
}

func (im *Image) Render() {
im.WidgetBase.Render()

Expand Down

0 comments on commit 9f896b3

Please sign in to comment.