Icon no longer panics on nil texture
This commit is contained in:
parent
67a0e09101
commit
59ca14cab6
9
icon.go
9
icon.go
@ -1,5 +1,6 @@
|
|||||||
package objects
|
package objects
|
||||||
|
|
||||||
|
import "image"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/tomo/data"
|
import "git.tebibyte.media/tomo/tomo/data"
|
||||||
import "git.tebibyte.media/tomo/tomo/theme"
|
import "git.tebibyte.media/tomo/tomo/theme"
|
||||||
@ -41,7 +42,11 @@ func NewApplicationIcon (id theme.ApplicationIcon, size theme.IconSize) *Icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Icon) SetTexture (texture canvas.Texture) {
|
func (this *Icon) SetTexture (texture canvas.Texture) {
|
||||||
bounds := texture.Bounds()
|
|
||||||
this.Box.SetTexture(texture)
|
this.Box.SetTexture(texture)
|
||||||
this.SetMinimumSize(bounds.Max.Sub(bounds.Min))
|
if texture == nil {
|
||||||
|
this.SetMinimumSize(image.Pt(0, 0))
|
||||||
|
} else {
|
||||||
|
bounds := texture.Bounds()
|
||||||
|
this.SetMinimumSize(bounds.Max.Sub(bounds.Min))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user