From f8f8149352102fe958e63b4e037e903c9c1ec8ad Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 3 Oct 2019 11:32:15 -0400 Subject: [PATCH] Update to latest Gio version. --- examples/sensors/android.go | 10 +++----- examples/sensors/main.go | 49 +++++++++++++++++-------------------- go.mod | 2 +- go.sum | 4 +-- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/examples/sensors/android.go b/examples/sensors/android.go index 8001e46..7634948 100644 --- a/examples/sensors/android.go +++ b/examples/sensors/android.go @@ -10,7 +10,7 @@ import ( "os" ndk "git.wow.st/gmp/android-go/android27" - "gioui.org/ui/app" + "gioui.org/app" ) var ( @@ -65,9 +65,7 @@ func getSensors() { func init() { tag = ndk.CharWithGoString("gio") log.Print("Android starting") - go func() { - apiLevel() - mkHomeDir() - getSensors() - }() + go apiLevel() + go mkHomeDir() + go getSensors() } diff --git a/examples/sensors/main.go b/examples/sensors/main.go index 5b11635..59289d4 100644 --- a/examples/sensors/main.go +++ b/examples/sensors/main.go @@ -6,11 +6,11 @@ import ( "log" "image/color" - "gioui.org/ui" - "gioui.org/ui/app" - "gioui.org/ui/layout" - "gioui.org/ui/measure" - "gioui.org/ui/text" + "gioui.org/app" + "gioui.org/layout" + "gioui.org/text" + "gioui.org/text/shape" + "gioui.org/unit" "golang.org/x/image/font/sfnt" "golang.org/x/image/font/gofont/goregular" @@ -42,22 +42,18 @@ func diffInsets(x, y app.Insets) bool { func eventloop() { w := app.NewWindow( - app.WithWidth(ui.Dp(400)), - app.WithHeight(ui.Dp(400)), + app.WithWidth(unit.Dp(400)), + app.WithHeight(unit.Dp(400)), app.WithTitle("Hello")) - q := w.Queue() - var c ui.Config - ops := new(ui.Ops) - //var dims layout.Dimensions - var cs layout.Constraints - var faces measure.Faces + gtx := &layout.Context{Queue: w.Queue()} + var faces shape.Faces regular, err := sfnt.Parse(goregular.TTF) 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{} - margin := layout.UniformInset(ui.Dp(10)) + margin := layout.UniformInset(unit.Dp(10)) labels := []*text.Label{} list := &layout.List{Axis: layout.Vertical} @@ -77,18 +73,19 @@ func eventloop() { case app.DestroyEvent: return case app.UpdateEvent: - c = &e.Config - ops.Reset() - faces.Reset(c) + gtx.Reset(&e.Config, e.Size) + faces.Reset(&e.Config) resetSysinset(e.Insets) - cs = layout.RigidConstraints(e.Size) - cs = sysinset.Begin(c, ops, cs) - cs = margin.Begin(c, ops, cs) - for list.Init(c, q, ops, cs, len(labels)); list.More(); list.Next() { - list.End(labels[list.Index()].Layout(ops, list.Constraints())) - } - sysinset.End(margin.End(list.Layout())) - w.Update(ops) + sysinset.Layout(gtx, func() { + margin.Layout(gtx, func() { + for i := 0; i < len(labels); i++ { + list.Layout(gtx, len(labels), func(i int) { + labels[i].Layout(gtx) + }) + } + }) + }) + w.Update(gtx.Ops) } } } diff --git a/go.mod b/go.mod index 85ee9c1..1c62467 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module git.wow.st/gmp/android-go go 1.13 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 ) diff --git a/go.sum b/go.sum index 18bb227..b9f0437 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea h1:rv21Wx1Inf27NY453rrrP6tuEG65PyWPhnP2Jx+Qb8k= -gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE= +gioui.org v0.0.0-20191003113651-f3819d816490 h1:gEVjHOvnfHdfOiPCTMQuwFp5iceBK/i8QcVd44F1ejs= +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-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=