1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  | 
/*
A Labeled label:
-----------------------------
|            |              |
|   Food:    |    Apple     |
|            |              |
-----------------------------
*/
package gadgets
import (
	"go.wit.com/gui"
	"go.wit.com/log"
)
type OneLiner struct {
	p *gui.Node // parent widget
	l *gui.Node // label widget
	v *gui.Node // value widget
	Custom func()
}
func (n *OneLiner) String() string {
	return n.v.String()
}
// 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)
}
func (n *OneLiner) SetText(s string) *OneLiner {
	log.Log(GADGETS, "OneLiner.Set() =", s)
	n.v.SetLabel(s)
	return n
}
func (n *OneLiner) SetValue(s string) *OneLiner {
	log.Log(GADGETS, "OneLiner.Set() =", s)
	n.v.SetLabel(s)
	return n
}
func (n *OneLiner) SetLabel(value string) *OneLiner {
	log.Log(GADGETS, "OneLiner.SetLabel() =", value)
	n.l.SetLabel(value)
	return n
}
func (n *OneLiner) Enable() {
	log.Log(GADGETS, "OneLiner.Enable()")
	n.v.Show()
}
func (n *OneLiner) Disable() {
	log.Log(GADGETS, "OneLiner.Disable()")
	n.v.Hide()
}
func (n *OneLiner) Show() {
	log.Log(GADGETS, "OneLiner.Disable()")
	n.l.Show()
	n.v.Show()
}
func (n *OneLiner) Hide() {
	log.Log(GADGETS, "OneLiner.Disable()")
	n.l.Hide()
	n.v.Hide()
}
func NewOneLiner(n *gui.Node, label string) *OneLiner {
	d := OneLiner{
		p: n,
	}
	// various timeout settings
	d.l = n.NewLabel(label)
	d.v = n.NewLabel("")
	d.v.Custom = func() {
		log.Log(GADGETS, "OneLiner.Custom() user changed value to =", d.v.String())
	}
	return &d
}
  |