~eliasnaur/gio

de7a5985d5a690a7ba91326afe1d3d858cbc183f — Elias Naur 7 months ago 57dee8e
widget/material: remove bogus minimum cosntraint from checkable

checkable.layout forces the label to take up at least constraints.min
space. However, for min == max, the total checkbox plus label would then
overflow. The minimum constraint doesn't seem necessary anymore, so drop
it.

Remove a superfluous layout.W layout as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
1 files changed, 3 insertions(+), 7 deletions(-)

M widget/material/checkable.go
M widget/material/checkable.go => widget/material/checkable.go +3 -7
@@ 38,7 38,6 @@ func (c *checkable) layout(gtx layout.Context, checked, hovered bool) layout.Dim
		icon = c.uncheckedStateIcon
	}

	min := gtx.Constraints.Min
	dims := layout.Flex{Alignment: layout.Middle}.Layout(gtx,
		layout.Rigid(func(gtx layout.Context) layout.Dimensions {
			return layout.Stack{Alignment: layout.Center}.Layout(gtx,


@@ 77,12 76,9 @@ func (c *checkable) layout(gtx layout.Context, checked, hovered bool) layout.Dim
		}),

		layout.Rigid(func(gtx layout.Context) layout.Dimensions {
			gtx.Constraints.Min = min
			return layout.W.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
				return layout.UniformInset(unit.Dp(2)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
					paint.ColorOp{Color: c.Color}.Add(gtx.Ops)
					return widget.Label{}.Layout(gtx, c.shaper, c.Font, c.TextSize, c.Label)
				})
			return layout.UniformInset(unit.Dp(2)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
				paint.ColorOp{Color: c.Color}.Add(gtx.Ops)
				return widget.Label{}.Layout(gtx, c.shaper, c.Font, c.TextSize, c.Label)
			})
		}),
	)