瀏覽代碼

created the size property for colorpicker and size, width, height are now always in sync

Adam Bowman 8 年之前
父節點
當前提交
e8dcfbc5d2
共有 1 個文件被更改,包括 32 次插入3 次删除
  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;
         }