~eliasnaur/gio-example

de858ec81f1db0d7fa003da9f37913c6bb8c0b91 — Chris Waldon a month ago 8a3a65c
all: update to use StateOp instead of StackOp

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
M galaxy/main.go => galaxy/main.go +3 -3
@@ 323,14 323,14 @@ func layoutSelectionLayer(gtx C) D {
	if selecting {
		paint.FillShape(gtx.Ops, color.NRGBA{R: 255, A: 100}, clip.Rect(selected).Op())
	}
	stack := op.Push(gtx.Ops)
	stack := op.Save(gtx.Ops)
	pointer.Rect(image.Rectangle{Max: gtx.Constraints.Max}).Add(gtx.Ops)
	pointer.CursorNameOp{Name: pointer.CursorCrossHair}.Add(gtx.Ops)
	pointer.InputOp{
		Tag:   &selected,
		Types: pointer.Press | pointer.Release | pointer.Drag,
	}.Add(gtx.Ops)
	stack.Pop()
	stack.Load()

	return D{Size: gtx.Constraints.Max}
}


@@ 350,7 350,7 @@ type (
// Layout renders the star into the gtx assuming that it is visible within the
// provided viewport. Stars outside of the viewport will be skipped.
func (s Star) Layout(gtx layout.Context, view *viewport) layout.Dimensions {
	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()
	px := gtx.Px(s.Size)
	if view != nil {
		if s.X < view.offset.X || s.X > view.offset.X+view.size.X {

M gophers/ui.go => gophers/ui.go +1 -1
@@ 358,7 358,7 @@ func (c *clipCircle) Layout(gtx layout.Context, w layout.Widget) layout.Dimensio
	}
	szf := float32(max)
	rr := szf * .5
	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()
	clip.RRect{
		Rect: f32.Rectangle{Max: f32.Point{X: szf, Y: szf}},
		NE:   rr, NW: rr, SE: rr, SW: rr,

M kitchen/kitchen.go => kitchen/kitchen.go +2 -2
@@ 151,7 151,7 @@ func transformedKitchen(gtx layout.Context, th *material.Theme) layout.Dimension
		dt := float32(gtx.Now.Sub(transformTime).Seconds())
		angle := dt * .1
		op.InvalidateOp{}.Add(gtx.Ops)
		defer op.Push(gtx.Ops).Pop()
		defer op.Save(gtx.Ops).Load()
		tr := f32.Affine2D{}
		tr = tr.Rotate(f32.Pt(300, 20), -angle)
		scale := 1.0 - dt*.5


@@ 261,7 261,7 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
			gtx.Constraints.Max.Y = gtx.Constraints.Min.Y

			dr := image.Rectangle{Max: gtx.Constraints.Min}
			defer op.Push(gtx.Ops).Pop()
			defer op.Save(gtx.Ops).Load()
			paint.LinearGradientOp{
				Stop1:  layout.FPt(dr.Min),
				Stop2:  layout.FPt(dr.Max),

M life/style.go => life/style.go +1 -1
@@ 22,7 22,7 @@ type BoardStyle struct {

// Layout draws the Board and accepts input for adding alive cells.
func (board BoardStyle) Layout(gtx layout.Context) layout.Dimensions {
	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()

	// Calculate the board size based on the cell size in pixels.
	size := board.Size.Mul(board.CellSizePx)

M tabs/slider.go => tabs/slider.go +1 -1
@@ 89,7 89,7 @@ func (s *Slider) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
		return dims
	}

	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()

	offset := smooth(s.offset)


M tabs/tabs.go => tabs/tabs.go +1 -1
@@ 143,7 143,7 @@ func fill(gtx layout.Context, col1, col2 color.NRGBA) {
		Color1: col1,
		Color2: col2,
	}.Add(gtx.Ops)
	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()
	clip.Rect(dr).Add(gtx.Ops)
	paint.PaintOp{}.Add(gtx.Ops)
}

M x/outlay/fan/widget/boring/cards.go => x/outlay/fan/widget/boring/cards.go +1 -1
@@ 82,7 82,7 @@ func (c *CardStyle) Layout(gtx C) D {
					}),
					layout.Stacked(func(gtx C) D {
						return layout.UniformInset(unit.Dp(2)).Layout(gtx, func(gtx C) D {
							defer op.Push(gtx.Ops).Pop()
							defer op.Save(gtx.Ops).Load()
							gtx.Constraints.Min = gtx.Constraints.Max
							origin := f32.Point{
								X: float32(gtx.Constraints.Max.X / 2),

M x/outlay/fan/widget/state.go => x/outlay/fan/widget/state.go +1 -1
@@ 39,7 39,7 @@ func (c *HoverState) Hovering(gtx C) bool {
}

func (c *HoverState) Layout(gtx C) D {
	defer op.Push(gtx.Ops).Pop()
	defer op.Save(gtx.Ops).Load()
	pointer.Rect(image.Rectangle{Max: gtx.Constraints.Max}).Add(gtx.Ops)
	pointer.InputOp{
		Tag:   c,