-
Notifications
You must be signed in to change notification settings - Fork 0
/
vsplit_auto.go
54 lines (49 loc) · 1.18 KB
/
vsplit_auto.go
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
package glui
// must return Element in order to implement Container interface
func (e *VSplit) A(children ...Element) Element {
for _, child := range children {
e.children = append(e.children, child)
child.RegisterParent(e)
}
return e
}
func (e *VSplit) CalcDepth(stack *ElementStack) {
e.zIndex = stack.Add(e, e.closerThan)
for _, child := range e.Children() {
child.CalcDepth(stack)
}
}
func (e *VSplit) Spacing(s int) *VSplit {
e.spacing = s
e.Root.ForcePosDirty()
return e
}
func (e *VSplit) Padding(p ...int) *VSplit {
switch len(p) {
case 1:
e.padding = [4]int{p[0], p[0], p[0], p[0]}
break
case 2:
e.padding = [4]int{p[0], p[1], p[0], p[1]}
break
case 3:
e.padding = [4]int{p[0], p[1], p[0], p[2]}
break
case 4:
e.padding = [4]int{p[0], p[1], p[2], p[3]}
break
default:
panic("unexpected number of padding elements")
}
e.Root.ForcePosDirty()
return e
}
func (e *VSplit) On(name string, fn EventListener) *VSplit {
old := e.evtListeners[name]
if old == nil {
e.evtListeners[name] = fn
} else {
e.evtListeners[name] = func(evt *Event) {fn(evt); if !evt.stopPropagation {old(evt)}}
}
return e
}