widget: make Icon honour its constraints

This is a breaking change as Icon.Layout no longer requests a size.

Before:
  sz := unit.Dp(20)
  ic.Layout(gtx, sz)

After:
  sz := gtx.Metric.Px(unit.Dp(20))
  gtx.Constraints.Min = image.Pt(sz, 0)
  ic.Layout(gtx)

Fixes gio#240

Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
pierre
2021-07-01 11:52:39 +02:00
committed by Elias Naur
parent cf778ecd06
commit 2e991f31be
4 changed files with 67 additions and 8 deletions
+2 -1
View File
@@ -67,7 +67,8 @@ func (c *checkable) layout(gtx layout.Context, checked, hovered bool) layout.Dim
if gtx.Queue == nil {
icon.Color = f32color.Disabled(icon.Color)
}
icon.Layout(gtx, unit.Px(float32(size)))
gtx.Constraints.Min = image.Point{X: size}
icon.Layout(gtx)
return layout.Dimensions{
Size: image.Point{X: size, Y: size},
}