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.

52 lines
1.5 KiB

  1. /**
  2. 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. //* Event providing hook to render this control. The event structure
  20. //* includes a _context_ member holding the active canvas context.
  21. onRender: ""
  22. },
  23. //* @protected
  24. constructor: function() {
  25. this.bounds = {l: enyo.irand(400), t: enyo.irand(400), w: enyo.irand(100), h: enyo.irand(100)};
  26. this.inherited(arguments);
  27. },
  28. importProps: function(inProps) {
  29. this.inherited(arguments);
  30. if (inProps.bounds) {
  31. enyo.mixin(this.bounds, inProps.bounds);
  32. delete inProps.bounds;
  33. }
  34. },
  35. renderSelf: function(inContext) {
  36. this.doRender({context: inContext});
  37. },
  38. render: function(inContext) {
  39. if (this.children.length) {
  40. this.renderChildren(inContext);
  41. } else {
  42. this.renderSelf(inContext);
  43. }
  44. },
  45. renderChildren: function(inContext) {
  46. for (var i=0, c; c=this.children[i]; i++) {
  47. c.render(inContext);
  48. }
  49. }
  50. });