mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
ui/text: use default colors to guard against empty materials
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -4,6 +4,7 @@ package text
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"image/color"
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@@ -203,9 +204,12 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
Offset: off,
|
Offset: off,
|
||||||
}
|
}
|
||||||
ui.PushOp{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
|
// Apply material. Set a default color in case the material is empty.
|
||||||
if e.rr.len() > 0 {
|
if e.rr.len() > 0 {
|
||||||
|
draw.ColorOp{Col: color.RGBA{A: 0xff}}.Add(ops)
|
||||||
e.Material.Add(ops)
|
e.Material.Add(ops)
|
||||||
} else {
|
} else {
|
||||||
|
draw.ColorOp{Col: color.RGBA{A: 0xaa}}.Add(ops)
|
||||||
e.HintMaterial.Add(ops)
|
e.HintMaterial.Add(ops)
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package text
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"image/color"
|
||||||
"math"
|
"math"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
@@ -109,6 +110,8 @@ func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
|||||||
ui.PushOp{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.TransformOp{Transform: ui.Offset(off)}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(off)}.Add(ops)
|
||||||
l.Face.Path(str).Add(ops)
|
l.Face.Path(str).Add(ops)
|
||||||
|
// Set a default color in case the material is empty.
|
||||||
|
draw.ColorOp{Col: color.RGBA{A: 0xff}}.Add(ops)
|
||||||
l.Material.Add(ops)
|
l.Material.Add(ops)
|
||||||
draw.DrawOp{Rect: lclip}.Add(ops)
|
draw.DrawOp{Rect: lclip}.Add(ops)
|
||||||
ui.PopOp{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
|
|||||||
Reference in New Issue
Block a user