-
Notifications
You must be signed in to change notification settings - Fork 0
/
ver_auto.go
50 lines (45 loc) · 1013 Bytes
/
ver_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
package glui
// must return Element in order to implement Container interface
func (e *Ver) A(children ...Element) Element {
for _, child := range children {
e.children = append(e.children, child)
child.RegisterParent(e)
}
return e
}
func (e *Ver) CalcDepth(stack *ElementStack) {
e.zIndex = stack.Add(e, e.closerThan)
for _, child := range e.Children() {
child.CalcDepth(stack)
}
}
func (e *Ver) Padding(p ...int) *Ver {
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 *Ver) Spacing(s int) *Ver {
e.spacing = s
e.Root.ForcePosDirty()
return e
}
func (e *Ver) W(w int) *Ver {
e.width = w
e.Root.ForcePosDirty()
return e
}