~eliasnaur/giox

7ce24a79aa1d3a98293aa56cd43032819db1a870 — Elias Naur 4 months ago 05dace2 master
layout: update gio version

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 files changed, 71 insertions(+), 101 deletions(-)

M go.mod
M go.sum
M layout/format.go
M go.mod => go.mod +1 -1
@@ 2,4 2,4 @@ module eliasnaur.com/giox

go 1.14

require gioui.org v0.0.0-20191023082108-9a62468c25c4
require gioui.org v0.0.0-20200113204813-a7dc7c01c0f5

M go.sum => go.sum +2 -2
@@ 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-20191023082108-9a62468c25c4 h1:YUa9L4ibNehC2VN1iNmf/kbuqdnnYAM8kMqBPdnnKJk=
gioui.org v0.0.0-20191023082108-9a62468c25c4/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
gioui.org v0.0.0-20200113204813-a7dc7c01c0f5 h1:1CDWs+aNGYck65Hcqmp4ySl5zD8UrjRq3nqD07j5hZc=
gioui.org v0.0.0-20200113204813-a7dc7c01c0f5/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

M layout/format.go => layout/format.go +68 -98
@@ 202,73 202,58 @@ func formatStack(gtx *layout.Context, f *formatter, widgets []layout.Widget) {
	if ok {
		st.Alignment = align
		expect(f, ",")
		backup = *f
	} else {
		*f = backup
	}
	var children []layout.StackChild
	commaOK := false
	// First, lay out rigid children.
loop:
	for {
		switch peek(f) {
		case ')':
			break loop
		case ',':
			if !commaOK {
				errorf("unexpected ,")
			}
			commaOK = false
			expect(f, ",")
		case 'r':
			expect(f, "r(")
			children = append(children, st.Rigid(gtx, func() {
			w := func() {
				expect(f, "r(")
				formatExpr(gtx, f, widgets)
			}))
			expect(f, ")")
			commaOK = true
		case 'e':
			expect(f, "e(")
			f.skip++
			formatExpr(gtx, f, widgets)
			children = append(children, layout.StackChild{})
			f.skip--
			expect(f, ")")
			commaOK = true
		default:
			errorf("invalid flex child")
		}
	}
	// Then, lay out expanded children.
	*f = backup
	child := 0
	for {
		switch peek(f) {
		case ')':
			if f.skip == 0 {
				st.Layout(gtx, children...)
				expect(f, ")")
				if peek(f) == ',' {
					expect(f, ",")
				}
			}
			return
		case ',':
			expect(f, ",")
		case 'r':
			expect(f, "r(")
			backup := *f
			f.skip++
			formatExpr(gtx, f, widgets)
			w()
			f.skip--
			expect(f, ")")
			child++
			children = append(children, layout.Stacked(func() {
				*f = backup
				w()
			}))
		case 'e':
			expect(f, "e(")
			children[child] = st.Expand(gtx, func() {
			w := func() {
				expect(f, "e(")
				formatExpr(gtx, f, widgets)
			})
			expect(f, ")")
			child++
				expect(f, ")")
				if peek(f) == ',' {
					expect(f, ",")
				}
			}
			backup := *f
			f.skip++
			w()
			f.skip--
			children = append(children, layout.Expanded(func() {
				*f = backup
				w()
			}))
		default:
			errorf("invalid flex child")
			errorf("invalid stack child")
		}
	}
	if f.skip == 0 {
		backup := *f
		st.Layout(gtx, children...)
		*f = backup
	}
}

func formatFlex(gtx *layout.Context, axis layout.Axis, f *formatter, widgets []layout.Widget) {


@@ 280,76 265,61 @@ func formatFlex(gtx *layout.Context, axis layout.Axis, f *formatter, widgets []l
	if ok {
		fl.Alignment = al
		expect(f, ",")
		backup = *f
	} else {
		*f = backup
	}
	var children []layout.FlexChild
	commaOK := false
	// First, lay out rigid children.
loop:
	for {
		switch peek(f) {
		case ')':
			break loop
		case ',':
			if !commaOK {
				errorf("unexpected ,")
			}
			expect(f, ",")
		case 'r':
			expect(f, "r(")
			children = append(children, fl.Rigid(gtx, func() {
			w := func() {
				expect(f, "r(")
				formatExpr(gtx, f, widgets)
			}))
			expect(f, ")")
			commaOK = true
		case 'f':
			expect(f, "f(")
			parseFloat(f)
			expect(f, ",")
			f.skip++
			formatExpr(gtx, f, widgets)
			children = append(children, layout.FlexChild{})
			f.skip--
			expect(f, ")")
			commaOK = true
		default:
			errorf("invalid flex child")
		}
	}
	// Then, lay out flexible children.
	*f = backup
	child := 0
	for {
		switch peek(f) {
		case ')':
			if f.skip == 0 {
				fl.Layout(gtx, children...)
				expect(f, ")")
				if peek(f) == ',' {
					expect(f, ",")
				}
			}
			return
		case ',':
			expect(f, ",")
		case 'r':
			expect(f, "r(")
			backup := *f
			f.skip++
			formatExpr(gtx, f, widgets)
			w()
			f.skip--
			expect(f, ")")
			child++
			children = append(children, layout.Rigid(func() {
				*f = backup
				w()
			}))
		case 'f':
			expect(f, "f(")
			weight := parseFloat(f)
			expect(f, ",")
			children[child] = fl.Flex(gtx, weight, func() {
			var weight float32
			w := func() {
				expect(f, "f(")
				weight = parseFloat(f)
				expect(f, ",")
				formatExpr(gtx, f, widgets)
			})
			expect(f, ")")
			child++
				expect(f, ")")
				if peek(f) == ',' {
					expect(f, ",")
				}
			}
			backup := *f
			f.skip++
			w()
			f.skip--
			children = append(children, layout.Flexed(weight, func() {
				*f = backup
				w()
			}))
		default:
			errorf("invalid flex child")
		}
	}
	if f.skip == 0 {
		backup := *f
		fl.Layout(gtx, children...)
		*f = backup
	}
}

func parseInset(gtx *layout.Context, f *formatter, widgets []layout.Widget) layout.Inset {