gui.nim 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import
  2. tri_engine/gfx/gl/primitive,
  3. tri_engine/gfx/tex,
  4. tri_engine/gfx/color,
  5. tri_engine/math/rect,
  6. tri_engine/math/vec
  7. type
  8. TWidgetLayer* = enum
  9. wlBg = 100,
  10. wlOverlap = 200,
  11. wlMain = 300,
  12. wlOverlay = 400,
  13. wlCursor = 500
  14. TWidgetLayerType = TWidgetLayer|int
  15. TWidgetType* = enum
  16. wtImg
  17. PWidget* = ref object
  18. `type`* : TWidgetType
  19. layer* : TWidgetLayer
  20. rect* : TRect
  21. prim* : PPrimitive
  22. const
  23. baseZ = 5000
  24. proc newWidget*(`type`: TWidgetType, layer: TWidgetLayerType, rect: TRect): PWidget =
  25. new(result)
  26. result.`type` = `type`
  27. result.layer = layer
  28. result.rect = rect
  29. var verts = newVert(rect)
  30. # This works because z is accessible at this scope.
  31. #var z = baseZ + layer.int
  32. #result.prim = newPrimitive(verts, z=z)
  33. # Doesn't work, because the compiler looks for a symbol called z in this scope,
  34. # but it should only check that it is the name of one of the params.
  35. #result.prim = newPrimitive(verts, z=baseZ + layer.int)
  36. # This doesn't work either.
  37. result.prim = newPrimitive(verts, z=0)