Bump gio version.

This commit is contained in:
gmp
2020-06-11 10:42:43 -04:00
parent 0dc003bd57
commit 19194e36f4
11 changed files with 120 additions and 59 deletions
+16 -11
View File
@@ -5,8 +5,9 @@ package main
import (
"gioui.org/app"
"gioui.org/layout"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/unit"
"gioui.org/widget/material"
@@ -17,6 +18,11 @@ var (
labchan chan string
)
type (
D = layout.Dimensions
C = layout.Context
)
func main() {
labchan = make(chan string)
go eventloop()
@@ -24,14 +30,13 @@ func main() {
}
func eventloop() {
gofont.Register()
w := app.NewWindow(app.Title("Dex"))
th := material.NewTheme()
gtx := &layout.Context{Queue: w.Queue()}
th := material.NewTheme(gofont.Collection())
var ops op.Ops
sysinset := &layout.Inset{}
margin := layout.UniformInset(unit.Dp(10))
labels := []material.Label{}
labels := []material.LabelStyle{}
list := &layout.List{Axis: layout.Vertical}
go func() {
@@ -49,18 +54,18 @@ func eventloop() {
for { select {
case x := <-labchan:
labels = append(labels, th.Body1(x))
labels = append(labels, material.Body1(th, x))
case e := <-w.Events():
switch e := e.(type) {
case system.DestroyEvent:
return
case system.FrameEvent:
gtx.Reset(e.Config, e.Size)
gtx := layout.NewContext(&ops, e)
resetSysinset(e.Insets)
sysinset.Layout(gtx, func() {
margin.Layout(gtx, func() {
list.Layout(gtx, len(labels), func(i int) {
labels[i].Layout(gtx)
sysinset.Layout(gtx, func(gtx C) D {
return margin.Layout(gtx, func(gtx C) D {
return list.Layout(gtx, len(labels), func(gtx C, i int) D {
return labels[i].Layout(gtx)
})
})
})