Update to latest Gio version.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
+23
-26
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user