/// var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var BABYLON; (function (BABYLON) { var GUI; (function (GUI) { var TextBlock = (function (_super) { __extends(TextBlock, _super); function TextBlock(name, text) { var _this = _super.call(this, name) || this; _this.name = name; _this.text = text; return _this; } Object.defineProperty(TextBlock.prototype, "text", { get: function () { return this._text; }, set: function (value) { if (this._text === value) { return; } this._text = value; this._markAsDirty(); }, enumerable: true, configurable: true }); TextBlock.prototype._draw = function (parentMeasure, context) { context.save(); this.applyStates(context); this._prepare(parentMeasure, context); context.fillText(this.text, this._currentMeasure.left, this._currentMeasure.top); context.restore(); }; TextBlock.prototype._prepare = function (parentMeasure, context) { var width = parentMeasure.width; var height = parentMeasure.height; var x = 0; var y = 0; var textSize = context.measureText(this.text); switch (this.horizontalAlignment) { case GUI.Control.HORIZONTAL_ALIGNMENT_LEFT: x = 0; break; case GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT: x = width - textSize.width; break; case GUI.Control.HORIZONTAL_ALIGNMENT_CENTER: x = (width - textSize.width) / 2; break; } if (!this._fontOffset) { this._fontOffset = GUI.Control._GetFontOffset(context.font); } switch (this.verticalAlignment) { case GUI.Control.VERTICAL_ALIGNMENT_TOP: y = this._fontOffset.ascent; break; case GUI.Control.VERTICAL_ALIGNMENT_BOTTOM: y = height - this._fontOffset.descent; break; case GUI.Control.VERTICAL_ALIGNMENT_CENTER: y = (height / 2) + (this._fontOffset.ascent - this._fontOffset.height / 2); break; } this._currentMeasure = new GUI.Measure(parentMeasure.left + x, parentMeasure.top + y, width, height); }; return TextBlock; }(GUI.Control)); GUI.TextBlock = TextBlock; })(GUI = BABYLON.GUI || (BABYLON.GUI = {})); })(BABYLON || (BABYLON = {})); //# sourceMappingURL=textBlock.js.map