ScreenEntity.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. require "Polycode/Entity"
  2. class "ScreenEntity" (Entity)
  3. POSITION_TOPLEFT = 0
  4. POSITION_CENTER = 1
  5. function ScreenEntity:__index__(name)
  6. if name == "hasFocus" then
  7. return Polycore.ScreenEntity_get_hasFocus(self.__ptr)
  8. elseif name == "blockMouseInput" then
  9. return Polycore.ScreenEntity_get_blockMouseInput(self.__ptr)
  10. elseif name == "zindex" then
  11. return Polycore.ScreenEntity_get_zindex(self.__ptr)
  12. elseif name == "snapToPixels" then
  13. return Polycore.ScreenEntity_get_snapToPixels(self.__ptr)
  14. end
  15. end
  16. function ScreenEntity:__set_callback(name,value)
  17. if name == "hasFocus" then
  18. Polycore.ScreenEntity_set_hasFocus(self.__ptr, value)
  19. return true
  20. elseif name == "blockMouseInput" then
  21. Polycore.ScreenEntity_set_blockMouseInput(self.__ptr, value)
  22. return true
  23. elseif name == "zindex" then
  24. Polycore.ScreenEntity_set_zindex(self.__ptr, value)
  25. return true
  26. elseif name == "snapToPixels" then
  27. Polycore.ScreenEntity_set_snapToPixels(self.__ptr, value)
  28. return true
  29. end
  30. return false
  31. end
  32. function ScreenEntity:ScreenEntity(...)
  33. for k,v in pairs(arg) do
  34. if type(v) == "table" then
  35. if v.__ptr ~= nil then
  36. arg[k] = v.__ptr
  37. end
  38. end
  39. end
  40. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  41. self.__ptr = Polycore.ScreenEntity(unpack(arg))
  42. Polycore.__ptr_lookup[self.__ptr] = self
  43. end
  44. end
  45. function ScreenEntity:setPosition(x, y)
  46. local retVal = Polycore.ScreenEntity_setPosition(self.__ptr, x, y)
  47. end
  48. function ScreenEntity:setScale(x, y)
  49. local retVal = Polycore.ScreenEntity_setScale(self.__ptr, x, y)
  50. end
  51. function ScreenEntity:setRotation(roatation)
  52. local retVal = Polycore.ScreenEntity_setRotation(self.__ptr, roatation)
  53. end
  54. function ScreenEntity:getRotation()
  55. local retVal = Polycore.ScreenEntity_getRotation(self.__ptr)
  56. return retVal
  57. end
  58. function ScreenEntity:_onMouseDown(x, y, mouseButton, timestamp)
  59. local retVal = Polycore.ScreenEntity__onMouseDown(self.__ptr, x, y, mouseButton, timestamp)
  60. return retVal
  61. end
  62. function ScreenEntity:_onMouseUp(x, y, mouseButton, timestamp)
  63. local retVal = Polycore.ScreenEntity__onMouseUp(self.__ptr, x, y, mouseButton, timestamp)
  64. return retVal
  65. end
  66. function ScreenEntity:_onMouseMove(x, y, timestamp)
  67. local retVal = Polycore.ScreenEntity__onMouseMove(self.__ptr, x, y, timestamp)
  68. end
  69. function ScreenEntity:_onMouseWheelUp(x, y, timestamp)
  70. local retVal = Polycore.ScreenEntity__onMouseWheelUp(self.__ptr, x, y, timestamp)
  71. end
  72. function ScreenEntity:_onMouseWheelDown(x, y, timestamp)
  73. local retVal = Polycore.ScreenEntity__onMouseWheelDown(self.__ptr, x, y, timestamp)
  74. end
  75. function ScreenEntity:onMouseDown(x, y)
  76. local retVal = Polycore.ScreenEntity_onMouseDown(self.__ptr, x, y)
  77. end
  78. function ScreenEntity:onMouseUp(x, y)
  79. local retVal = Polycore.ScreenEntity_onMouseUp(self.__ptr, x, y)
  80. end
  81. function ScreenEntity:onMouseMove(x, y)
  82. local retVal = Polycore.ScreenEntity_onMouseMove(self.__ptr, x, y)
  83. end
  84. function ScreenEntity:onMouseWheelUp(x, y)
  85. local retVal = Polycore.ScreenEntity_onMouseWheelUp(self.__ptr, x, y)
  86. end
  87. function ScreenEntity:onMouseWheelDown(x, y)
  88. local retVal = Polycore.ScreenEntity_onMouseWheelDown(self.__ptr, x, y)
  89. end
  90. function ScreenEntity:_onKeyDown(key, charCode)
  91. local retVal = Polycore.ScreenEntity__onKeyDown(self.__ptr, key.__ptr, charCode.__ptr)
  92. end
  93. function ScreenEntity:_onKeyUp(key, charCode)
  94. local retVal = Polycore.ScreenEntity__onKeyUp(self.__ptr, key.__ptr, charCode.__ptr)
  95. end
  96. function ScreenEntity:onKeyDown(key, charCode)
  97. local retVal = Polycore.ScreenEntity_onKeyDown(self.__ptr, key.__ptr, charCode.__ptr)
  98. end
  99. function ScreenEntity:onKeyUp(key, charCode)
  100. local retVal = Polycore.ScreenEntity_onKeyUp(self.__ptr, key.__ptr, charCode.__ptr)
  101. end
  102. function ScreenEntity:hitTest(x, y)
  103. local retVal = Polycore.ScreenEntity_hitTest(self.__ptr, x, y)
  104. return retVal
  105. end
  106. function ScreenEntity:buildPositionMatrix()
  107. local retVal = Polycore.ScreenEntity_buildPositionMatrix(self.__ptr)
  108. if Polycore.__ptr_lookup[retVal] ~= nil then
  109. return Polycore.__ptr_lookup[retVal]
  110. else
  111. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  112. Polycore.__ptr_lookup[retVal].__ptr = retVal
  113. return Polycore.__ptr_lookup[retVal]
  114. end
  115. end
  116. function ScreenEntity:adjustMatrixForChildren()
  117. local retVal = Polycore.ScreenEntity_adjustMatrixForChildren(self.__ptr)
  118. end
  119. function ScreenEntity:getWidth()
  120. local retVal = Polycore.ScreenEntity_getWidth(self.__ptr)
  121. return retVal
  122. end
  123. function ScreenEntity:getHeight()
  124. local retVal = Polycore.ScreenEntity_getHeight(self.__ptr)
  125. return retVal
  126. end
  127. function ScreenEntity:setWidth(w)
  128. local retVal = Polycore.ScreenEntity_setWidth(self.__ptr, w)
  129. end
  130. function ScreenEntity:setHeight(h)
  131. local retVal = Polycore.ScreenEntity_setHeight(self.__ptr, h)
  132. end
  133. function ScreenEntity:onGainFocus()
  134. local retVal = Polycore.ScreenEntity_onGainFocus(self.__ptr)
  135. end
  136. function ScreenEntity:onLoseFocus()
  137. local retVal = Polycore.ScreenEntity_onLoseFocus(self.__ptr)
  138. end
  139. function ScreenEntity:startDrag(xOffset, yOffset)
  140. local retVal = Polycore.ScreenEntity_startDrag(self.__ptr, xOffset, yOffset)
  141. end
  142. function ScreenEntity:stopDrag()
  143. local retVal = Polycore.ScreenEntity_stopDrag(self.__ptr)
  144. end
  145. function ScreenEntity:setBlendingMode(newBl_endingMode)
  146. local retVal = Polycore.ScreenEntity_setBlendingMode(self.__ptr, newBl_endingMode)
  147. end
  148. function ScreenEntity:setPositionMode(newPositionMode)
  149. local retVal = Polycore.ScreenEntity_setPositionMode(self.__ptr, newPositionMode)
  150. end
  151. function ScreenEntity:setDragLimits(rect)
  152. local retVal = Polycore.ScreenEntity_setDragLimits(self.__ptr, rect.__ptr)
  153. end
  154. function ScreenEntity:clearDragLimits()
  155. local retVal = Polycore.ScreenEntity_clearDragLimits(self.__ptr)
  156. end
  157. function ScreenEntity:focusChild(child)
  158. local retVal = Polycore.ScreenEntity_focusChild(self.__ptr, child.__ptr)
  159. end
  160. function ScreenEntity:focusNextChild()
  161. local retVal = Polycore.ScreenEntity_focusNextChild(self.__ptr)
  162. end
  163. function ScreenEntity:getPosition2D()
  164. local retVal = Polycore.ScreenEntity_getPosition2D(self.__ptr)
  165. if Polycore.__ptr_lookup[retVal] ~= nil then
  166. return Polycore.__ptr_lookup[retVal]
  167. else
  168. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  169. Polycore.__ptr_lookup[retVal].__ptr = retVal
  170. return Polycore.__ptr_lookup[retVal]
  171. end
  172. end
  173. function ScreenEntity:isFocusable()
  174. local retVal = Polycore.ScreenEntity_isFocusable(self.__ptr)
  175. return retVal
  176. end