ui: split OpImage into OpImage and OpDraw

In preparation for an OpColor (and future OpGradient and similar).

Label and Editor no longer take an explicit source image. They
draw with the current image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-01 12:43:33 +02:00
parent 29993af408
commit 0061c73a89
6 changed files with 78 additions and 49 deletions
+2 -4
View File
@@ -20,7 +20,6 @@ import (
)
type Editor struct {
Src image.Image
Face Face
Alignment Alignment
SingleLine bool
@@ -175,7 +174,7 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
ops.Begin()
ui.OpTransform{Transform: ui.Offset(lineOff)}.Add(ops)
draw.OpClip{Path: path}.Add(ops)
draw.OpImage{Rect: toRectF(clip).Sub(lineOff), Src: e.Src, SrcRect: e.Src.Bounds()}.Add(ops)
draw.OpDraw{Rect: toRectF(clip).Sub(lineOff)}.Add(ops)
ops.End().Add(ops)
}
if e.focused {
@@ -199,8 +198,7 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
})
carRect = clip.Intersect(carRect)
if !carRect.Empty() {
img := draw.OpImage{Src: e.Src, Rect: toRectF(carRect), SrcRect: e.Src.Bounds()}
img.Add(ops)
draw.OpDraw{Rect: toRectF(carRect)}.Add(ops)
}
}
if blinking {