From 62d0ceef660dc2f2f913f58878c16a477d21d3a4 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 22 Aug 2019 18:15:14 -0400 Subject: [PATCH] Add ColorOpt to giowrap.Label. --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index d3269c2..61574d6 100644 --- a/main.go +++ b/main.go @@ -86,11 +86,13 @@ func Align(x text.Alignment) AlignOpt { return AlignOpt { x } } type LabelOpts struct { FaceOpt + c *color.RGBA AlignOpt } type LabelOption interface { DoLabelOption(*LabelOpts) } func (x FaceOpt) DoLabelOption(o *LabelOpts) { o.face = x.face } func (x AlignOpt) DoLabelOption(o *LabelOpts) { o.alignment = x.alignment } +func (x ColorOpt) DoLabelOption(o *LabelOpts) { o.c = &x.c; } func NewLabel(t string, lops ...LabelOption) *Label { ret := &Label{} @@ -101,6 +103,12 @@ func NewLabel(t string, lops ...LabelOption) *Label { Text: t, Alignment: opts.alignment, } + if opts.c != nil { // got a color option... + ops := new(ui.Ops) + ret.l.Material.Record(ops) + paint.ColorOp{Color: *opts.c}.Add(ops) + ret.l.Material.Stop() + } return ret }