Explorar o código

Merge pull request #4135 from royibernthal/master

item passed to push + what's new
David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
f39a457bbe
Modificáronse 2 ficheiros con 20 adicións e 17 borrados
  1. 19 17
      gui/src/controls/multiLine.ts
  2. 1 0
      what's new.md

+ 19 - 17
gui/src/controls/multiLine.ts

@@ -49,25 +49,27 @@ module BABYLON.GUI {
             this._markAsDirty();
         }
 
-        public add(...items: (AbstractMesh | Control | { x: string | number, y: string | number })[]): void {
-            items.forEach(item => {
-                var point: MultiLinePoint = this.push();
-
-                if (item instanceof AbstractMesh) {
-                    point.mesh = item;
-                }
-                else if (item instanceof Control) {
-                    point.control = item;
-                }
-                else if (item.x != null && item.y != null) {
-                    point.x = item.x;
-                    point.y = item.y;
-                }
-            });
+        public add(...items: (AbstractMesh | Control | { x: string | number, y: string | number })[]): MultiLinePoint[] {
+            return items.map(item => this.push(item));
         }
 
-        public push(): MultiLinePoint {
-            return this.getAt(this._points.length);
+        public push(item?: (AbstractMesh | Control | { x: string | number, y: string | number })): MultiLinePoint {
+            var point: MultiLinePoint = this.getAt(this._points.length);
+
+            if (item == null) return point;
+
+            if (item instanceof AbstractMesh) {
+                point.mesh = item;
+            }
+            else if (item instanceof Control) {
+                point.control = item;
+            }
+            else if (item.x != null && item.y != null) {
+                point.x = item.x;
+                point.y = item.y;
+            }
+
+            return point;
         }
 
         public remove(value: number | MultiLinePoint): void {

+ 1 - 0
what's new.md

@@ -67,6 +67,7 @@
 - Added shadowBlur, shadowOffsetX, shadowOffsetY, shadowColor to GUI Controls ([adam](https://github.com/abow))
 - Added alignWithNormal to AbstractMesh ([adam](https://github.com/abow))
 - Added transformNode.forward/up/right ([bobalazek](https://github.com/bobalazek))
+- GUI: Introduced `MultiLine` which will draw lines between any number of meshes, controls and points. [Documentation](http://doc.babylonjs.com/how_to/gui#multiline) ([royibernthal](https://github.com/royibernthal))
 
 ## Bug fixes