Update docs.

This commit is contained in:
Greg 2019-08-15 09:32:39 -04:00
parent 13ffbd4fa3
commit 10b99f3ffb
3 changed files with 30 additions and 3 deletions

View File

@ -34,3 +34,30 @@ type Enclosure interface {
func Enclose(e Enclosure, w ...Widget) Widget { ... }
```
The `Context` struct also contains a `map[string]interface{}` allowing arbitrary
data to be maintained. This can be used, for example, to define themes, and control
the operation of a `WidgetCombinator` during operation. For example>
```go
type fWidget struct { l Layout }
func NewfWidget(l layout) fWidget { return fWidget{ l: l } }
func (f Flex) Flexible(v float32) Widget {
return NewfWidget(func(ctx Context) Context {
ctx.extra["Flexible"] = v
return ctx
})
}
...
ctx = giowrap.LayoutWithContext(ctx,
myFlex(
w1,
giowrap.Flexible(0.5),
w2,
giowrap.Flexible(1),
w3,
))
...
```

View File

@ -57,9 +57,9 @@ func main() {
OuterInset(
f(
e1,
f.Flexible(5),
giowrap.Flexible(5),
InnerInset(e2),
f.Flexible(10),
giowrap.Flexible(10),
btn,
)))
ctx.Draw()

View File

@ -149,7 +149,7 @@ type FlexChild struct {
type Flex WidgetCombinator
func (f Flex) Flexible(v float32) Widget {
func Flexible(v float32) Widget {
return NewfWidget(func(ctx Context) Context {
ctx.extra["Flexible"] = v
return ctx