mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
ui: rename ops to have Op suffixed, not prefixed
Match Go's FooError name pattern. While we're here, rename RedrawOp to InvalidateOp. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -78,10 +78,10 @@ type drawState struct {
|
|||||||
rect bool
|
rect bool
|
||||||
z int
|
z int
|
||||||
|
|
||||||
// Current OpImage image and rect, if any.
|
// Current ImageOp image and rect, if any.
|
||||||
img image.Image
|
img image.Image
|
||||||
imgRect image.Rectangle
|
imgRect image.Rectangle
|
||||||
// Current OpColor, if any.
|
// Current ColorOp, if any.
|
||||||
color color.NRGBA
|
color color.NRGBA
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +666,7 @@ loop:
|
|||||||
}
|
}
|
||||||
switch ops.OpType(encOp.Data[0]) {
|
switch ops.OpType(encOp.Data[0]) {
|
||||||
case ops.TypeTransform:
|
case ops.TypeTransform:
|
||||||
var op ui.OpTransform
|
var op ui.TransformOp
|
||||||
op.Decode(encOp.Data)
|
op.Decode(encOp.Data)
|
||||||
state.t = state.t.Mul(op.Transform)
|
state.t = state.t.Mul(op.Transform)
|
||||||
case ops.TypeAux:
|
case ops.TypeAux:
|
||||||
@@ -696,17 +696,17 @@ loop:
|
|||||||
aux = nil
|
aux = nil
|
||||||
auxKey = ui.OpKey{}
|
auxKey = ui.OpKey{}
|
||||||
case ops.TypeColor:
|
case ops.TypeColor:
|
||||||
var op gdraw.OpColor
|
var op gdraw.ColorOp
|
||||||
op.Decode(encOp.Data, encOp.Refs)
|
op.Decode(encOp.Data, encOp.Refs)
|
||||||
state.img = nil
|
state.img = nil
|
||||||
state.color = op.Col
|
state.color = op.Col
|
||||||
case ops.TypeImage:
|
case ops.TypeImage:
|
||||||
var op gdraw.OpImage
|
var op gdraw.ImageOp
|
||||||
op.Decode(encOp.Data, encOp.Refs)
|
op.Decode(encOp.Data, encOp.Refs)
|
||||||
state.img = op.Img
|
state.img = op.Img
|
||||||
state.imgRect = op.Rect
|
state.imgRect = op.Rect
|
||||||
case ops.TypeDraw:
|
case ops.TypeDraw:
|
||||||
var op gdraw.OpDraw
|
var op gdraw.DrawOp
|
||||||
op.Decode(encOp.Data, encOp.Refs)
|
op.Decode(encOp.Data, encOp.Refs)
|
||||||
off := state.t.Transform(f32.Point{})
|
off := state.t.Transform(f32.Point{})
|
||||||
clip := state.clip.Intersect(op.Rect.Add(off))
|
clip := state.clip.Intersect(op.Rect.Add(off))
|
||||||
|
|||||||
+2
-2
@@ -161,8 +161,8 @@ func collectRedraws(r *ui.OpsReader) (time.Time, bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch ops.OpType(encOp.Data[0]) {
|
switch ops.OpType(encOp.Data[0]) {
|
||||||
case ops.TypeRedraw:
|
case ops.TypeInvalidate:
|
||||||
var op ui.OpRedraw
|
var op ui.InvalidateOp
|
||||||
op.Decode(encOp.Data)
|
op.Decode(encOp.Data)
|
||||||
if !redraw || op.At.Before(t) {
|
if !redraw || op.At.Before(t) {
|
||||||
redraw = true
|
redraw = true
|
||||||
|
|||||||
+15
-15
@@ -13,20 +13,20 @@ import (
|
|||||||
"gioui.org/ui/internal/ops"
|
"gioui.org/ui/internal/ops"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpImage struct {
|
type ImageOp struct {
|
||||||
Img image.Image
|
Img image.Image
|
||||||
Rect image.Rectangle
|
Rect image.Rectangle
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpColor struct {
|
type ColorOp struct {
|
||||||
Col color.NRGBA
|
Col color.NRGBA
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpDraw struct {
|
type DrawOp struct {
|
||||||
Rect f32.Rectangle
|
Rect f32.Rectangle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i OpImage) Add(o *ui.Ops) {
|
func (i ImageOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeImageLen)
|
data := make([]byte, ops.TypeImageLen)
|
||||||
data[0] = byte(ops.TypeImage)
|
data[0] = byte(ops.TypeImage)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -37,7 +37,7 @@ func (i OpImage) Add(o *ui.Ops) {
|
|||||||
o.Write(data, i.Img)
|
o.Write(data, i.Img)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *OpImage) Decode(data []byte, refs []interface{}) {
|
func (i *ImageOp) Decode(data []byte, refs []interface{}) {
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
if ops.OpType(data[0]) != ops.TypeImage {
|
if ops.OpType(data[0]) != ops.TypeImage {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
@@ -52,13 +52,13 @@ func (i *OpImage) Decode(data []byte, refs []interface{}) {
|
|||||||
Y: int(bo.Uint32(data[13:])),
|
Y: int(bo.Uint32(data[13:])),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
*i = OpImage{
|
*i = ImageOp{
|
||||||
Img: refs[0].(image.Image),
|
Img: refs[0].(image.Image),
|
||||||
Rect: sr,
|
Rect: sr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c OpColor) Add(o *ui.Ops) {
|
func (c ColorOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeColorLen)
|
data := make([]byte, ops.TypeColorLen)
|
||||||
data[0] = byte(ops.TypeColor)
|
data[0] = byte(ops.TypeColor)
|
||||||
data[1] = c.Col.R
|
data[1] = c.Col.R
|
||||||
@@ -68,11 +68,11 @@ func (c OpColor) Add(o *ui.Ops) {
|
|||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OpColor) Decode(data []byte, refs []interface{}) {
|
func (c *ColorOp) Decode(data []byte, refs []interface{}) {
|
||||||
if ops.OpType(data[0]) != ops.TypeColor {
|
if ops.OpType(data[0]) != ops.TypeColor {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
*c = OpColor{
|
*c = ColorOp{
|
||||||
Col: color.NRGBA{
|
Col: color.NRGBA{
|
||||||
R: data[1],
|
R: data[1],
|
||||||
G: data[2],
|
G: data[2],
|
||||||
@@ -82,7 +82,7 @@ func (c *OpColor) Decode(data []byte, refs []interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d OpDraw) Add(o *ui.Ops) {
|
func (d DrawOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeDrawLen)
|
data := make([]byte, ops.TypeDrawLen)
|
||||||
data[0] = byte(ops.TypeDraw)
|
data[0] = byte(ops.TypeDraw)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -93,7 +93,7 @@ func (d OpDraw) Add(o *ui.Ops) {
|
|||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *OpDraw) Decode(data []byte, refs []interface{}) {
|
func (d *DrawOp) Decode(data []byte, refs []interface{}) {
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
if ops.OpType(data[0]) != ops.TypeDraw {
|
if ops.OpType(data[0]) != ops.TypeDraw {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
@@ -108,15 +108,15 @@ func (d *OpDraw) Decode(data []byte, refs []interface{}) {
|
|||||||
Y: math.Float32frombits(bo.Uint32(data[13:])),
|
Y: math.Float32frombits(bo.Uint32(data[13:])),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
*d = OpDraw{
|
*d = DrawOp{
|
||||||
Rect: r,
|
Rect: r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RectClip returns an OpClip op corresponding to
|
// RectClip returns a ClipOp op corresponding to
|
||||||
// a pixel aligned rectangular area.
|
// a pixel aligned rectangular area.
|
||||||
func RectClip(r image.Rectangle) OpClip {
|
func RectClip(r image.Rectangle) ClipOp {
|
||||||
return OpClip{bounds: toRectF(r)}
|
return ClipOp{bounds: toRectF(r)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func itof(i int) float32 {
|
func itof(i int) float32 {
|
||||||
|
|||||||
+4
-4
@@ -23,13 +23,13 @@ type PathBuilder struct {
|
|||||||
hasBounds bool
|
hasBounds bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpClip structure must match opClip in package ui/internal/gpu.
|
// ClipOp structure must match opClip in package ui/internal/gpu.
|
||||||
|
|
||||||
type OpClip struct {
|
type ClipOp struct {
|
||||||
bounds f32.Rectangle
|
bounds f32.Rectangle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p OpClip) Add(o *ui.Ops) {
|
func (p ClipOp) 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
|
||||||
@@ -278,7 +278,7 @@ func (p *PathBuilder) simpleQuadTo(ctrl, to f32.Point) {
|
|||||||
|
|
||||||
func (p *PathBuilder) End() {
|
func (p *PathBuilder) End() {
|
||||||
p.end()
|
p.end()
|
||||||
OpClip{
|
ClipOp{
|
||||||
bounds: p.bounds,
|
bounds: p.bounds,
|
||||||
}.Add(p.ops)
|
}.Add(p.ops)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Click) Add(ops *ui.Ops) {
|
func (c *Click) Add(ops *ui.Ops) {
|
||||||
op := pointer.OpHandler{Key: c}
|
op := pointer.HandlerOp{Key: c}
|
||||||
op.Add(ops)
|
op.Add(ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +118,10 @@ func (c *Click) Update(q input.Events) []ClickEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scroll) Add(ops *ui.Ops) {
|
func (s *Scroll) Add(ops *ui.Ops) {
|
||||||
oph := pointer.OpHandler{Key: s, Grab: s.grab}
|
oph := pointer.HandlerOp{Key: s, Grab: s.grab}
|
||||||
oph.Add(ops)
|
oph.Add(ops)
|
||||||
if s.flinger.Active() {
|
if s.flinger.Active() {
|
||||||
ui.OpRedraw{}.Add(ops)
|
ui.InvalidateOp{}.Add(ops)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ loop:
|
|||||||
}
|
}
|
||||||
switch ops.OpType(encOp.Data[0]) {
|
switch ops.OpType(encOp.Data[0]) {
|
||||||
case ops.TypeKeyHandler:
|
case ops.TypeKeyHandler:
|
||||||
var op key.OpHandler
|
var op key.HandlerOp
|
||||||
op.Decode(encOp.Data, encOp.Refs)
|
op.Decode(encOp.Data, encOp.Refs)
|
||||||
var newPri listenerPriority
|
var newPri listenerPriority
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
+5
-5
@@ -40,7 +40,7 @@ type pointerHandler struct {
|
|||||||
|
|
||||||
type area struct {
|
type area struct {
|
||||||
trans ui.Transform
|
trans ui.Transform
|
||||||
area pointer.OpArea
|
area pointer.AreaOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type areaIntersection []area
|
type areaIntersection []area
|
||||||
@@ -68,15 +68,15 @@ func (q *pointerQueue) collectHandlers(r *ui.OpsReader, t ui.Transform, layer in
|
|||||||
layer++
|
layer++
|
||||||
q.hitTree = append(q.hitTree, hitNode{level: layer})
|
q.hitTree = append(q.hitTree, hitNode{level: layer})
|
||||||
case ops.TypeArea:
|
case ops.TypeArea:
|
||||||
var op pointer.OpArea
|
var op pointer.AreaOp
|
||||||
op.Decode(encOp.Data)
|
op.Decode(encOp.Data)
|
||||||
q.areas.add(t, op)
|
q.areas.add(t, op)
|
||||||
case ops.TypeTransform:
|
case ops.TypeTransform:
|
||||||
var op ui.OpTransform
|
var op ui.TransformOp
|
||||||
op.Decode(encOp.Data)
|
op.Decode(encOp.Data)
|
||||||
t = t.Mul(op.Transform)
|
t = t.Mul(op.Transform)
|
||||||
case ops.TypePointerHandler:
|
case ops.TypePointerHandler:
|
||||||
var op pointer.OpHandler
|
var op pointer.HandlerOp
|
||||||
op.Decode(encOp.Data, encOp.Refs)
|
op.Decode(encOp.Data, encOp.Refs)
|
||||||
q.hitTree = append(q.hitTree, hitNode{level: layer, key: op.Key})
|
q.hitTree = append(q.hitTree, hitNode{level: layer, key: op.Key})
|
||||||
h, ok := q.handlers[op.Key]
|
h, ok := q.handlers[op.Key]
|
||||||
@@ -251,7 +251,7 @@ func (a areaIntersection) hit(p f32.Point) pointer.HitResult {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *areaStack) add(t ui.Transform, a pointer.OpArea) {
|
func (s *areaStack) add(t ui.Transform, a pointer.AreaOp) {
|
||||||
s.areas = append(s.areas, area{t, a})
|
s.areas = append(s.areas, area{t, a})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const (
|
|||||||
TypeBlock
|
TypeBlock
|
||||||
TypeTransform
|
TypeTransform
|
||||||
TypeLayer
|
TypeLayer
|
||||||
TypeRedraw
|
TypeInvalidate
|
||||||
TypeImage
|
TypeImage
|
||||||
TypeDraw
|
TypeDraw
|
||||||
TypeColor
|
TypeColor
|
||||||
|
|||||||
+6
-6
@@ -7,12 +7,12 @@ import (
|
|||||||
"gioui.org/ui/internal/ops"
|
"gioui.org/ui/internal/ops"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpHandler struct {
|
type HandlerOp struct {
|
||||||
Key Key
|
Key Key
|
||||||
Focus bool
|
Focus bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpHideInput struct{}
|
type HideInputOp struct{}
|
||||||
|
|
||||||
type Key interface{}
|
type Key interface{}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ func (m Modifiers) Contain(m2 Modifiers) bool {
|
|||||||
return m&m2 == m2
|
return m&m2 == m2
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OpHandler) Add(o *ui.Ops) {
|
func (h HandlerOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeKeyHandlerLen)
|
data := make([]byte, ops.TypeKeyHandlerLen)
|
||||||
data[0] = byte(ops.TypeKeyHandler)
|
data[0] = byte(ops.TypeKeyHandler)
|
||||||
if h.Focus {
|
if h.Focus {
|
||||||
@@ -74,17 +74,17 @@ func (h OpHandler) Add(o *ui.Ops) {
|
|||||||
o.Write(data, h.Key)
|
o.Write(data, h.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *OpHandler) Decode(d []byte, refs []interface{}) {
|
func (h *HandlerOp) Decode(d []byte, refs []interface{}) {
|
||||||
if ops.OpType(d[0]) != ops.TypeKeyHandler {
|
if ops.OpType(d[0]) != ops.TypeKeyHandler {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
*h = OpHandler{
|
*h = HandlerOp{
|
||||||
Focus: d[1] != 0,
|
Focus: d[1] != 0,
|
||||||
Key: refs[0].(Key),
|
Key: refs[0].(Key),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OpHideInput) Add(o *ui.Ops) {
|
func (h HideInputOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeHideInputLen)
|
data := make([]byte, ops.TypeHideInputLen)
|
||||||
data[0] = byte(ops.TypeHideInput)
|
data[0] = byte(ops.TypeHideInput)
|
||||||
o.Write(data)
|
o.Write(data)
|
||||||
|
|||||||
+5
-5
@@ -25,7 +25,7 @@ type Flex struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FlexChild struct {
|
type FlexChild struct {
|
||||||
block ui.OpBlock
|
block ui.BlockOp
|
||||||
dims Dimens
|
dims Dimens
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ func (f *Flex) begin() {
|
|||||||
}
|
}
|
||||||
f.begun = true
|
f.begun = true
|
||||||
f.ops.Begin()
|
f.ops.Begin()
|
||||||
ui.OpLayer{}.Add(f.ops)
|
ui.LayerOp{}.Add(f.ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flex) Rigid() Constraints {
|
func (f *Flex) Rigid() Constraints {
|
||||||
@@ -159,12 +159,12 @@ func (f *Flex) Layout(children ...FlexChild) Dimens {
|
|||||||
cross = f.maxBaseline - b
|
cross = f.maxBaseline - b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(f.ops)
|
ui.PushOp{}.Add(f.ops)
|
||||||
ui.OpTransform{
|
ui.TransformOp{
|
||||||
Transform: ui.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))),
|
Transform: ui.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))),
|
||||||
}.Add(f.ops)
|
}.Add(f.ops)
|
||||||
child.block.Add(f.ops)
|
child.block.Add(f.ops)
|
||||||
ui.OpPop{}.Add(f.ops)
|
ui.PopOp{}.Add(f.ops)
|
||||||
mainSize += axisMain(f.Axis, dims.Size)
|
mainSize += axisMain(f.Axis, dims.Size)
|
||||||
switch f.MainAxisAlignment {
|
switch f.MainAxisAlignment {
|
||||||
case SpaceEvenly:
|
case SpaceEvenly:
|
||||||
|
|||||||
+6
-6
@@ -104,8 +104,8 @@ func (in *Insets) Begin(ops *ui.Ops, cs Constraints) Constraints {
|
|||||||
mcs.Height.Max = mcs.Height.Min
|
mcs.Height.Max = mcs.Height.Min
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.OpTransform{Transform: ui.Offset(toPointF(image.Point{X: l, Y: t}))}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(toPointF(image.Point{X: l, Y: t}))}.Add(ops)
|
||||||
return mcs
|
return mcs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ func (in *Insets) End(dims Dimens) Dimens {
|
|||||||
}
|
}
|
||||||
in.begun = false
|
in.begun = false
|
||||||
ops := in.ops
|
ops := in.ops
|
||||||
ui.OpPop{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
t, r, b, l := int(math.Round(float64(in.Top))), int(math.Round(float64(in.Right))), int(math.Round(float64(in.Bottom))), int(math.Round(float64(in.Left)))
|
t, r, b, l := int(math.Round(float64(in.Top))), int(math.Round(float64(in.Right))), int(math.Round(float64(in.Bottom))), int(math.Round(float64(in.Left)))
|
||||||
return Dimens{
|
return Dimens{
|
||||||
Size: in.cs.Constrain(dims.Size.Add(image.Point{X: r + l, Y: t + b})),
|
Size: in.cs.Constrain(dims.Size.Add(image.Point{X: r + l, Y: t + b})),
|
||||||
@@ -201,10 +201,10 @@ func (a *Align) End(dims Dimens) Dimens {
|
|||||||
case SW, S, SE:
|
case SW, S, SE:
|
||||||
p.Y = sz.Y - dims.Size.Y
|
p.Y = sz.Y - dims.Size.Y
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.OpTransform{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
||||||
block.Add(ops)
|
block.Add(ops)
|
||||||
ui.OpPop{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
return Dimens{
|
return Dimens{
|
||||||
Size: sz,
|
Size: sz,
|
||||||
Baseline: dims.Baseline,
|
Baseline: dims.Baseline,
|
||||||
|
|||||||
+5
-5
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
type scrollChild struct {
|
type scrollChild struct {
|
||||||
size image.Point
|
size image.Point
|
||||||
block ui.OpBlock
|
block ui.BlockOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type List struct {
|
type List struct {
|
||||||
@@ -91,7 +91,7 @@ func (l *List) Next() (int, Constraints, bool) {
|
|||||||
if ok {
|
if ok {
|
||||||
cs = axisConstraints(l.Axis, Constraint{Max: ui.Inf}, l.crossConstraintChild(l.cs))
|
cs = axisConstraints(l.Axis, Constraint{Max: ui.Inf}, l.crossConstraintChild(l.cs))
|
||||||
l.ops.Begin()
|
l.ops.Begin()
|
||||||
ui.OpLayer{}.Add(l.ops)
|
ui.LayerOp{}.Add(l.ops)
|
||||||
}
|
}
|
||||||
return i, cs, ok
|
return i, cs, ok
|
||||||
}
|
}
|
||||||
@@ -194,13 +194,13 @@ func (l *List) Layout() Dimens {
|
|||||||
Min: axisPoint(l.Axis, min, -ui.Inf),
|
Min: axisPoint(l.Axis, min, -ui.Inf),
|
||||||
Max: axisPoint(l.Axis, max, ui.Inf),
|
Max: axisPoint(l.Axis, max, ui.Inf),
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
draw.RectClip(r).Add(ops)
|
draw.RectClip(r).Add(ops)
|
||||||
ui.OpTransform{
|
ui.TransformOp{
|
||||||
Transform: ui.Offset(toPointF(axisPoint(l.Axis, transPos, cross))),
|
Transform: ui.Offset(toPointF(axisPoint(l.Axis, transPos, cross))),
|
||||||
}.Add(ops)
|
}.Add(ops)
|
||||||
child.block.Add(ops)
|
child.block.Add(ops)
|
||||||
ui.OpPop{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
pos += childSize
|
pos += childSize
|
||||||
}
|
}
|
||||||
atStart := l.first == 0 && l.offset <= 0
|
atStart := l.first == 0 && l.offset <= 0
|
||||||
|
|||||||
+5
-5
@@ -20,7 +20,7 @@ type Stack struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StackChild struct {
|
type StackChild struct {
|
||||||
block ui.OpBlock
|
block ui.BlockOp
|
||||||
dims Dimens
|
dims Dimens
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ func (s *Stack) begin() {
|
|||||||
}
|
}
|
||||||
s.begun = true
|
s.begun = true
|
||||||
s.ops.Begin()
|
s.ops.Begin()
|
||||||
ui.OpLayer{}.Add(s.ops)
|
ui.LayerOp{}.Add(s.ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stack) Rigid() Constraints {
|
func (s *Stack) Rigid() Constraints {
|
||||||
@@ -103,10 +103,10 @@ func (s *Stack) Layout(children ...StackChild) Dimens {
|
|||||||
case SW, S, SE:
|
case SW, S, SE:
|
||||||
p.Y = s.maxSZ.Y - sz.Y
|
p.Y = s.maxSZ.Y - sz.Y
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(s.ops)
|
ui.PushOp{}.Add(s.ops)
|
||||||
ui.OpTransform{Transform: ui.Offset(toPointF(p))}.Add(s.ops)
|
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(s.ops)
|
||||||
ch.block.Add(s.ops)
|
ch.block.Add(s.ops)
|
||||||
ui.OpPop{}.Add(s.ops)
|
ui.PopOp{}.Add(s.ops)
|
||||||
}
|
}
|
||||||
b := s.baseline
|
b := s.baseline
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type cachedLayout struct {
|
|||||||
|
|
||||||
type cachedPath struct {
|
type cachedPath struct {
|
||||||
active bool
|
active bool
|
||||||
path ui.OpBlock
|
path ui.BlockOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type layoutKey struct {
|
type layoutKey struct {
|
||||||
@@ -121,7 +121,7 @@ func (f *textFace) Layout(str string, singleLine bool, maxWidth int) *text.Layou
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *textFace) Path(str text.String) ui.OpBlock {
|
func (f *textFace) Path(str text.String) ui.BlockOp {
|
||||||
ppem := fixed.Int26_6(f.faces.Config.Val(f.size)*64 + .5)
|
ppem := fixed.Int26_6(f.faces.Config.Val(f.size)*64 + .5)
|
||||||
pk := pathKey{
|
pk := pathKey{
|
||||||
f: f.font.Font,
|
f: f.font.Font,
|
||||||
@@ -229,7 +229,7 @@ func layoutText(ppem fixed.Int26_6, str string, f *opentype, singleLine bool, ma
|
|||||||
return &text.Layout{Lines: lines}
|
return &text.Layout{Lines: lines}
|
||||||
}
|
}
|
||||||
|
|
||||||
func textPath(ppem fixed.Int26_6, f *opentype, str text.String) ui.OpBlock {
|
func textPath(ppem fixed.Int26_6, f *opentype, str text.String) ui.BlockOp {
|
||||||
var lastPos f32.Point
|
var lastPos f32.Point
|
||||||
var builder draw.PathBuilder
|
var builder draw.PathBuilder
|
||||||
ops := new(ui.Ops)
|
ops := new(ui.Ops)
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ type pc struct {
|
|||||||
refs int
|
refs int
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpPush struct{}
|
type PushOp struct{}
|
||||||
|
|
||||||
type OpPop struct{}
|
type PopOp struct{}
|
||||||
|
|
||||||
type OpBlock struct {
|
type BlockOp struct {
|
||||||
ops *opsData
|
ops *opsData
|
||||||
version int
|
version int
|
||||||
pc pc
|
pc pc
|
||||||
@@ -76,11 +76,11 @@ type opAux struct {
|
|||||||
len int
|
len int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p OpPush) Add(o *Ops) {
|
func (p PushOp) Add(o *Ops) {
|
||||||
o.Write([]byte{byte(ops.TypePush)})
|
o.Write([]byte{byte(ops.TypePush)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p OpPop) Add(o *Ops) {
|
func (p PopOp) Add(o *Ops) {
|
||||||
o.Write([]byte{byte(ops.TypePop)})
|
o.Write([]byte{byte(ops.TypePop)})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ func (op *opBlockDef) decode(data []byte) {
|
|||||||
|
|
||||||
// End the most recent block and return
|
// End the most recent block and return
|
||||||
// an op for invoking the completed block.
|
// an op for invoking the completed block.
|
||||||
func (o *Ops) End() OpBlock {
|
func (o *Ops) End() BlockOp {
|
||||||
start := o.stack[len(o.stack)-1]
|
start := o.stack[len(o.stack)-1]
|
||||||
o.stack = o.stack[:len(o.stack)-1]
|
o.stack = o.stack[:len(o.stack)-1]
|
||||||
pc := o.ops.pc()
|
pc := o.ops.pc()
|
||||||
@@ -128,7 +128,7 @@ func (o *Ops) End() OpBlock {
|
|||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
bo.PutUint32(data[1:], uint32(pc.data))
|
bo.PutUint32(data[1:], uint32(pc.data))
|
||||||
bo.PutUint32(data[5:], uint32(pc.refs))
|
bo.PutUint32(data[5:], uint32(pc.refs))
|
||||||
return OpBlock{ops: &o.ops, pc: start, version: o.ops.version}
|
return BlockOp{ops: &o.ops, pc: start, version: o.ops.version}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the Ops, preparing it for re-use.
|
// Reset the Ops, preparing it for re-use.
|
||||||
@@ -189,7 +189,7 @@ func (d *opsData) pc() pc {
|
|||||||
return pc{data: len(d.data), refs: len(d.refs)}
|
return pc{data: len(d.data), refs: len(d.refs)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *OpBlock) decode(data []byte, refs []interface{}) {
|
func (b *BlockOp) decode(data []byte, refs []interface{}) {
|
||||||
if ops.OpType(data[0]) != ops.TypeBlock {
|
if ops.OpType(data[0]) != ops.TypeBlock {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ func (b *OpBlock) decode(data []byte, refs []interface{}) {
|
|||||||
dataIdx := int(bo.Uint32(data[1:]))
|
dataIdx := int(bo.Uint32(data[1:]))
|
||||||
refsIdx := int(bo.Uint32(data[5:]))
|
refsIdx := int(bo.Uint32(data[5:]))
|
||||||
version := int(bo.Uint32(data[9:]))
|
version := int(bo.Uint32(data[9:]))
|
||||||
*b = OpBlock{
|
*b = BlockOp{
|
||||||
ops: refs[0].(*opsData),
|
ops: refs[0].(*opsData),
|
||||||
pc: pc{
|
pc: pc{
|
||||||
data: dataIdx,
|
data: dataIdx,
|
||||||
@@ -207,7 +207,7 @@ func (b *OpBlock) decode(data []byte, refs []interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b OpBlock) Add(o *Ops) {
|
func (b BlockOp) Add(o *Ops) {
|
||||||
data := make([]byte, ops.TypeBlockLen)
|
data := make([]byte, ops.TypeBlockLen)
|
||||||
data[0] = byte(ops.TypeBlock)
|
data[0] = byte(ops.TypeBlock)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -251,14 +251,14 @@ func (r *OpsReader) Decode() (EncodedOp, bool) {
|
|||||||
n += op.len
|
n += op.len
|
||||||
data = r.ops.data[r.pc.data : r.pc.data+n]
|
data = r.ops.data[r.pc.data : r.pc.data+n]
|
||||||
case ops.TypeBlock:
|
case ops.TypeBlock:
|
||||||
var op OpBlock
|
var op BlockOp
|
||||||
op.decode(data, refs)
|
op.decode(data, refs)
|
||||||
blockOps := op.ops
|
blockOps := op.ops
|
||||||
if ops.OpType(blockOps.data[op.pc.data]) != ops.TypeBlockDef {
|
if ops.OpType(blockOps.data[op.pc.data]) != ops.TypeBlockDef {
|
||||||
panic("invalid block reference")
|
panic("invalid block reference")
|
||||||
}
|
}
|
||||||
if op.version != op.ops.version {
|
if op.version != op.ops.version {
|
||||||
panic("invalid OpBlock reference to reset Ops")
|
panic("invalid BlockOp reference to reset Ops")
|
||||||
}
|
}
|
||||||
var opDef opBlockDef
|
var opDef opBlockDef
|
||||||
opDef.decode(blockOps.data[op.pc.data : op.pc.data+ops.TypeBlockDef.Size()])
|
opDef.decode(blockOps.data[op.pc.data : op.pc.data+ops.TypeBlockDef.Size()])
|
||||||
|
|||||||
+13
-13
@@ -23,14 +23,14 @@ type Event struct {
|
|||||||
Scroll f32.Point
|
Scroll f32.Point
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpArea struct {
|
type AreaOp struct {
|
||||||
Transparent bool
|
Transparent bool
|
||||||
|
|
||||||
kind areaKind
|
kind areaKind
|
||||||
size image.Point
|
size image.Point
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpHandler struct {
|
type HandlerOp struct {
|
||||||
Key Key
|
Key Key
|
||||||
Grab bool
|
Grab bool
|
||||||
}
|
}
|
||||||
@@ -75,21 +75,21 @@ const (
|
|||||||
areaEllipse
|
areaEllipse
|
||||||
)
|
)
|
||||||
|
|
||||||
func AreaRect(size image.Point) OpArea {
|
func AreaRect(size image.Point) AreaOp {
|
||||||
return OpArea{
|
return AreaOp{
|
||||||
kind: areaRect,
|
kind: areaRect,
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AreaEllipse(size image.Point) OpArea {
|
func AreaEllipse(size image.Point) AreaOp {
|
||||||
return OpArea{
|
return AreaOp{
|
||||||
kind: areaEllipse,
|
kind: areaEllipse,
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op OpArea) Add(o *ui.Ops) {
|
func (op AreaOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypeAreaLen)
|
data := make([]byte, ops.TypeAreaLen)
|
||||||
data[0] = byte(ops.TypeArea)
|
data[0] = byte(ops.TypeArea)
|
||||||
data[1] = byte(op.kind)
|
data[1] = byte(op.kind)
|
||||||
@@ -99,7 +99,7 @@ func (op OpArea) Add(o *ui.Ops) {
|
|||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *OpArea) Decode(d []byte) {
|
func (op *AreaOp) Decode(d []byte) {
|
||||||
if ops.OpType(d[0]) != ops.TypeArea {
|
if ops.OpType(d[0]) != ops.TypeArea {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
@@ -108,13 +108,13 @@ func (op *OpArea) Decode(d []byte) {
|
|||||||
X: int(bo.Uint32(d[2:])),
|
X: int(bo.Uint32(d[2:])),
|
||||||
Y: int(bo.Uint32(d[6:])),
|
Y: int(bo.Uint32(d[6:])),
|
||||||
}
|
}
|
||||||
*op = OpArea{
|
*op = AreaOp{
|
||||||
kind: areaKind(d[1]),
|
kind: areaKind(d[1]),
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *OpArea) Hit(pos f32.Point) HitResult {
|
func (op *AreaOp) Hit(pos f32.Point) HitResult {
|
||||||
res := HitOpaque
|
res := HitOpaque
|
||||||
if op.Transparent {
|
if op.Transparent {
|
||||||
res = HitTransparent
|
res = HitTransparent
|
||||||
@@ -144,7 +144,7 @@ func (op *OpArea) Hit(pos f32.Point) HitResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OpHandler) Add(o *ui.Ops) {
|
func (h HandlerOp) Add(o *ui.Ops) {
|
||||||
data := make([]byte, ops.TypePointerHandlerLen)
|
data := make([]byte, ops.TypePointerHandlerLen)
|
||||||
data[0] = byte(ops.TypePointerHandler)
|
data[0] = byte(ops.TypePointerHandler)
|
||||||
if h.Grab {
|
if h.Grab {
|
||||||
@@ -153,11 +153,11 @@ func (h OpHandler) Add(o *ui.Ops) {
|
|||||||
o.Write(data, h.Key)
|
o.Write(data, h.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *OpHandler) Decode(d []byte, refs []interface{}) {
|
func (h *HandlerOp) Decode(d []byte, refs []interface{}) {
|
||||||
if ops.OpType(d[0]) != ops.TypePointerHandler {
|
if ops.OpType(d[0]) != ops.TypePointerHandler {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
*h = OpHandler{
|
*h = HandlerOp{
|
||||||
Grab: d[1] != 0,
|
Grab: d[1] != 0,
|
||||||
Key: refs[0].(Key),
|
Key: refs[0].(Key),
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -180,7 +180,7 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
Min: image.Point{X: 0, Y: 0},
|
Min: image.Point{X: 0, Y: 0},
|
||||||
Max: image.Point{X: e.viewSize.X, Y: e.viewSize.Y},
|
Max: image.Point{X: e.viewSize.X, Y: e.viewSize.Y},
|
||||||
}
|
}
|
||||||
key.OpHandler{Key: e, Focus: e.requestFocus}.Add(ops)
|
key.HandlerOp{Key: e, Focus: e.requestFocus}.Add(ops)
|
||||||
e.requestFocus = false
|
e.requestFocus = false
|
||||||
e.it = lineIterator{
|
e.it = lineIterator{
|
||||||
Lines: lines,
|
Lines: lines,
|
||||||
@@ -194,11 +194,11 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
ui.OpPush{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.OpTransform{Transform: ui.Offset(lineOff)}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(lineOff)}.Add(ops)
|
||||||
e.Face.Path(str).Add(ops)
|
e.Face.Path(str).Add(ops)
|
||||||
draw.OpDraw{Rect: toRectF(clip).Sub(lineOff)}.Add(ops)
|
draw.DrawOp{Rect: toRectF(clip).Sub(lineOff)}.Add(ops)
|
||||||
ui.OpPop{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
}
|
}
|
||||||
if e.focused {
|
if e.focused {
|
||||||
now := e.Config.Now
|
now := e.Config.Now
|
||||||
@@ -221,11 +221,11 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
})
|
})
|
||||||
carRect = clip.Intersect(carRect)
|
carRect = clip.Intersect(carRect)
|
||||||
if !carRect.Empty() {
|
if !carRect.Empty() {
|
||||||
draw.OpDraw{Rect: toRectF(carRect)}.Add(ops)
|
draw.DrawOp{Rect: toRectF(carRect)}.Add(ops)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if blinking {
|
if blinking {
|
||||||
redraw := ui.OpRedraw{At: nextBlink}
|
redraw := ui.InvalidateOp{At: nextBlink}
|
||||||
redraw.Add(ops)
|
redraw.Add(ops)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -101,11 +101,11 @@ func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
lclip := toRectF(clip).Sub(off)
|
lclip := toRectF(clip).Sub(off)
|
||||||
ui.OpPush{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.OpTransform{Transform: ui.Offset(off)}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(off)}.Add(ops)
|
||||||
l.Face.Path(str).Add(ops)
|
l.Face.Path(str).Add(ops)
|
||||||
draw.OpDraw{Rect: lclip}.Add(ops)
|
draw.DrawOp{Rect: lclip}.Add(ops)
|
||||||
ui.OpPop{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
}
|
}
|
||||||
return dims
|
return dims
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ type Layout struct {
|
|||||||
|
|
||||||
type Face interface {
|
type Face interface {
|
||||||
Layout(str string, singleLine bool, maxWidth int) *Layout
|
Layout(str string, singleLine bool, maxWidth int) *Layout
|
||||||
Path(str String) ui.OpBlock
|
Path(str String) ui.BlockOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type Alignment uint8
|
type Alignment uint8
|
||||||
|
|||||||
@@ -46,18 +46,18 @@ func (c *Config) Val(v Value) float32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpLayer represents a semantic layer of UI.
|
// LayerOp represents a semantic layer of UI.
|
||||||
type OpLayer struct {
|
type LayerOp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpRedraw requests a redraw at the given time. Use
|
// InvalidateOp requests a redraw at the given time. Use
|
||||||
// the zero value to request an immediate redraw.
|
// the zero value to request an immediate redraw.
|
||||||
type OpRedraw struct {
|
type InvalidateOp struct {
|
||||||
At time.Time
|
At time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpTransform transforms an op.
|
// TransformOp transforms an op.
|
||||||
type OpTransform struct {
|
type TransformOp struct {
|
||||||
Transform Transform
|
Transform Transform
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ type Transform struct {
|
|||||||
offset f32.Point
|
offset f32.Point
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r OpRedraw) Add(o *Ops) {
|
func (r InvalidateOp) Add(o *Ops) {
|
||||||
data := make([]byte, ops.TypeRedrawLen)
|
data := make([]byte, ops.TypeRedrawLen)
|
||||||
data[0] = byte(ops.TypeRedraw)
|
data[0] = byte(ops.TypeInvalidate)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
// UnixNano cannot represent the zero time.
|
// UnixNano cannot represent the zero time.
|
||||||
if t := r.At; !t.IsZero() {
|
if t := r.At; !t.IsZero() {
|
||||||
@@ -80,9 +80,9 @@ func (r OpRedraw) Add(o *Ops) {
|
|||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OpRedraw) Decode(d []byte) {
|
func (r *InvalidateOp) Decode(d []byte) {
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
if ops.OpType(d[0]) != ops.TypeRedraw {
|
if ops.OpType(d[0]) != ops.TypeInvalidate {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
if nanos := bo.Uint64(d[1:]); nanos > 0 {
|
if nanos := bo.Uint64(d[1:]); nanos > 0 {
|
||||||
@@ -104,7 +104,7 @@ func (t Transform) Mul(t2 Transform) Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t OpTransform) Add(o *Ops) {
|
func (t TransformOp) Add(o *Ops) {
|
||||||
data := make([]byte, ops.TypeTransformLen)
|
data := make([]byte, ops.TypeTransformLen)
|
||||||
data[0] = byte(ops.TypeTransform)
|
data[0] = byte(ops.TypeTransform)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -113,12 +113,12 @@ func (t OpTransform) Add(o *Ops) {
|
|||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *OpTransform) Decode(d []byte) {
|
func (t *TransformOp) Decode(d []byte) {
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
if ops.OpType(d[0]) != ops.TypeTransform {
|
if ops.OpType(d[0]) != ops.TypeTransform {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
*t = OpTransform{
|
*t = TransformOp{
|
||||||
Transform: Offset(f32.Point{
|
Transform: Offset(f32.Point{
|
||||||
X: math.Float32frombits(bo.Uint32(d[1:])),
|
X: math.Float32frombits(bo.Uint32(d[1:])),
|
||||||
Y: math.Float32frombits(bo.Uint32(d[5:])),
|
Y: math.Float32frombits(bo.Uint32(d[5:])),
|
||||||
@@ -126,17 +126,17 @@ func (t *OpTransform) Decode(d []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l OpLayer) Add(o *Ops) {
|
func (l LayerOp) Add(o *Ops) {
|
||||||
data := make([]byte, ops.TypeLayerLen)
|
data := make([]byte, ops.TypeLayerLen)
|
||||||
data[0] = byte(ops.TypeLayer)
|
data[0] = byte(ops.TypeLayer)
|
||||||
o.Write(data)
|
o.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *OpLayer) Decode(d []byte) {
|
func (l *LayerOp) Decode(d []byte) {
|
||||||
if ops.OpType(d[0]) != ops.TypeLayer {
|
if ops.OpType(d[0]) != ops.TypeLayer {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
*l = OpLayer{}
|
*l = LayerOp{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Offset(o f32.Point) Transform {
|
func Offset(o f32.Point) Transform {
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ func (im Image) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
dr := f32.Rectangle{
|
dr := f32.Rectangle{
|
||||||
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
||||||
}
|
}
|
||||||
draw.OpImage{Img: im.Src, Rect: im.Rect}.Add(ops)
|
draw.ImageOp{Img: im.Src, Rect: im.Rect}.Add(ops)
|
||||||
draw.OpDraw{Rect: dr}.Add(ops)
|
draw.DrawOp{Rect: dr}.Add(ops)
|
||||||
return layout.Dimens{Size: d, Baseline: d.Y}
|
return layout.Dimens{Size: d, Baseline: d.Y}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user