David Catuhe 7 years ago
parent
commit
937471a42b

File diff suppressed because it is too large
+ 1438 - 1438
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1438 - 1438
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 746 - 746
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 746 - 746
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 2 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -502,6 +502,8 @@ declare module BABYLON.GUI {
         private _textVerticalAlignment;
         private _lines;
         private _totalHeight;
+        private _resizeToFit;
+        resizeToFit: boolean;
         textWrapping: boolean;
         text: string;
         textHorizontalAlignment: number;

+ 23 - 1
dist/preview release/gui/babylon.gui.js

@@ -2933,9 +2933,24 @@ var BABYLON;
                 _this._textWrapping = false;
                 _this._textHorizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
                 _this._textVerticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_CENTER;
+                _this._resizeToFit = false;
                 _this.text = text;
                 return _this;
             }
+            Object.defineProperty(TextBlock.prototype, "resizeToFit", {
+                get: function () {
+                    return this._resizeToFit;
+                },
+                set: function (value) {
+                    this._resizeToFit = value;
+                    if (this._resizeToFit) {
+                        this._width.ignoreAdaptiveScaling = true;
+                        this._height.ignoreAdaptiveScaling = true;
+                    }
+                },
+                enumerable: true,
+                configurable: true
+            });
             Object.defineProperty(TextBlock.prototype, "textWrapping", {
                 get: function () {
                     return this._textWrapping;
@@ -3023,7 +3038,7 @@ var BABYLON;
             TextBlock.prototype._additionalProcessing = function (parentMeasure, context) {
                 this._lines = [];
                 var _lines = this.text.split("\n");
-                if (this._textWrapping) {
+                if (this._textWrapping && !this._resizeToFit) {
                     for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
                         var _line = _lines_1[_i];
                         this._lines.push(this._parseLineWithTextWrapping(_line, context));
@@ -3080,10 +3095,17 @@ var BABYLON;
                         break;
                 }
                 rootY += this._currentMeasure.top;
+                var maxLineWidth = 0;
                 for (var _i = 0, _a = this._lines; _i < _a.length; _i++) {
                     var line = _a[_i];
                     this._drawText(line.text, line.width, rootY, context);
                     rootY += this._fontOffset.height;
+                    if (line.width > maxLineWidth)
+                        maxLineWidth = line.width;
+                }
+                if (this._resizeToFit) {
+                    this.width = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth + 'px';
+                    this.height = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length + 'px';
                 }
             };
             return TextBlock;

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/gui/babylon.gui.min.js


+ 2 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -507,6 +507,8 @@ declare module BABYLON.GUI {
         private _textVerticalAlignment;
         private _lines;
         private _totalHeight;
+        private _resizeToFit;
+        resizeToFit: boolean;
         textWrapping: boolean;
         text: string;
         textHorizontalAlignment: number;

+ 0 - 6
gui/src/controls/textBlock.ts

@@ -193,12 +193,6 @@ module BABYLON.GUI {
                 this.width = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth + 'px';
                 this.height = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length + 'px';
             }
-
-            console.log('width', this.width);
-            console.log('height', this.height);
-
-            /*console.log('width', maxLineWidth);
-            console.log('height', this._fontOffset.height * this._lines.length);*/
         }
     }
 }