Make value getters/setters more consistent

See #6
This commit is contained in:
2024-06-27 14:01:14 -04:00
parent d0ee6c432c
commit 638fc61d83
11 changed files with 128 additions and 105 deletions

View File

@@ -36,6 +36,11 @@ func NewSwatch (value color.Color) *Swatch {
return swatch
}
// Value returns the color of the swatch.
func (this *Swatch) Value () color.Color {
return this.value
}
// SetValue sets the color of the swatch.
func (this *Swatch) SetValue (value color.Color) {
this.value = value
@@ -43,9 +48,10 @@ func (this *Swatch) SetValue (value color.Color) {
this.Invalidate()
}
// Value returns the color of the swatch.
func (this *Swatch) Value () color.Color {
return this.value
// OnValueChange specifies a function to be called when the swatch's color
// is changed by the user.
func (this *Swatch) OnValueChange (callback func ()) event.Cookie {
return this.on.valueChange.Connect(callback)
}
// RGBA satisfies the color.Color interface
@@ -54,12 +60,6 @@ func (this *Swatch) RGBA () (r, g, b, a uint32) {
return this.value.RGBA()
}
// OnValueChange specifies a function to be called when the swatch's color
// is changed by the user.
func (this *Swatch) OnValueChange (callback func ()) event.Cookie {
return this.on.valueChange.Connect(callback)
}
// OnEnter specifies a function to be called when the user selects "OK" in the
// color picker.
func (this *Swatch) OnEnter (callback func ()) event.Cookie {