~eliasnaur/gio

f7a23ad46a883057e6a7b9641bad493c623d9f6c — metaclips 5 months ago 43df9f2
widget/material: draw button to max width with ButtonLayout

This patch allows support to draw button to maximum width using ButtonLayout.
1 files changed, 4 insertions(+), 0 deletions(-)

M widget/material/button.go
M widget/material/button.go => widget/material/button.go +4 -0
@@ 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)