mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
widget/material: draw button to max width with ButtonLayout
This patch allows support to draw button to maximum width using ButtonLayout.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user