Add README.md

This commit is contained in:
Greg 2019-08-15 09:27:04 -04:00
parent 86245ad484
commit 13ffbd4fa3
2 changed files with 39 additions and 5 deletions

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# GIOWrap
An experimental wrapper package for the Gio immediate mode GUI, designed to reduce
boilerplate.
The basic concept is to define a `Context` type that contains the Gio variables
required for layout and drawing. `Context` contains a pointer to `app.Window` and
`ui.Ops` so that, once layout is complete, you can call `Context.Draw()` to draw
your objects in your window.
The following types and functions are defined in order to transform a `Context`
variable during layout:
```go
type Layout func(Context) Context
type Widget interface {
Layout(Context) Context
}
func LayoutWithContext(ctx Context, ws ...Widget) Context {
for _, w := range ws {
ctx = w.Layout(ctx)
}
return ctx
}
type WidgetCombinator func(...Widget) Widget
type Enclosure interface {
Begin(Context) Context
End(Context) Context
}
func Enclose(e Enclosure, w ...Widget) Widget { ... }
```

View File

@ -51,11 +51,9 @@ func (ctx Context) Draw() {
type Layout func(Context) Context
type LayoutCombinator func(...Layout) Layout
func LayoutWithContext(ctx Context, ls ...Widget) Context {
for _, l := range ls {
ctx = l.Layout(ctx)
func LayoutWithContext(ctx Context, ws ...Widget) Context {
for _, w := range ws {
ctx = w.Layout(ctx)
}
return ctx
}