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