diff --git a/app/headless/headless_test.go b/app/headless/headless_test.go index e92bb510..2630a840 100644 --- a/app/headless/headless_test.go +++ b/app/headless/headless_test.go @@ -61,7 +61,7 @@ func TestClipping(t *testing.T) { Max: f32.Point{X: 250, Y: 250}, }, SE: 75, - }.Op(&ops).Add(&ops) + }.Add(&ops) pop.Add(&ops) paint.ColorOp{Color: col2}.Add(&ops) clip.Rect{ @@ -70,7 +70,7 @@ func TestClipping(t *testing.T) { Max: f32.Point{X: 350, Y: 350}, }, NW: 75, - }.Op(&ops).Add(&ops) + }.Add(&ops) pop.Add(&ops) if err := w.Frame(&ops); err != nil { t.Fatal(err) diff --git a/example/gophers/ui.go b/example/gophers/ui.go index 16a6c9c0..405eeb87 100644 --- a/example/gophers/ui.go +++ b/example/gophers/ui.go @@ -364,7 +364,7 @@ func (c *clipCircle) Layout(gtx layout.Context, w layout.Widget) layout.Dimensio clip.Rect{ Rect: f32.Rectangle{Max: f32.Point{X: szf, Y: szf}}, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) call.Add(gtx.Ops) return dims } diff --git a/layout/list.go b/layout/list.go index 68b63f74..ebc7f2ee 100644 --- a/layout/list.go +++ b/layout/list.go @@ -258,7 +258,7 @@ func (l *List) layout() Dimensions { Max: axisPoint(l.Axis, max, inf), } stack := op.Push(ops) - clip.Rect{Rect: FRect(r)}.Op(ops).Add(ops) + clip.Rect{Rect: FRect(r)}.Add(ops) op.Offset(FPt(axisPoint(l.Axis, pos, cross))).Add(ops) child.call.Add(ops) stack.Pop() diff --git a/op/clip/clip.go b/op/clip/clip.go index 59554b53..f77d45d7 100644 --- a/op/clip/clip.go +++ b/op/clip/clip.go @@ -193,8 +193,8 @@ func (p *Path) End() Op { } // Rect represents the clip area of a rectangle with rounded -// corners.The origin is in the upper left -// corner. +// corners. +// // Specify a square with corner radii equal to half the square size to // construct a circular clip area. type Rect struct { @@ -203,8 +203,8 @@ type Rect struct { SE, SW, NW, NE float32 } -// Op returns the Op for the rectangle. -func (rr Rect) Op(ops *op.Ops) Op { +// op returns the op for the rectangle. +func (rr Rect) op(ops *op.Ops) Op { r := rr.Rect // Optimize for the common pixel aligned rectangle with no // corner rounding. @@ -221,9 +221,9 @@ func (rr Rect) Op(ops *op.Ops) Op { return roundRect(ops, r, rr.SE, rr.SW, rr.NW, rr.NE) } -// Add is a shorthand for Op(ops).Add(ops). +// Add the rectangle clip operation. func (rr Rect) Add(ops *op.Ops) { - rr.Op(ops).Add(ops) + rr.op(ops).Add(ops) } // roundRect returns the clip area of a rectangle with rounded diff --git a/widget/image.go b/widget/image.go index 5ade15d5..979be90d 100644 --- a/widget/image.go +++ b/widget/image.go @@ -34,7 +34,7 @@ func (im Image) Layout(gtx layout.Context) layout.Dimensions { cs := gtx.Constraints d := cs.Constrain(image.Pt(w, h)) stack := op.Push(gtx.Ops) - clip.Rect{Rect: f32.Rectangle{Max: layout.FPt(d)}}.Op(gtx.Ops).Add(gtx.Ops) + clip.Rect{Rect: f32.Rectangle{Max: layout.FPt(d)}}.Add(gtx.Ops) im.Src.Add(gtx.Ops) paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: float32(w), Y: float32(h)}}}.Add(gtx.Ops) stack.Pop() diff --git a/widget/material/button.go b/widget/material/button.go index 7d7dba0c..c70a2848 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -94,7 +94,7 @@ func Clickable(gtx layout.Context, button *widget.Clickable, w layout.Widget) la X: float32(gtx.Constraints.Min.X), Y: float32(gtx.Constraints.Min.Y), }}, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) for _, c := range button.History() { drawInk(gtx, c) } @@ -128,7 +128,7 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di Y: float32(gtx.Constraints.Min.Y), }}, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) background := b.Background if gtx.Queue == nil { background = mulAlpha(b.Background, 150) @@ -156,7 +156,7 @@ func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions { clip.Rect{ Rect: f32.Rectangle{Max: f32.Point{X: sizef, Y: sizef}}, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) background := b.Background if gtx.Queue == nil { background = mulAlpha(b.Background, 150) @@ -288,6 +288,6 @@ func drawInk(gtx layout.Context, c widget.Press) { Y: float32(size), }}, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: float32(size), Y: float32(size)}}}.Add(gtx.Ops) } diff --git a/widget/material/progressbar.go b/widget/material/progressbar.go index 173a9c0b..d5d519c0 100644 --- a/widget/material/progressbar.go +++ b/widget/material/progressbar.go @@ -38,7 +38,7 @@ func (p ProgressBarStyle) Layout(gtx layout.Context) layout.Dimensions { clip.Rect{ Rect: f32.Rectangle{Max: f32.Point{X: width, Y: float32(gtx.Px(maxHeight))}}, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) paint.ColorOp{Color: color}.Add(gtx.Ops) paint.PaintOp{Rect: dr}.Add(gtx.Ops) diff --git a/widget/material/slider.go b/widget/material/slider.go index fa2cbd08..0f49b308 100644 --- a/widget/material/slider.go +++ b/widget/material/slider.go @@ -70,7 +70,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions { Y: halfWidth + trackWidth/2, }, } - clip.Rect{Rect: track}.Op(gtx.Ops).Add(gtx.Ops) + clip.Rect{Rect: track}.Add(gtx.Ops) paint.ColorOp{Color: color}.Add(gtx.Ops) paint.PaintOp{Rect: track}.Add(gtx.Ops) st.Pop() @@ -79,7 +79,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions { st = op.Push(gtx.Ops) track.Min.X = thumbPos track.Max.X = float32(size.X) - halfWidth - clip.Rect{Rect: track}.Op(gtx.Ops).Add(gtx.Ops) + clip.Rect{Rect: track}.Add(gtx.Ops) paint.ColorOp{Color: mulAlpha(color, 96)}.Add(gtx.Ops) paint.PaintOp{Rect: track}.Add(gtx.Ops) st.Pop() @@ -100,7 +100,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions { clip.Rect{ Rect: thumb, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) paint.ColorOp{Color: color}.Add(gtx.Ops) paint.PaintOp{Rect: thumb}.Add(gtx.Ops) st.Pop() diff --git a/widget/material/switch.go b/widget/material/switch.go index cb35c38c..9172b99d 100644 --- a/widget/material/switch.go +++ b/widget/material/switch.go @@ -59,7 +59,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions { clip.Rect{ Rect: trackRect, NE: trackCorner, NW: trackCorner, SE: trackCorner, SW: trackCorner, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) paint.ColorOp{Color: trackColor}.Add(gtx.Ops) paint.PaintOp{Rect: trackRect}.Add(gtx.Ops) stack.Pop() @@ -79,7 +79,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions { Max: layout.FPt(gtx.Constraints.Min), }, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(gtx.Ops).Add(gtx.Ops) + }.Add(gtx.Ops) for _, p := range s.Switch.History() { drawInk(gtx, p) } @@ -130,7 +130,7 @@ func drawDisc(ops *op.Ops, sz float32, col color.RGBA) { clip.Rect{ Rect: r, NE: rr, NW: rr, SE: rr, SW: rr, - }.Op(ops).Add(ops) + }.Add(ops) paint.ColorOp{Color: col}.Add(ops) paint.PaintOp{Rect: r}.Add(ops) }