@babylonjs/gui 5.0.0-rc.0 → 5.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/adtInstrumentation.d.ts +52 -52
- package/2D/adtInstrumentation.js +126 -126
- package/2D/adtInstrumentation.js.map +1 -1
- package/2D/advancedDynamicTexture.d.ts +449 -423
- package/2D/advancedDynamicTexture.js +1318 -1286
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/button.d.ts +135 -97
- package/2D/controls/button.js +276 -238
- package/2D/controls/button.js.map +1 -1
- package/2D/controls/checkbox.d.ts +59 -51
- package/2D/controls/checkbox.js +188 -178
- package/2D/controls/checkbox.js.map +1 -1
- package/2D/controls/colorpicker.d.ts +103 -90
- package/2D/controls/colorpicker.js +1417 -1400
- package/2D/controls/colorpicker.js.map +1 -1
- package/2D/controls/container.d.ts +175 -130
- package/2D/controls/container.js +570 -525
- package/2D/controls/container.js.map +1 -1
- package/2D/controls/control.d.ts +866 -743
- package/2D/controls/control.js +2433 -2308
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/displayGrid.d.ts +53 -55
- package/2D/controls/displayGrid.js +245 -245
- package/2D/controls/displayGrid.js.map +1 -1
- package/2D/controls/ellipse.d.ts +21 -21
- package/2D/controls/ellipse.js +85 -85
- package/2D/controls/ellipse.js.map +1 -1
- package/2D/controls/focusableButton.d.ts +59 -52
- package/2D/controls/focusableButton.js +99 -92
- package/2D/controls/focusableButton.js.map +1 -1
- package/2D/controls/focusableControl.d.ts +34 -34
- package/2D/controls/focusableControl.js +1 -1
- package/2D/controls/focusableControl.js.map +1 -1
- package/2D/controls/grid.d.ts +139 -135
- package/2D/controls/grid.js +529 -525
- package/2D/controls/grid.js.map +1 -1
- package/2D/controls/image.d.ts +204 -197
- package/2D/controls/image.js +887 -879
- package/2D/controls/image.js.map +1 -1
- package/2D/controls/index.d.ts +29 -29
- package/2D/controls/index.js +29 -29
- package/2D/controls/index.js.map +1 -1
- package/2D/controls/inputPassword.d.ts +9 -8
- package/2D/controls/inputPassword.js +28 -25
- package/2D/controls/inputPassword.js.map +1 -1
- package/2D/controls/inputText.d.ts +201 -182
- package/2D/controls/inputText.js +1119 -1096
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/line.d.ts +66 -66
- package/2D/controls/line.js +271 -271
- package/2D/controls/line.js.map +1 -1
- package/2D/controls/multiLine.d.ts +75 -77
- package/2D/controls/multiLine.js +262 -262
- package/2D/controls/multiLine.js.map +1 -1
- package/2D/controls/radioButton.d.ts +49 -49
- package/2D/controls/radioButton.js +205 -205
- package/2D/controls/radioButton.js.map +1 -1
- package/2D/controls/rectangle.d.ts +29 -29
- package/2D/controls/rectangle.js +150 -150
- package/2D/controls/rectangle.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewer.d.ts +182 -175
- package/2D/controls/scrollViewers/scrollViewer.js +677 -676
- package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +57 -45
- package/2D/controls/scrollViewers/scrollViewerWindow.js +278 -263
- package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
- package/2D/controls/selector.d.ts +263 -209
- package/2D/controls/selector.js +692 -629
- package/2D/controls/selector.js.map +1 -1
- package/2D/controls/sliders/baseSlider.d.ts +82 -78
- package/2D/controls/sliders/baseSlider.js +347 -343
- package/2D/controls/sliders/baseSlider.js.map +1 -1
- package/2D/controls/sliders/imageBasedSlider.d.ts +49 -47
- package/2D/controls/sliders/imageBasedSlider.js +192 -188
- package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
- package/2D/controls/sliders/imageScrollBar.d.ts +65 -61
- package/2D/controls/sliders/imageScrollBar.js +263 -256
- package/2D/controls/sliders/imageScrollBar.js.map +1 -1
- package/2D/controls/sliders/scrollBar.d.ts +38 -34
- package/2D/controls/sliders/scrollBar.js +143 -136
- package/2D/controls/sliders/scrollBar.js.map +1 -1
- package/2D/controls/sliders/slider.d.ts +35 -37
- package/2D/controls/sliders/slider.js +271 -271
- package/2D/controls/sliders/slider.js.map +1 -1
- package/2D/controls/stackPanel.d.ts +64 -56
- package/2D/controls/stackPanel.js +246 -236
- package/2D/controls/stackPanel.js.map +1 -1
- package/2D/controls/statics.d.ts +6 -6
- package/2D/controls/statics.js +49 -47
- package/2D/controls/statics.js.map +1 -1
- package/2D/controls/textBlock.d.ts +175 -172
- package/2D/controls/textBlock.js +603 -598
- package/2D/controls/textBlock.js.map +1 -1
- package/2D/controls/textWrapper.d.ts +13 -13
- package/2D/controls/textWrapper.js +101 -101
- package/2D/controls/textWrapper.js.map +1 -1
- package/2D/controls/toggleButton.d.ts +117 -83
- package/2D/controls/toggleButton.js +268 -234
- package/2D/controls/toggleButton.js.map +1 -1
- package/2D/controls/virtualKeyboard.d.ts +96 -96
- package/2D/controls/virtualKeyboard.js +256 -256
- package/2D/controls/virtualKeyboard.js.map +1 -1
- package/2D/index.d.ts +9 -9
- package/2D/index.js +10 -9
- package/2D/index.js.map +1 -1
- package/2D/math2D.d.ts +117 -117
- package/2D/math2D.js +221 -221
- package/2D/math2D.js.map +1 -1
- package/2D/measure.d.ts +77 -77
- package/2D/measure.js +139 -149
- package/2D/measure.js.map +1 -1
- package/2D/multiLinePoint.d.ts +47 -47
- package/2D/multiLinePoint.js +127 -127
- package/2D/multiLinePoint.js.map +1 -1
- package/2D/style.d.ts +46 -46
- package/2D/style.js +97 -97
- package/2D/style.js.map +1 -1
- package/2D/valueAndUnit.d.ts +89 -89
- package/2D/valueAndUnit.js +226 -222
- package/2D/valueAndUnit.js.map +1 -1
- package/2D/xmlLoader.d.ts +60 -60
- package/2D/xmlLoader.js +348 -348
- package/2D/xmlLoader.js.map +1 -1
- package/3D/behaviors/defaultBehavior.d.ts +73 -73
- package/3D/behaviors/defaultBehavior.js +121 -121
- package/3D/behaviors/defaultBehavior.js.map +1 -1
- package/3D/controls/abstractButton3D.d.ts +15 -15
- package/3D/controls/abstractButton3D.js +25 -25
- package/3D/controls/abstractButton3D.js.map +1 -1
- package/3D/controls/button3D.d.ts +30 -30
- package/3D/controls/button3D.js +93 -93
- package/3D/controls/button3D.js.map +1 -1
- package/3D/controls/container3D.d.ts +72 -72
- package/3D/controls/container3D.js +139 -140
- package/3D/controls/container3D.js.map +1 -1
- package/3D/controls/contentDisplay3D.d.ts +30 -30
- package/3D/controls/contentDisplay3D.js +79 -78
- package/3D/controls/contentDisplay3D.js.map +1 -1
- package/3D/controls/control3D.d.ts +201 -165
- package/3D/controls/control3D.js +445 -408
- package/3D/controls/control3D.js.map +1 -1
- package/3D/controls/cylinderPanel.d.ts +17 -17
- package/3D/controls/cylinderPanel.js +66 -66
- package/3D/controls/cylinderPanel.js.map +1 -1
- package/3D/controls/handMenu.d.ts +28 -28
- package/3D/controls/handMenu.js +47 -47
- package/3D/controls/handMenu.js.map +1 -1
- package/3D/controls/holographicBackplate.d.ts +49 -48
- package/3D/controls/holographicBackplate.js +120 -120
- package/3D/controls/holographicBackplate.js.map +1 -1
- package/3D/controls/holographicButton.d.ts +84 -83
- package/3D/controls/holographicButton.js +339 -338
- package/3D/controls/holographicButton.js.map +1 -1
- package/3D/controls/holographicSlate.d.ts +131 -128
- package/3D/controls/holographicSlate.js +431 -428
- package/3D/controls/holographicSlate.js.map +1 -1
- package/3D/controls/index.d.ts +21 -21
- package/3D/controls/index.js +21 -21
- package/3D/controls/index.js.map +1 -1
- package/3D/controls/meshButton3D.d.ts +21 -21
- package/3D/controls/meshButton3D.js +62 -61
- package/3D/controls/meshButton3D.js.map +1 -1
- package/3D/controls/nearMenu.d.ts +44 -44
- package/3D/controls/nearMenu.js +114 -112
- package/3D/controls/nearMenu.js.map +1 -1
- package/3D/controls/planePanel.d.ts +9 -9
- package/3D/controls/planePanel.js +36 -36
- package/3D/controls/planePanel.js.map +1 -1
- package/3D/controls/scatterPanel.d.ts +18 -18
- package/3D/controls/scatterPanel.js +108 -108
- package/3D/controls/scatterPanel.js.map +1 -1
- package/3D/controls/slider3D.d.ts +81 -80
- package/3D/controls/slider3D.js +268 -267
- package/3D/controls/slider3D.js.map +1 -1
- package/3D/controls/spherePanel.d.ts +17 -17
- package/3D/controls/spherePanel.js +67 -67
- package/3D/controls/spherePanel.js.map +1 -1
- package/3D/controls/stackPanel3D.d.ts +22 -22
- package/3D/controls/stackPanel3D.js +107 -107
- package/3D/controls/stackPanel3D.js.map +1 -1
- package/3D/controls/touchButton3D.d.ts +80 -75
- package/3D/controls/touchButton3D.js +233 -227
- package/3D/controls/touchButton3D.js.map +1 -1
- package/3D/controls/touchHolographicButton.d.ts +110 -109
- package/3D/controls/touchHolographicButton.js +445 -445
- package/3D/controls/touchHolographicButton.js.map +1 -1
- package/3D/controls/touchHolographicMenu.d.ts +61 -61
- package/3D/controls/touchHolographicMenu.js +149 -148
- package/3D/controls/touchHolographicMenu.js.map +1 -1
- package/3D/controls/touchMeshButton3D.d.ts +21 -22
- package/3D/controls/touchMeshButton3D.js +62 -62
- package/3D/controls/touchMeshButton3D.js.map +1 -1
- package/3D/controls/volumeBasedPanel.d.ts +53 -52
- package/3D/controls/volumeBasedPanel.js +174 -174
- package/3D/controls/volumeBasedPanel.js.map +1 -1
- package/3D/gizmos/gizmoHandle.d.ts +108 -108
- package/3D/gizmos/gizmoHandle.js +209 -209
- package/3D/gizmos/gizmoHandle.js.map +1 -1
- package/3D/gizmos/index.d.ts +2 -2
- package/3D/gizmos/index.js +2 -2
- package/3D/gizmos/index.js.map +1 -1
- package/3D/gizmos/slateGizmo.d.ts +57 -57
- package/3D/gizmos/slateGizmo.js +369 -369
- package/3D/gizmos/slateGizmo.js.map +1 -1
- package/3D/gui3DManager.d.ts +94 -94
- package/3D/gui3DManager.js +257 -257
- package/3D/gui3DManager.js.map +1 -1
- package/3D/index.d.ts +5 -5
- package/3D/index.js +6 -5
- package/3D/index.js.map +1 -1
- package/3D/materials/fluent/fluentMaterial.d.ts +91 -90
- package/3D/materials/fluent/fluentMaterial.js +292 -281
- package/3D/materials/fluent/fluentMaterial.js.map +1 -1
- package/3D/materials/fluent/index.d.ts +1 -1
- package/3D/materials/fluent/index.js +1 -1
- package/3D/materials/fluent/index.js.map +1 -1
- package/3D/materials/fluent/shaders/fluent.fragment.d.ts +5 -5
- package/3D/materials/fluent/shaders/fluent.fragment.js +8 -6
- package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -1
- package/3D/materials/fluent/shaders/fluent.vertex.d.ts +5 -5
- package/3D/materials/fluent/shaders/fluent.vertex.js +8 -6
- package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -1
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +155 -154
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +469 -434
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
- package/3D/materials/fluentBackplate/index.d.ts +1 -1
- package/3D/materials/fluentBackplate/index.js +1 -1
- package/3D/materials/fluentBackplate/index.js.map +1 -1
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -5
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +8 -6
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -1
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -5
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +8 -6
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -1
- package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +190 -189
- package/3D/materials/fluentButton/fluentButtonMaterial.js +539 -537
- package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
- package/3D/materials/fluentButton/index.d.ts +1 -1
- package/3D/materials/fluentButton/index.js +1 -1
- package/3D/materials/fluentButton/index.js.map +1 -1
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -5
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +8 -6
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -1
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -5
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +8 -6
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -1
- package/3D/materials/fluentMaterial.d.ts +4 -4
- package/3D/materials/fluentMaterial.js +4 -4
- package/3D/materials/fluentMaterial.js.map +1 -1
- package/3D/materials/handle/handleMaterial.d.ts +68 -68
- package/3D/materials/handle/handleMaterial.js +126 -126
- package/3D/materials/handle/handleMaterial.js.map +1 -1
- package/3D/materials/handle/index.d.ts +1 -1
- package/3D/materials/handle/index.js +1 -1
- package/3D/materials/handle/index.js.map +1 -1
- package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -5
- package/3D/materials/handle/shaders/handle.fragment.js +8 -6
- package/3D/materials/handle/shaders/handle.fragment.js.map +1 -1
- package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -5
- package/3D/materials/handle/shaders/handle.vertex.js +8 -6
- package/3D/materials/handle/shaders/handle.vertex.js.map +1 -1
- package/3D/materials/index.d.ts +5 -5
- package/3D/materials/index.js +6 -5
- package/3D/materials/index.js.map +1 -1
- package/3D/materials/mrdl/index.d.ts +3 -3
- package/3D/materials/mrdl/index.js +3 -3
- package/3D/materials/mrdl/index.js.map +1 -1
- package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +148 -147
- package/3D/materials/mrdl/mrdlBackplateMaterial.js +436 -409
- package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +334 -333
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js +851 -786
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +334 -333
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +851 -786
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -1
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -5
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +8 -6
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -1
- package/3D/vector3WithInfo.d.ts +16 -16
- package/3D/vector3WithInfo.js +23 -23
- package/3D/vector3WithInfo.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +14 -13
- package/legacy/legacy.js.map +1 -1
- package/package.json +21 -328
- package/readme.md +2 -2
|
@@ -1,1401 +1,1418 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
2
|
-
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
|
-
import { Control } from "./control
|
|
4
|
-
import { InputText } from "./inputText
|
|
5
|
-
import { Rectangle } from "./rectangle
|
|
6
|
-
import { Button } from "./button
|
|
7
|
-
import { Grid } from "./grid
|
|
8
|
-
import { TextBlock } from "../controls/textBlock
|
|
9
|
-
import { RegisterClass } from
|
|
10
|
-
import { Color3 } from
|
|
11
|
-
import { serialize } from
|
|
12
|
-
import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
|
|
13
|
-
/** Class used to create color pickers */
|
|
14
|
-
var ColorPicker = /** @class */ (function (_super) {
|
|
15
|
-
__extends(ColorPicker, _super);
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new ColorPicker
|
|
18
|
-
* @param name defines the control name
|
|
19
|
-
*/
|
|
20
|
-
function ColorPicker(name) {
|
|
21
|
-
var _this = _super.call(this, name) || this;
|
|
22
|
-
_this.name = name;
|
|
23
|
-
_this._value = Color3.Red();
|
|
24
|
-
_this._tmpColor = new Color3();
|
|
25
|
-
_this._pointerStartedOnSquare = false;
|
|
26
|
-
_this._pointerStartedOnWheel = false;
|
|
27
|
-
_this._squareLeft = 0;
|
|
28
|
-
_this._squareTop = 0;
|
|
29
|
-
_this._squareSize = 0;
|
|
30
|
-
_this._h = 360;
|
|
31
|
-
_this._s = 1;
|
|
32
|
-
_this._v = 1;
|
|
33
|
-
_this._lastPointerDownId = -1;
|
|
34
|
-
/**
|
|
35
|
-
* Observable raised when the value changes
|
|
36
|
-
*/
|
|
37
|
-
_this.onValueChangedObservable = new Observable();
|
|
38
|
-
// Events
|
|
39
|
-
_this._pointerIsDown = false;
|
|
40
|
-
_this.value = new Color3(.88, .1, .1);
|
|
41
|
-
_this.size = "200px";
|
|
42
|
-
_this.isPointerBlocker = true;
|
|
43
|
-
return _this;
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(ColorPicker.prototype, "value", {
|
|
46
|
-
/** Gets or sets the color of the color picker */
|
|
47
|
-
get: function () {
|
|
48
|
-
return this._value;
|
|
49
|
-
},
|
|
50
|
-
set: function (value) {
|
|
51
|
-
if (this._value.equals(value)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this._value.copyFrom(value);
|
|
55
|
-
this._value.toHSVToRef(this._tmpColor);
|
|
56
|
-
this._h = this._tmpColor.r;
|
|
57
|
-
this._s = Math.max(this._tmpColor.g, 0.00001);
|
|
58
|
-
this._v = Math.max(this._tmpColor.b, 0.00001);
|
|
59
|
-
this._markAsDirty();
|
|
60
|
-
if (this._value.r <= ColorPicker._Epsilon) {
|
|
61
|
-
this._value.r = 0;
|
|
62
|
-
}
|
|
63
|
-
if (this._value.g <= ColorPicker._Epsilon) {
|
|
64
|
-
this._value.g = 0;
|
|
65
|
-
}
|
|
66
|
-
if (this._value.b <= ColorPicker._Epsilon) {
|
|
67
|
-
this._value.b = 0;
|
|
68
|
-
}
|
|
69
|
-
if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
|
|
70
|
-
this._value.r = 1.0;
|
|
71
|
-
}
|
|
72
|
-
if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
|
|
73
|
-
this._value.g = 1.0;
|
|
74
|
-
}
|
|
75
|
-
if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
|
|
76
|
-
this._value.b = 1.0;
|
|
77
|
-
}
|
|
78
|
-
this.onValueChangedObservable.notifyObservers(this._value);
|
|
79
|
-
},
|
|
80
|
-
enumerable: false,
|
|
81
|
-
configurable: true
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(ColorPicker.prototype, "width", {
|
|
84
|
-
/**
|
|
85
|
-
* Gets or sets control width
|
|
86
|
-
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
87
|
-
*/
|
|
88
|
-
get: function () {
|
|
89
|
-
return this._width.toString(this._host);
|
|
90
|
-
},
|
|
91
|
-
set: function (value) {
|
|
92
|
-
if (this._width.toString(this._host) === value) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (this._width.fromString(value)) {
|
|
96
|
-
if (this._width.getValue(this._host) === 0) {
|
|
97
|
-
value =
|
|
98
|
-
this._width.fromString(value);
|
|
99
|
-
}
|
|
100
|
-
this._height.fromString(value);
|
|
101
|
-
this._markAsDirty();
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
enumerable: false,
|
|
105
|
-
configurable: true
|
|
106
|
-
});
|
|
107
|
-
Object.defineProperty(ColorPicker.prototype, "height", {
|
|
108
|
-
/**
|
|
109
|
-
* Gets or sets control height
|
|
110
|
-
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
111
|
-
*/
|
|
112
|
-
get: function () {
|
|
113
|
-
return this._height.toString(this._host);
|
|
114
|
-
},
|
|
115
|
-
/** Gets or sets control height */
|
|
116
|
-
set: function (value) {
|
|
117
|
-
if (this._height.toString(this._host) === value) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (this._height.fromString(value)) {
|
|
121
|
-
if (this._height.getValue(this._host) === 0) {
|
|
122
|
-
value =
|
|
123
|
-
this._height.fromString(value);
|
|
124
|
-
}
|
|
125
|
-
this._width.fromString(value);
|
|
126
|
-
this._markAsDirty();
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
enumerable: false,
|
|
130
|
-
configurable: true
|
|
131
|
-
});
|
|
132
|
-
Object.defineProperty(ColorPicker.prototype, "size", {
|
|
133
|
-
/** Gets or sets control size */
|
|
134
|
-
get: function () {
|
|
135
|
-
return this.width;
|
|
136
|
-
},
|
|
137
|
-
set: function (value) {
|
|
138
|
-
this.width = value;
|
|
139
|
-
},
|
|
140
|
-
enumerable: false,
|
|
141
|
-
configurable: true
|
|
142
|
-
});
|
|
143
|
-
ColorPicker.prototype._getTypeName = function () {
|
|
144
|
-
return "ColorPicker";
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this._currentMeasure.
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
context.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
context.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
context.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
context.
|
|
182
|
-
context.
|
|
183
|
-
context.
|
|
184
|
-
context.
|
|
185
|
-
context.
|
|
186
|
-
context.
|
|
187
|
-
context.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
var
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
alphaAmount =
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
alphaAmount =
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
data[index + 3] = 255 * (
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
data[index + 3] = 255;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
context.
|
|
269
|
-
context.
|
|
270
|
-
context.
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
this.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
var
|
|
319
|
-
var
|
|
320
|
-
var
|
|
321
|
-
var
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
this.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
this.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
_super.prototype.
|
|
373
|
-
};
|
|
374
|
-
ColorPicker.prototype.
|
|
375
|
-
this.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
*
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
var
|
|
409
|
-
var
|
|
410
|
-
var
|
|
411
|
-
var
|
|
412
|
-
var
|
|
413
|
-
var
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
var
|
|
418
|
-
var
|
|
419
|
-
var
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
var
|
|
423
|
-
var
|
|
424
|
-
var
|
|
425
|
-
|
|
426
|
-
var
|
|
427
|
-
//
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
var
|
|
432
|
-
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
var
|
|
436
|
-
|
|
437
|
-
var
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
var
|
|
441
|
-
var
|
|
442
|
-
var
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (
|
|
748
|
-
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if (activeField ==
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
var
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
});
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
if (
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1
|
+
import { __decorate, __extends } from "tslib";
|
|
2
|
+
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
|
+
import { Control } from "./control";
|
|
4
|
+
import { InputText } from "./inputText";
|
|
5
|
+
import { Rectangle } from "./rectangle";
|
|
6
|
+
import { Button } from "./button";
|
|
7
|
+
import { Grid } from "./grid";
|
|
8
|
+
import { TextBlock } from "../controls/textBlock";
|
|
9
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
10
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
11
|
+
import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
12
|
+
import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
|
|
13
|
+
/** Class used to create color pickers */
|
|
14
|
+
var ColorPicker = /** @class */ (function (_super) {
|
|
15
|
+
__extends(ColorPicker, _super);
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new ColorPicker
|
|
18
|
+
* @param name defines the control name
|
|
19
|
+
*/
|
|
20
|
+
function ColorPicker(name) {
|
|
21
|
+
var _this = _super.call(this, name) || this;
|
|
22
|
+
_this.name = name;
|
|
23
|
+
_this._value = Color3.Red();
|
|
24
|
+
_this._tmpColor = new Color3();
|
|
25
|
+
_this._pointerStartedOnSquare = false;
|
|
26
|
+
_this._pointerStartedOnWheel = false;
|
|
27
|
+
_this._squareLeft = 0;
|
|
28
|
+
_this._squareTop = 0;
|
|
29
|
+
_this._squareSize = 0;
|
|
30
|
+
_this._h = 360;
|
|
31
|
+
_this._s = 1;
|
|
32
|
+
_this._v = 1;
|
|
33
|
+
_this._lastPointerDownId = -1;
|
|
34
|
+
/**
|
|
35
|
+
* Observable raised when the value changes
|
|
36
|
+
*/
|
|
37
|
+
_this.onValueChangedObservable = new Observable();
|
|
38
|
+
// Events
|
|
39
|
+
_this._pointerIsDown = false;
|
|
40
|
+
_this.value = new Color3(0.88, 0.1, 0.1);
|
|
41
|
+
_this.size = "200px";
|
|
42
|
+
_this.isPointerBlocker = true;
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
Object.defineProperty(ColorPicker.prototype, "value", {
|
|
46
|
+
/** Gets or sets the color of the color picker */
|
|
47
|
+
get: function () {
|
|
48
|
+
return this._value;
|
|
49
|
+
},
|
|
50
|
+
set: function (value) {
|
|
51
|
+
if (this._value.equals(value)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this._value.copyFrom(value);
|
|
55
|
+
this._value.toHSVToRef(this._tmpColor);
|
|
56
|
+
this._h = this._tmpColor.r;
|
|
57
|
+
this._s = Math.max(this._tmpColor.g, 0.00001);
|
|
58
|
+
this._v = Math.max(this._tmpColor.b, 0.00001);
|
|
59
|
+
this._markAsDirty();
|
|
60
|
+
if (this._value.r <= ColorPicker._Epsilon) {
|
|
61
|
+
this._value.r = 0;
|
|
62
|
+
}
|
|
63
|
+
if (this._value.g <= ColorPicker._Epsilon) {
|
|
64
|
+
this._value.g = 0;
|
|
65
|
+
}
|
|
66
|
+
if (this._value.b <= ColorPicker._Epsilon) {
|
|
67
|
+
this._value.b = 0;
|
|
68
|
+
}
|
|
69
|
+
if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
|
|
70
|
+
this._value.r = 1.0;
|
|
71
|
+
}
|
|
72
|
+
if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
|
|
73
|
+
this._value.g = 1.0;
|
|
74
|
+
}
|
|
75
|
+
if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
|
|
76
|
+
this._value.b = 1.0;
|
|
77
|
+
}
|
|
78
|
+
this.onValueChangedObservable.notifyObservers(this._value);
|
|
79
|
+
},
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(ColorPicker.prototype, "width", {
|
|
84
|
+
/**
|
|
85
|
+
* Gets or sets control width
|
|
86
|
+
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
87
|
+
*/
|
|
88
|
+
get: function () {
|
|
89
|
+
return this._width.toString(this._host);
|
|
90
|
+
},
|
|
91
|
+
set: function (value) {
|
|
92
|
+
if (this._width.toString(this._host) === value) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (this._width.fromString(value)) {
|
|
96
|
+
if (this._width.getValue(this._host) === 0) {
|
|
97
|
+
value = "1px";
|
|
98
|
+
this._width.fromString(value);
|
|
99
|
+
}
|
|
100
|
+
this._height.fromString(value);
|
|
101
|
+
this._markAsDirty();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(ColorPicker.prototype, "height", {
|
|
108
|
+
/**
|
|
109
|
+
* Gets or sets control height
|
|
110
|
+
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
111
|
+
*/
|
|
112
|
+
get: function () {
|
|
113
|
+
return this._height.toString(this._host);
|
|
114
|
+
},
|
|
115
|
+
/** Gets or sets control height */
|
|
116
|
+
set: function (value) {
|
|
117
|
+
if (this._height.toString(this._host) === value) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (this._height.fromString(value)) {
|
|
121
|
+
if (this._height.getValue(this._host) === 0) {
|
|
122
|
+
value = "1px";
|
|
123
|
+
this._height.fromString(value);
|
|
124
|
+
}
|
|
125
|
+
this._width.fromString(value);
|
|
126
|
+
this._markAsDirty();
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
enumerable: false,
|
|
130
|
+
configurable: true
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(ColorPicker.prototype, "size", {
|
|
133
|
+
/** Gets or sets control size */
|
|
134
|
+
get: function () {
|
|
135
|
+
return this.width;
|
|
136
|
+
},
|
|
137
|
+
set: function (value) {
|
|
138
|
+
this.width = value;
|
|
139
|
+
},
|
|
140
|
+
enumerable: false,
|
|
141
|
+
configurable: true
|
|
142
|
+
});
|
|
143
|
+
ColorPicker.prototype._getTypeName = function () {
|
|
144
|
+
return "ColorPicker";
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* @param parentMeasure
|
|
148
|
+
* @hidden
|
|
149
|
+
*/
|
|
150
|
+
ColorPicker.prototype._preMeasure = function (parentMeasure) {
|
|
151
|
+
if (parentMeasure.width < parentMeasure.height) {
|
|
152
|
+
this._currentMeasure.height = parentMeasure.width;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this._currentMeasure.width = parentMeasure.height;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
ColorPicker.prototype._updateSquareProps = function () {
|
|
159
|
+
var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * 0.5;
|
|
160
|
+
var wheelThickness = radius * 0.2;
|
|
161
|
+
var innerDiameter = (radius - wheelThickness) * 2;
|
|
162
|
+
var squareSize = innerDiameter / Math.sqrt(2);
|
|
163
|
+
var offset = radius - squareSize * 0.5;
|
|
164
|
+
this._squareLeft = this._currentMeasure.left + offset;
|
|
165
|
+
this._squareTop = this._currentMeasure.top + offset;
|
|
166
|
+
this._squareSize = squareSize;
|
|
167
|
+
};
|
|
168
|
+
ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
|
|
169
|
+
var lgh = context.createLinearGradient(left, top, width + left, top);
|
|
170
|
+
lgh.addColorStop(0, "#fff");
|
|
171
|
+
lgh.addColorStop(1, "hsl(" + hueValue + ", 100%, 50%)");
|
|
172
|
+
context.fillStyle = lgh;
|
|
173
|
+
context.fillRect(left, top, width, height);
|
|
174
|
+
var lgv = context.createLinearGradient(left, top, left, height + top);
|
|
175
|
+
lgv.addColorStop(0, "rgba(0,0,0,0)");
|
|
176
|
+
lgv.addColorStop(1, "#000");
|
|
177
|
+
context.fillStyle = lgv;
|
|
178
|
+
context.fillRect(left, top, width, height);
|
|
179
|
+
};
|
|
180
|
+
ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
|
|
181
|
+
context.beginPath();
|
|
182
|
+
context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
|
|
183
|
+
context.lineWidth = 3;
|
|
184
|
+
context.strokeStyle = "#333333";
|
|
185
|
+
context.stroke();
|
|
186
|
+
context.beginPath();
|
|
187
|
+
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
|
|
188
|
+
context.lineWidth = 3;
|
|
189
|
+
context.strokeStyle = "#ffffff";
|
|
190
|
+
context.stroke();
|
|
191
|
+
};
|
|
192
|
+
ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
|
|
193
|
+
// Shoudl abstract platform instead of using LastCreatedEngine
|
|
194
|
+
var engine = EngineStore.LastCreatedEngine;
|
|
195
|
+
if (!engine) {
|
|
196
|
+
throw new Error("Invalid engine. Unable to create a canvas.");
|
|
197
|
+
}
|
|
198
|
+
var canvas = engine.createCanvas(radius * 2, radius * 2);
|
|
199
|
+
var context = canvas.getContext("2d");
|
|
200
|
+
var image = context.getImageData(0, 0, radius * 2, radius * 2);
|
|
201
|
+
var data = image.data;
|
|
202
|
+
var color = this._tmpColor;
|
|
203
|
+
var maxDistSq = radius * radius;
|
|
204
|
+
var innerRadius = radius - thickness;
|
|
205
|
+
var minDistSq = innerRadius * innerRadius;
|
|
206
|
+
for (var x = -radius; x < radius; x++) {
|
|
207
|
+
for (var y = -radius; y < radius; y++) {
|
|
208
|
+
var distSq = x * x + y * y;
|
|
209
|
+
if (distSq > maxDistSq || distSq < minDistSq) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
var dist = Math.sqrt(distSq);
|
|
213
|
+
var ang = Math.atan2(y, x);
|
|
214
|
+
Color3.HSVtoRGBToRef((ang * 180) / Math.PI + 180, dist / radius, 1, color);
|
|
215
|
+
var index = (x + radius + (y + radius) * 2 * radius) * 4;
|
|
216
|
+
data[index] = color.r * 255;
|
|
217
|
+
data[index + 1] = color.g * 255;
|
|
218
|
+
data[index + 2] = color.b * 255;
|
|
219
|
+
var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
|
|
220
|
+
//apply less alpha to bigger color pickers
|
|
221
|
+
var alphaAmount = 0.2;
|
|
222
|
+
var maxAlpha = 0.2;
|
|
223
|
+
var minAlpha = 0.04;
|
|
224
|
+
var lowerRadius = 50;
|
|
225
|
+
var upperRadius = 150;
|
|
226
|
+
if (radius < lowerRadius) {
|
|
227
|
+
alphaAmount = maxAlpha;
|
|
228
|
+
}
|
|
229
|
+
else if (radius > upperRadius) {
|
|
230
|
+
alphaAmount = minAlpha;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
alphaAmount = ((minAlpha - maxAlpha) * (radius - lowerRadius)) / (upperRadius - lowerRadius) + maxAlpha;
|
|
234
|
+
}
|
|
235
|
+
alphaRatio = (dist - innerRadius) / (radius - innerRadius);
|
|
236
|
+
if (alphaRatio < alphaAmount) {
|
|
237
|
+
data[index + 3] = 255 * (alphaRatio / alphaAmount);
|
|
238
|
+
}
|
|
239
|
+
else if (alphaRatio > 1 - alphaAmount) {
|
|
240
|
+
data[index + 3] = 255 * (1.0 - (alphaRatio - (1 - alphaAmount)) / alphaAmount);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
data[index + 3] = 255;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
context.putImageData(image, 0, 0);
|
|
248
|
+
return canvas;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* @param context
|
|
252
|
+
* @hidden
|
|
253
|
+
*/
|
|
254
|
+
ColorPicker.prototype._draw = function (context) {
|
|
255
|
+
context.save();
|
|
256
|
+
this._applyStates(context);
|
|
257
|
+
var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * 0.5;
|
|
258
|
+
var wheelThickness = radius * 0.2;
|
|
259
|
+
var left = this._currentMeasure.left;
|
|
260
|
+
var top = this._currentMeasure.top;
|
|
261
|
+
if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
|
|
262
|
+
this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
|
|
263
|
+
}
|
|
264
|
+
this._updateSquareProps();
|
|
265
|
+
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
266
|
+
context.shadowColor = this.shadowColor;
|
|
267
|
+
context.shadowBlur = this.shadowBlur;
|
|
268
|
+
context.shadowOffsetX = this.shadowOffsetX;
|
|
269
|
+
context.shadowOffsetY = this.shadowOffsetY;
|
|
270
|
+
context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
|
|
271
|
+
}
|
|
272
|
+
context.drawImage(this._colorWheelCanvas, left, top);
|
|
273
|
+
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
274
|
+
context.shadowBlur = 0;
|
|
275
|
+
context.shadowOffsetX = 0;
|
|
276
|
+
context.shadowOffsetY = 0;
|
|
277
|
+
}
|
|
278
|
+
this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
|
|
279
|
+
var cx = this._squareLeft + this._squareSize * this._s;
|
|
280
|
+
var cy = this._squareTop + this._squareSize * (1 - this._v);
|
|
281
|
+
this._drawCircle(cx, cy, radius * 0.04, context);
|
|
282
|
+
var dist = radius - wheelThickness * 0.5;
|
|
283
|
+
cx = left + radius + Math.cos(((this._h - 180) * Math.PI) / 180) * dist;
|
|
284
|
+
cy = top + radius + Math.sin(((this._h - 180) * Math.PI) / 180) * dist;
|
|
285
|
+
this._drawCircle(cx, cy, wheelThickness * 0.35, context);
|
|
286
|
+
context.restore();
|
|
287
|
+
};
|
|
288
|
+
ColorPicker.prototype._updateValueFromPointer = function (x, y) {
|
|
289
|
+
if (this._pointerStartedOnWheel) {
|
|
290
|
+
var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * 0.5;
|
|
291
|
+
var centerX = radius + this._currentMeasure.left;
|
|
292
|
+
var centerY = radius + this._currentMeasure.top;
|
|
293
|
+
this._h = (Math.atan2(y - centerY, x - centerX) * 180) / Math.PI + 180;
|
|
294
|
+
}
|
|
295
|
+
else if (this._pointerStartedOnSquare) {
|
|
296
|
+
this._updateSquareProps();
|
|
297
|
+
this._s = (x - this._squareLeft) / this._squareSize;
|
|
298
|
+
this._v = 1 - (y - this._squareTop) / this._squareSize;
|
|
299
|
+
this._s = Math.min(this._s, 1);
|
|
300
|
+
this._s = Math.max(this._s, ColorPicker._Epsilon);
|
|
301
|
+
this._v = Math.min(this._v, 1);
|
|
302
|
+
this._v = Math.max(this._v, ColorPicker._Epsilon);
|
|
303
|
+
}
|
|
304
|
+
Color3.HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
|
|
305
|
+
this.value = this._tmpColor;
|
|
306
|
+
};
|
|
307
|
+
ColorPicker.prototype._isPointOnSquare = function (x, y) {
|
|
308
|
+
this._updateSquareProps();
|
|
309
|
+
var left = this._squareLeft;
|
|
310
|
+
var top = this._squareTop;
|
|
311
|
+
var size = this._squareSize;
|
|
312
|
+
if (x >= left && x <= left + size && y >= top && y <= top + size) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
return false;
|
|
316
|
+
};
|
|
317
|
+
ColorPicker.prototype._isPointOnWheel = function (x, y) {
|
|
318
|
+
var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * 0.5;
|
|
319
|
+
var centerX = radius + this._currentMeasure.left;
|
|
320
|
+
var centerY = radius + this._currentMeasure.top;
|
|
321
|
+
var wheelThickness = radius * 0.2;
|
|
322
|
+
var innerRadius = radius - wheelThickness;
|
|
323
|
+
var radiusSq = radius * radius;
|
|
324
|
+
var innerRadiusSq = innerRadius * innerRadius;
|
|
325
|
+
var dx = x - centerX;
|
|
326
|
+
var dy = y - centerY;
|
|
327
|
+
var distSq = dx * dx + dy * dy;
|
|
328
|
+
if (distSq <= radiusSq && distSq >= innerRadiusSq) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
};
|
|
333
|
+
ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
|
|
334
|
+
if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
if (this.isReadOnly) {
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
this._pointerIsDown = true;
|
|
341
|
+
this._pointerStartedOnSquare = false;
|
|
342
|
+
this._pointerStartedOnWheel = false;
|
|
343
|
+
// Invert transform
|
|
344
|
+
this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
|
|
345
|
+
var x = this._transformedPosition.x;
|
|
346
|
+
var y = this._transformedPosition.y;
|
|
347
|
+
if (this._isPointOnSquare(x, y)) {
|
|
348
|
+
this._pointerStartedOnSquare = true;
|
|
349
|
+
}
|
|
350
|
+
else if (this._isPointOnWheel(x, y)) {
|
|
351
|
+
this._pointerStartedOnWheel = true;
|
|
352
|
+
}
|
|
353
|
+
this._updateValueFromPointer(x, y);
|
|
354
|
+
this._host._capturingControl[pointerId] = this;
|
|
355
|
+
this._lastPointerDownId = pointerId;
|
|
356
|
+
return true;
|
|
357
|
+
};
|
|
358
|
+
ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
|
|
359
|
+
// Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
|
|
360
|
+
if (pointerId != this._lastPointerDownId) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (!this.isReadOnly) {
|
|
364
|
+
// Invert transform
|
|
365
|
+
this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
|
|
366
|
+
var x = this._transformedPosition.x;
|
|
367
|
+
var y = this._transformedPosition.y;
|
|
368
|
+
if (this._pointerIsDown) {
|
|
369
|
+
this._updateValueFromPointer(x, y);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
_super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
|
|
373
|
+
};
|
|
374
|
+
ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
|
|
375
|
+
this._pointerIsDown = false;
|
|
376
|
+
delete this._host._capturingControl[pointerId];
|
|
377
|
+
_super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
|
|
378
|
+
};
|
|
379
|
+
ColorPicker.prototype._onCanvasBlur = function () {
|
|
380
|
+
this._forcePointerUp();
|
|
381
|
+
_super.prototype._onCanvasBlur.call(this);
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* This function expands the color picker by creating a color picker dialog with manual
|
|
385
|
+
* color value input and the ability to save colors into an array to be used later in
|
|
386
|
+
* subsequent launches of the dialogue.
|
|
387
|
+
* @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
|
|
388
|
+
* @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
|
|
389
|
+
* @param options.pickerWidth
|
|
390
|
+
* @param options.pickerHeight
|
|
391
|
+
* @param options.headerHeight
|
|
392
|
+
* @param options.lastColor
|
|
393
|
+
* @param options.swatchLimit
|
|
394
|
+
* @param options.numSwatchesPerLine
|
|
395
|
+
* @param options.savedColors
|
|
396
|
+
* @returns picked color as a hex string and the saved colors array as hex strings.
|
|
397
|
+
*/
|
|
398
|
+
ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
|
|
399
|
+
return new Promise(function (resolve) {
|
|
400
|
+
// Default options
|
|
401
|
+
options.pickerWidth = options.pickerWidth || "640px";
|
|
402
|
+
options.pickerHeight = options.pickerHeight || "400px";
|
|
403
|
+
options.headerHeight = options.headerHeight || "35px";
|
|
404
|
+
options.lastColor = options.lastColor || "#000000";
|
|
405
|
+
options.swatchLimit = options.swatchLimit || 20;
|
|
406
|
+
options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
|
|
407
|
+
// Window size settings
|
|
408
|
+
var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
|
|
409
|
+
var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
|
|
410
|
+
var gutterSize = Math.floor(rawSwatchSize * 0.25);
|
|
411
|
+
var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
|
|
412
|
+
var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
|
|
413
|
+
var drawerMaxSize = swatchSize * drawerMaxRows + gutterSize * (drawerMaxRows + 1);
|
|
414
|
+
var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
|
|
415
|
+
// Button Colors
|
|
416
|
+
var buttonColor = "#c0c0c0";
|
|
417
|
+
var buttonBackgroundColor = "#535353";
|
|
418
|
+
var buttonBackgroundHoverColor = "#414141";
|
|
419
|
+
var buttonBackgroundClickColor = "515151";
|
|
420
|
+
var buttonDisabledColor = "#555555";
|
|
421
|
+
var buttonDisabledBackgroundColor = "#454545";
|
|
422
|
+
var currentSwatchesOutlineColor = "#404040";
|
|
423
|
+
var luminanceLimitColor = Color3.FromHexString("#dddddd");
|
|
424
|
+
var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
|
|
425
|
+
var iconColorDark = "#aaaaaa";
|
|
426
|
+
var iconColorLight = "#ffffff";
|
|
427
|
+
// Button settings
|
|
428
|
+
var buttonFontSize;
|
|
429
|
+
var butEdit;
|
|
430
|
+
// Input Text Colors
|
|
431
|
+
var inputFieldLabels = ["R", "G", "B"];
|
|
432
|
+
var inputTextBackgroundColor = "#454545";
|
|
433
|
+
var inputTextColor = "#f0f0f0";
|
|
434
|
+
// This int is used for naming swatches and serves as the index for calling them from the list
|
|
435
|
+
var swatchNumber;
|
|
436
|
+
// Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
|
|
437
|
+
var swatchDrawer;
|
|
438
|
+
var editSwatchMode = false;
|
|
439
|
+
// Color InputText fields that will be updated upon value change
|
|
440
|
+
var butSave;
|
|
441
|
+
var lastVal;
|
|
442
|
+
var activeField;
|
|
443
|
+
// Dialog menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
|
|
444
|
+
var dialogContainer = new Grid();
|
|
445
|
+
dialogContainer.name = "Dialog Container";
|
|
446
|
+
dialogContainer.width = options.pickerWidth;
|
|
447
|
+
if (options.savedColors) {
|
|
448
|
+
dialogContainer.height = containerSize;
|
|
449
|
+
var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
|
|
450
|
+
dialogContainer.addRowDefinition(topRow, false);
|
|
451
|
+
dialogContainer.addRowDefinition(1.0 - topRow, false);
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
dialogContainer.height = options.pickerHeight;
|
|
455
|
+
dialogContainer.addRowDefinition(1.0, false);
|
|
456
|
+
}
|
|
457
|
+
advancedTexture.addControl(dialogContainer);
|
|
458
|
+
// Swatch drawer which contains all saved color buttons
|
|
459
|
+
if (options.savedColors) {
|
|
460
|
+
swatchDrawer = new Grid();
|
|
461
|
+
swatchDrawer.name = "Swatch Drawer";
|
|
462
|
+
swatchDrawer.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
|
|
463
|
+
swatchDrawer.background = buttonBackgroundColor;
|
|
464
|
+
swatchDrawer.width = options.pickerWidth;
|
|
465
|
+
var initialRows = options.savedColors.length / options.numSwatchesPerLine;
|
|
466
|
+
var gutterCount = void 0;
|
|
467
|
+
if (initialRows == 0) {
|
|
468
|
+
gutterCount = 0;
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
gutterCount = initialRows + 1;
|
|
472
|
+
}
|
|
473
|
+
swatchDrawer.height = (swatchSize * initialRows + gutterCount * gutterSize).toString() + "px";
|
|
474
|
+
swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
|
|
475
|
+
for (var i = 0; i < Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2 + 1; i++) {
|
|
476
|
+
if (i % 2 != 0) {
|
|
477
|
+
swatchDrawer.addRowDefinition(swatchSize, true);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
swatchDrawer.addRowDefinition(gutterSize, true);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
|
|
484
|
+
if (i % 2 != 0) {
|
|
485
|
+
swatchDrawer.addColumnDefinition(swatchSize, true);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
swatchDrawer.addColumnDefinition(gutterSize, true);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
dialogContainer.addControl(swatchDrawer, 1, 0);
|
|
492
|
+
}
|
|
493
|
+
// Picker container
|
|
494
|
+
var pickerPanel = new Grid();
|
|
495
|
+
pickerPanel.name = "Picker Panel";
|
|
496
|
+
pickerPanel.height = options.pickerHeight;
|
|
497
|
+
var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
|
|
498
|
+
var pickerPanelRows = [panelHead, 1.0 - panelHead];
|
|
499
|
+
pickerPanel.addRowDefinition(pickerPanelRows[0], false);
|
|
500
|
+
pickerPanel.addRowDefinition(pickerPanelRows[1], false);
|
|
501
|
+
dialogContainer.addControl(pickerPanel, 0, 0);
|
|
502
|
+
// Picker container header
|
|
503
|
+
var header = new Rectangle();
|
|
504
|
+
header.name = "Dialogue Header Bar";
|
|
505
|
+
header.background = "#cccccc";
|
|
506
|
+
header.thickness = 0;
|
|
507
|
+
pickerPanel.addControl(header, 0, 0);
|
|
508
|
+
// Header close button
|
|
509
|
+
var closeButton = Button.CreateSimpleButton("closeButton", "a");
|
|
510
|
+
closeButton.fontFamily = "coreglyphs";
|
|
511
|
+
var headerColor3 = Color3.FromHexString(header.background);
|
|
512
|
+
var closeIconColor = new Color3(1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
|
|
513
|
+
closeButton.color = closeIconColor.toHexString();
|
|
514
|
+
closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
|
|
515
|
+
closeButton.textBlock.textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
516
|
+
closeButton.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_RIGHT;
|
|
517
|
+
closeButton.height = closeButton.width = options.headerHeight;
|
|
518
|
+
closeButton.background = header.background;
|
|
519
|
+
closeButton.thickness = 0;
|
|
520
|
+
closeButton.pointerDownAnimation = function () { };
|
|
521
|
+
closeButton.pointerUpAnimation = function () {
|
|
522
|
+
closeButton.background = header.background;
|
|
523
|
+
};
|
|
524
|
+
closeButton.pointerEnterAnimation = function () {
|
|
525
|
+
closeButton.color = header.background;
|
|
526
|
+
closeButton.background = "red";
|
|
527
|
+
};
|
|
528
|
+
closeButton.pointerOutAnimation = function () {
|
|
529
|
+
closeButton.color = closeIconColor.toHexString();
|
|
530
|
+
closeButton.background = header.background;
|
|
531
|
+
};
|
|
532
|
+
closeButton.onPointerClickObservable.add(function () {
|
|
533
|
+
closePicker(currentSwatch.background);
|
|
534
|
+
});
|
|
535
|
+
pickerPanel.addControl(closeButton, 0, 0);
|
|
536
|
+
// Dialog container body
|
|
537
|
+
var dialogBody = new Grid();
|
|
538
|
+
dialogBody.name = "Dialogue Body";
|
|
539
|
+
dialogBody.background = buttonBackgroundColor;
|
|
540
|
+
var dialogBodyCols = [0.4375, 0.5625];
|
|
541
|
+
dialogBody.addRowDefinition(1.0, false);
|
|
542
|
+
dialogBody.addColumnDefinition(dialogBodyCols[0], false);
|
|
543
|
+
dialogBody.addColumnDefinition(dialogBodyCols[1], false);
|
|
544
|
+
pickerPanel.addControl(dialogBody, 1, 0);
|
|
545
|
+
// Picker grid
|
|
546
|
+
var pickerGrid = new Grid();
|
|
547
|
+
pickerGrid.name = "Picker Grid";
|
|
548
|
+
pickerGrid.addRowDefinition(0.85, false);
|
|
549
|
+
pickerGrid.addRowDefinition(0.15, false);
|
|
550
|
+
dialogBody.addControl(pickerGrid, 0, 0);
|
|
551
|
+
// Picker control
|
|
552
|
+
var picker = new ColorPicker();
|
|
553
|
+
picker.name = "GUI Color Picker";
|
|
554
|
+
if (options.pickerHeight < options.pickerWidth) {
|
|
555
|
+
picker.width = 0.89;
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
picker.height = 0.89;
|
|
559
|
+
}
|
|
560
|
+
picker.value = Color3.FromHexString(options.lastColor);
|
|
561
|
+
picker.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
|
|
562
|
+
picker.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
563
|
+
picker.onPointerDownObservable.add(function () {
|
|
564
|
+
activeField = picker.name;
|
|
565
|
+
lastVal = "";
|
|
566
|
+
editSwatches(false);
|
|
567
|
+
});
|
|
568
|
+
picker.onValueChangedObservable.add(function (value) {
|
|
569
|
+
// value is a color3
|
|
570
|
+
if (activeField == picker.name) {
|
|
571
|
+
updateValues(value, picker.name);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
pickerGrid.addControl(picker, 0, 0);
|
|
575
|
+
// Picker body right quarant
|
|
576
|
+
var pickerBodyRight = new Grid();
|
|
577
|
+
pickerBodyRight.name = "Dialogue Right Half";
|
|
578
|
+
pickerBodyRight.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
|
|
579
|
+
var pickerBodyRightRows = [0.514, 0.486];
|
|
580
|
+
pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
|
|
581
|
+
pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
|
|
582
|
+
dialogBody.addControl(pickerBodyRight, 1, 1);
|
|
583
|
+
// Picker container swatches and buttons
|
|
584
|
+
var pickerSwatchesButtons = new Grid();
|
|
585
|
+
pickerSwatchesButtons.name = "Swatches and Buttons";
|
|
586
|
+
var pickerButtonsCol = [0.417, 0.583];
|
|
587
|
+
pickerSwatchesButtons.addRowDefinition(1.0, false);
|
|
588
|
+
pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
|
|
589
|
+
pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
|
|
590
|
+
pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
|
|
591
|
+
// Picker Swatches quadrant
|
|
592
|
+
var pickerSwatches = new Grid();
|
|
593
|
+
pickerSwatches.name = "New and Current Swatches";
|
|
594
|
+
var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
|
|
595
|
+
pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
|
|
596
|
+
pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
|
|
597
|
+
pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
|
|
598
|
+
pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
|
|
599
|
+
pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
|
|
600
|
+
// Active swatches
|
|
601
|
+
var activeSwatches = new Grid();
|
|
602
|
+
activeSwatches.name = "Active Swatches";
|
|
603
|
+
activeSwatches.width = 0.67;
|
|
604
|
+
activeSwatches.addRowDefinition(0.5, false);
|
|
605
|
+
activeSwatches.addRowDefinition(0.5, false);
|
|
606
|
+
pickerSwatches.addControl(activeSwatches, 2, 0);
|
|
607
|
+
var labelWidth = Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11);
|
|
608
|
+
var labelHeight = Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5);
|
|
609
|
+
var labelTextSize;
|
|
610
|
+
if (options.pickerWidth > options.pickerHeight) {
|
|
611
|
+
labelTextSize = labelHeight;
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
labelTextSize = labelWidth;
|
|
615
|
+
}
|
|
616
|
+
// New color swatch and previous color button
|
|
617
|
+
var newText = new TextBlock();
|
|
618
|
+
newText.text = "new";
|
|
619
|
+
newText.name = "New Color Label";
|
|
620
|
+
newText.color = buttonColor;
|
|
621
|
+
newText.fontSize = labelTextSize;
|
|
622
|
+
pickerSwatches.addControl(newText, 1, 0);
|
|
623
|
+
var newSwatch = new Rectangle();
|
|
624
|
+
newSwatch.name = "New Color Swatch";
|
|
625
|
+
newSwatch.background = options.lastColor;
|
|
626
|
+
newSwatch.thickness = 0;
|
|
627
|
+
activeSwatches.addControl(newSwatch, 0, 0);
|
|
628
|
+
var currentSwatch = Button.CreateSimpleButton("currentSwatch", "");
|
|
629
|
+
currentSwatch.background = options.lastColor;
|
|
630
|
+
currentSwatch.thickness = 0;
|
|
631
|
+
currentSwatch.onPointerClickObservable.add(function () {
|
|
632
|
+
var revertColor = Color3.FromHexString(currentSwatch.background);
|
|
633
|
+
updateValues(revertColor, currentSwatch.name);
|
|
634
|
+
editSwatches(false);
|
|
635
|
+
});
|
|
636
|
+
currentSwatch.pointerDownAnimation = function () { };
|
|
637
|
+
currentSwatch.pointerUpAnimation = function () { };
|
|
638
|
+
currentSwatch.pointerEnterAnimation = function () { };
|
|
639
|
+
currentSwatch.pointerOutAnimation = function () { };
|
|
640
|
+
activeSwatches.addControl(currentSwatch, 1, 0);
|
|
641
|
+
var swatchOutline = new Rectangle();
|
|
642
|
+
swatchOutline.name = "Swatch Outline";
|
|
643
|
+
swatchOutline.width = 0.67;
|
|
644
|
+
swatchOutline.thickness = 2;
|
|
645
|
+
swatchOutline.color = currentSwatchesOutlineColor;
|
|
646
|
+
swatchOutline.isHitTestVisible = false;
|
|
647
|
+
pickerSwatches.addControl(swatchOutline, 2, 0);
|
|
648
|
+
var currentText = new TextBlock();
|
|
649
|
+
currentText.name = "Current Color Label";
|
|
650
|
+
currentText.text = "current";
|
|
651
|
+
currentText.color = buttonColor;
|
|
652
|
+
currentText.fontSize = labelTextSize;
|
|
653
|
+
pickerSwatches.addControl(currentText, 3, 0);
|
|
654
|
+
// Buttons grid
|
|
655
|
+
var buttonGrid = new Grid();
|
|
656
|
+
buttonGrid.name = "Button Grid";
|
|
657
|
+
buttonGrid.height = 0.8;
|
|
658
|
+
var buttonGridRows = 1 / 3;
|
|
659
|
+
buttonGrid.addRowDefinition(buttonGridRows, false);
|
|
660
|
+
buttonGrid.addRowDefinition(buttonGridRows, false);
|
|
661
|
+
buttonGrid.addRowDefinition(buttonGridRows, false);
|
|
662
|
+
pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
|
|
663
|
+
// Determine pixel width and height for all buttons from overall panel dimensions
|
|
664
|
+
var buttonWidth = Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67).toString() + "px";
|
|
665
|
+
var buttonHeight = Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7).toString() + "px";
|
|
666
|
+
// Determine button type size
|
|
667
|
+
if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
|
|
668
|
+
buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
|
|
672
|
+
}
|
|
673
|
+
// Panel Buttons
|
|
674
|
+
var butOK = Button.CreateSimpleButton("butOK", "OK");
|
|
675
|
+
butOK.width = buttonWidth;
|
|
676
|
+
butOK.height = buttonHeight;
|
|
677
|
+
butOK.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
678
|
+
butOK.thickness = 2;
|
|
679
|
+
butOK.color = buttonColor;
|
|
680
|
+
butOK.fontSize = buttonFontSize;
|
|
681
|
+
butOK.background = buttonBackgroundColor;
|
|
682
|
+
butOK.onPointerEnterObservable.add(function () {
|
|
683
|
+
butOK.background = buttonBackgroundHoverColor;
|
|
684
|
+
});
|
|
685
|
+
butOK.onPointerOutObservable.add(function () {
|
|
686
|
+
butOK.background = buttonBackgroundColor;
|
|
687
|
+
});
|
|
688
|
+
butOK.pointerDownAnimation = function () {
|
|
689
|
+
butOK.background = buttonBackgroundClickColor;
|
|
690
|
+
};
|
|
691
|
+
butOK.pointerUpAnimation = function () {
|
|
692
|
+
butOK.background = buttonBackgroundHoverColor;
|
|
693
|
+
};
|
|
694
|
+
butOK.onPointerClickObservable.add(function () {
|
|
695
|
+
editSwatches(false);
|
|
696
|
+
closePicker(newSwatch.background);
|
|
697
|
+
});
|
|
698
|
+
buttonGrid.addControl(butOK, 0, 0);
|
|
699
|
+
var butCancel = Button.CreateSimpleButton("butCancel", "Cancel");
|
|
700
|
+
butCancel.width = buttonWidth;
|
|
701
|
+
butCancel.height = buttonHeight;
|
|
702
|
+
butCancel.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
703
|
+
butCancel.thickness = 2;
|
|
704
|
+
butCancel.color = buttonColor;
|
|
705
|
+
butCancel.fontSize = buttonFontSize;
|
|
706
|
+
butCancel.background = buttonBackgroundColor;
|
|
707
|
+
butCancel.onPointerEnterObservable.add(function () {
|
|
708
|
+
butCancel.background = buttonBackgroundHoverColor;
|
|
709
|
+
});
|
|
710
|
+
butCancel.onPointerOutObservable.add(function () {
|
|
711
|
+
butCancel.background = buttonBackgroundColor;
|
|
712
|
+
});
|
|
713
|
+
butCancel.pointerDownAnimation = function () {
|
|
714
|
+
butCancel.background = buttonBackgroundClickColor;
|
|
715
|
+
};
|
|
716
|
+
butCancel.pointerUpAnimation = function () {
|
|
717
|
+
butCancel.background = buttonBackgroundHoverColor;
|
|
718
|
+
};
|
|
719
|
+
butCancel.onPointerClickObservable.add(function () {
|
|
720
|
+
editSwatches(false);
|
|
721
|
+
closePicker(currentSwatch.background);
|
|
722
|
+
});
|
|
723
|
+
buttonGrid.addControl(butCancel, 1, 0);
|
|
724
|
+
if (options.savedColors) {
|
|
725
|
+
butSave = Button.CreateSimpleButton("butSave", "Save");
|
|
726
|
+
butSave.width = buttonWidth;
|
|
727
|
+
butSave.height = buttonHeight;
|
|
728
|
+
butSave.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
729
|
+
butSave.thickness = 2;
|
|
730
|
+
butSave.fontSize = buttonFontSize;
|
|
731
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
732
|
+
butSave.color = buttonColor;
|
|
733
|
+
butSave.background = buttonBackgroundColor;
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
disableButton(butSave, true);
|
|
737
|
+
}
|
|
738
|
+
butSave.onPointerEnterObservable.add(function () {
|
|
739
|
+
if (options.savedColors) {
|
|
740
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
741
|
+
butSave.background = buttonBackgroundHoverColor;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
butSave.onPointerOutObservable.add(function () {
|
|
746
|
+
if (options.savedColors) {
|
|
747
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
748
|
+
butSave.background = buttonBackgroundColor;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
butSave.pointerDownAnimation = function () {
|
|
753
|
+
if (options.savedColors) {
|
|
754
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
755
|
+
butSave.background = buttonBackgroundClickColor;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
butSave.pointerUpAnimation = function () {
|
|
760
|
+
if (options.savedColors) {
|
|
761
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
762
|
+
butSave.background = buttonBackgroundHoverColor;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
butSave.onPointerClickObservable.add(function () {
|
|
767
|
+
if (options.savedColors) {
|
|
768
|
+
if (options.savedColors.length == 0) {
|
|
769
|
+
setEditButtonVisibility(true);
|
|
770
|
+
}
|
|
771
|
+
if (options.savedColors.length < options.swatchLimit) {
|
|
772
|
+
updateSwatches(newSwatch.background, butSave);
|
|
773
|
+
}
|
|
774
|
+
editSwatches(false);
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
if (options.savedColors.length > 0) {
|
|
778
|
+
setEditButtonVisibility(true);
|
|
779
|
+
}
|
|
780
|
+
buttonGrid.addControl(butSave, 2, 0);
|
|
781
|
+
}
|
|
782
|
+
// Picker color values input
|
|
783
|
+
var pickerColorValues = new Grid();
|
|
784
|
+
pickerColorValues.name = "Dialog Lower Right";
|
|
785
|
+
pickerColorValues.addRowDefinition(0.02, false);
|
|
786
|
+
pickerColorValues.addRowDefinition(0.63, false);
|
|
787
|
+
pickerColorValues.addRowDefinition(0.21, false);
|
|
788
|
+
pickerColorValues.addRowDefinition(0.14, false);
|
|
789
|
+
pickerBodyRight.addControl(pickerColorValues, 1, 0);
|
|
790
|
+
// RGB values text boxes
|
|
791
|
+
var currentColor = Color3.FromHexString(options.lastColor);
|
|
792
|
+
var rgbValuesQuadrant = new Grid();
|
|
793
|
+
rgbValuesQuadrant.name = "RGB Values";
|
|
794
|
+
rgbValuesQuadrant.width = 0.82;
|
|
795
|
+
rgbValuesQuadrant.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
796
|
+
rgbValuesQuadrant.addRowDefinition(1 / 3, false);
|
|
797
|
+
rgbValuesQuadrant.addRowDefinition(1 / 3, false);
|
|
798
|
+
rgbValuesQuadrant.addRowDefinition(1 / 3, false);
|
|
799
|
+
rgbValuesQuadrant.addColumnDefinition(0.1, false);
|
|
800
|
+
rgbValuesQuadrant.addColumnDefinition(0.2, false);
|
|
801
|
+
rgbValuesQuadrant.addColumnDefinition(0.7, false);
|
|
802
|
+
pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
|
|
803
|
+
for (var i = 0; i < inputFieldLabels.length; i++) {
|
|
804
|
+
var labelText_1 = new TextBlock();
|
|
805
|
+
labelText_1.text = inputFieldLabels[i];
|
|
806
|
+
labelText_1.color = buttonColor;
|
|
807
|
+
labelText_1.fontSize = buttonFontSize;
|
|
808
|
+
rgbValuesQuadrant.addControl(labelText_1, i, 0);
|
|
809
|
+
}
|
|
810
|
+
// Input fields for RGB values
|
|
811
|
+
var rValInt = new InputText();
|
|
812
|
+
rValInt.width = 0.83;
|
|
813
|
+
rValInt.height = 0.72;
|
|
814
|
+
rValInt.name = "rIntField";
|
|
815
|
+
rValInt.fontSize = buttonFontSize;
|
|
816
|
+
rValInt.text = (currentColor.r * 255).toString();
|
|
817
|
+
rValInt.color = inputTextColor;
|
|
818
|
+
rValInt.background = inputTextBackgroundColor;
|
|
819
|
+
rValInt.onFocusObservable.add(function () {
|
|
820
|
+
activeField = rValInt.name;
|
|
821
|
+
lastVal = rValInt.text;
|
|
822
|
+
editSwatches(false);
|
|
823
|
+
});
|
|
824
|
+
rValInt.onBlurObservable.add(function () {
|
|
825
|
+
if (rValInt.text == "") {
|
|
826
|
+
rValInt.text = "0";
|
|
827
|
+
}
|
|
828
|
+
updateInt(rValInt, "r");
|
|
829
|
+
if (activeField == rValInt.name) {
|
|
830
|
+
activeField = "";
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
rValInt.onTextChangedObservable.add(function () {
|
|
834
|
+
if (activeField == rValInt.name) {
|
|
835
|
+
updateInt(rValInt, "r");
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
rgbValuesQuadrant.addControl(rValInt, 0, 1);
|
|
839
|
+
var gValInt = new InputText();
|
|
840
|
+
gValInt.width = 0.83;
|
|
841
|
+
gValInt.height = 0.72;
|
|
842
|
+
gValInt.name = "gIntField";
|
|
843
|
+
gValInt.fontSize = buttonFontSize;
|
|
844
|
+
gValInt.text = (currentColor.g * 255).toString();
|
|
845
|
+
gValInt.color = inputTextColor;
|
|
846
|
+
gValInt.background = inputTextBackgroundColor;
|
|
847
|
+
gValInt.onFocusObservable.add(function () {
|
|
848
|
+
activeField = gValInt.name;
|
|
849
|
+
lastVal = gValInt.text;
|
|
850
|
+
editSwatches(false);
|
|
851
|
+
});
|
|
852
|
+
gValInt.onBlurObservable.add(function () {
|
|
853
|
+
if (gValInt.text == "") {
|
|
854
|
+
gValInt.text = "0";
|
|
855
|
+
}
|
|
856
|
+
updateInt(gValInt, "g");
|
|
857
|
+
if (activeField == gValInt.name) {
|
|
858
|
+
activeField = "";
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
gValInt.onTextChangedObservable.add(function () {
|
|
862
|
+
if (activeField == gValInt.name) {
|
|
863
|
+
updateInt(gValInt, "g");
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
rgbValuesQuadrant.addControl(gValInt, 1, 1);
|
|
867
|
+
var bValInt = new InputText();
|
|
868
|
+
bValInt.width = 0.83;
|
|
869
|
+
bValInt.height = 0.72;
|
|
870
|
+
bValInt.name = "bIntField";
|
|
871
|
+
bValInt.fontSize = buttonFontSize;
|
|
872
|
+
bValInt.text = (currentColor.b * 255).toString();
|
|
873
|
+
bValInt.color = inputTextColor;
|
|
874
|
+
bValInt.background = inputTextBackgroundColor;
|
|
875
|
+
bValInt.onFocusObservable.add(function () {
|
|
876
|
+
activeField = bValInt.name;
|
|
877
|
+
lastVal = bValInt.text;
|
|
878
|
+
editSwatches(false);
|
|
879
|
+
});
|
|
880
|
+
bValInt.onBlurObservable.add(function () {
|
|
881
|
+
if (bValInt.text == "") {
|
|
882
|
+
bValInt.text = "0";
|
|
883
|
+
}
|
|
884
|
+
updateInt(bValInt, "b");
|
|
885
|
+
if (activeField == bValInt.name) {
|
|
886
|
+
activeField = "";
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
bValInt.onTextChangedObservable.add(function () {
|
|
890
|
+
if (activeField == bValInt.name) {
|
|
891
|
+
updateInt(bValInt, "b");
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
rgbValuesQuadrant.addControl(bValInt, 2, 1);
|
|
895
|
+
var rValDec = new InputText();
|
|
896
|
+
rValDec.width = 0.95;
|
|
897
|
+
rValDec.height = 0.72;
|
|
898
|
+
rValDec.name = "rDecField";
|
|
899
|
+
rValDec.fontSize = buttonFontSize;
|
|
900
|
+
rValDec.text = currentColor.r.toString();
|
|
901
|
+
rValDec.color = inputTextColor;
|
|
902
|
+
rValDec.background = inputTextBackgroundColor;
|
|
903
|
+
rValDec.onFocusObservable.add(function () {
|
|
904
|
+
activeField = rValDec.name;
|
|
905
|
+
lastVal = rValDec.text;
|
|
906
|
+
editSwatches(false);
|
|
907
|
+
});
|
|
908
|
+
rValDec.onBlurObservable.add(function () {
|
|
909
|
+
if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
|
|
910
|
+
rValDec.text = "0";
|
|
911
|
+
updateFloat(rValDec, "r");
|
|
912
|
+
}
|
|
913
|
+
if (activeField == rValDec.name) {
|
|
914
|
+
activeField = "";
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
rValDec.onTextChangedObservable.add(function () {
|
|
918
|
+
if (activeField == rValDec.name) {
|
|
919
|
+
updateFloat(rValDec, "r");
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
rgbValuesQuadrant.addControl(rValDec, 0, 2);
|
|
923
|
+
var gValDec = new InputText();
|
|
924
|
+
gValDec.width = 0.95;
|
|
925
|
+
gValDec.height = 0.72;
|
|
926
|
+
gValDec.name = "gDecField";
|
|
927
|
+
gValDec.fontSize = buttonFontSize;
|
|
928
|
+
gValDec.text = currentColor.g.toString();
|
|
929
|
+
gValDec.color = inputTextColor;
|
|
930
|
+
gValDec.background = inputTextBackgroundColor;
|
|
931
|
+
gValDec.onFocusObservable.add(function () {
|
|
932
|
+
activeField = gValDec.name;
|
|
933
|
+
lastVal = gValDec.text;
|
|
934
|
+
editSwatches(false);
|
|
935
|
+
});
|
|
936
|
+
gValDec.onBlurObservable.add(function () {
|
|
937
|
+
if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
|
|
938
|
+
gValDec.text = "0";
|
|
939
|
+
updateFloat(gValDec, "g");
|
|
940
|
+
}
|
|
941
|
+
if (activeField == gValDec.name) {
|
|
942
|
+
activeField = "";
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
gValDec.onTextChangedObservable.add(function () {
|
|
946
|
+
if (activeField == gValDec.name) {
|
|
947
|
+
updateFloat(gValDec, "g");
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
rgbValuesQuadrant.addControl(gValDec, 1, 2);
|
|
951
|
+
var bValDec = new InputText();
|
|
952
|
+
bValDec.width = 0.95;
|
|
953
|
+
bValDec.height = 0.72;
|
|
954
|
+
bValDec.name = "bDecField";
|
|
955
|
+
bValDec.fontSize = buttonFontSize;
|
|
956
|
+
bValDec.text = currentColor.b.toString();
|
|
957
|
+
bValDec.color = inputTextColor;
|
|
958
|
+
bValDec.background = inputTextBackgroundColor;
|
|
959
|
+
bValDec.onFocusObservable.add(function () {
|
|
960
|
+
activeField = bValDec.name;
|
|
961
|
+
lastVal = bValDec.text;
|
|
962
|
+
editSwatches(false);
|
|
963
|
+
});
|
|
964
|
+
bValDec.onBlurObservable.add(function () {
|
|
965
|
+
if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
|
|
966
|
+
bValDec.text = "0";
|
|
967
|
+
updateFloat(bValDec, "b");
|
|
968
|
+
}
|
|
969
|
+
if (activeField == bValDec.name) {
|
|
970
|
+
activeField = "";
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
bValDec.onTextChangedObservable.add(function () {
|
|
974
|
+
if (activeField == bValDec.name) {
|
|
975
|
+
updateFloat(bValDec, "b");
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
rgbValuesQuadrant.addControl(bValDec, 2, 2);
|
|
979
|
+
// Hex value input
|
|
980
|
+
var hexValueQuadrant = new Grid();
|
|
981
|
+
hexValueQuadrant.name = "Hex Value";
|
|
982
|
+
hexValueQuadrant.width = 0.82;
|
|
983
|
+
hexValueQuadrant.addRowDefinition(1.0, false);
|
|
984
|
+
hexValueQuadrant.addColumnDefinition(0.1, false);
|
|
985
|
+
hexValueQuadrant.addColumnDefinition(0.9, false);
|
|
986
|
+
pickerColorValues.addControl(hexValueQuadrant, 2, 0);
|
|
987
|
+
var labelText = new TextBlock();
|
|
988
|
+
labelText.text = "#";
|
|
989
|
+
labelText.color = buttonColor;
|
|
990
|
+
labelText.fontSize = buttonFontSize;
|
|
991
|
+
hexValueQuadrant.addControl(labelText, 0, 0);
|
|
992
|
+
var hexVal = new InputText();
|
|
993
|
+
hexVal.width = 0.96;
|
|
994
|
+
hexVal.height = 0.72;
|
|
995
|
+
hexVal.name = "hexField";
|
|
996
|
+
hexVal.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
|
|
997
|
+
hexVal.fontSize = buttonFontSize;
|
|
998
|
+
var minusPound = options.lastColor.split("#");
|
|
999
|
+
hexVal.text = minusPound[1];
|
|
1000
|
+
hexVal.color = inputTextColor;
|
|
1001
|
+
hexVal.background = inputTextBackgroundColor;
|
|
1002
|
+
hexVal.onFocusObservable.add(function () {
|
|
1003
|
+
activeField = hexVal.name;
|
|
1004
|
+
lastVal = hexVal.text;
|
|
1005
|
+
editSwatches(false);
|
|
1006
|
+
});
|
|
1007
|
+
hexVal.onBlurObservable.add(function () {
|
|
1008
|
+
if (hexVal.text.length == 3) {
|
|
1009
|
+
var val = hexVal.text.split("");
|
|
1010
|
+
hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
|
|
1011
|
+
}
|
|
1012
|
+
if (hexVal.text == "") {
|
|
1013
|
+
hexVal.text = "000000";
|
|
1014
|
+
updateValues(Color3.FromHexString(hexVal.text), "b");
|
|
1015
|
+
}
|
|
1016
|
+
if (activeField == hexVal.name) {
|
|
1017
|
+
activeField = "";
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
hexVal.onTextChangedObservable.add(function () {
|
|
1021
|
+
var newHexValue = hexVal.text;
|
|
1022
|
+
var checkHex = /[^0-9A-F]/i.test(newHexValue);
|
|
1023
|
+
if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
|
|
1024
|
+
hexVal.text = lastVal;
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
if (hexVal.text.length < 6) {
|
|
1028
|
+
var leadingZero = 6 - hexVal.text.length;
|
|
1029
|
+
for (var i = 0; i < leadingZero; i++) {
|
|
1030
|
+
newHexValue = "0" + newHexValue;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (hexVal.text.length == 3) {
|
|
1034
|
+
var val = hexVal.text.split("");
|
|
1035
|
+
newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
|
|
1036
|
+
}
|
|
1037
|
+
newHexValue = "#" + newHexValue;
|
|
1038
|
+
if (activeField == hexVal.name) {
|
|
1039
|
+
lastVal = hexVal.text;
|
|
1040
|
+
updateValues(Color3.FromHexString(newHexValue), hexVal.name);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
hexValueQuadrant.addControl(hexVal, 0, 1);
|
|
1045
|
+
if (options.savedColors && options.savedColors.length > 0) {
|
|
1046
|
+
updateSwatches("", butSave);
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
|
|
1050
|
+
* Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
|
|
1051
|
+
* are will receive no update. This is to prevent the input from the user being overwritten.
|
|
1052
|
+
* @param value
|
|
1053
|
+
* @param inputField
|
|
1054
|
+
*/
|
|
1055
|
+
function updateValues(value, inputField) {
|
|
1056
|
+
activeField = inputField;
|
|
1057
|
+
var pickedColor = value.toHexString();
|
|
1058
|
+
newSwatch.background = pickedColor;
|
|
1059
|
+
if (rValInt.name != activeField) {
|
|
1060
|
+
rValInt.text = Math.floor(value.r * 255).toString();
|
|
1061
|
+
}
|
|
1062
|
+
if (gValInt.name != activeField) {
|
|
1063
|
+
gValInt.text = Math.floor(value.g * 255).toString();
|
|
1064
|
+
}
|
|
1065
|
+
if (bValInt.name != activeField) {
|
|
1066
|
+
bValInt.text = Math.floor(value.b * 255).toString();
|
|
1067
|
+
}
|
|
1068
|
+
if (rValDec.name != activeField) {
|
|
1069
|
+
rValDec.text = value.r.toString();
|
|
1070
|
+
}
|
|
1071
|
+
if (gValDec.name != activeField) {
|
|
1072
|
+
gValDec.text = value.g.toString();
|
|
1073
|
+
}
|
|
1074
|
+
if (bValDec.name != activeField) {
|
|
1075
|
+
bValDec.text = value.b.toString();
|
|
1076
|
+
}
|
|
1077
|
+
if (hexVal.name != activeField) {
|
|
1078
|
+
var minusPound_1 = pickedColor.split("#");
|
|
1079
|
+
hexVal.text = minusPound_1[1];
|
|
1080
|
+
}
|
|
1081
|
+
if (picker.name != activeField) {
|
|
1082
|
+
picker.value = value;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
// When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
|
|
1086
|
+
function updateInt(field, channel) {
|
|
1087
|
+
var newValue = field.text;
|
|
1088
|
+
var checkVal = /[^0-9]/g.test(newValue);
|
|
1089
|
+
if (checkVal) {
|
|
1090
|
+
field.text = lastVal;
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
if (newValue != "") {
|
|
1095
|
+
if (Math.floor(parseInt(newValue)) < 0) {
|
|
1096
|
+
newValue = "0";
|
|
1097
|
+
}
|
|
1098
|
+
else if (Math.floor(parseInt(newValue)) > 255) {
|
|
1099
|
+
newValue = "255";
|
|
1100
|
+
}
|
|
1101
|
+
else if (isNaN(parseInt(newValue))) {
|
|
1102
|
+
newValue = "0";
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (activeField == field.name) {
|
|
1106
|
+
lastVal = newValue;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
if (newValue != "") {
|
|
1110
|
+
newValue = parseInt(newValue).toString();
|
|
1111
|
+
field.text = newValue;
|
|
1112
|
+
var newSwatchRGB = Color3.FromHexString(newSwatch.background);
|
|
1113
|
+
if (activeField == field.name) {
|
|
1114
|
+
if (channel == "r") {
|
|
1115
|
+
updateValues(new Color3(parseInt(newValue) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
|
|
1116
|
+
}
|
|
1117
|
+
else if (channel == "g") {
|
|
1118
|
+
updateValues(new Color3(newSwatchRGB.r, parseInt(newValue) / 255, newSwatchRGB.b), field.name);
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
updateValues(new Color3(newSwatchRGB.r, newSwatchRGB.g, parseInt(newValue) / 255), field.name);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
// When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
|
|
1127
|
+
function updateFloat(field, channel) {
|
|
1128
|
+
var newValue = field.text;
|
|
1129
|
+
var checkVal = /[^0-9.]/g.test(newValue);
|
|
1130
|
+
if (checkVal) {
|
|
1131
|
+
field.text = lastVal;
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
|
|
1136
|
+
if (parseFloat(newValue) < 0.0) {
|
|
1137
|
+
newValue = "0.0";
|
|
1138
|
+
}
|
|
1139
|
+
else if (parseFloat(newValue) > 1.0) {
|
|
1140
|
+
newValue = "1.0";
|
|
1141
|
+
}
|
|
1142
|
+
else if (isNaN(parseFloat(newValue))) {
|
|
1143
|
+
newValue = "0.0";
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (activeField == field.name) {
|
|
1147
|
+
lastVal = newValue;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
|
|
1151
|
+
newValue = parseFloat(newValue).toString();
|
|
1152
|
+
field.text = newValue;
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
newValue = "0.0";
|
|
1156
|
+
}
|
|
1157
|
+
var newSwatchRGB = Color3.FromHexString(newSwatch.background);
|
|
1158
|
+
if (activeField == field.name) {
|
|
1159
|
+
if (channel == "r") {
|
|
1160
|
+
updateValues(new Color3(parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
|
|
1161
|
+
}
|
|
1162
|
+
else if (channel == "g") {
|
|
1163
|
+
updateValues(new Color3(newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
|
|
1164
|
+
}
|
|
1165
|
+
else {
|
|
1166
|
+
updateValues(new Color3(newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
// Removes the current index from the savedColors array. Drawer can then be regenerated.
|
|
1171
|
+
function deleteSwatch(index) {
|
|
1172
|
+
if (options.savedColors) {
|
|
1173
|
+
options.savedColors.splice(index, 1);
|
|
1174
|
+
}
|
|
1175
|
+
if (options.savedColors && options.savedColors.length == 0) {
|
|
1176
|
+
setEditButtonVisibility(false);
|
|
1177
|
+
editSwatchMode = false;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
// Creates and styles an individual swatch when updateSwatches is called.
|
|
1181
|
+
function createSwatch() {
|
|
1182
|
+
if (options.savedColors && options.savedColors[swatchNumber]) {
|
|
1183
|
+
var icon = void 0;
|
|
1184
|
+
if (editSwatchMode) {
|
|
1185
|
+
icon = "b";
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
icon = "";
|
|
1189
|
+
}
|
|
1190
|
+
var swatch_1 = Button.CreateSimpleButton("Swatch_" + swatchNumber, icon);
|
|
1191
|
+
swatch_1.fontFamily = "coreglyphs";
|
|
1192
|
+
var swatchColor = Color3.FromHexString(options.savedColors[swatchNumber]);
|
|
1193
|
+
var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
|
|
1194
|
+
// Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
|
|
1195
|
+
if (swatchLuminence > luminanceLimit) {
|
|
1196
|
+
swatch_1.color = iconColorDark;
|
|
1197
|
+
}
|
|
1198
|
+
else {
|
|
1199
|
+
swatch_1.color = iconColorLight;
|
|
1200
|
+
}
|
|
1201
|
+
swatch_1.fontSize = Math.floor(swatchSize * 0.7);
|
|
1202
|
+
swatch_1.textBlock.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
|
|
1203
|
+
swatch_1.height = swatch_1.width = swatchSize.toString() + "px";
|
|
1204
|
+
swatch_1.background = options.savedColors[swatchNumber];
|
|
1205
|
+
swatch_1.thickness = 2;
|
|
1206
|
+
var metadata_1 = swatchNumber;
|
|
1207
|
+
swatch_1.pointerDownAnimation = function () {
|
|
1208
|
+
swatch_1.thickness = 4;
|
|
1209
|
+
};
|
|
1210
|
+
swatch_1.pointerUpAnimation = function () {
|
|
1211
|
+
swatch_1.thickness = 3;
|
|
1212
|
+
};
|
|
1213
|
+
swatch_1.pointerEnterAnimation = function () {
|
|
1214
|
+
swatch_1.thickness = 3;
|
|
1215
|
+
};
|
|
1216
|
+
swatch_1.pointerOutAnimation = function () {
|
|
1217
|
+
swatch_1.thickness = 2;
|
|
1218
|
+
};
|
|
1219
|
+
swatch_1.onPointerClickObservable.add(function () {
|
|
1220
|
+
if (!editSwatchMode) {
|
|
1221
|
+
if (options.savedColors) {
|
|
1222
|
+
updateValues(Color3.FromHexString(options.savedColors[metadata_1]), swatch_1.name);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
deleteSwatch(metadata_1);
|
|
1227
|
+
updateSwatches("", butSave);
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
return swatch_1;
|
|
1231
|
+
}
|
|
1232
|
+
else {
|
|
1233
|
+
return null;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
// Mode switch to render button text and close symbols on swatch controls
|
|
1237
|
+
function editSwatches(mode) {
|
|
1238
|
+
if (mode !== undefined) {
|
|
1239
|
+
editSwatchMode = mode;
|
|
1240
|
+
}
|
|
1241
|
+
var thisButton;
|
|
1242
|
+
if (editSwatchMode) {
|
|
1243
|
+
for (var i = 0; i < swatchDrawer.children.length; i++) {
|
|
1244
|
+
thisButton = swatchDrawer.children[i];
|
|
1245
|
+
thisButton.textBlock.text = "b";
|
|
1246
|
+
}
|
|
1247
|
+
if (butEdit !== undefined) {
|
|
1248
|
+
butEdit.textBlock.text = "Done";
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
for (var i = 0; i < swatchDrawer.children.length; i++) {
|
|
1253
|
+
thisButton = swatchDrawer.children[i];
|
|
1254
|
+
thisButton.textBlock.text = "";
|
|
1255
|
+
}
|
|
1256
|
+
if (butEdit !== undefined) {
|
|
1257
|
+
butEdit.textBlock.text = "Edit";
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* When Save Color button is pressed this function will first create a swatch drawer if one is not already
|
|
1263
|
+
* made. Then all controls are removed from the drawer and we step through the savedColors array and
|
|
1264
|
+
* creates one swatch per color. It will also set the height of the drawer control based on how many
|
|
1265
|
+
* saved colors there are and how many can be stored per row.
|
|
1266
|
+
* @param color
|
|
1267
|
+
* @param button
|
|
1268
|
+
*/
|
|
1269
|
+
function updateSwatches(color, button) {
|
|
1270
|
+
if (options.savedColors) {
|
|
1271
|
+
if (color != "") {
|
|
1272
|
+
options.savedColors.push(color);
|
|
1273
|
+
}
|
|
1274
|
+
swatchNumber = 0;
|
|
1275
|
+
swatchDrawer.clearControls();
|
|
1276
|
+
var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
|
|
1277
|
+
var gutterCount = void 0;
|
|
1278
|
+
if (rowCount == 0) {
|
|
1279
|
+
gutterCount = 0;
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
gutterCount = rowCount + 1;
|
|
1283
|
+
}
|
|
1284
|
+
if (swatchDrawer.rowCount != rowCount + gutterCount) {
|
|
1285
|
+
var currentRows = swatchDrawer.rowCount;
|
|
1286
|
+
for (var i = 0; i < currentRows; i++) {
|
|
1287
|
+
swatchDrawer.removeRowDefinition(0);
|
|
1288
|
+
}
|
|
1289
|
+
for (var i = 0; i < rowCount + gutterCount; i++) {
|
|
1290
|
+
if (i % 2) {
|
|
1291
|
+
swatchDrawer.addRowDefinition(swatchSize, true);
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
swatchDrawer.addRowDefinition(gutterSize, true);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
swatchDrawer.height = (swatchSize * rowCount + gutterCount * gutterSize).toString() + "px";
|
|
1299
|
+
for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
|
|
1300
|
+
// Determine number of buttons to create per row based on the button limit per row and number of saved colors
|
|
1301
|
+
var totalButtonsThisRow = void 0;
|
|
1302
|
+
if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
|
|
1303
|
+
totalButtonsThisRow = options.numSwatchesPerLine;
|
|
1304
|
+
}
|
|
1305
|
+
else {
|
|
1306
|
+
totalButtonsThisRow = options.savedColors.length - (thisRow - 1) * options.numSwatchesPerLine;
|
|
1307
|
+
}
|
|
1308
|
+
var buttonIterations = Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine);
|
|
1309
|
+
for (var x = 0, w = 1; x < buttonIterations; x++) {
|
|
1310
|
+
if (x > options.numSwatchesPerLine) {
|
|
1311
|
+
continue;
|
|
1312
|
+
}
|
|
1313
|
+
var swatch = createSwatch();
|
|
1314
|
+
if (swatch != null) {
|
|
1315
|
+
swatchDrawer.addControl(swatch, y, w);
|
|
1316
|
+
w += 2;
|
|
1317
|
+
swatchNumber++;
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (options.savedColors.length >= options.swatchLimit) {
|
|
1325
|
+
disableButton(button, true);
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
disableButton(button, false);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
// Shows or hides edit swatches button depending on if there are saved swatches
|
|
1333
|
+
function setEditButtonVisibility(enableButton) {
|
|
1334
|
+
if (enableButton) {
|
|
1335
|
+
butEdit = Button.CreateSimpleButton("butEdit", "Edit");
|
|
1336
|
+
butEdit.width = buttonWidth;
|
|
1337
|
+
butEdit.height = buttonHeight;
|
|
1338
|
+
butEdit.left = Math.floor(parseInt(buttonWidth) * 0.1).toString() + "px";
|
|
1339
|
+
butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
|
|
1340
|
+
butEdit.verticalAlignment = Control.VERTICAL_ALIGNMENT_BOTTOM;
|
|
1341
|
+
butEdit.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
|
|
1342
|
+
butEdit.thickness = 2;
|
|
1343
|
+
butEdit.color = buttonColor;
|
|
1344
|
+
butEdit.fontSize = buttonFontSize;
|
|
1345
|
+
butEdit.background = buttonBackgroundColor;
|
|
1346
|
+
butEdit.onPointerEnterObservable.add(function () {
|
|
1347
|
+
butEdit.background = buttonBackgroundHoverColor;
|
|
1348
|
+
});
|
|
1349
|
+
butEdit.onPointerOutObservable.add(function () {
|
|
1350
|
+
butEdit.background = buttonBackgroundColor;
|
|
1351
|
+
});
|
|
1352
|
+
butEdit.pointerDownAnimation = function () {
|
|
1353
|
+
butEdit.background = buttonBackgroundClickColor;
|
|
1354
|
+
};
|
|
1355
|
+
butEdit.pointerUpAnimation = function () {
|
|
1356
|
+
butEdit.background = buttonBackgroundHoverColor;
|
|
1357
|
+
};
|
|
1358
|
+
butEdit.onPointerClickObservable.add(function () {
|
|
1359
|
+
if (editSwatchMode) {
|
|
1360
|
+
editSwatchMode = false;
|
|
1361
|
+
}
|
|
1362
|
+
else {
|
|
1363
|
+
editSwatchMode = true;
|
|
1364
|
+
}
|
|
1365
|
+
editSwatches();
|
|
1366
|
+
});
|
|
1367
|
+
pickerGrid.addControl(butEdit, 1, 0);
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
pickerGrid.removeControl(butEdit);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
// Called when the user hits the limit of saved colors in the drawer.
|
|
1374
|
+
function disableButton(button, disabled) {
|
|
1375
|
+
if (disabled) {
|
|
1376
|
+
button.color = buttonDisabledColor;
|
|
1377
|
+
button.background = buttonDisabledBackgroundColor;
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
button.color = buttonColor;
|
|
1381
|
+
button.background = buttonBackgroundColor;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
// Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
|
|
1385
|
+
function closePicker(color) {
|
|
1386
|
+
if (options.savedColors && options.savedColors.length > 0) {
|
|
1387
|
+
resolve({
|
|
1388
|
+
savedColors: options.savedColors,
|
|
1389
|
+
pickedColor: color,
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
else {
|
|
1393
|
+
resolve({
|
|
1394
|
+
pickedColor: color,
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
advancedTexture.removeControl(dialogContainer);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
};
|
|
1401
|
+
ColorPicker._Epsilon = 0.000001;
|
|
1402
|
+
__decorate([
|
|
1403
|
+
serialize()
|
|
1404
|
+
], ColorPicker.prototype, "value", null);
|
|
1405
|
+
__decorate([
|
|
1406
|
+
serialize()
|
|
1407
|
+
], ColorPicker.prototype, "width", null);
|
|
1408
|
+
__decorate([
|
|
1409
|
+
serialize()
|
|
1410
|
+
], ColorPicker.prototype, "height", null);
|
|
1411
|
+
__decorate([
|
|
1412
|
+
serialize()
|
|
1413
|
+
], ColorPicker.prototype, "size", null);
|
|
1414
|
+
return ColorPicker;
|
|
1415
|
+
}(Control));
|
|
1416
|
+
export { ColorPicker };
|
|
1417
|
+
RegisterClass("BABYLON.GUI.ColorPicker", ColorPicker);
|
|
1401
1418
|
//# sourceMappingURL=colorpicker.js.map
|