~eliasnaur/gio-patches

widget/material: draw button to max width with ButtonLayout v1 PROPOSED

metaclips: 1
 widget/material: draw button to max width with ButtonLayout

 1 files changed, 4 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/10061/mbox | git am -3
Learn more about email & git

[PATCH] widget/material: draw button to max width with ButtonLayout Export this patch

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 81a4672..09053c7 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)
-- 
2.21.1 (Apple Git-122.3)
Thank you, merged.
View this thread in the archives