Compare commits
No commits in common. "6f8d5cc426e1999e2050b27d203b427b7283c87f" and "6ee2c5669e7911936464ba1897fd9b4689f10535" have entirely different histories.
6f8d5cc426
...
6ee2c5669e
@ -47,11 +47,6 @@ func (this *LabelCheckbox) SetFocused (focused bool) {
|
|||||||
this.checkbox.SetFocused(focused)
|
this.checkbox.SetFocused(focused)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetText sets the text label of the checkbox.
|
|
||||||
func (this *LabelCheckbox) SetText (text string) {
|
|
||||||
this.label.SetText(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value returns the value of the checkbox.
|
// Value returns the value of the checkbox.
|
||||||
func (this *LabelCheckbox) Value () bool {
|
func (this *LabelCheckbox) Value () bool {
|
||||||
return this.checkbox.Value()
|
return this.checkbox.Value()
|
||||||
|
@ -6,52 +6,33 @@ import "git.tebibyte.media/tomo/tomo/input"
|
|||||||
import "git.tebibyte.media/tomo/tomo/event"
|
import "git.tebibyte.media/tomo/tomo/event"
|
||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
|
|
||||||
var _ tomo.Object = new(LabelSwatch)
|
|
||||||
|
|
||||||
// LabelSwatch is a swatch with a label.
|
// LabelSwatch is a swatch with a label.
|
||||||
type LabelSwatch struct {
|
type LabelSwatch struct {
|
||||||
box tomo.ContainerBox
|
tomo.ContainerBox
|
||||||
swatch *Swatch
|
swatch *Swatch
|
||||||
label *Label
|
label *Label
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLabelSwatch creates a new labeled swatch with the specified color and
|
// NewLabelSwatch creates a new labeled swatch with the specified color and
|
||||||
// label text.
|
// label text.
|
||||||
func NewLabelSwatch (value color.Color, text string) *LabelSwatch {
|
func NewLabelSwatch (value color.Color, text string) *LabelSwatch {
|
||||||
labelSwatch := &LabelSwatch {
|
box := &LabelSwatch {
|
||||||
box: tomo.NewContainerBox(),
|
ContainerBox: tomo.NewContainerBox(),
|
||||||
swatch: NewSwatch(value),
|
swatch: NewSwatch(value),
|
||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
labelSwatch.box.SetRole(tomo.R("objects", "LabelSwatch"))
|
box.SetRole(tomo.R("objects", "LabelSwatch"))
|
||||||
labelSwatch.swatch.label = text
|
box.swatch.label = text
|
||||||
labelSwatch.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
labelSwatch.label.GetBox().(tomo.TextBox).SetSelectable(false)
|
box.label.GetBox().(tomo.TextBox).SetSelectable(false)
|
||||||
labelSwatch.label.GetBox().(tomo.TextBox).SetFocusable(false)
|
box.label.GetBox().(tomo.TextBox).SetFocusable(false)
|
||||||
labelSwatch.box.Add(labelSwatch.swatch)
|
box.Add(box.swatch)
|
||||||
labelSwatch.box.Add(labelSwatch.label)
|
box.Add(box.label)
|
||||||
labelSwatch.box.SetAttr(tomo.ALayout(layouts.Row { false, true }))
|
box.SetAttr(tomo.ALayout(layouts.Row { false, true }))
|
||||||
|
|
||||||
labelSwatch.box.OnButtonDown(labelSwatch.handleButtonDown)
|
box.OnButtonDown(box.handleButtonDown)
|
||||||
labelSwatch.box.OnButtonUp(labelSwatch.handleButtonUp)
|
box.OnButtonUp(box.handleButtonUp)
|
||||||
return labelSwatch
|
return box
|
||||||
}
|
|
||||||
|
|
||||||
// GetBox returns the underlying box.
|
|
||||||
func (this *LabelSwatch) GetBox () tomo.Box {
|
|
||||||
return this.box
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetFocused sets whether or not this swatch has keyboard focus. If set to
|
|
||||||
// true, this method will steal focus away from whichever object currently has
|
|
||||||
// focus.
|
|
||||||
func (this *LabelSwatch) SetFocused (focused bool) {
|
|
||||||
this.swatch.SetFocused(focused)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetText sets the text label of the swatch.
|
|
||||||
func (this *LabelSwatch) SetText (text string) {
|
|
||||||
this.label.SetText(text)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value returns the color of the swatch.
|
// Value returns the color of the swatch.
|
||||||
@ -88,7 +69,7 @@ func (this *LabelSwatch) handleButtonDown (button input.Button) bool {
|
|||||||
|
|
||||||
func (this *LabelSwatch) handleButtonUp (button input.Button) bool {
|
func (this *LabelSwatch) handleButtonUp (button input.Button) bool {
|
||||||
if !isClickingButton(button) { return true }
|
if !isClickingButton(button) { return true }
|
||||||
if this.box.Window().MousePosition().In(this.box.Bounds()) {
|
if this.Window().MousePosition().In(this.Bounds()) {
|
||||||
this.swatch.SetFocused(true)
|
this.swatch.SetFocused(true)
|
||||||
this.swatch.Choose()
|
this.swatch.Choose()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user