Add README.md
This commit is contained in:
parent
86245ad484
commit
13ffbd4fa3
36
README.md
Normal file
36
README.md
Normal 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 { ... }
|
||||
```
|
8
main.go
8
main.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user