Color editing popups use swatch label for title
This commit is contained in:
parent
e8a3a376ea
commit
48bfa05452
@ -62,8 +62,6 @@ func RGBAToHSVA (r, g, b, a uint32) HSVA {
|
|||||||
// Adapted from:
|
// Adapted from:
|
||||||
// https://www.cs.rit.edu/~ncs/color/t_convert.html
|
// https://www.cs.rit.edu/~ncs/color/t_convert.html
|
||||||
|
|
||||||
// FIXME: this does not always work!
|
|
||||||
|
|
||||||
component := func (x uint32) float64 {
|
component := func (x uint32) float64 {
|
||||||
return clamp01(float64(x) / 0xFFFF)
|
return clamp01(float64(x) / 0xFFFF)
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ func NewLabelSwatch (value color.Color, text string) *LabelSwatch {
|
|||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "LabelSwatch", ""))
|
box.SetRole(tomo.R("objects", "LabelSwatch", ""))
|
||||||
|
box.swatch.label = text
|
||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.Add(box.swatch)
|
box.Add(box.swatch)
|
||||||
box.Add(box.label)
|
box.Add(box.label)
|
||||||
|
@ -14,6 +14,7 @@ type Swatch struct {
|
|||||||
tomo.CanvasBox
|
tomo.CanvasBox
|
||||||
value color.Color
|
value color.Color
|
||||||
editing bool
|
editing bool
|
||||||
|
label string
|
||||||
on struct {
|
on struct {
|
||||||
valueChange event.FuncBroadcaster
|
valueChange event.FuncBroadcaster
|
||||||
}
|
}
|
||||||
@ -72,7 +73,11 @@ func (this *Swatch) Choose () {
|
|||||||
log.Println("objects: could not create swatch modal:", err)
|
log.Println("objects: could not create swatch modal:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
window.SetTitle("Select Color")
|
if this.label == "" {
|
||||||
|
window.SetTitle("Select Color")
|
||||||
|
} else {
|
||||||
|
window.SetTitle(this.label)
|
||||||
|
}
|
||||||
|
|
||||||
colorPicker := NewColorPicker(this.Value())
|
colorPicker := NewColorPicker(this.Value())
|
||||||
colorPicker.OnValueChange(func () {
|
colorPicker.OnValueChange(func () {
|
||||||
|
Loading…
Reference in New Issue
Block a user