example,cmd: bump gio version

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-23 19:54:27 +02:00
parent 2451750782
commit d8000880c3
13 changed files with 236 additions and 216 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/cmd
go 1.13
require (
gioui.org v0.0.0-20200521183411-67382bec3949
gioui.org v0.0.0-20200523202849-2451750782b8
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4
github.com/chromedp/chromedp v0.5.2
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
+2 -2
View File
@@ -1,6 +1,6 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200521183411-67382bec3949 h1:Nvvyn28PT4kyRKBKg04QY2ZU6y9J1hFGJtBDV5VyBmM=
gioui.org v0.0.0-20200521183411-67382bec3949/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200523202849-2451750782b8 h1:TB+F3jDAVjNemdtgc8yfvsPy1xWkyn7JLOsm5r+YUuQ=
gioui.org v0.0.0-20200523202849-2451750782b8/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4 h1:QD3KxSJ59L2lxG6MXBjNHxiQO2RmxTQ3XcK+wO44WOg=
+18 -12
View File
@@ -14,6 +14,7 @@ import (
"gioui.org/io/pointer"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/paint"
)
@@ -39,6 +40,11 @@ const (
// when a frame is ready. Initially we want to notify about the first frame.
var notify = notifyInvalidate
type (
C = layout.Context
D = layout.Dimensions
)
func loop(w *app.Window) error {
topLeft := quarterWidget{
color: color.RGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff},
@@ -53,30 +59,29 @@ func loop(w *app.Window) error {
color: color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x80},
}
gtx := new(layout.Context)
var ops op.Ops
for {
e := <-w.Events()
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case system.FrameEvent:
gtx.Reset(e.Queue, e.Config, e.Size)
gtx := layout.NewContext(&ops, e.Queue, e.Config, e.Size)
layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Flexed(0.5, func() {
layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Flexed(0.5, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
// r1c1
layout.Flexed(0.5, func() { topLeft.Layout(gtx) }),
layout.Flexed(0.5, func(gtx C) D { return topLeft.Layout(gtx) }),
// r1c2
layout.Flexed(0.5, func() { topRight.Layout(gtx) }),
layout.Flexed(0.5, func(gtx C) D { return topRight.Layout(gtx) }),
)
}),
layout.Flexed(0.5, func() {
layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Flexed(0.5, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
// r2c1
layout.Flexed(0.5, func() { botLeft.Layout(gtx) }),
layout.Flexed(0.5, func(gtx C) D { return botLeft.Layout(gtx) }),
// r2c2
layout.Flexed(0.5, func() { botRight.Layout(gtx) }),
layout.Flexed(0.5, func(gtx C) D { return botRight.Layout(gtx) }),
)
}),
)
@@ -105,7 +110,7 @@ type quarterWidget struct {
var red = color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
func (w *quarterWidget) Layout(gtx *layout.Context) {
func (w *quarterWidget) Layout(gtx layout.Context) layout.Dimensions {
if w.clicked {
paint.ColorOp{Color: red}.Add(gtx.Ops)
} else {
@@ -128,4 +133,5 @@ func (w *quarterWidget) Layout(gtx *layout.Context) {
notify = notifyInvalidate
}
}
return layout.Dimensions{Size: gtx.Constraints.Max}
}