ui: make OpPush and OpPop explicit

We're about to allow OpBlock for invoking ops from multiple (cached)
Ops containers. To allow for drawing state changes to stick after
invoking such a cached block, we can't let OpBlock perform an implicit
save and restore of drawing state.

Instead, introduce OpPush and OpPop for explicit drawing state stack
management.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-02 15:10:09 +02:00
parent bf5d083b8a
commit 9142345fd4
7 changed files with 28 additions and 20 deletions
+2 -2
View File
@@ -171,11 +171,11 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
break
}
path := e.Face.Path(str)
ops.Begin()
ui.OpPush{}.Add(ops)
ui.OpTransform{Transform: ui.Offset(lineOff)}.Add(ops)
draw.OpClip{Path: path}.Add(ops)
draw.OpDraw{Rect: toRectF(clip).Sub(lineOff)}.Add(ops)
ops.End().Add(ops)
ui.OpPop{}.Add(ops)
}
if e.focused {
now := e.cfg.Now