Update to latest Gio version.
This commit is contained in:
parent
be46398183
commit
f8f8149352
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
go.mod
2
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
|
||||
)
|
||||
|
|
4
go.sum
4
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=
|
||||
|
|
Loading…
Reference in New Issue
Block a user