Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7KB

  1. --- JUCE Component.
  2. -- Is a pointer to a [JUCE Component](http://www.juce.com/api/classComponent.html)
  3. --
  4. -- As of now, components can't be created by protoplug scripts. This is mainly
  5. -- for accessing the custom GUI component using @{gui.getComponent}.
  6. -- @classmod juce.Component
  7. ffi.cdef [[
  8. void Component_repaint(pComponent self);
  9. void Component_repaint2(pComponent self, int x, int y, int width, int height);
  10. void Component_repaint3(pComponent self, Rectangle_int area);
  11. pImage Component_createComponentSnapshot (pComponent self,
  12. Rectangle_int areaToGrab,
  13. bool clipImageToComponentBounds,
  14. float scaleFactor);
  15. ]]
  16. local Component_mt = {
  17. -- methods
  18. __index = {
  19. --- Request total repaint.
  20. -- Tell the operating system that the component is "dirty" and needs to be redrawn.
  21. -- The component's paint method will be called asynchronously (@{gui.paint})
  22. -- @function repaint
  23. --- Request partial repaint.
  24. -- Tell the operating system that a portion of the component is "dirty" and needs to be redrawn.
  25. -- The component's paint method will be called asynchronously (@{gui.paint}). The dirty region will be accessible
  26. -- with Graphics.getClipBounds().
  27. -- @tparam juce.Rectangle_int area the region needing the be redrawn
  28. -- @function repaint
  29. --- Request partial repaint.
  30. -- Tell the operating system that a portion of the component is "dirty" and needs to be redrawn.
  31. -- The component's paint method will be called asynchronously (@{gui.paint}). The dirty region will be accessible
  32. -- with Graphics.getClipBounds().
  33. -- @param x the region needing the be redrawn
  34. -- @param y the region needing the be redrawn
  35. -- @param width the region needing the be redrawn
  36. -- @param height the region needing the be redrawn
  37. -- @function repaint
  38. repaint = function (self, ...)
  39. if select("#", ...) == 4 then
  40. protolib.Component_repaint2(self, ...)
  41. elseif select("#", ...) == 1 then
  42. protolib.Component_repaint3(self, ...)
  43. else
  44. protolib.Component_repaint(self)
  45. end
  46. end;
  47. --- Create component snapshot.
  48. -- Paint the component into a virtual buffer and return it as an image.
  49. -- @tparam juce.Rectangle_int areaToGrab the region to the be drawn
  50. -- @param[opt=true] clipImageToComponentBounds
  51. -- @param[opt=1] scaleFactor
  52. -- @treturn juce.Image
  53. -- @function createComponentSnapshot
  54. createComponentSnapshot = function (self, areaToGrab, clipImageToComponentBounds, scaleFactor)
  55. clipImageToComponentBounds = clipImageToComponentBounds or true
  56. scaleFactor = scaleFactor or 1
  57. local i = protolib.Component_createComponentSnapshot(self, areaToGrab, clipImageToComponentBounds, scaleFactor)
  58. i = ffi.gc(i, protolib.Image_delete)
  59. return i
  60. end
  61. }
  62. }
  63. ffi.metatype("pComponent", Component_mt)
  64. return {}