-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement.go
More file actions
59 lines (43 loc) · 2.11 KB
/
element.go
File metadata and controls
59 lines (43 loc) · 2.11 KB
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
package glui
type Element interface {
RegisterParent(parent Element) // implemented by ElementData
Parent() Element // implemented by ElementData
Children() []Element // implemented by ElementData
Cursor(x, y int) int // defaults to -1 (which in turn defaults to system default, or cursor of parent element)
Tooltip() string // defaults to empty string
CalcDepth(stack *ElementStack) // auto generated by gen_element
// returns actual width and height used
// maxZIndex is used to normalize Z
CalcPos(maxWidth, maxHeight, maxZIndex int) (int, int) // ***must be implemented by custom Element***
Animate(tick uint64) // defaults to passing Animate to children
Rect() Rect // implemented by ElementData, needed for focusrect and menu anchors
ZIndex() int // implemented by ElementData
Hit(x, y int) int // return -1 if no hit, otherwise returns zIndex, implemented by ElementData
Translate(dx, dy int) // implemented by ElementData
Visible() bool // implemented by ElementData
Hide() // implemented by ElementData
Show() // default implemented by ElementData simply shows children and sets visible to true
Enable() // implemented by ElementData
Disable() // implemented by ElementData
GetEventListener(name string) EventListener // returns nil if no EventListener specified, implemented by ElementData
Delete() // deallocs all owned tris, implemented by ElementData
Deleted() bool // implemented by ElementData
IsFocusable() bool // implemented by ElementData in general case (i.e. hasEvent(e, "focus) && e.Visible())
Crop(r Rect)
}
type Container interface {
Element
A(children ...Element) Container
Padding(p ...int) Container
Spacing(s int) Container
ClearChildren()
}
// other utility methods often implemented by Elements, but not part of interface
// * InitRect(w, h int) (w, h)
// * A(children ...Element) Element
// * Size(w, h int) Element
// * GetSize() (int, int) // implement by ElementData
// * Padding(p ...int) Element
// * Spacing(s int) Element
// * On(name string, fn EventListener) Element
// * ClearChildren()