@babylonjs/gui 9.15.0 → 9.16.1

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.
Files changed (64) hide show
  1. package/2D/controls/checkbox.pure.js +164 -153
  2. package/2D/controls/checkbox.pure.js.map +1 -1
  3. package/2D/controls/colorpicker.pure.js +1300 -1289
  4. package/2D/controls/colorpicker.pure.js.map +1 -1
  5. package/2D/controls/container.pure.js +597 -582
  6. package/2D/controls/container.pure.js.map +1 -1
  7. package/2D/controls/control.pure.js +2474 -2434
  8. package/2D/controls/control.pure.js.map +1 -1
  9. package/2D/controls/displayGrid.pure.js +201 -190
  10. package/2D/controls/displayGrid.pure.js.map +1 -1
  11. package/2D/controls/ellipse.pure.js +96 -85
  12. package/2D/controls/ellipse.pure.js.map +1 -1
  13. package/2D/controls/grid.pure.js +511 -500
  14. package/2D/controls/grid.pure.js.map +1 -1
  15. package/2D/controls/image.pure.js +888 -877
  16. package/2D/controls/image.pure.js.map +1 -1
  17. package/2D/controls/inputText.pure.js +988 -973
  18. package/2D/controls/inputText.pure.js.map +1 -1
  19. package/2D/controls/inputTextArea.pure.js +955 -944
  20. package/2D/controls/inputTextArea.pure.js.map +1 -1
  21. package/2D/controls/line.pure.js +237 -226
  22. package/2D/controls/line.pure.js.map +1 -1
  23. package/2D/controls/multiLine.pure.js +233 -222
  24. package/2D/controls/multiLine.pure.js.map +1 -1
  25. package/2D/controls/radioButton.pure.js +182 -169
  26. package/2D/controls/radioButton.pure.js.map +1 -1
  27. package/2D/controls/rectangle.pure.js +211 -200
  28. package/2D/controls/rectangle.pure.js.map +1 -1
  29. package/2D/controls/scrollViewers/scrollViewer.pure.js +579 -567
  30. package/2D/controls/scrollViewers/scrollViewer.pure.js.map +1 -1
  31. package/2D/controls/sliders/baseSlider.js +291 -280
  32. package/2D/controls/sliders/baseSlider.js.map +1 -1
  33. package/2D/controls/sliders/imageBasedSlider.pure.js +158 -147
  34. package/2D/controls/sliders/imageBasedSlider.pure.js.map +1 -1
  35. package/2D/controls/sliders/imageScrollBar.js +237 -223
  36. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  37. package/2D/controls/sliders/scrollBar.pure.js +169 -158
  38. package/2D/controls/sliders/scrollBar.pure.js.map +1 -1
  39. package/2D/controls/sliders/slider.pure.js +251 -240
  40. package/2D/controls/sliders/slider.pure.js.map +1 -1
  41. package/2D/controls/stackPanel.pure.js +236 -221
  42. package/2D/controls/stackPanel.pure.js.map +1 -1
  43. package/2D/controls/textBlock.pure.js +637 -626
  44. package/2D/controls/textBlock.pure.js.map +1 -1
  45. package/3D/materials/fluent/fluentMaterial.pure.d.ts +4 -4
  46. package/3D/materials/fluent/fluentMaterial.pure.js +322 -273
  47. package/3D/materials/fluent/fluentMaterial.pure.js.map +1 -1
  48. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js +510 -454
  49. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js.map +1 -1
  50. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js +612 -529
  51. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js.map +1 -1
  52. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js +313 -274
  53. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js.map +1 -1
  54. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js +462 -405
  55. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js.map +1 -1
  56. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js +583 -501
  57. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js.map +1 -1
  58. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js +226 -203
  59. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js.map +1 -1
  60. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js +961 -825
  61. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js.map +1 -1
  62. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js +961 -825
  63. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js.map +1 -1
  64. package/package.json +2 -2
@@ -1,246 +1,260 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
1
+ import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
2
2
  import { BaseSlider } from "./baseSlider.js";
3
3
  import { Measure } from "../../measure.js";
4
4
  import { serialize } from "@babylonjs/core/Misc/decorators.js";
5
5
  /**
6
6
  * Class used to create slider controls
7
7
  */
8
- export class ImageScrollBar extends BaseSlider {
9
- /** Inverts the scrolling direction (default: false) */
10
- get invertScrollDirection() {
11
- return this._invertScrollDirection;
12
- }
13
- set invertScrollDirection(invert) {
14
- this._invertScrollDirection = invert;
15
- }
16
- /**
17
- * Gets or sets the image used to render the background for horizontal bar
18
- */
19
- get backgroundImage() {
20
- return this._backgroundBaseImage;
21
- }
22
- set backgroundImage(value) {
23
- if (this._backgroundBaseImage === value) {
24
- return;
25
- }
26
- this._backgroundBaseImage = value;
27
- if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
28
- if (!value.isLoaded) {
29
- value.onImageLoadedObservable.addOnce(() => {
30
- const rotatedValue = value._rotate90(this.num90RotationInVerticalMode, true);
31
- this._backgroundImage = rotatedValue;
32
- if (!rotatedValue.isLoaded) {
33
- rotatedValue.onImageLoadedObservable.addOnce(() => {
8
+ let ImageScrollBar = (() => {
9
+ var _a;
10
+ let _classSuper = BaseSlider;
11
+ let _instanceExtraInitializers = [];
12
+ let _num90RotationInVerticalMode_decorators;
13
+ let _num90RotationInVerticalMode_initializers = [];
14
+ let _num90RotationInVerticalMode_extraInitializers = [];
15
+ let _get_invertScrollDirection_decorators;
16
+ return _a = class ImageScrollBar extends _classSuper {
17
+ /** Inverts the scrolling direction (default: false) */
18
+ get invertScrollDirection() {
19
+ return this._invertScrollDirection;
20
+ }
21
+ set invertScrollDirection(invert) {
22
+ this._invertScrollDirection = invert;
23
+ }
24
+ /**
25
+ * Gets or sets the image used to render the background for horizontal bar
26
+ */
27
+ get backgroundImage() {
28
+ return this._backgroundBaseImage;
29
+ }
30
+ set backgroundImage(value) {
31
+ if (this._backgroundBaseImage === value) {
32
+ return;
33
+ }
34
+ this._backgroundBaseImage = value;
35
+ if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
36
+ if (!value.isLoaded) {
37
+ value.onImageLoadedObservable.addOnce(() => {
38
+ const rotatedValue = value._rotate90(this.num90RotationInVerticalMode, true);
39
+ this._backgroundImage = rotatedValue;
40
+ if (!rotatedValue.isLoaded) {
41
+ rotatedValue.onImageLoadedObservable.addOnce(() => {
42
+ this._markAsDirty();
43
+ });
44
+ }
45
+ this._markAsDirty();
46
+ });
47
+ }
48
+ else {
49
+ this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
50
+ this._markAsDirty();
51
+ }
52
+ }
53
+ else {
54
+ this._backgroundImage = value;
55
+ if (value && !value.isLoaded) {
56
+ value.onImageLoadedObservable.addOnce(() => {
34
57
  this._markAsDirty();
35
58
  });
36
59
  }
37
60
  this._markAsDirty();
38
- });
61
+ }
39
62
  }
40
- else {
41
- this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
42
- this._markAsDirty();
63
+ /**
64
+ * Gets or sets the image used to render the thumb
65
+ */
66
+ get thumbImage() {
67
+ return this._thumbBaseImage;
43
68
  }
44
- }
45
- else {
46
- this._backgroundImage = value;
47
- if (value && !value.isLoaded) {
48
- value.onImageLoadedObservable.addOnce(() => {
49
- this._markAsDirty();
50
- });
51
- }
52
- this._markAsDirty();
53
- }
54
- }
55
- /**
56
- * Gets or sets the image used to render the thumb
57
- */
58
- get thumbImage() {
59
- return this._thumbBaseImage;
60
- }
61
- set thumbImage(value) {
62
- if (this._thumbBaseImage === value) {
63
- return;
64
- }
65
- this._thumbBaseImage = value;
66
- if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
67
- if (!value.isLoaded) {
68
- value.onImageLoadedObservable.addOnce(() => {
69
- const rotatedValue = value._rotate90(-this.num90RotationInVerticalMode, true);
70
- this._thumbImage = rotatedValue;
71
- if (!rotatedValue.isLoaded) {
72
- rotatedValue.onImageLoadedObservable.addOnce(() => {
69
+ set thumbImage(value) {
70
+ if (this._thumbBaseImage === value) {
71
+ return;
72
+ }
73
+ this._thumbBaseImage = value;
74
+ if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
75
+ if (!value.isLoaded) {
76
+ value.onImageLoadedObservable.addOnce(() => {
77
+ const rotatedValue = value._rotate90(-this.num90RotationInVerticalMode, true);
78
+ this._thumbImage = rotatedValue;
79
+ if (!rotatedValue.isLoaded) {
80
+ rotatedValue.onImageLoadedObservable.addOnce(() => {
81
+ this._markAsDirty();
82
+ });
83
+ }
84
+ this._markAsDirty();
85
+ });
86
+ }
87
+ else {
88
+ this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
89
+ this._markAsDirty();
90
+ }
91
+ }
92
+ else {
93
+ this._thumbImage = value;
94
+ if (value && !value.isLoaded) {
95
+ value.onImageLoadedObservable.addOnce(() => {
73
96
  this._markAsDirty();
74
97
  });
75
98
  }
76
99
  this._markAsDirty();
77
- });
100
+ }
101
+ }
102
+ /**
103
+ * Gets or sets the length of the thumb
104
+ */
105
+ get thumbLength() {
106
+ return this._thumbLength;
78
107
  }
79
- else {
80
- this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
108
+ set thumbLength(value) {
109
+ if (this._thumbLength === value) {
110
+ return;
111
+ }
112
+ this._thumbLength = value;
81
113
  this._markAsDirty();
82
114
  }
83
- }
84
- else {
85
- this._thumbImage = value;
86
- if (value && !value.isLoaded) {
87
- value.onImageLoadedObservable.addOnce(() => {
88
- this._markAsDirty();
89
- });
90
- }
91
- this._markAsDirty();
92
- }
93
- }
94
- /**
95
- * Gets or sets the length of the thumb
96
- */
97
- get thumbLength() {
98
- return this._thumbLength;
99
- }
100
- set thumbLength(value) {
101
- if (this._thumbLength === value) {
102
- return;
103
- }
104
- this._thumbLength = value;
105
- this._markAsDirty();
106
- }
107
- /**
108
- * Gets or sets the height of the thumb
109
- */
110
- get thumbHeight() {
111
- return this._thumbHeight;
112
- }
113
- set thumbHeight(value) {
114
- if (this._thumbHeight === value) {
115
- return;
116
- }
117
- this._thumbHeight = value;
118
- this._markAsDirty();
119
- }
120
- /**
121
- * Gets or sets the height of the bar image
122
- */
123
- get barImageHeight() {
124
- return this._barImageHeight;
125
- }
126
- set barImageHeight(value) {
127
- if (this._barImageHeight === value) {
128
- return;
129
- }
130
- this._barImageHeight = value;
131
- this._markAsDirty();
132
- }
133
- /**
134
- * Creates a new ImageScrollBar
135
- * @param name defines the control name
136
- */
137
- constructor(name) {
138
- super(name);
139
- this.name = name;
140
- this._thumbLength = 0.5;
141
- this._thumbHeight = 1;
142
- this._barImageHeight = 1;
143
- this._tempMeasure = new Measure(0, 0, 0, 0);
144
- this._invertScrollDirection = false;
145
- /** Number of 90° rotation to apply on the images when in vertical mode */
146
- this.num90RotationInVerticalMode = 1;
147
- }
148
- _getTypeName() {
149
- return "ImageScrollBar";
150
- }
151
- _getThumbThickness() {
152
- let thumbThickness;
153
- if (this._thumbWidth.isPixel) {
154
- thumbThickness = this._thumbWidth.getValue(this._host);
155
- }
156
- else {
157
- thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
158
- }
159
- return thumbThickness;
160
- }
161
- _draw(context) {
162
- context.save();
163
- this._applyStates(context);
164
- this._prepareRenderingData("rectangle");
165
- const thumbPosition = this._getThumbPosition();
166
- const left = this._renderLeft;
167
- const top = this._renderTop;
168
- const width = this._renderWidth;
169
- const height = this._renderHeight;
170
- // Background
171
- if (this._backgroundImage) {
172
- this._tempMeasure.copyFromFloats(left, top, width, height);
173
- if (this.isVertical) {
174
- this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
175
- this._tempMeasure.height += this._effectiveThumbThickness;
176
- this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
177
- }
178
- else {
179
- this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
180
- this._tempMeasure.width += this._effectiveThumbThickness;
181
- this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
182
- }
183
- this._backgroundImage._draw(context);
184
- }
185
- // Thumb
186
- if (this.isVertical) {
187
- this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
188
- }
189
- else {
190
- this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
191
- }
192
- if (this._thumbImage) {
193
- this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
194
- this._thumbImage._draw(context);
195
- }
196
- context.restore();
197
- }
198
- /**
199
- * @internal
200
- */
201
- _updateValueFromPointer(x, y) {
202
- this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
203
- x = this._transformedPosition.x;
204
- y = this._transformedPosition.y;
205
- const sign = this._invertScrollDirection ? -1 : 1;
206
- if (this._first) {
207
- this._first = false;
208
- this._originX = x;
209
- this._originY = y;
210
- // Check if move is required
211
- if (x < this._tempMeasure.left ||
212
- x > this._tempMeasure.left + this._tempMeasure.width ||
213
- y < this._tempMeasure.top ||
214
- y > this._tempMeasure.top + this._tempMeasure.height) {
115
+ /**
116
+ * Gets or sets the height of the thumb
117
+ */
118
+ get thumbHeight() {
119
+ return this._thumbHeight;
120
+ }
121
+ set thumbHeight(value) {
122
+ if (this._thumbHeight === value) {
123
+ return;
124
+ }
125
+ this._thumbHeight = value;
126
+ this._markAsDirty();
127
+ }
128
+ /**
129
+ * Gets or sets the height of the bar image
130
+ */
131
+ get barImageHeight() {
132
+ return this._barImageHeight;
133
+ }
134
+ set barImageHeight(value) {
135
+ if (this._barImageHeight === value) {
136
+ return;
137
+ }
138
+ this._barImageHeight = value;
139
+ this._markAsDirty();
140
+ }
141
+ /**
142
+ * Creates a new ImageScrollBar
143
+ * @param name defines the control name
144
+ */
145
+ constructor(name) {
146
+ super(name);
147
+ this.name = (__runInitializers(this, _instanceExtraInitializers), name);
148
+ this._thumbLength = 0.5;
149
+ this._thumbHeight = 1;
150
+ this._barImageHeight = 1;
151
+ this._tempMeasure = new Measure(0, 0, 0, 0);
152
+ this._invertScrollDirection = false;
153
+ /** Number of 90° rotation to apply on the images when in vertical mode */
154
+ this.num90RotationInVerticalMode = __runInitializers(this, _num90RotationInVerticalMode_initializers, 1);
155
+ this._first = __runInitializers(this, _num90RotationInVerticalMode_extraInitializers);
156
+ }
157
+ _getTypeName() {
158
+ return "ImageScrollBar";
159
+ }
160
+ _getThumbThickness() {
161
+ let thumbThickness;
162
+ if (this._thumbWidth.isPixel) {
163
+ thumbThickness = this._thumbWidth.getValue(this._host);
164
+ }
165
+ else {
166
+ thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
167
+ }
168
+ return thumbThickness;
169
+ }
170
+ _draw(context) {
171
+ context.save();
172
+ this._applyStates(context);
173
+ this._prepareRenderingData("rectangle");
174
+ const thumbPosition = this._getThumbPosition();
175
+ const left = this._renderLeft;
176
+ const top = this._renderTop;
177
+ const width = this._renderWidth;
178
+ const height = this._renderHeight;
179
+ // Background
180
+ if (this._backgroundImage) {
181
+ this._tempMeasure.copyFromFloats(left, top, width, height);
182
+ if (this.isVertical) {
183
+ this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
184
+ this._tempMeasure.height += this._effectiveThumbThickness;
185
+ this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
186
+ }
187
+ else {
188
+ this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
189
+ this._tempMeasure.width += this._effectiveThumbThickness;
190
+ this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
191
+ }
192
+ this._backgroundImage._draw(context);
193
+ }
194
+ // Thumb
215
195
  if (this.isVertical) {
216
- this.value = this.minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this.maximum - this.minimum);
196
+ this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
217
197
  }
218
198
  else {
219
- this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
220
- }
221
- }
222
- }
223
- // Delta mode
224
- let delta;
225
- if (this.isVertical) {
226
- delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
227
- }
228
- else {
229
- delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
230
- }
231
- this.value += sign * delta * (this.maximum - this.minimum);
232
- this._originX = x;
233
- this._originY = y;
234
- }
235
- _onPointerDown(target, coordinates, pointerId, buttonIndex, pi) {
236
- this._first = true;
237
- return super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
238
- }
239
- }
240
- __decorate([
241
- serialize()
242
- ], ImageScrollBar.prototype, "num90RotationInVerticalMode", void 0);
243
- __decorate([
244
- serialize()
245
- ], ImageScrollBar.prototype, "invertScrollDirection", null);
199
+ this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
200
+ }
201
+ if (this._thumbImage) {
202
+ this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
203
+ this._thumbImage._draw(context);
204
+ }
205
+ context.restore();
206
+ }
207
+ /**
208
+ * @internal
209
+ */
210
+ _updateValueFromPointer(x, y) {
211
+ this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
212
+ x = this._transformedPosition.x;
213
+ y = this._transformedPosition.y;
214
+ const sign = this._invertScrollDirection ? -1 : 1;
215
+ if (this._first) {
216
+ this._first = false;
217
+ this._originX = x;
218
+ this._originY = y;
219
+ // Check if move is required
220
+ if (x < this._tempMeasure.left ||
221
+ x > this._tempMeasure.left + this._tempMeasure.width ||
222
+ y < this._tempMeasure.top ||
223
+ y > this._tempMeasure.top + this._tempMeasure.height) {
224
+ if (this.isVertical) {
225
+ this.value = this.minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this.maximum - this.minimum);
226
+ }
227
+ else {
228
+ this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
229
+ }
230
+ }
231
+ }
232
+ // Delta mode
233
+ let delta;
234
+ if (this.isVertical) {
235
+ delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
236
+ }
237
+ else {
238
+ delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
239
+ }
240
+ this.value += sign * delta * (this.maximum - this.minimum);
241
+ this._originX = x;
242
+ this._originY = y;
243
+ }
244
+ _onPointerDown(target, coordinates, pointerId, buttonIndex, pi) {
245
+ this._first = true;
246
+ return super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
247
+ }
248
+ },
249
+ (() => {
250
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
251
+ _num90RotationInVerticalMode_decorators = [serialize()];
252
+ _get_invertScrollDirection_decorators = [serialize()];
253
+ __esDecorate(_a, null, _get_invertScrollDirection_decorators, { kind: "getter", name: "invertScrollDirection", static: false, private: false, access: { has: obj => "invertScrollDirection" in obj, get: obj => obj.invertScrollDirection }, metadata: _metadata }, null, _instanceExtraInitializers);
254
+ __esDecorate(null, null, _num90RotationInVerticalMode_decorators, { kind: "field", name: "num90RotationInVerticalMode", static: false, private: false, access: { has: obj => "num90RotationInVerticalMode" in obj, get: obj => obj.num90RotationInVerticalMode, set: (obj, value) => { obj.num90RotationInVerticalMode = value; } }, metadata: _metadata }, _num90RotationInVerticalMode_initializers, _num90RotationInVerticalMode_extraInitializers);
255
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
256
+ })(),
257
+ _a;
258
+ })();
259
+ export { ImageScrollBar };
246
260
  //# sourceMappingURL=imageScrollBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"imageScrollBar.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/imageScrollBar.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAe1C,uDAAuD;IAEvD,IAAW,qBAAqB;QAC5B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAED,IAAW,qBAAqB,CAAC,MAAe;QAC5C,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,IAAW,eAAe,CAAC,KAAY;QACnC,IAAI,IAAI,CAAC,oBAAoB,KAAK,KAAK,EAAE,CAAC;YACtC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAElC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,2BAA2B,KAAK,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAClB,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE;oBACvC,MAAM,Y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/math.vector\";\r\nimport { BaseSlider } from \"./baseSlider\";\r\nimport { type Control } from \"../control\";\r\nimport { type Image } from \"../image\";\r\nimport { Measure } from \"../../measure\";\r\nimport { type PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { type ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class ImageScrollBar extends BaseSlider {\r\n private _backgroundBaseImage: Image;\r\n private _backgroundImage: Image;\r\n private _thumbImage: Image;\r\n private _thumbBaseImage: Image;\r\n private _thumbLength: number = 0.5;\r\n private _thumbHeight: number = 1;\r\n private _barImageHeight: number = 1;\r\n private _tempMeasure = new Measure(0, 0, 0, 0);\r\n private _invertScrollDirection = false;\r\n\r\n /** Number of 90° rotation to apply on the images when in vertical mode */\r\n @serialize()\r\n public num90RotationInVerticalMode = 1;\r\n\r\n /** Inverts the scrolling direction (default: false) */\r\n @serialize()\r\n public get invertScrollDirection() {\r\n return this._invertScrollDirection;\r\n }\r\n\r\n public set invertScrollDirection(invert: boolean) {\r\n this._invertScrollDirection = invert;\r\n }\r\n\r\n /**\r\n * Gets or sets the image used to render the background for horizontal bar\r\n */\r\n public get backgroundImage(): Image {\r\n return this._backgroundBaseImage;\r\n }\r\n\r\n public set backgroundImage(value: Image) {\r\n if (this._backgroundBaseImage === value) {\r\n return;\r\n }\r\n\r\n this._backgroundBaseImage = value;\r\n\r\n if (this.isVertical && this.num90RotationInVerticalMode !== 0) {\r\n if (!value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n const rotatedValue = value._rotate90(this.num90RotationInVerticalMode, true);\r\n this._backgroundImage = rotatedValue;\r\n if (!rotatedValue.isLoaded) {\r\n rotatedValue.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n this._markAsDirty();\r\n });\r\n } else {\r\n this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);\r\n this._markAsDirty();\r\n }\r\n } else {\r\n this._backgroundImage = value;\r\n if (value && !value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the image used to render the thumb\r\n */\r\n public get thumbImage(): Image {\r\n return this._thumbBaseImage;\r\n }\r\n\r\n public set thumbImage(value: Image) {\r\n if (this._thumbBaseImage === value) {\r\n return;\r\n }\r\n\r\n this._thumbBaseImage = value;\r\n\r\n if (this.isVertical && this.num90RotationInVerticalMode !== 0) {\r\n if (!value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n const rotatedValue = value._rotate90(-this.num90RotationInVerticalMode, true);\r\n this._thumbImage = rotatedValue;\r\n if (!rotatedValue.isLoaded) {\r\n rotatedValue.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n this._markAsDirty();\r\n });\r\n } else {\r\n this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);\r\n this._markAsDirty();\r\n }\r\n } else {\r\n this._thumbImage = value;\r\n if (value && !value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the length of the thumb\r\n */\r\n public get thumbLength(): number {\r\n return this._thumbLength;\r\n }\r\n\r\n public set thumbLength(value: number) {\r\n if (this._thumbLength === value) {\r\n return;\r\n }\r\n\r\n this._thumbLength = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height of the thumb\r\n */\r\n public get thumbHeight(): number {\r\n return this._thumbHeight;\r\n }\r\n\r\n public set thumbHeight(value: number) {\r\n if (this._thumbHeight === value) {\r\n return;\r\n }\r\n\r\n this._thumbHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height of the bar image\r\n */\r\n public get barImageHeight(): number {\r\n return this._barImageHeight;\r\n }\r\n\r\n public set barImageHeight(value: number) {\r\n if (this._barImageHeight === value) {\r\n return;\r\n }\r\n\r\n this._barImageHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new ImageScrollBar\r\n * @param name defines the control name\r\n */\r\n constructor(public override name?: string) {\r\n super(name);\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"ImageScrollBar\";\r\n }\r\n\r\n protected override _getThumbThickness(): number {\r\n let thumbThickness: number;\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = this._thumbWidth.getValue(this._host);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n return thumbThickness;\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n this._prepareRenderingData(\"rectangle\");\r\n const thumbPosition = this._getThumbPosition();\r\n const left = this._renderLeft;\r\n const top = this._renderTop;\r\n const width = this._renderWidth;\r\n const height = this._renderHeight;\r\n\r\n // Background\r\n if (this._backgroundImage) {\r\n this._tempMeasure.copyFromFloats(left, top, width, height);\r\n if (this.isVertical) {\r\n this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);\r\n this._tempMeasure.height += this._effectiveThumbThickness;\r\n this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);\r\n } else {\r\n this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);\r\n this._tempMeasure.width += this._effectiveThumbThickness;\r\n this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);\r\n }\r\n this._backgroundImage._draw(context);\r\n }\r\n\r\n // Thumb\r\n if (this.isVertical) {\r\n this._tempMeasure.copyFromFloats(\r\n left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5,\r\n this._currentMeasure.top + thumbPosition,\r\n this._currentMeasure.width * this._thumbHeight,\r\n this._effectiveThumbThickness\r\n );\r\n } else {\r\n this._tempMeasure.copyFromFloats(\r\n this._currentMeasure.left + thumbPosition,\r\n this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5,\r\n this._effectiveThumbThickness,\r\n this._currentMeasure.height * this._thumbHeight\r\n );\r\n }\r\n\r\n if (this._thumbImage) {\r\n this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);\r\n this._thumbImage._draw(context);\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _first: boolean;\r\n private _originX: number;\r\n private _originY: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n protected override _updateValueFromPointer(x: number, y: number): void {\r\n this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);\r\n x = this._transformedPosition.x;\r\n y = this._transformedPosition.y;\r\n\r\n const sign = this._invertScrollDirection ? -1 : 1;\r\n\r\n if (this._first) {\r\n this._first = false;\r\n this._originX = x;\r\n this._originY = y;\r\n\r\n // Check if move is required\r\n if (\r\n x < this._tempMeasure.left ||\r\n x > this._tempMeasure.left + this._tempMeasure.width ||\r\n y < this._tempMeasure.top ||\r\n y > this._tempMeasure.top + this._tempMeasure.height\r\n ) {\r\n if (this.isVertical) {\r\n this.value = this.minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this.maximum - this.minimum);\r\n } else {\r\n this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);\r\n }\r\n }\r\n }\r\n\r\n // Delta mode\r\n let delta: number;\r\n if (this.isVertical) {\r\n delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));\r\n } else {\r\n delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);\r\n }\r\n\r\n this.value += sign * delta * (this.maximum - this.minimum);\r\n\r\n this._originX = x;\r\n this._originY = y;\r\n }\r\n\r\n public override _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n this._first = true;\r\n\r\n return super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"imageScrollBar.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/imageScrollBar.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;GAEG;IACU,cAAc;;sBAAS,UAAU;;;;;;sBAAjC,cAAe,SAAQ,WAAU;YAe1C,uDAAuD;YAEvD,IAAW,qBAAqB;gBAC5B,OAAO,IAAI,CAAC,sBAAsB,CAAC;YACvC,CAAC;YAED,IAAW,qBAAqB,CAAC,MAAe;gBAC5C,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;YACzC,CAAC;YAED;;eAEG;YACH,IAAW,eAAe;gBACtB,OAAO,IAAI,CAAC,oBAAoB,CAAC;YACrC,CAAC;YAED,IAAW,eAAe,CAAC,KAAY;gBACnC,IAAI,IAAI,CAAC,oBAAoB,KAAK,KAAK,EAAE,CAAC;oBACtC,OAAO;gBACX,CAAC;gBAED,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;gBAElC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,2BAA2B,KAAK,CAAC,EAAE,CAAC;oBAC5D,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;wBAClB,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE;4BACvC,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;4BAC7E,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC;4BACrC,IAAI,CAAC,YA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AND,mOAAO,2BAA2B,6BAA3B,2BAA2B,iIAAK;;;;;SAb9B,cAAc","sourcesContent":["import { type Vector2 } from \"core/Maths/math.vector\";\r\nimport { BaseSlider } from \"./baseSlider\";\r\nimport { type Control } from \"../control\";\r\nimport { type Image } from \"../image\";\r\nimport { Measure } from \"../../measure\";\r\nimport { type PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { type ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class ImageScrollBar extends BaseSlider {\r\n private _backgroundBaseImage: Image;\r\n private _backgroundImage: Image;\r\n private _thumbImage: Image;\r\n private _thumbBaseImage: Image;\r\n private _thumbLength: number = 0.5;\r\n private _thumbHeight: number = 1;\r\n private _barImageHeight: number = 1;\r\n private _tempMeasure = new Measure(0, 0, 0, 0);\r\n private _invertScrollDirection = false;\r\n\r\n /** Number of 90° rotation to apply on the images when in vertical mode */\r\n @serialize()\r\n public num90RotationInVerticalMode = 1;\r\n\r\n /** Inverts the scrolling direction (default: false) */\r\n @serialize()\r\n public get invertScrollDirection() {\r\n return this._invertScrollDirection;\r\n }\r\n\r\n public set invertScrollDirection(invert: boolean) {\r\n this._invertScrollDirection = invert;\r\n }\r\n\r\n /**\r\n * Gets or sets the image used to render the background for horizontal bar\r\n */\r\n public get backgroundImage(): Image {\r\n return this._backgroundBaseImage;\r\n }\r\n\r\n public set backgroundImage(value: Image) {\r\n if (this._backgroundBaseImage === value) {\r\n return;\r\n }\r\n\r\n this._backgroundBaseImage = value;\r\n\r\n if (this.isVertical && this.num90RotationInVerticalMode !== 0) {\r\n if (!value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n const rotatedValue = value._rotate90(this.num90RotationInVerticalMode, true);\r\n this._backgroundImage = rotatedValue;\r\n if (!rotatedValue.isLoaded) {\r\n rotatedValue.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n this._markAsDirty();\r\n });\r\n } else {\r\n this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);\r\n this._markAsDirty();\r\n }\r\n } else {\r\n this._backgroundImage = value;\r\n if (value && !value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the image used to render the thumb\r\n */\r\n public get thumbImage(): Image {\r\n return this._thumbBaseImage;\r\n }\r\n\r\n public set thumbImage(value: Image) {\r\n if (this._thumbBaseImage === value) {\r\n return;\r\n }\r\n\r\n this._thumbBaseImage = value;\r\n\r\n if (this.isVertical && this.num90RotationInVerticalMode !== 0) {\r\n if (!value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n const rotatedValue = value._rotate90(-this.num90RotationInVerticalMode, true);\r\n this._thumbImage = rotatedValue;\r\n if (!rotatedValue.isLoaded) {\r\n rotatedValue.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n this._markAsDirty();\r\n });\r\n } else {\r\n this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);\r\n this._markAsDirty();\r\n }\r\n } else {\r\n this._thumbImage = value;\r\n if (value && !value.isLoaded) {\r\n value.onImageLoadedObservable.addOnce(() => {\r\n this._markAsDirty();\r\n });\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the length of the thumb\r\n */\r\n public get thumbLength(): number {\r\n return this._thumbLength;\r\n }\r\n\r\n public set thumbLength(value: number) {\r\n if (this._thumbLength === value) {\r\n return;\r\n }\r\n\r\n this._thumbLength = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height of the thumb\r\n */\r\n public get thumbHeight(): number {\r\n return this._thumbHeight;\r\n }\r\n\r\n public set thumbHeight(value: number) {\r\n if (this._thumbHeight === value) {\r\n return;\r\n }\r\n\r\n this._thumbHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height of the bar image\r\n */\r\n public get barImageHeight(): number {\r\n return this._barImageHeight;\r\n }\r\n\r\n public set barImageHeight(value: number) {\r\n if (this._barImageHeight === value) {\r\n return;\r\n }\r\n\r\n this._barImageHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new ImageScrollBar\r\n * @param name defines the control name\r\n */\r\n constructor(public override name?: string) {\r\n super(name);\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"ImageScrollBar\";\r\n }\r\n\r\n protected override _getThumbThickness(): number {\r\n let thumbThickness: number;\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = this._thumbWidth.getValue(this._host);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n return thumbThickness;\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n this._prepareRenderingData(\"rectangle\");\r\n const thumbPosition = this._getThumbPosition();\r\n const left = this._renderLeft;\r\n const top = this._renderTop;\r\n const width = this._renderWidth;\r\n const height = this._renderHeight;\r\n\r\n // Background\r\n if (this._backgroundImage) {\r\n this._tempMeasure.copyFromFloats(left, top, width, height);\r\n if (this.isVertical) {\r\n this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);\r\n this._tempMeasure.height += this._effectiveThumbThickness;\r\n this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);\r\n } else {\r\n this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);\r\n this._tempMeasure.width += this._effectiveThumbThickness;\r\n this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);\r\n }\r\n this._backgroundImage._draw(context);\r\n }\r\n\r\n // Thumb\r\n if (this.isVertical) {\r\n this._tempMeasure.copyFromFloats(\r\n left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5,\r\n this._currentMeasure.top + thumbPosition,\r\n this._currentMeasure.width * this._thumbHeight,\r\n this._effectiveThumbThickness\r\n );\r\n } else {\r\n this._tempMeasure.copyFromFloats(\r\n this._currentMeasure.left + thumbPosition,\r\n this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5,\r\n this._effectiveThumbThickness,\r\n this._currentMeasure.height * this._thumbHeight\r\n );\r\n }\r\n\r\n if (this._thumbImage) {\r\n this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);\r\n this._thumbImage._draw(context);\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _first: boolean;\r\n private _originX: number;\r\n private _originY: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n protected override _updateValueFromPointer(x: number, y: number): void {\r\n this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);\r\n x = this._transformedPosition.x;\r\n y = this._transformedPosition.y;\r\n\r\n const sign = this._invertScrollDirection ? -1 : 1;\r\n\r\n if (this._first) {\r\n this._first = false;\r\n this._originX = x;\r\n this._originY = y;\r\n\r\n // Check if move is required\r\n if (\r\n x < this._tempMeasure.left ||\r\n x > this._tempMeasure.left + this._tempMeasure.width ||\r\n y < this._tempMeasure.top ||\r\n y > this._tempMeasure.top + this._tempMeasure.height\r\n ) {\r\n if (this.isVertical) {\r\n this.value = this.minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this.maximum - this.minimum);\r\n } else {\r\n this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);\r\n }\r\n }\r\n }\r\n\r\n // Delta mode\r\n let delta: number;\r\n if (this.isVertical) {\r\n delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));\r\n } else {\r\n delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);\r\n }\r\n\r\n this.value += sign * delta * (this.maximum - this.minimum);\r\n\r\n this._originX = x;\r\n this._originY = y;\r\n }\r\n\r\n public override _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n this._first = true;\r\n\r\n return super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);\r\n }\r\n}\r\n"]}