ui: replace PushOp, PopOp with a StackOp

Before this change, there was no guarantee that a PopOp matched
the intended PushOp. With a single stack operation, the client is
forced to match pop with the right push.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-16 13:41:10 +02:00
parent f9fda47d25
commit 586d33c26e
7 changed files with 50 additions and 25 deletions
+3 -2
View File
@@ -107,14 +107,15 @@ func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
break
}
lclip := toRectF(clip).Sub(off)
ui.PushOp{}.Add(ops)
var stack ui.StackOp
stack.Push(ops)
ui.TransformOp{Transform: ui.Offset(off)}.Add(ops)
l.Face.Path(str).Add(ops)
// Set a default color in case the material is empty.
draw.ColorOp{Color: color.RGBA{A: 0xff}}.Add(ops)
l.Material.Add(ops)
draw.DrawOp{Rect: lclip}.Add(ops)
ui.PopOp{}.Add(ops)
stack.Pop()
}
return dims
}