mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
ui/draw,ui/layout: export OpClip
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+3
-3
@@ -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.
|
// a pixel aligned rectangular area.
|
||||||
func RectClip(ops *ui.Ops, r image.Rectangle) {
|
func RectClip(r image.Rectangle) OpClip {
|
||||||
opClip{bounds: toRectF(r)}.Add(ops)
|
return OpClip{bounds: toRectF(r)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func itof(i int) float32 {
|
func itof(i int) float32 {
|
||||||
|
|||||||
+5
-4
@@ -23,12 +23,13 @@ type PathBuilder struct {
|
|||||||
hasBounds bool
|
hasBounds bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// opClip structure must match opClip in package ui/internal/gpu.
|
// OpClip structure must match opClip in package ui/internal/gpu.
|
||||||
type opClip struct {
|
|
||||||
|
type OpClip struct {
|
||||||
bounds f32.Rectangle
|
bounds f32.Rectangle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p opClip) Add(o *ui.Ops) {
|
func (p OpClip) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeClipLen)
|
data := make([]byte, ops.TypeClipLen)
|
||||||
data[0] = byte(ops.TypeClip)
|
data[0] = byte(ops.TypeClip)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -277,7 +278,7 @@ func (p *PathBuilder) simpleQuadTo(ctrl, to f32.Point) {
|
|||||||
|
|
||||||
func (p *PathBuilder) End() {
|
func (p *PathBuilder) End() {
|
||||||
p.end()
|
p.end()
|
||||||
opClip{
|
OpClip{
|
||||||
bounds: p.bounds,
|
bounds: p.bounds,
|
||||||
}.Add(p.ops)
|
}.Add(p.ops)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -180,7 +180,7 @@ func (l *List) Layout() Dimens {
|
|||||||
Max: axisPoint(l.Axis, max, ui.Inf),
|
Max: axisPoint(l.Axis, max, ui.Inf),
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(ops)
|
ui.OpPush{}.Add(ops)
|
||||||
draw.RectClip(ops, r)
|
draw.RectClip(r).Add(ops)
|
||||||
ui.OpTransform{
|
ui.OpTransform{
|
||||||
Transform: ui.Offset(toPointF(axisPoint(l.Axis, pos, cross))),
|
Transform: ui.Offset(toPointF(axisPoint(l.Axis, pos, cross))),
|
||||||
}.Add(ops)
|
}.Add(ops)
|
||||||
|
|||||||
Reference in New Issue
Block a user