From d67b7eca6c52a7ab39140f187c250fe87b47f9f4 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 17 Jun 2019 16:45:49 +0200 Subject: [PATCH] ui/draw,ui/layout: export OpClip Signed-off-by: Elias Naur --- ui/draw/draw.go | 6 +++--- ui/draw/path.go | 9 +++++---- ui/layout/list.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/draw/draw.go b/ui/draw/draw.go index fd116cea..e102abeb 100644 --- a/ui/draw/draw.go +++ b/ui/draw/draw.go @@ -113,10 +113,10 @@ func (d *OpDraw) Decode(data []byte, refs []interface{}) { } } -// RectClip append a clip op corresponding to +// RectClip returns an OpClip op corresponding to // a pixel aligned rectangular area. -func RectClip(ops *ui.Ops, r image.Rectangle) { - opClip{bounds: toRectF(r)}.Add(ops) +func RectClip(r image.Rectangle) OpClip { + return OpClip{bounds: toRectF(r)} } func itof(i int) float32 { diff --git a/ui/draw/path.go b/ui/draw/path.go index 27e67f63..8f9f1bbf 100644 --- a/ui/draw/path.go +++ b/ui/draw/path.go @@ -23,12 +23,13 @@ type PathBuilder struct { hasBounds bool } -// opClip structure must match opClip in package ui/internal/gpu. -type opClip struct { +// OpClip structure must match opClip in package ui/internal/gpu. + +type OpClip struct { bounds f32.Rectangle } -func (p opClip) Add(o *ui.Ops) { +func (p OpClip) Add(o *ui.Ops) { data := make([]byte, ops.TypeClipLen) data[0] = byte(ops.TypeClip) bo := binary.LittleEndian @@ -277,7 +278,7 @@ func (p *PathBuilder) simpleQuadTo(ctrl, to f32.Point) { func (p *PathBuilder) End() { p.end() - opClip{ + OpClip{ bounds: p.bounds, }.Add(p.ops) } diff --git a/ui/layout/list.go b/ui/layout/list.go index de5aad6b..2bfc7b58 100644 --- a/ui/layout/list.go +++ b/ui/layout/list.go @@ -180,7 +180,7 @@ func (l *List) Layout() Dimens { Max: axisPoint(l.Axis, max, ui.Inf), } ui.OpPush{}.Add(ops) - draw.RectClip(ops, r) + draw.RectClip(r).Add(ops) ui.OpTransform{ Transform: ui.Offset(toPointF(axisPoint(l.Axis, pos, cross))), }.Add(ops)