-
Notifications
You must be signed in to change notification settings - Fork 0
/
overflow_auto.go
54 lines (47 loc) · 1.14 KB
/
overflow_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
func (e *Overflow) CalcDepth(stack *ElementStack) {
e.zIndex = stack.Add(e, e.closerThan)
for _, child := range e.Children() {
child.CalcDepth(stack)
}
}
func (e *Overflow) appendChild(children ...Element) Element {
for _, child := range children {
e.children = append(e.children, child)
child.RegisterParent(e)
}
return e
}
// must return Element in order to implement Container interface
func (e *Overflow) A(children ...Element) Element {
for _, child := range children {
e.children = append(e.children, child)
child.RegisterParent(e)
}
return e
}
func (e *Overflow) Size(w, h int) *Overflow {
e.width = w
e.height = h
e.Root.ForcePosDirty()
return e
}
func (e *Overflow) H(h int) *Overflow {
e.height = h
e.Root.ForcePosDirty()
return e
}
func (e *Overflow) W(w int) *Overflow {
e.width = w
e.Root.ForcePosDirty()
return e
}
func (e *Overflow) On(name string, fn EventListener) *Overflow {
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
}