Update to latest Gio version.

This commit is contained in:
Greg 2019-10-03 11:32:15 -04:00
parent be46398183
commit f8f8149352
4 changed files with 30 additions and 35 deletions

View File

@ -10,7 +10,7 @@ import (
"os" "os"
ndk "git.wow.st/gmp/android-go/android27" ndk "git.wow.st/gmp/android-go/android27"
"gioui.org/ui/app" "gioui.org/app"
) )
var ( var (
@ -65,9 +65,7 @@ func getSensors() {
func init() { func init() {
tag = ndk.CharWithGoString("gio") tag = ndk.CharWithGoString("gio")
log.Print("Android starting") log.Print("Android starting")
go func() { go apiLevel()
apiLevel() go mkHomeDir()
mkHomeDir() go getSensors()
getSensors()
}()
} }

View File

@ -6,11 +6,11 @@ import (
"log" "log"
"image/color" "image/color"
"gioui.org/ui" "gioui.org/app"
"gioui.org/ui/app" "gioui.org/layout"
"gioui.org/ui/layout" "gioui.org/text"
"gioui.org/ui/measure" "gioui.org/text/shape"
"gioui.org/ui/text" "gioui.org/unit"
"golang.org/x/image/font/sfnt" "golang.org/x/image/font/sfnt"
"golang.org/x/image/font/gofont/goregular" "golang.org/x/image/font/gofont/goregular"
@ -42,22 +42,18 @@ func diffInsets(x, y app.Insets) bool {
func eventloop() { func eventloop() {
w := app.NewWindow( w := app.NewWindow(
app.WithWidth(ui.Dp(400)), app.WithWidth(unit.Dp(400)),
app.WithHeight(ui.Dp(400)), app.WithHeight(unit.Dp(400)),
app.WithTitle("Hello")) app.WithTitle("Hello"))
q := w.Queue() gtx := &layout.Context{Queue: w.Queue()}
var c ui.Config var faces shape.Faces
ops := new(ui.Ops)
//var dims layout.Dimensions
var cs layout.Constraints
var faces measure.Faces
regular, err := sfnt.Parse(goregular.TTF) regular, err := sfnt.Parse(goregular.TTF)
if err != nil { log.Fatal("Cannot parse font.") } if err != nil { log.Fatal("Cannot parse font.") }
face = faces.For(regular, ui.Sp(16)) face = faces.For(regular, unit.Sp(16))
sysinset := &layout.Inset{} sysinset := &layout.Inset{}
margin := layout.UniformInset(ui.Dp(10)) margin := layout.UniformInset(unit.Dp(10))
labels := []*text.Label{} labels := []*text.Label{}
list := &layout.List{Axis: layout.Vertical} list := &layout.List{Axis: layout.Vertical}
@ -77,18 +73,19 @@ func eventloop() {
case app.DestroyEvent: case app.DestroyEvent:
return return
case app.UpdateEvent: case app.UpdateEvent:
c = &e.Config gtx.Reset(&e.Config, e.Size)
ops.Reset() faces.Reset(&e.Config)
faces.Reset(c)
resetSysinset(e.Insets) resetSysinset(e.Insets)
cs = layout.RigidConstraints(e.Size) sysinset.Layout(gtx, func() {
cs = sysinset.Begin(c, ops, cs) margin.Layout(gtx, func() {
cs = margin.Begin(c, ops, cs) for i := 0; i < len(labels); i++ {
for list.Init(c, q, ops, cs, len(labels)); list.More(); list.Next() { list.Layout(gtx, len(labels), func(i int) {
list.End(labels[list.Index()].Layout(ops, list.Constraints())) labels[i].Layout(gtx)
} })
sysinset.End(margin.End(list.Layout())) }
w.Update(ops) })
})
w.Update(gtx.Ops)
} }
} }
} }

2
go.mod
View File

@ -3,6 +3,6 @@ module git.wow.st/gmp/android-go
go 1.13 go 1.13
require ( require (
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea gioui.org v0.0.0-20191003113651-f3819d816490
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a
) )

4
go.sum
View File

@ -1,5 +1,5 @@
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea h1:rv21Wx1Inf27NY453rrrP6tuEG65PyWPhnP2Jx+Qb8k= gioui.org v0.0.0-20191003113651-f3819d816490 h1:gEVjHOvnfHdfOiPCTMQuwFp5iceBK/i8QcVd44F1ejs=
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE= gioui.org v0.0.0-20191003113651-f3819d816490/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=