blob: a89b1860c0879c3faf831499575a6b235f2dd66c (
plain)
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
|
package gui
// an experiemental idea
import (
"go.wit.com/log"
"go.wit.com/widget"
)
// an experiemental idea
// basically, this is like a cell in a spreadsheet that is viable
// in one place but also exists sonewhere else
func (parent *Node) Mirror(m *Node) *Node {
switch m.WidgetType {
case widget.Label:
text := m.label
newNode := parent.newNode(text, widget.Label)
newNode.label = text
newNode.progname = text
newNode.isMirror = m
m.hasMirrors = append(m.hasMirrors, newNode)
// inform the toolkits
sendAction(newNode, widget.Add)
return newNode
default:
return nil
}
}
// make a mirror widget without a parent
func RawMirror(m *Node) *Node {
switch m.WidgetType {
case widget.Label:
newNode := rawNode("MIRROR", widget.Label)
newNode.isMirror = m
m.hasMirrors = append(m.hasMirrors, newNode)
return newNode
default:
return nil
}
}
func (n *Node) IsMirror() bool {
if n.isMirror == nil {
return false
}
return true
}
func (n *Node) hasMirror() bool {
if len(n.hasMirrors) == 0 {
return false
}
return true
}
func (n *Node) updateMirrors() {
if n.IsMirror() {
// n is a mirror of something else
return
}
for _, m := range n.hasMirrors {
switch m.WidgetType {
case widget.Label:
m.label = n.label
m.changed = true
// inform the toolkits
sendAction(m, widget.SetText)
default:
log.Log(WARN, "can not mirror widget type", m.WidgetType)
}
}
}
|