2024-01-01 16:19:40 -06:00
|
|
|
/*
|
2024-01-18 05:04:18 -06:00
|
|
|
A Labeled label:
|
2024-01-01 16:19:40 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
-----------------------------
|
|
|
|
| | |
|
|
|
|
| Food: | Apple |
|
|
|
|
| | |
|
|
|
|
-----------------------------
|
2024-01-01 16:19:40 -06:00
|
|
|
*/
|
|
|
|
package gadgets
|
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/gui"
|
2024-01-01 16:19:40 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type OneLiner struct {
|
2024-01-18 05:04:18 -06:00
|
|
|
p *gui.Node // parent widget
|
|
|
|
l *gui.Node // label widget
|
|
|
|
v *gui.Node // value widget
|
2024-01-01 16:19:40 -06:00
|
|
|
|
|
|
|
Custom func()
|
|
|
|
}
|
|
|
|
|
2024-01-17 21:46:50 -06:00
|
|
|
func (n *OneLiner) String() string {
|
|
|
|
return n.v.String()
|
2024-01-01 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
2024-02-19 14:42:06 -06:00
|
|
|
// returns a widget of the last tag that acts as a mirror
|
|
|
|
func (n *OneLiner) MirrorLabel() *gui.Node {
|
|
|
|
return gui.RawMirror(n.l)
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns a widget of the last tag that acts as a mirror
|
|
|
|
func (n *OneLiner) MirrorValue() *gui.Node {
|
|
|
|
return gui.RawMirror(n.v)
|
|
|
|
}
|
|
|
|
|
2024-01-26 11:11:47 -06:00
|
|
|
func (n *OneLiner) SetText(s string) *OneLiner {
|
2024-01-31 14:02:20 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.Set() =", s)
|
|
|
|
n.v.SetLabel(s)
|
2024-01-26 11:11:47 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-19 12:37:32 -06:00
|
|
|
func (n *OneLiner) SetValue(s string) *OneLiner {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.Set() =", s)
|
2024-01-19 12:21:04 -06:00
|
|
|
n.v.SetLabel(s)
|
2024-01-01 16:19:40 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:04:51 -06:00
|
|
|
func (n *OneLiner) SetLabel(value string) *OneLiner {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.SetLabel() =", value)
|
2024-01-19 17:16:51 -06:00
|
|
|
n.l.SetLabel(value)
|
2024-01-10 20:04:51 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *OneLiner) Enable() {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.Enable()")
|
2024-01-19 17:16:51 -06:00
|
|
|
n.v.Show()
|
2024-01-10 20:04:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (n *OneLiner) Disable() {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.Disable()")
|
2024-01-19 17:16:51 -06:00
|
|
|
n.v.Hide()
|
2024-01-10 20:04:51 -06:00
|
|
|
}
|
|
|
|
|
2024-02-13 16:17:08 -06:00
|
|
|
func (n *OneLiner) Show() {
|
|
|
|
log.Log(GADGETS, "OneLiner.Disable()")
|
|
|
|
n.l.Show()
|
|
|
|
n.v.Show()
|
|
|
|
}
|
|
|
|
|
2024-01-23 03:18:07 -06:00
|
|
|
func (n *OneLiner) Hide() {
|
|
|
|
log.Log(GADGETS, "OneLiner.Disable()")
|
|
|
|
n.l.Hide()
|
|
|
|
n.v.Hide()
|
|
|
|
}
|
|
|
|
|
2024-01-17 21:46:50 -06:00
|
|
|
func NewOneLiner(n *gui.Node, label string) *OneLiner {
|
2024-01-18 05:04:18 -06:00
|
|
|
d := OneLiner{
|
2024-01-01 16:19:40 -06:00
|
|
|
p: n,
|
|
|
|
}
|
|
|
|
|
|
|
|
// various timeout settings
|
2024-01-17 21:46:50 -06:00
|
|
|
d.l = n.NewLabel(label)
|
2024-01-01 16:19:40 -06:00
|
|
|
d.v = n.NewLabel("")
|
|
|
|
d.v.Custom = func() {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "OneLiner.Custom() user changed value to =", d.v.String())
|
2024-01-01 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &d
|
|
|
|
}
|