From b1aed3eae023d6f18804d9d028acf95c28aa0c87 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 16 Apr 2020 19:57:19 +0200 Subject: [PATCH] Revert "widget/material: propagate ButtonLayout minimum constraints to content" This reverts commit 52ccc183b54c2a3ccc04fe69cfa08eebaab662a1. Reason for revert: This doesn't seem like a good idea after all. The reason for the change was to propagate the minimum constraints to the button content. But in the simplest case, a label, stretching the button will make the label stretch as well, leaving the label top-aligned. We'll revisit this issue if a real use-case comes up. --- widget/material/button.go | 4 ++-- widget/material/material_test.go | 25 ------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 widget/material/material_test.go diff --git a/widget/material/button.go b/widget/material/button.go index 194518a8..d3ee9207 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -109,9 +109,9 @@ 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() { - gtx.Constraints.Width.Min = hmin - gtx.Constraints.Height.Min = vmin b.Inset.Layout(gtx, func() { paint.ColorOp{Color: b.Color}.Add(gtx.Ops) w() diff --git a/widget/material/material_test.go b/widget/material/material_test.go deleted file mode 100644 index cd084326..00000000 --- a/widget/material/material_test.go +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: Unlicense OR MIT - -package material - -import ( - "image" - "testing" - - "gioui.org/layout" - "gioui.org/widget" -) - -func TestButtonLayout(t *testing.T) { - var gtx layout.Context - gtx.Reset(nil, image.Point{X: 100, Y: 100}) - - ButtonLayout{}.Layout(>x, new(widget.Button), func() { - if got, exp := gtx.Constraints.Width.Min, 100; got != exp { - t.Errorf("minimum width is %d, expected %d", got, exp) - } - if got, exp := gtx.Constraints.Height.Min, 100; got != exp { - t.Errorf("minimum width is %d, expected %d", got, exp) - } - }) -}