Procházet zdrojové kódy

Merge pull request #2312 from abow/colorpicker

created the size property for colorpicker and size, width, height are…
David Catuhe před 8 roky
rodič
revize
2361b93a24
1 změnil soubory, kde provedl 32 přidání a 3 odebrání
  1. 32 3
      gui/src/controls/colorpicker.ts

+ 32 - 3
gui/src/controls/colorpicker.ts

@@ -42,13 +42,42 @@ module BABYLON.GUI {
             this._markAsDirty();
 
             this.onValueChangedObservable.notifyObservers(this._value);
-        }                             
+        }
+
+        public set width(value: string | number ) {
+            if (this._width.toString(this._host) === value) {
+                return;
+            }
+
+            if (this._width.fromString(value)) {
+                this._height.fromString(value);
+                this._markAsDirty();
+            }
+        }
+
+        public set height(value: string | number ) {
+            if (this._height.toString(this._host) === value) {
+                return;
+            }
+
+            if (this._height.fromString(value)) {
+                this._width.fromString(value);
+                this._markAsDirty();
+            }
+        }
+
+        public get size(): string | number {
+            return this.width;
+        }
+
+        public set size(value: string | number){
+            this.width = value;
+        }              
 
         constructor(public name?: string) {
             super(name);
             this.value = new BABYLON.Color3(.88, .1, .1);
-            this.width = "200px";
-            this.height = "200px";
+            this.size = "200px";
             this.isPointerBlocker = true;
         }