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
|
import
tri_engine/gfx/gl/primitive,
tri_engine/gfx/tex,
tri_engine/gfx/color,
tri_engine/math/rect,
tri_engine/math/vec
type
TWidgetLayer* = enum
wlBg = 100,
wlOverlap = 200,
wlMain = 300,
wlOverlay = 400,
wlCursor = 500
TWidgetLayerType = TWidgetLayer|int
TWidgetType* = enum
wtImg
PWidget* = ref object
`type`* : TWidgetType
layer* : TWidgetLayer
rect* : TRect
prim* : PPrimitive
const
baseZ = 5000
proc newWidget*(`type`: TWidgetType, layer: TWidgetLayerType, rect: TRect): PWidget =
new(result)
result.`type` = `type`
result.layer = layer
result.rect = rect
var verts = newVert(rect)
# This works because z is accessible at this scope.
#var z = baseZ + layer.int
#result.prim = newPrimitive(verts, z=z)
# Doesn't work, because the compiler looks for a symbol called z in this scope,
# but it should only check that it is the name of one of the params.
#result.prim = newPrimitive(verts, z=baseZ + layer.int)
# This doesn't work either.
result.prim = newPrimitive(verts, z=0)
|