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