mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
Revert "widget/material: propagate ButtonLayout minimum constraints to content"
This reverts commit 52ccc183b5.
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.
This commit is contained in:
@@ -109,9 +109,9 @@ func (b ButtonLayout) Layout(gtx *layout.Context, button *widget.Button, w layou
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
layout.Stacked(func() {
|
layout.Stacked(func() {
|
||||||
|
gtx.Constraints.Width.Min = hmin
|
||||||
|
gtx.Constraints.Height.Min = vmin
|
||||||
layout.Center.Layout(gtx, func() {
|
layout.Center.Layout(gtx, func() {
|
||||||
gtx.Constraints.Width.Min = hmin
|
|
||||||
gtx.Constraints.Height.Min = vmin
|
|
||||||
b.Inset.Layout(gtx, func() {
|
b.Inset.Layout(gtx, func() {
|
||||||
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
||||||
w()
|
w()
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user