mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
layout: replace Align with a Layout method on Direction
It's one less type (Align) and shorter: Before: layout.Align(layout.Center).Layout(...) After layout.Center.Layout(...) It is also safer: since `layout.Align(...)` was a casting operation, the Go compiler would not complain about an incompatible constant. For example, the widget/material package contained a wrong cast: layout.Align(layout.Start) which should have been layout.Align(layout.W) After this change, attempting `layout.Start.Layout(...)` result in a compile error. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -80,7 +80,7 @@ func (b Button) Layout(gtx *layout.Context, button *widget.Button) {
|
||||
layout.Stacked(func() {
|
||||
gtx.Constraints.Width.Min = hmin
|
||||
gtx.Constraints.Height.Min = vmin
|
||||
layout.Align(layout.Center).Layout(gtx, func() {
|
||||
layout.Center.Layout(gtx, func() {
|
||||
layout.Inset{Top: unit.Dp(10), Bottom: unit.Dp(10), Left: unit.Dp(12), Right: unit.Dp(12)}.Layout(gtx, func() {
|
||||
paint.ColorOp{Color: col}.Add(gtx.Ops)
|
||||
widget.Label{}.Layout(gtx, b.shaper, b.Font, b.Text)
|
||||
|
||||
Reference in New Issue
Block a user