From f7a23ad46a883057e6a7b9641bad493c623d9f6c Mon Sep 17 00:00:00 2001 From: metaclips Date: Wed, 25 Mar 2020 16:16:53 +0100 Subject: [PATCH] widget/material: draw button to max width with ButtonLayout This patch allows support to draw button to maximum width using ButtonLayout. --- widget/material/button.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widget/material/button.go b/widget/material/button.go index 81a4672a..09053c72 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -91,6 +91,8 @@ func (b Button) Layout(gtx *layout.Context, button *widget.Button) { } func (b ButtonLayout) Layout(gtx *layout.Context, button *widget.Button, w layout.Widget) { + hmin := gtx.Constraints.Width.Min + vmin := gtx.Constraints.Height.Min layout.Stack{Alignment: layout.Center}.Layout(gtx, layout.Expanded(func() { rr := float32(gtx.Px(b.CornerRadius)) @@ -107,6 +109,8 @@ func (b ButtonLayout) Layout(gtx *layout.Context, button *widget.Button, w layou } }), layout.Stacked(func() { + gtx.Constraints.Width.Min = hmin + gtx.Constraints.Height.Min = vmin layout.Center.Layout(gtx, func() { b.Inset.Layout(gtx, func() { paint.ColorOp{Color: b.Color}.Add(gtx.Ops)