Add ColorOpt to giowrap.Label.
This commit is contained in:
parent
014ace99a6
commit
62d0ceef66
8
main.go
8
main.go
|
@ -86,11 +86,13 @@ func Align(x text.Alignment) AlignOpt { return AlignOpt { x } }
|
||||||
|
|
||||||
type LabelOpts struct {
|
type LabelOpts struct {
|
||||||
FaceOpt
|
FaceOpt
|
||||||
|
c *color.RGBA
|
||||||
AlignOpt
|
AlignOpt
|
||||||
}
|
}
|
||||||
type LabelOption interface { DoLabelOption(*LabelOpts) }
|
type LabelOption interface { DoLabelOption(*LabelOpts) }
|
||||||
func (x FaceOpt) DoLabelOption(o *LabelOpts) { o.face = x.face }
|
func (x FaceOpt) DoLabelOption(o *LabelOpts) { o.face = x.face }
|
||||||
func (x AlignOpt) DoLabelOption(o *LabelOpts) { o.alignment = x.alignment }
|
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 {
|
func NewLabel(t string, lops ...LabelOption) *Label {
|
||||||
ret := &Label{}
|
ret := &Label{}
|
||||||
|
@ -101,6 +103,12 @@ func NewLabel(t string, lops ...LabelOption) *Label {
|
||||||
Text: t,
|
Text: t,
|
||||||
Alignment: opts.alignment,
|
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
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user