forked from joejulian/gio
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:
@@ -30,13 +30,12 @@ func ExampleInset() {
|
||||
// (70,70)
|
||||
}
|
||||
|
||||
func ExampleAlign() {
|
||||
func ExampleDirection() {
|
||||
gtx := new(layout.Context)
|
||||
// Rigid constraints with both minimum and maximum set.
|
||||
gtx.Reset(nil, image.Point{X: 100, Y: 100})
|
||||
|
||||
align := layout.Align(layout.Center)
|
||||
align.Layout(gtx, func() {
|
||||
layout.Center.Layout(gtx, func() {
|
||||
// Lay out a 50x50 sized widget.
|
||||
layoutWidget(gtx, 50, 50)
|
||||
fmt.Println(gtx.Dimensions.Size)
|
||||
|
||||
Reference in New Issue
Block a user