-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.nim
More file actions
32 lines (26 loc) · 790 Bytes
/
types.nim
File metadata and controls
32 lines (26 loc) · 790 Bytes
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
type
ElementKind* = enum
Panel = 0,
Window = 1,
Button = 2,
Label = 3
Element* = ref object
x*,y*,w*,h*: float32
text*: string
z*: int
case kind*: ElementKind:
of Window, Panel:
discard
of Label:
relation*: int
else: discard
{.experimental: "callOperator".}
proc `()`*(e: ElementKind; x,y,w,h: float32; text: string = ""): Element =
result = Element(kind: e, x: x, y: y, w: w, h: h, text: text)
proc compareByZ*(a,b: Element): int =
if a.z == b.z:
return cmp(a.kind.int, b.kind.int)
return cmp(a.z, b.z)
import strformat
proc `$`*(e: Element): string =
fmt"{e.kind}: {e.x},{e.y},{e.h},{e.w}; Z: {e.z}; text: {e.text}"