forked from joejulian/gio
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
@@ -157,12 +157,12 @@ func (f *Flex) Layout(ops *ui.Ops, children ...FlexChild) Dimens {
|
||||
cross = f.maxBaseline - b
|
||||
}
|
||||
}
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
ui.OpTransform{
|
||||
Transform: ui.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))),
|
||||
}.Add(ops)
|
||||
child.block.Add(ops)
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.Add(ops)
|
||||
mainSize += axisMain(f.Axis, dims.Size)
|
||||
switch f.MainAxisAlignment {
|
||||
case SpaceEvenly:
|
||||
|
||||
+4
-4
@@ -97,13 +97,13 @@ func (in *Insets) Begin(ops *ui.Ops, cs Constraints) Constraints {
|
||||
mcs.Height.Max = mcs.Height.Min
|
||||
}
|
||||
}
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
ui.OpTransform{Transform: ui.Offset(toPointF(image.Point{X: l, Y: t}))}.Add(ops)
|
||||
return mcs
|
||||
}
|
||||
|
||||
func (in *Insets) End(ops *ui.Ops, dims Dimens) Dimens {
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.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)))
|
||||
return Dimens{
|
||||
Size: in.cs.Constrain(dims.Size.Add(image.Point{X: r + l, Y: t + b})),
|
||||
@@ -176,10 +176,10 @@ func (a *Align) End(ops *ui.Ops, dims Dimens) Dimens {
|
||||
case SW, S, SE:
|
||||
p.Y = sz.Y - dims.Size.Y
|
||||
}
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
ui.OpTransform{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
||||
block.Add(ops)
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.Add(ops)
|
||||
return Dimens{
|
||||
Size: sz,
|
||||
Baseline: dims.Baseline,
|
||||
|
||||
+2
-2
@@ -178,13 +178,13 @@ func (l *List) Layout(ops *ui.Ops) Dimens {
|
||||
Min: axisPoint(l.Axis, min, -ui.Inf),
|
||||
Max: axisPoint(l.Axis, max, ui.Inf),
|
||||
}
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
draw.OpClip{Path: draw.RectPath(r)}.Add(ops)
|
||||
ui.OpTransform{
|
||||
Transform: ui.Offset(toPointF(axisPoint(l.Axis, pos, cross))),
|
||||
}.Add(ops)
|
||||
child.block.Add(ops)
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.Add(ops)
|
||||
pos += axisMain(l.Axis, sz)
|
||||
}
|
||||
atStart := l.first == 0 && l.offset <= 0
|
||||
|
||||
+2
-2
@@ -101,10 +101,10 @@ func (s *Stack) Layout(ops *ui.Ops, children ...StackChild) Dimens {
|
||||
case SW, S, SE:
|
||||
p.Y = s.maxSZ.Y - sz.Y
|
||||
}
|
||||
ops.Begin()
|
||||
ui.OpPush{}.Add(ops)
|
||||
ui.OpTransform{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
||||
ch.block.Add(ops)
|
||||
ops.End().Add(ops)
|
||||
ui.OpPop{}.Add(ops)
|
||||
}
|
||||
b := s.baseline
|
||||
if b == 0 {
|
||||
|
||||
Reference in New Issue
Block a user