forked from joejulian/gio
ui/layout: update documentation to reflect the function scope changes
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+9
-9
@@ -17,12 +17,12 @@ For example, to add space above a widget:
|
|||||||
|
|
||||||
// Configure a top inset.
|
// Configure a top inset.
|
||||||
inset := layout.Inset{Top: ui.Dp(8), ...}
|
inset := layout.Inset{Top: ui.Dp(8), ...}
|
||||||
// Start insetting and modify the constraints.
|
// Use the inset to lay out a widget.
|
||||||
cs = inset.Begin(..., cs)
|
inset.Layout(..., cs, func(cs layout.Constraints) layout.Dimensions {
|
||||||
// Lay out widget and determine its size given the constraints.
|
// Lay out widget and determine its size given the constraints.
|
||||||
dimensions := widget.Layout(..., cs)
|
dimensions := widget.Layout(..., cs)
|
||||||
// End the inset and account for the insets.
|
return dimensions
|
||||||
dimensions = inset.End(dimensions)
|
})
|
||||||
|
|
||||||
Note that the example does not generate any garbage even though the
|
Note that the example does not generate any garbage even though the
|
||||||
Inset is transient. Layouts that don't accept user input are designed
|
Inset is transient. Layouts that don't accept user input are designed
|
||||||
@@ -35,12 +35,12 @@ be created from a few generic layouts.
|
|||||||
This example both aligns and insets a child:
|
This example both aligns and insets a child:
|
||||||
|
|
||||||
inset := layout.Inset{...}
|
inset := layout.Inset{...}
|
||||||
cs = inset.Begin(..., cs)
|
inset.Layout(..., cs, func(cs layout.Constraints) layout.Dimensions {
|
||||||
align := layout.Align{...}
|
align := layout.Align{...}
|
||||||
cs = align.Begin(..., cs)
|
return align.Layout(..., cs, func(cs layout.Constraints) layout.Dimensions {
|
||||||
dims := widget.Layout(..., cs)
|
return widget.Layout(..., cs)
|
||||||
dims = align.End(dims)
|
})
|
||||||
dims = inset.End(dims)
|
})
|
||||||
|
|
||||||
More complex layouts such as Stack and Flex lay out multiple children,
|
More complex layouts such as Stack and Flex lay out multiple children,
|
||||||
and stateful layouts such as List accept user input.
|
and stateful layouts such as List accept user input.
|
||||||
|
|||||||
Reference in New Issue
Block a user