mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
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:
+2
-2
@@ -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
|
||||
|
||||
+2
-2
@@ -102,11 +102,11 @@ func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
||||
}
|
||||
path := l.Face.Path(str)
|
||||
lclip := toRectF(clip).Sub(off)
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
ui.OpTransform{Transform: ui.Offset(off)}.Add(ops)
|
||||
draw.OpClip{Path: path}.Add(ops)
|
||||
draw.OpDraw{Rect: lclip}.Add(ops)
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.Add(ops)
|
||||
}
|
||||
return dims
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user