|
@@ -0,0 +1,180 @@
|
|
|
|
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
|
|
+var BABYLON;
|
|
|
|
+(function (BABYLON) {
|
|
|
|
+ var GUI;
|
|
|
|
+ (function (GUI) {
|
|
|
|
+ var Control = (function () {
|
|
|
|
+ function Control(name) {
|
|
|
|
+ this.name = name;
|
|
|
|
+ this._zIndex = 0;
|
|
|
|
+ this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
|
|
|
|
+ this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
|
|
+ }
|
|
|
|
+ Object.defineProperty(Control.prototype, "horizontalAlignment", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._horizontalAlignment;
|
|
|
|
+ },
|
|
|
|
+ set: function (value) {
|
|
|
|
+ if (this._horizontalAlignment === value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._horizontalAlignment = value;
|
|
|
|
+ this._markAsDirty();
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control.prototype, "verticalAlignment", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._verticalAlignment;
|
|
|
|
+ },
|
|
|
|
+ set: function (value) {
|
|
|
|
+ if (this._verticalAlignment === value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._verticalAlignment = value;
|
|
|
|
+ this._markAsDirty();
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control.prototype, "font", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._font;
|
|
|
|
+ },
|
|
|
|
+ set: function (value) {
|
|
|
|
+ if (this._font === value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._font = value;
|
|
|
|
+ this._fontHeight = Control._GetFontHeight(this._font);
|
|
|
|
+ this._markAsDirty();
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control.prototype, "color", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._color;
|
|
|
|
+ },
|
|
|
|
+ set: function (value) {
|
|
|
|
+ if (this._color === value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._color = value;
|
|
|
|
+ this._markAsDirty();
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control.prototype, "zIndex", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._zIndex;
|
|
|
|
+ },
|
|
|
|
+ set: function (value) {
|
|
|
|
+ if (this.zIndex === value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._zIndex = value;
|
|
|
|
+ this._root._reOrderControl(this);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Control.prototype._markAsDirty = function () {
|
|
|
|
+ if (!this._root) {
|
|
|
|
+ return; // Not yet connected
|
|
|
|
+ }
|
|
|
|
+ this._root._markAsDirty();
|
|
|
|
+ };
|
|
|
|
+ Control.prototype._setRoot = function (root) {
|
|
|
|
+ this._root = root;
|
|
|
|
+ };
|
|
|
|
+ Control.prototype._draw = function (parentMeasure, context) {
|
|
|
|
+ this._currentMeasure = parentMeasure.copy();
|
|
|
|
+ // Do nothing
|
|
|
|
+ };
|
|
|
|
+ Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._HORIZONTAL_ALIGNMENT_LEFT;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._HORIZONTAL_ALIGNMENT_RIGHT;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._HORIZONTAL_ALIGNMENT_CENTER;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._VERTICAL_ALIGNMENT_TOP;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._VERTICAL_ALIGNMENT_BOTTOM;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Control._VERTICAL_ALIGNMENT_CENTER;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Control._GetFontHeight = function (font) {
|
|
|
|
+ if (Control._FontHeightSizes[font]) {
|
|
|
|
+ return Control._FontHeightSizes[font];
|
|
|
|
+ }
|
|
|
|
+ var text = document.createElement("span");
|
|
|
|
+ text.innerHTML = "Hg";
|
|
|
|
+ text.style.font = font;
|
|
|
|
+ var block = document.createElement("div");
|
|
|
|
+ block.style.display = "inline-block";
|
|
|
|
+ block.style.width = "1px";
|
|
|
|
+ block.style.height = "0px";
|
|
|
|
+ block.style.verticalAlign = "bottom";
|
|
|
|
+ var div = document.createElement("div");
|
|
|
|
+ div.appendChild(text);
|
|
|
|
+ div.appendChild(block);
|
|
|
|
+ document.body.appendChild(div);
|
|
|
|
+ var fontHeight = 0;
|
|
|
|
+ try {
|
|
|
|
+ fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
|
|
+ div.remove();
|
|
|
|
+ }
|
|
|
|
+ Control._FontHeightSizes[font] = fontHeight;
|
|
|
|
+ return fontHeight;
|
|
|
|
+ };
|
|
|
|
+ ;
|
|
|
|
+ return Control;
|
|
|
|
+ }());
|
|
|
|
+ // Statics
|
|
|
|
+ Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
|
|
|
|
+ Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
|
|
|
|
+ Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
|
|
|
|
+ Control._VERTICAL_ALIGNMENT_TOP = 0;
|
|
|
|
+ Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
|
|
|
|
+ Control._VERTICAL_ALIGNMENT_CENTER = 2;
|
|
|
|
+ Control._FontHeightSizes = {};
|
|
|
|
+ GUI.Control = Control;
|
|
|
|
+ })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
|
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
|
+
|
|
|
|
+//# sourceMappingURL=control.js.map
|