contentControl.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. var BABYLON;
  13. (function (BABYLON) {
  14. var GUI;
  15. (function (GUI) {
  16. var ContentControl = (function (_super) {
  17. __extends(ContentControl, _super);
  18. function ContentControl(name) {
  19. var _this = _super.call(this, name) || this;
  20. _this.name = name;
  21. return _this;
  22. }
  23. Object.defineProperty(ContentControl.prototype, "child", {
  24. get: function () {
  25. return this._child;
  26. },
  27. set: function (control) {
  28. if (this._child === control) {
  29. return;
  30. }
  31. this._child = control;
  32. control._setRoot(this._root);
  33. this._markAsDirty();
  34. },
  35. enumerable: true,
  36. configurable: true
  37. });
  38. ContentControl.prototype._localDraw = function (context) {
  39. // Implemented by child to be injected inside main draw
  40. };
  41. ContentControl.prototype._draw = function (parentMeasure, context) {
  42. this._currentMeasure = parentMeasure.copy();
  43. context.save();
  44. if (this.font) {
  45. context.font = this.font;
  46. }
  47. if (this.color) {
  48. context.fillStyle = this.color;
  49. }
  50. this._localDraw(context);
  51. if (this._child) {
  52. this._child._draw(this._currentMeasure, context);
  53. }
  54. context.restore();
  55. };
  56. return ContentControl;
  57. }(GUI.Control));
  58. GUI.ContentControl = ContentControl;
  59. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  60. })(BABYLON || (BABYLON = {}));
  61. //# sourceMappingURL=contentControl.js.map