~whereswaldon/gio-x

c4d415101573ddc16092127af38b3521749a3455 — Chris Waldon 2 years ago 8b84dab op-stacks
deps,all: replace op.Save with appropriate push/pop

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
M colorpicker/color.go => colorpicker/color.go +5 -8
@@ 122,11 122,10 @@ func (m MuxStyle) layoutOption(gtx C, option string) D {
}

func borderedSquare(gtx C, c color.NRGBA) D {
	defer op.Save(gtx.Ops).Load()
	dims := square(gtx, unit.Dp(20), color.NRGBA{A: 255})

	off := float32(gtx.Px(unit.Dp(1)))
	op.Offset(f32.Pt(off, off)).Add(gtx.Ops)
	defer op.Offset(f32.Pt(off, off)).Push(gtx.Ops).Pop()
	square(gtx, unit.Dp(18), c)
	return dims
}


@@ 268,15 267,13 @@ func (p PickerStyle) Layout(gtx layout.Context) layout.Dimensions {
	layoutLeft.Add(gtx.Ops)

	// offset downwards and lay out the color sample
	var stack op.SaveStack
	stack = op.Save(gtx.Ops)
	op.Offset(f32.Pt(float32(margin), float32(leftSideDims.Size.Y))).Add(gtx.Ops)
	var stack op.TransformStack
	stack = op.Offset(f32.Pt(float32(margin), float32(leftSideDims.Size.Y))).Push(gtx.Ops)
	rectAbs(gtx, sampleWidth-(2*margin), sampleHeight-(2*margin), p.State.Color())
	stack.Load()
	stack.Pop()

	// offset to the right to lay out the sliders
	defer op.Save(gtx.Ops).Load()
	op.Offset(f32.Pt(float32(leftSideDims.Size.X), 0)).Add(gtx.Ops)
	defer op.Offset(f32.Pt(float32(leftSideDims.Size.X), 0)).Push(gtx.Ops).Pop()
	layoutRight.Add(gtx.Ops)

	return layout.Dimensions{

M explorer/go.mod => explorer/go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/x/explorer
go 1.16

require (
	gioui.org v0.0.0-20211009145857-a4242d04d1cb
	gioui.org v0.0.0-20211026101311-563eb603823d
	git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
	golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac
)

M explorer/go.sum => explorer/go.sum +4 -4
@@ 1,13 1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20211009145857-a4242d04d1cb h1:hXqpQ48G0ZGk0H6SGUS/dFGJPuqsUd9BzUdcIfvz9SQ=
gioui.org v0.0.0-20211009145857-a4242d04d1cb/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211026101311-563eb603823d h1:mQAK03CMwPUnSZbuRa6gDSQH7XMV/ClLR7Y+GCmrr7o=
gioui.org v0.0.0-20211026101311-563eb603823d/go.mod h1:yoWOxPng6WkDpsud+NRmkoftmyWn3rkKsYGEcWHpjTI=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.4 h1:taS5l4MYdnKOQ5cRh1FPUaOp0YAs0qkRrhwbZqHSYrQ=
gioui.org/shader v1.0.4/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/x
go 1.16

require (
	gioui.org v0.0.0-20211009145857-a4242d04d1cb
	gioui.org v0.0.0-20211026101311-563eb603823d
	golang.org/x/exp v0.0.0-20210722180016-6781d3edade3
	golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
)

M go.sum => go.sum +4 -4
@@ 1,13 1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20211009145857-a4242d04d1cb h1:hXqpQ48G0ZGk0H6SGUS/dFGJPuqsUd9BzUdcIfvz9SQ=
gioui.org v0.0.0-20211009145857-a4242d04d1cb/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211026101311-563eb603823d h1:mQAK03CMwPUnSZbuRa6gDSQH7XMV/ClLR7Y+GCmrr7o=
gioui.org v0.0.0-20211026101311-563eb603823d/go.mod h1:yoWOxPng6WkDpsud+NRmkoftmyWn3rkKsYGEcWHpjTI=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.4 h1:taS5l4MYdnKOQ5cRh1FPUaOp0YAs0qkRrhwbZqHSYrQ=
gioui.org/shader v1.0.4/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=

M haptic/go.mod => haptic/go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/x/haptic
go 1.14

require (
	gioui.org v0.0.0-20211009145857-a4242d04d1cb
	gioui.org v0.0.0-20211026101311-563eb603823d
	git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
	golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
)

M haptic/go.sum => haptic/go.sum +4 -4
@@ 1,13 1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20211009145857-a4242d04d1cb h1:hXqpQ48G0ZGk0H6SGUS/dFGJPuqsUd9BzUdcIfvz9SQ=
gioui.org v0.0.0-20211009145857-a4242d04d1cb/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211026101311-563eb603823d h1:mQAK03CMwPUnSZbuRa6gDSQH7XMV/ClLR7Y+GCmrr7o=
gioui.org v0.0.0-20211026101311-563eb603823d/go.mod h1:yoWOxPng6WkDpsud+NRmkoftmyWn3rkKsYGEcWHpjTI=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.4 h1:taS5l4MYdnKOQ5cRh1FPUaOp0YAs0qkRrhwbZqHSYrQ=
gioui.org/shader v1.0.4/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

M notify/go.mod => notify/go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/x/notify
go 1.14

require (
	gioui.org v0.0.0-20211009145857-a4242d04d1cb
	gioui.org v0.0.0-20211026101311-563eb603823d
	git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
	github.com/esiqveland/notify v0.11.0
	github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4

M notify/go.sum => notify/go.sum +4 -4
@@ 1,13 1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20211009145857-a4242d04d1cb h1:hXqpQ48G0ZGk0H6SGUS/dFGJPuqsUd9BzUdcIfvz9SQ=
gioui.org v0.0.0-20211009145857-a4242d04d1cb/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211026101311-563eb603823d h1:mQAK03CMwPUnSZbuRa6gDSQH7XMV/ClLR7Y+GCmrr7o=
gioui.org v0.0.0-20211026101311-563eb603823d/go.mod h1:yoWOxPng6WkDpsud+NRmkoftmyWn3rkKsYGEcWHpjTI=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.4 h1:taS5l4MYdnKOQ5cRh1FPUaOp0YAs0qkRrhwbZqHSYrQ=
gioui.org/shader v1.0.4/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

M outlay/fan.go => outlay/fan.go +3 -5
@@ 74,11 74,10 @@ func (f *Fan) offsetRadians() float32 {
}

func (f *Fan) Layout(gtx layout.Context, items ...FanItem) layout.Dimensions {
	defer op.Save(gtx.Ops).Load()
	op.Offset(f32.Point{
	defer op.Offset(f32.Point{
		X: float32(gtx.Constraints.Max.X / 2),
		Y: float32(gtx.Constraints.Max.Y / 2),
	}).Add(gtx.Ops)
	}).Push(gtx.Ops).Pop()
	f.itemsCache = f.itemsCache[:0]
	maxWidth := 0
	for i := range items {


@@ 155,7 154,6 @@ func min(a, b int) int {
}

func (f *Fan) layoutItem(gtx layout.Context, index int, params fanParams) layout.Dimensions {
	defer op.Save(gtx.Ops).Load()
	arc := params.arc
	radius := params.radius
	arc = arc*float32(index) + f.offsetRadians()


@@ 163,7 161,7 @@ func (f *Fan) layoutItem(gtx layout.Context, index int, params fanParams) layout
	transform = transform.Rotate(f32.Point{}, -math.Pi/2).
		Offset(f32.Pt(-radius, float32(f.itemsCache[index].Dimensions.Size.X/2))).
		Rotate(f32.Point{}, arc)
	op.Affine(transform).Add(gtx.Ops)
	defer op.Affine(transform).Push(gtx.Ops).Pop()
	f.itemsCache[index].Add(gtx.Ops)
	return layout.Dimensions{}
}

M outlay/grid.go => outlay/grid.go +3 -2
@@ 3,6 3,7 @@ package outlay
import (
	"image"

	"gioui.org/f32"
	"gioui.org/layout"
	"gioui.org/op"
)


@@ 35,7 36,7 @@ type wrapData struct {
}

func (g GridWrap) Layout(gtx layout.Context, num int, el GridElement) layout.Dimensions {
	defer op.Save(gtx.Ops).Load()
	defer op.Offset(f32.Point{}).Push(gtx.Ops).Pop()
	csMax := gtx.Constraints.Max
	var mainSize, crossSize, mainPos, crossPos, base int
	gtx.Constraints.Min = image.Point{}


@@ 149,7 150,7 @@ func (g *Grid) Layout(gtx layout.Context, num int, el GridElement) layout.Dimens
	}
	csMax := gtx.Constraints.Max
	return g.list.Layout(gtx, (num+g.Num-1)/g.Num, func(gtx layout.Context, idx int) layout.Dimensions {
		defer op.Save(gtx.Ops).Load()
		defer op.Offset(f32.Point{}).Push(gtx.Ops).Pop()
		if g.Axis == layout.Horizontal {
			gtx.Constraints.Max.Y = inf
		} else {

M outlay/table.go => outlay/table.go +1 -1
@@ 26,7 26,7 @@ type Table struct {
}

func (t *Table) Layout(gtx layout.Context, xn, yn int, el Cell) layout.Dimensions {
	defer op.Save(gtx.Ops).Load()
	defer op.Offset(f32.Point{}).Push(gtx.Ops).Pop()
	csMax := gtx.Constraints.Max

	// In order to deliver the same scroll events for both lists,

M pref/go.mod => pref/go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/x/pref
go 1.16

require (
	gioui.org v0.0.0-20211009145857-a4242d04d1cb
	gioui.org v0.0.0-20211026101311-563eb603823d
	git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
	golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac
	golang.org/x/text v0.3.7

M pref/go.sum => pref/go.sum +4 -4
@@ 1,13 1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20211009145857-a4242d04d1cb h1:hXqpQ48G0ZGk0H6SGUS/dFGJPuqsUd9BzUdcIfvz9SQ=
gioui.org v0.0.0-20211009145857-a4242d04d1cb/go.mod h1:vJAHQwoR+DMYs8X5RpdWAgkpnw31wFSofF1hHHcZ6gs=
gioui.org v0.0.0-20211026101311-563eb603823d h1:mQAK03CMwPUnSZbuRa6gDSQH7XMV/ClLR7Y+GCmrr7o=
gioui.org v0.0.0-20211026101311-563eb603823d/go.mod h1:yoWOxPng6WkDpsud+NRmkoftmyWn3rkKsYGEcWHpjTI=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.4 h1:taS5l4MYdnKOQ5cRh1FPUaOp0YAs0qkRrhwbZqHSYrQ=
gioui.org/shader v1.0.4/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

M richtext/richtext.go => richtext/richtext.go +2 -4
@@ 180,7 180,6 @@ func (ss *SpanStyle) Set(key, value string) {

// Layout renders the span using the provided text shaping.
func (ss SpanStyle) Layout(gtx layout.Context, s text.Shaper, shape spanShape) layout.Dimensions {
	defer op.Save(gtx.Ops).Load()
	paint.ColorOp{Color: ss.Color}.Add(gtx.Ops)
	op.Offset(layout.FPt(shape.offset)).Add(gtx.Ops)
	defer s.Shape(ss.Font, fixed.I(gtx.Px(ss.Size)), shape.layout).Push(gtx.Ops).Pop()


@@ 290,15 289,14 @@ func (t TextStyle) Layout(gtx layout.Context) layout.Dimensions {
					state.contents = span.Content
					state.metadata = span.metadata
				}
				stack := op.Save(gtx.Ops)
				// set this offset to the upper corner of the text, not the lower
				shape.offset.Y -= lineDims.Y
				op.Offset(layout.FPt(shape.offset)).Add(gtx.Ops)
				offStack := op.Offset(layout.FPt(shape.offset)).Push(gtx.Ops)
				pr := pointer.Rect(image.Rectangle{Max: shape.size}).Push(gtx.Ops)
				state.Layout(gtx)
				pointer.CursorNameOp{Name: pointer.CursorPointer}.Add(gtx.Ops)
				pr.Pop()
				stack.Load()
				offStack.Pop()
				// ensure that we request new state for each interactive text
				// that isn't breaking across a line.
				if i < len(lineShapes)-1 {