not really known
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.

55 lines
1.5 KiB

  1. /**
  2. _enyo.canvas.Control_ is the base kind for items that live inside an
  3. <a href="#enyo.Canvas">enyo.Canvas</a> control.
  4. If you're using this kind directly, you may implement an _onRender_ event
  5. handler in the owner to handle drawing into the canvas.
  6. If you're deriving a new kind based on this one, override the _renderSelf_
  7. method and use that for your drawing code.
  8. */
  9. enyo.kind({
  10. name: "enyo.canvas.Control",
  11. kind: enyo.UiComponent,
  12. defaultKind: "enyo.canvas.Control",
  13. published: {
  14. //* Structure with l (left), t (top), w (width), and h (height) members.
  15. //* The default constructor sets those properties to random values.
  16. bounds: null
  17. },
  18. events: {
  19. /**
  20. Fires when this control is to be rendered.
  21. _inEvent.context_ contains the active canvas context.
  22. */
  23. onRender: ""
  24. },
  25. //* @protected
  26. constructor: function() {
  27. this.bounds = {l: enyo.irand(400), t: enyo.irand(400), w: enyo.irand(100), h: enyo.irand(100)};
  28. this.inherited(arguments);
  29. },
  30. importProps: function(inProps) {
  31. this.inherited(arguments);
  32. if (inProps && inProps.bounds) {
  33. enyo.mixin(this.bounds, inProps.bounds);
  34. delete inProps.bounds;
  35. }
  36. },
  37. renderSelf: function(inContext) {
  38. this.doRender({context: inContext});
  39. },
  40. render: function(inContext) {
  41. if (this.children.length) {
  42. this.renderChildren(inContext);
  43. } else {
  44. this.renderSelf(inContext);
  45. }
  46. },
  47. renderChildren: function(inContext) {
  48. for (var i=0, c; (c=this.children[i]); i++) {
  49. c.render(inContext);
  50. }
  51. }
  52. });