From ca3ad6305ec0655ad8475a12ac2228b61cdd9ba0 Mon Sep 17 00:00:00 2001 From: Lionel LASKE Date: Sat, 25 Aug 2012 20:23:36 +0000 Subject: Init commit --- (limited to 'html/lib/canvas/CanvasControl.js') diff --git a/html/lib/canvas/CanvasControl.js b/html/lib/canvas/CanvasControl.js new file mode 100644 index 0000000..ce16446 --- /dev/null +++ b/html/lib/canvas/CanvasControl.js @@ -0,0 +1,52 @@ +/** + The base kind for items that live inside an + enyo.Canvas control. + + If you're using this kind directly, you may implement an _onRender_ event + handler in the owner to handle drawing into the canvas. + + If you're deriving a new kind based on this one, override the _renderSelf_ + method and use that for your drawing code. +*/ +enyo.kind({ + name: "enyo.canvas.Control", + kind: enyo.UiComponent, + defaultKind: "enyo.canvas.Control", + published: { + //* Structure with l (left), t (top), w (width), and h (height) members. + //* The default constructor sets those properties to random values. + bounds: null + }, + events: { + //* Event providing hook to render this control. The event structure + //* includes a _context_ member holding the active canvas context. + onRender: "" + }, + //* @protected + constructor: function() { + this.bounds = {l: enyo.irand(400), t: enyo.irand(400), w: enyo.irand(100), h: enyo.irand(100)}; + this.inherited(arguments); + }, + importProps: function(inProps) { + this.inherited(arguments); + if (inProps.bounds) { + enyo.mixin(this.bounds, inProps.bounds); + delete inProps.bounds; + } + }, + renderSelf: function(inContext) { + this.doRender({context: inContext}); + }, + render: function(inContext) { + if (this.children.length) { + this.renderChildren(inContext); + } else { + this.renderSelf(inContext); + } + }, + renderChildren: function(inContext) { + for (var i=0, c; c=this.children[i]; i++) { + c.render(inContext); + } + } +}); -- cgit v0.9.1