From 48bfa054527df5292777f170c3fb95dd6f6488dd Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Sat, 22 Jun 2024 18:48:54 -0400 Subject: [PATCH] Color editing popups use swatch label for title --- internal/color.go | 2 -- labelswatch.go | 1 + swatch.go | 7 ++++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/color.go b/internal/color.go index e728cdf..5276c66 100644 --- a/internal/color.go +++ b/internal/color.go @@ -62,8 +62,6 @@ func RGBAToHSVA (r, g, b, a uint32) HSVA { // Adapted from: // https://www.cs.rit.edu/~ncs/color/t_convert.html - // FIXME: this does not always work! - component := func (x uint32) float64 { return clamp01(float64(x) / 0xFFFF) } diff --git a/labelswatch.go b/labelswatch.go index e882a65..10947cb 100644 --- a/labelswatch.go +++ b/labelswatch.go @@ -22,6 +22,7 @@ func NewLabelSwatch (value color.Color, text string) *LabelSwatch { label: NewLabel(text), } box.SetRole(tomo.R("objects", "LabelSwatch", "")) + box.swatch.label = text box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle) box.Add(box.swatch) box.Add(box.label) diff --git a/swatch.go b/swatch.go index ce7681b..8b87051 100644 --- a/swatch.go +++ b/swatch.go @@ -14,6 +14,7 @@ type Swatch struct { tomo.CanvasBox value color.Color editing bool + label string on struct { valueChange event.FuncBroadcaster } @@ -72,7 +73,11 @@ func (this *Swatch) Choose () { log.Println("objects: could not create swatch modal:", err) return } - window.SetTitle("Select Color") + if this.label == "" { + window.SetTitle("Select Color") + } else { + window.SetTitle(this.label) + } colorPicker := NewColorPicker(this.Value()) colorPicker.OnValueChange(func () {