HSVAColorPicker no longer embeds tomo.ContainerBox
This commit is contained in:
parent
fc51e7ab9f
commit
0c4e098680
@ -8,10 +8,12 @@ import "git.tebibyte.media/tomo/tomo/canvas"
|
|||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
import "git.tebibyte.media/tomo/objects/internal"
|
import "git.tebibyte.media/tomo/objects/internal"
|
||||||
|
|
||||||
|
var _ tomo.Object = new(HSVAColorPicker)
|
||||||
|
|
||||||
// HSVAColorPicker allows the user to pick a color by controlling its HSVA
|
// HSVAColorPicker allows the user to pick a color by controlling its HSVA
|
||||||
// parameters.
|
// parameters.
|
||||||
type HSVAColorPicker struct {
|
type HSVAColorPicker struct {
|
||||||
tomo.ContainerBox
|
box tomo.ContainerBox
|
||||||
value internal.HSVA
|
value internal.HSVA
|
||||||
|
|
||||||
pickerMap *hsvaColorPickerMap
|
pickerMap *hsvaColorPickerMap
|
||||||
@ -26,15 +28,15 @@ type HSVAColorPicker struct {
|
|||||||
// NewHSVAColorPicker creates a new color picker with the specified color.
|
// NewHSVAColorPicker creates a new color picker with the specified color.
|
||||||
func NewHSVAColorPicker (value color.Color) *HSVAColorPicker {
|
func NewHSVAColorPicker (value color.Color) *HSVAColorPicker {
|
||||||
picker := &HSVAColorPicker {
|
picker := &HSVAColorPicker {
|
||||||
ContainerBox: tomo.NewContainerBox(),
|
box: tomo.NewContainerBox(),
|
||||||
}
|
}
|
||||||
picker.SetRole(tomo.R("objects", "ColorPicker"))
|
picker.box.SetRole(tomo.R("objects", "ColorPicker"))
|
||||||
picker.SetAttr(tomo.ALayout(layouts.Row { true, false, false }))
|
picker.box.SetAttr(tomo.ALayout(layouts.Row { true, false, false }))
|
||||||
picker.pickerMap = newHsvaColorPickerMap(picker)
|
picker.pickerMap = newHsvaColorPickerMap(picker)
|
||||||
picker.Add(picker.pickerMap)
|
picker.box.Add(picker.pickerMap)
|
||||||
|
|
||||||
picker.hueSlider = NewVerticalSlider(0.0)
|
picker.hueSlider = NewVerticalSlider(0.0)
|
||||||
picker.Add(picker.hueSlider)
|
picker.box.Add(picker.hueSlider)
|
||||||
picker.hueSlider.OnValueChange(func () {
|
picker.hueSlider.OnValueChange(func () {
|
||||||
picker.value.H = picker.hueSlider.Value()
|
picker.value.H = picker.hueSlider.Value()
|
||||||
picker.on.valueChange.Broadcast()
|
picker.on.valueChange.Broadcast()
|
||||||
@ -42,7 +44,7 @@ func NewHSVAColorPicker (value color.Color) *HSVAColorPicker {
|
|||||||
})
|
})
|
||||||
|
|
||||||
picker.alphaSlider = NewVerticalSlider(0.0)
|
picker.alphaSlider = NewVerticalSlider(0.0)
|
||||||
picker.Add(picker.alphaSlider)
|
picker.box.Add(picker.alphaSlider)
|
||||||
picker.alphaSlider.OnValueChange(func () {
|
picker.alphaSlider.OnValueChange(func () {
|
||||||
picker.value.A = uint16(picker.alphaSlider.Value() * 0xFFFF)
|
picker.value.A = uint16(picker.alphaSlider.Value() * 0xFFFF)
|
||||||
picker.on.valueChange.Broadcast()
|
picker.on.valueChange.Broadcast()
|
||||||
@ -54,6 +56,18 @@ func NewHSVAColorPicker (value color.Color) *HSVAColorPicker {
|
|||||||
return picker
|
return picker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBox returns the underlying box.
|
||||||
|
func (this *HSVAColorPicker) GetBox () tomo.Box {
|
||||||
|
return this.box
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetFocused sets whether or not this color picker has keyboard focus. If set
|
||||||
|
// to true, this method will steal focus away from whichever object currently
|
||||||
|
// has focus.
|
||||||
|
func (this *HSVAColorPicker) SetFocused (focused bool) {
|
||||||
|
this.box.SetFocused(focused)
|
||||||
|
}
|
||||||
|
|
||||||
// Value returns the color of the picker.
|
// Value returns the color of the picker.
|
||||||
func (this *HSVAColorPicker) Value () color.Color {
|
func (this *HSVAColorPicker) Value () color.Color {
|
||||||
return this.value
|
return this.value
|
||||||
|
Loading…
Reference in New Issue
Block a user