-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.go
69 lines (51 loc) · 1.18 KB
/
image.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package glui
import (
)
//go:generate ./gen_element Image "CalcDepth"
type Image struct {
ElementData
img *ImageData
}
func NewImage(img *ImageData) *Image {
e := &Image{
NewElementData(2, 0),
img,
}
if img != nil {
e.width = img.W
e.height = img.H
e.Root.P1.SetQuadImage(e.p1Tris[0], e.p1Tris[1], img)
} else {
e.Hide()
}
return e
}
func (e *Image) Img(img *ImageData) *Image {
e.img = img
if img != nil {
e.width = img.W
e.height = img.H
e.Root.P1.SetQuadImage(e.p1Tris[0], e.p1Tris[1], img)
} else {
e.Hide()
}
e.Root.ForcePosDirty()
return e
}
func (e *Image) Show() {
if e.img != nil {
e.Root.P1.SetTriType(e.p1Tris[0], VTYPE_IMAGE)
e.Root.P1.SetTriType(e.p1Tris[1], VTYPE_IMAGE)
}
e.ElementData.Show()
}
// ignores the maxWidth and maxHeight args
func (e *Image) CalcPos(maxWidth, maxHeight, maxZIndex int) (int, int) {
if e.img != nil {
e.Root.P1.SetQuadPos(e.p1Tris[0], e.p1Tris[1], Rect{0, 0, e.width, e.height}, e.Z(maxZIndex))
e.Root.P1.setQuadImageRelTCoords(e.p1Tris[0], e.p1Tris[1], e.width, e.height)
return e.InitRect(e.width, e.height)
} else {
return e.InitRect(0, 0)
}
}