Update docs.
This commit is contained in:
parent
13ffbd4fa3
commit
10b99f3ffb
27
README.md
27
README.md
|
@ -34,3 +34,30 @@ type Enclosure interface {
|
||||||
|
|
||||||
func Enclose(e Enclosure, w ...Widget) Widget { ... }
|
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,
|
||||||
|
))
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
|
@ -57,9 +57,9 @@ func main() {
|
||||||
OuterInset(
|
OuterInset(
|
||||||
f(
|
f(
|
||||||
e1,
|
e1,
|
||||||
f.Flexible(5),
|
giowrap.Flexible(5),
|
||||||
InnerInset(e2),
|
InnerInset(e2),
|
||||||
f.Flexible(10),
|
giowrap.Flexible(10),
|
||||||
btn,
|
btn,
|
||||||
)))
|
)))
|
||||||
ctx.Draw()
|
ctx.Draw()
|
||||||
|
|
2
main.go
2
main.go
|
@ -149,7 +149,7 @@ type FlexChild struct {
|
||||||
|
|
||||||
type Flex WidgetCombinator
|
type Flex WidgetCombinator
|
||||||
|
|
||||||
func (f Flex) Flexible(v float32) Widget {
|
func Flexible(v float32) Widget {
|
||||||
return NewfWidget(func(ctx Context) Context {
|
return NewfWidget(func(ctx Context) Context {
|
||||||
ctx.extra["Flexible"] = v
|
ctx.extra["Flexible"] = v
|
||||||
return ctx
|
return ctx
|
||||||
|
|
Loading…
Reference in New Issue
Block a user