@effindomv2/fui-as 0.1.36 → 0.1.39
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/browser/routed-app-conventions.ts +1 -1
- package/browser/src/common-harness.ts +1 -27
- package/browser/src/index.ts +19 -26
- package/browser/src/routed-harness.ts +1 -194
- package/browser/src/shared-browser.ts +6 -0
- package/package.json +26 -16
- package/scripts/build.sh +51 -47
- package/scripts/framework-host-services.ts +1 -1
- package/scripts/generate-host-events.ts +15 -241
- package/scripts/generate-host-services.ts +13 -261
- package/scripts/hostgen/assemblyscript-host-events.ts +165 -0
- package/scripts/hostgen/assemblyscript-host-services.ts +207 -0
- package/scripts/hostgen/common.ts +73 -0
- package/scripts/hostgen/registry.ts +159 -0
- package/src/Fui.ts +70 -4
- package/src/FuiExports.ts +13 -1
- package/src/bindings/ui.ts +165 -8
- package/src/controls/Button.ts +98 -71
- package/src/controls/Checkbox.ts +23 -21
- package/src/controls/ComboBox.ts +1201 -0
- package/src/controls/ContextMenu.ts +279 -165
- package/src/controls/Dialog.ts +91 -17
- package/src/controls/Dropdown.ts +101 -333
- package/src/controls/NavLink.ts +29 -6
- package/src/controls/Popup.ts +10 -5
- package/src/controls/ProgressBar.ts +1 -2
- package/src/controls/RadioButton.ts +34 -13
- package/src/controls/RadioGroup.ts +32 -19
- package/src/controls/Slider.ts +21 -23
- package/src/controls/Switch.ts +34 -17
- package/src/controls/index.ts +2 -1
- package/src/controls/internal/ButtonPresenter.ts +5 -2
- package/src/controls/internal/CheckboxIndicatorPresenter.ts +10 -10
- package/src/controls/internal/DropdownChevronPresenter.ts +3 -3
- package/src/controls/internal/DropdownFieldPresenter.ts +6 -6
- package/src/controls/internal/DropdownOptionRowPresenter.ts +5 -4
- package/src/controls/internal/PressableLabeledControl.ts +4 -7
- package/src/controls/internal/RadioIndicatorPresenter.ts +7 -7
- package/src/controls/internal/SelectablePopupList.ts +463 -0
- package/src/controls/internal/SliderPresenter.ts +5 -5
- package/src/controls/internal/SwitchIndicatorPresenter.ts +63 -17
- package/src/controls/internal/TextInputCore.ts +307 -41
- package/src/controls/internal/TextInputPresenter.ts +2 -2
- package/src/controls/templating.ts +10 -0
- package/src/core/Application.ts +19 -9
- package/src/core/Bitmap.ts +219 -1
- package/src/core/ContextMenuManager.ts +128 -44
- package/src/core/DebugApi.ts +17 -2
- package/src/core/DragGesture.ts +8 -7
- package/src/core/EventRouter.ts +332 -12
- package/src/core/Fetch.ts +15 -7
- package/src/core/FetchFfi.ts +1 -15
- package/src/core/File.ts +75 -34
- package/src/core/FocusAdornerManager.ts +3 -3
- package/src/core/FocusVisibility.ts +7 -0
- package/src/core/FrameScheduler.ts +126 -0
- package/src/core/ImageSampling.ts +43 -0
- package/src/core/Logger.ts +2 -0
- package/src/core/MobileTextSelectionToolbarManager.ts +901 -0
- package/src/core/Node.ts +1039 -97
- package/src/core/Platform.ts +16 -16
- package/src/core/SelectionHandleAdornerManager.ts +697 -0
- package/src/core/Theme.ts +34 -20
- package/src/core/ToolTipManager.ts +3 -3
- package/src/core/Typography.ts +411 -19
- package/src/core/Worker.ts +69 -33
- package/src/core/event_exports.ts +123 -5
- package/src/core/ffi.ts +5 -746
- package/src/core/generated/FetchHostAbi.ts +10 -0
- package/src/core/generated/FrameworkHostServices.ts +1 -1
- package/src/core/generated/HostAbi.ts +220 -0
- package/src/core/generated/UiAbi.ts +356 -0
- package/src/core/generated/UiEnums.ts +186 -0
- package/src/drawing/DrawCallback.ts +34 -0
- package/src/drawing/DrawContext.ts +189 -0
- package/src/drawing/Paint.ts +34 -0
- package/src/drawing/Path.ts +40 -0
- package/src/nodes/CustomDrawable.ts +61 -0
- package/src/nodes/FlexBox.ts +57 -11
- package/src/nodes/Grid.ts +5 -5
- package/src/nodes/Image.ts +20 -1
- package/src/nodes/RichText.ts +36 -25
- package/src/nodes/ScrollBar.ts +2 -1
- package/src/nodes/ScrollBox.ts +7 -2
- package/src/nodes/ScrollView.ts +17 -6
- package/src/nodes/Svg.ts +18 -1
- package/src/nodes/Text.ts +1 -1
- package/src/nodes/TextCore.ts +115 -20
- package/src/nodes/index.ts +3 -1
- package/src/text/DynamicTextLayout.ts +275 -0
- package/src/text/TextLayout.ts +308 -0
- package/src/worker/Worker.ts +3 -36
- package/src/worker/WorkerJob.ts +5 -9
- package/src/worker/ffi.ts +0 -6
- package/browser/src/common-harness/host-imports.ts +0 -447
- package/browser/src/common-harness/interop.ts +0 -39
- package/browser/src/common-harness/managed-harness-bitmap-host.ts +0 -92
- package/browser/src/common-harness/managed-harness-fetch-host.ts +0 -201
- package/browser/src/common-harness/managed-harness-file-host.ts +0 -1066
- package/browser/src/common-harness/managed-harness-file-payloads.ts +0 -143
- package/browser/src/common-harness/managed-harness-file-types.ts +0 -71
- package/browser/src/common-harness/managed-harness-session.ts +0 -15
- package/browser/src/common-harness/managed-harness.ts +0 -1451
- package/browser/src/common-harness/managed-history.ts +0 -168
- package/browser/src/common-harness/persisted-restore-policy.ts +0 -50
- package/browser/src/common-harness/persisted-ui-state-controller.ts +0 -309
- package/browser/src/common-harness/text-session-bridge.ts +0 -452
- package/browser/src/common-harness/types.ts +0 -205
- package/browser/src/common-harness/ui-chrome.ts +0 -206
- package/browser/src/common-harness/ui-imports.ts +0 -553
- package/browser/src/common-harness/wasm-module-cache.ts +0 -47
- package/browser/src/file-processing-worker.ts +0 -89
- package/browser/src/host-events.ts +0 -118
- package/browser/src/host-services.ts +0 -483
- package/browser/src/persisted-ui-state.ts +0 -206
- package/browser/src/routed-app-conventions.ts +0 -292
- package/browser/src/worker-bootstrap.ts +0 -916
- package/browser/src/worker-manager.ts +0 -234
- package/browser/src/worker-types.ts +0 -68
package/src/controls/Button.ts
CHANGED
|
@@ -10,16 +10,17 @@ import {
|
|
|
10
10
|
JustifyContent,
|
|
11
11
|
SemanticRole,
|
|
12
12
|
} from "../core/ffi";
|
|
13
|
-
import {
|
|
13
|
+
import { Callback1, Handler1 } from "../core/BoundCallback";
|
|
14
14
|
import { HandlerAction } from "../core/Action";
|
|
15
|
-
import {
|
|
15
|
+
import { bind1 } from "../core/bind";
|
|
16
16
|
import { Disposable, disposeAll } from "../core/Disposable";
|
|
17
17
|
import { FocusAdornerManager } from "../core/FocusAdornerManager";
|
|
18
18
|
import { keyboardFocusVisible } from "../core/FocusVisibility";
|
|
19
19
|
import { Signal } from "../core/Signal";
|
|
20
20
|
import { Theme, activeTheme } from "../core/Theme";
|
|
21
21
|
import { FontFamily, FontStyle, FontWeight } from "../core/Typography";
|
|
22
|
-
import { FlexBox, TextCore } from "../nodes";
|
|
22
|
+
import { Border, FlexBox, TextCore } from "../nodes";
|
|
23
|
+
import { ClickEventArgs, HoverChangedEventArgs, PointerEventArgs } from "../core/Node";
|
|
23
24
|
import { ButtonColors } from "./ButtonColors";
|
|
24
25
|
import { getControlTemplates } from "./ControlTemplateSet";
|
|
25
26
|
import {
|
|
@@ -50,9 +51,6 @@ class ButtonPresenterHostState {
|
|
|
50
51
|
readonly borderWidthValue: f32,
|
|
51
52
|
readonly borderColorValue: u32,
|
|
52
53
|
readonly borderStyleValue: BorderStyle,
|
|
53
|
-
readonly borderDashOnValue: f32,
|
|
54
|
-
readonly borderDashOffValue: f32,
|
|
55
|
-
readonly borderDashedValue: bool,
|
|
56
54
|
readonly shadowOverridden: bool,
|
|
57
55
|
readonly shadowColorValue: u32,
|
|
58
56
|
readonly shadowOffsetXValue: f32,
|
|
@@ -74,10 +72,14 @@ export class Button extends FlexBox {
|
|
|
74
72
|
private readonly hovered: Signal<bool> = new Signal<bool>(false);
|
|
75
73
|
private readonly pressed: Signal<bool> = new Signal<bool>(false);
|
|
76
74
|
private readonly disposables: Array<Disposable> = new Array<Disposable>();
|
|
77
|
-
private action: (() => void) | null = null;
|
|
78
|
-
private actionBinding:
|
|
79
|
-
private
|
|
80
|
-
private
|
|
75
|
+
private action: ((event: ClickEventArgs) => void) | null = null;
|
|
76
|
+
private actionBinding: Callback1<ClickEventArgs> | null = null;
|
|
77
|
+
private doubleAction: ((event: ClickEventArgs) => void) | null = null;
|
|
78
|
+
private doubleActionBinding: Callback1<ClickEventArgs> | null = null;
|
|
79
|
+
private tripleAction: ((event: ClickEventArgs) => void) | null = null;
|
|
80
|
+
private tripleActionBinding: Callback1<ClickEventArgs> | null = null;
|
|
81
|
+
private hoverChanged: ((event: HoverChangedEventArgs) => void) | null = null;
|
|
82
|
+
private hoverChangedBinding: Callback1<HoverChangedEventArgs> | null = null;
|
|
81
83
|
private disposed: bool = false;
|
|
82
84
|
private focusedState: bool = false;
|
|
83
85
|
private opacityBeforeDisabled: f32 = 1.0;
|
|
@@ -101,9 +103,6 @@ export class Button extends FlexBox {
|
|
|
101
103
|
private borderWidthValue: f32 = 1.0;
|
|
102
104
|
private borderColorValue: u32 = activeTheme.value.colors.border;
|
|
103
105
|
private borderStyleValue: BorderStyle = BorderStyle.Solid;
|
|
104
|
-
private borderDashOnValue: f32 = 0.0;
|
|
105
|
-
private borderDashOffValue: f32 = 0.0;
|
|
106
|
-
private borderDashedValue: bool = false;
|
|
107
106
|
private paddingLeftValue: f32 = activeTheme.value.spacing.md;
|
|
108
107
|
private paddingTopValue: f32 = activeTheme.value.spacing.sm;
|
|
109
108
|
private paddingRightValue: f32 = activeTheme.value.spacing.md;
|
|
@@ -112,8 +111,6 @@ export class Button extends FlexBox {
|
|
|
112
111
|
private fontWeightValue: FontWeight = FontWeight.Regular;
|
|
113
112
|
private fontStyleValue: FontStyle = FontStyle.Normal;
|
|
114
113
|
private fontSizeValue: f32 = activeTheme.value.fonts.sizeBody;
|
|
115
|
-
private fontIdValue: u32 = 0;
|
|
116
|
-
private hasFontIdOverride: bool = false;
|
|
117
114
|
private textColorValue: u32 = activeTheme.value.colors.textOnAccent;
|
|
118
115
|
private shadowColorValue: u32 = 0x00000000;
|
|
119
116
|
private shadowOffsetXValue: f32 = 0.0;
|
|
@@ -157,36 +154,70 @@ export class Button extends FlexBox {
|
|
|
157
154
|
this.applyBackground();
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
onClick(cb: () => void): this {
|
|
157
|
+
onClick(cb: (event: ClickEventArgs) => void): this {
|
|
161
158
|
this.action = cb;
|
|
162
159
|
this.actionBinding = null;
|
|
163
160
|
return this;
|
|
164
161
|
}
|
|
165
162
|
|
|
166
|
-
bindClick<Owner>(owner: Owner, handler:
|
|
163
|
+
bindClick<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
167
164
|
this.action = null;
|
|
168
|
-
this.actionBinding =
|
|
165
|
+
this.actionBinding = bind1<Owner, ClickEventArgs>(owner, handler);
|
|
169
166
|
return this;
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
onClickWith<Owner>(owner: Owner, handler:
|
|
169
|
+
onClickWith<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
173
170
|
this.bindClick(owner, handler);
|
|
174
171
|
return this;
|
|
175
172
|
}
|
|
176
173
|
|
|
177
|
-
|
|
174
|
+
onDoubleClick(cb: (event: ClickEventArgs) => void): this {
|
|
175
|
+
this.doubleAction = cb;
|
|
176
|
+
this.doubleActionBinding = null;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
bindDoubleClick<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
181
|
+
this.doubleAction = null;
|
|
182
|
+
this.doubleActionBinding = bind1<Owner, ClickEventArgs>(owner, handler);
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
onDoubleClickWith<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
187
|
+
this.bindDoubleClick(owner, handler);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
onTripleClick(cb: (event: ClickEventArgs) => void): this {
|
|
192
|
+
this.tripleAction = cb;
|
|
193
|
+
this.tripleActionBinding = null;
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
bindTripleClick<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
198
|
+
this.tripleAction = null;
|
|
199
|
+
this.tripleActionBinding = bind1<Owner, ClickEventArgs>(owner, handler);
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
onTripleClickWith<Owner>(owner: Owner, handler: Handler1<Owner, ClickEventArgs>): this {
|
|
204
|
+
this.bindTripleClick(owner, handler);
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
onHoverChanged(cb: (event: HoverChangedEventArgs) => void): this {
|
|
178
209
|
this.hoverChanged = cb;
|
|
179
210
|
this.hoverChangedBinding = null;
|
|
180
211
|
return this;
|
|
181
212
|
}
|
|
182
213
|
|
|
183
|
-
bindHoverChanged<Owner>(owner: Owner, handler: Handler1<Owner,
|
|
214
|
+
bindHoverChanged<Owner>(owner: Owner, handler: Handler1<Owner, HoverChangedEventArgs>): this {
|
|
184
215
|
this.hoverChanged = null;
|
|
185
|
-
this.hoverChangedBinding = bind1<Owner,
|
|
216
|
+
this.hoverChangedBinding = bind1<Owner, HoverChangedEventArgs>(owner, handler);
|
|
186
217
|
return this;
|
|
187
218
|
}
|
|
188
219
|
|
|
189
|
-
onHoverChangedWith<Owner>(owner: Owner, handler: Handler1<Owner,
|
|
220
|
+
onHoverChangedWith<Owner>(owner: Owner, handler: Handler1<Owner, HoverChangedEventArgs>): this {
|
|
190
221
|
this.bindHoverChanged(owner, handler);
|
|
191
222
|
return this;
|
|
192
223
|
}
|
|
@@ -254,22 +285,21 @@ export class Button extends FlexBox {
|
|
|
254
285
|
return this;
|
|
255
286
|
}
|
|
256
287
|
|
|
257
|
-
border(width: f32, color: u32
|
|
288
|
+
border(width: f32, color: u32): this {
|
|
258
289
|
this.borderOverridden = true;
|
|
259
290
|
this.borderWidthValue = width;
|
|
260
291
|
this.borderColorValue = color;
|
|
261
|
-
this.borderStyleValue =
|
|
262
|
-
this.borderDashedValue = false;
|
|
292
|
+
this.borderStyleValue = BorderStyle.Solid;
|
|
263
293
|
this.applyCurrentBorder();
|
|
264
294
|
return this;
|
|
265
295
|
}
|
|
266
296
|
|
|
267
|
-
|
|
297
|
+
borderConfig(border: Border): this {
|
|
268
298
|
this.borderOverridden = true;
|
|
269
|
-
this.
|
|
270
|
-
this.
|
|
271
|
-
this.
|
|
272
|
-
|
|
299
|
+
this.borderWidthValue = border.width;
|
|
300
|
+
this.borderColorValue = border.color;
|
|
301
|
+
this.borderStyleValue = border.style;
|
|
302
|
+
this.applyCurrentBorder();
|
|
273
303
|
return this;
|
|
274
304
|
}
|
|
275
305
|
|
|
@@ -295,18 +325,8 @@ export class Button extends FlexBox {
|
|
|
295
325
|
return this;
|
|
296
326
|
}
|
|
297
327
|
|
|
298
|
-
font(fontId: u32, size: f32): this {
|
|
299
|
-
this.fontOverridden = true;
|
|
300
|
-
this.hasFontIdOverride = true;
|
|
301
|
-
this.fontIdValue = fontId;
|
|
302
|
-
this.fontSizeValue = size;
|
|
303
|
-
this.labelNode.font(fontId, size);
|
|
304
|
-
return this;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
328
|
fontFamily(family: FontFamily): this {
|
|
308
329
|
this.fontOverridden = true;
|
|
309
|
-
this.hasFontIdOverride = false;
|
|
310
330
|
this.fontFamilyValue = family;
|
|
311
331
|
this.labelNode.fontFamily(family);
|
|
312
332
|
return this;
|
|
@@ -314,7 +334,6 @@ export class Button extends FlexBox {
|
|
|
314
334
|
|
|
315
335
|
fontWeight(weight: FontWeight): this {
|
|
316
336
|
this.fontOverridden = true;
|
|
317
|
-
this.hasFontIdOverride = false;
|
|
318
337
|
this.fontWeightValue = weight;
|
|
319
338
|
this.labelNode.fontWeight(weight);
|
|
320
339
|
return this;
|
|
@@ -322,7 +341,6 @@ export class Button extends FlexBox {
|
|
|
322
341
|
|
|
323
342
|
fontStyle(style: FontStyle): this {
|
|
324
343
|
this.fontOverridden = true;
|
|
325
|
-
this.hasFontIdOverride = false;
|
|
326
344
|
this.fontStyleValue = style;
|
|
327
345
|
this.labelNode.fontStyle(style);
|
|
328
346
|
return this;
|
|
@@ -331,10 +349,6 @@ export class Button extends FlexBox {
|
|
|
331
349
|
fontSize(size: f32): this {
|
|
332
350
|
this.fontOverridden = true;
|
|
333
351
|
this.fontSizeValue = size;
|
|
334
|
-
if (this.hasFontIdOverride) {
|
|
335
|
-
this.labelNode.font(this.fontIdValue, size);
|
|
336
|
-
return this;
|
|
337
|
-
}
|
|
338
352
|
this.labelNode.fontSize(size);
|
|
339
353
|
return this;
|
|
340
354
|
}
|
|
@@ -346,7 +360,7 @@ export class Button extends FlexBox {
|
|
|
346
360
|
return this;
|
|
347
361
|
}
|
|
348
362
|
|
|
349
|
-
_setAction(cb: () => void): void {
|
|
363
|
+
_setAction(cb: (event: ClickEventArgs) => void): void {
|
|
350
364
|
this.action = cb;
|
|
351
365
|
this.actionBinding = null;
|
|
352
366
|
}
|
|
@@ -355,7 +369,7 @@ export class Button extends FlexBox {
|
|
|
355
369
|
this.pressed.value = true;
|
|
356
370
|
}
|
|
357
371
|
|
|
358
|
-
endPress(fireAction: bool = true): void {
|
|
372
|
+
endPress(clickCount: i32 = 1, fireAction: bool = true): void {
|
|
359
373
|
const wasPressed = this.pressed.value;
|
|
360
374
|
this.pressed.value = false;
|
|
361
375
|
if (!wasPressed || !fireAction) {
|
|
@@ -363,11 +377,31 @@ export class Button extends FlexBox {
|
|
|
363
377
|
}
|
|
364
378
|
const callback = this.action;
|
|
365
379
|
if (callback !== null) {
|
|
366
|
-
callback();
|
|
380
|
+
callback(ClickEventArgs.Empty);
|
|
367
381
|
}
|
|
368
382
|
const binding = this.actionBinding;
|
|
369
383
|
if (binding !== null) {
|
|
370
|
-
binding.invoke();
|
|
384
|
+
binding.invoke(ClickEventArgs.Empty);
|
|
385
|
+
}
|
|
386
|
+
if (clickCount == 2) {
|
|
387
|
+
const doubleCallback = this.doubleAction;
|
|
388
|
+
if (doubleCallback !== null) {
|
|
389
|
+
doubleCallback(ClickEventArgs.Empty);
|
|
390
|
+
}
|
|
391
|
+
const doubleBinding = this.doubleActionBinding;
|
|
392
|
+
if (doubleBinding !== null) {
|
|
393
|
+
doubleBinding.invoke(ClickEventArgs.Empty);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (clickCount == 3) {
|
|
397
|
+
const tripleCallback = this.tripleAction;
|
|
398
|
+
if (tripleCallback !== null) {
|
|
399
|
+
tripleCallback(ClickEventArgs.Empty);
|
|
400
|
+
}
|
|
401
|
+
const tripleBinding = this.tripleActionBinding;
|
|
402
|
+
if (tripleBinding !== null) {
|
|
403
|
+
tripleBinding.invoke(ClickEventArgs.Empty);
|
|
404
|
+
}
|
|
371
405
|
}
|
|
372
406
|
}
|
|
373
407
|
|
|
@@ -397,6 +431,13 @@ export class Button extends FlexBox {
|
|
|
397
431
|
}
|
|
398
432
|
|
|
399
433
|
_handlePointerEvent(eventType: PointerEventType, x: f32, y: f32, modifiers: u32): void {
|
|
434
|
+
const pending = Button.pendingPointerEventArgs;
|
|
435
|
+
const event = pending !== null &&
|
|
436
|
+
changetype<PointerEventArgs>(pending).eventType == eventType &&
|
|
437
|
+
changetype<PointerEventArgs>(pending).sceneX == x &&
|
|
438
|
+
changetype<PointerEventArgs>(pending).sceneY == y
|
|
439
|
+
? changetype<PointerEventArgs>(pending)
|
|
440
|
+
: null;
|
|
400
441
|
if (!this.isEnabled) {
|
|
401
442
|
return;
|
|
402
443
|
}
|
|
@@ -418,7 +459,7 @@ export class Button extends FlexBox {
|
|
|
418
459
|
return;
|
|
419
460
|
}
|
|
420
461
|
if (eventType == PointerEventType.Up && this.pressed.value) {
|
|
421
|
-
this.endPress(true);
|
|
462
|
+
this.endPress(event === null || event.clickCount <= 0 ? 1 : event.clickCount, true);
|
|
422
463
|
}
|
|
423
464
|
}
|
|
424
465
|
|
|
@@ -456,7 +497,7 @@ export class Button extends FlexBox {
|
|
|
456
497
|
}
|
|
457
498
|
if (eventType == KeyEventType.Up && this.keyboardArmedKey !== null && changetype<string>(this.keyboardArmedKey) == key) {
|
|
458
499
|
this.keyboardArmedKey = null;
|
|
459
|
-
this.endPress(true);
|
|
500
|
+
this.endPress(1, true);
|
|
460
501
|
return true;
|
|
461
502
|
}
|
|
462
503
|
return callbackHandled;
|
|
@@ -496,13 +537,14 @@ export class Button extends FlexBox {
|
|
|
496
537
|
if (!this.hovered.set(next)) {
|
|
497
538
|
return;
|
|
498
539
|
}
|
|
540
|
+
const event = new HoverChangedEventArgs(next);
|
|
499
541
|
const callback = this.hoverChanged;
|
|
500
542
|
if (callback !== null) {
|
|
501
|
-
callback(
|
|
543
|
+
callback(event);
|
|
502
544
|
}
|
|
503
545
|
const binding = this.hoverChangedBinding;
|
|
504
546
|
if (binding !== null) {
|
|
505
|
-
binding.invoke(
|
|
547
|
+
binding.invoke(event);
|
|
506
548
|
}
|
|
507
549
|
}
|
|
508
550
|
|
|
@@ -545,7 +587,6 @@ export class Button extends FlexBox {
|
|
|
545
587
|
? colors.borderColor
|
|
546
588
|
: theme.colors.border;
|
|
547
589
|
this.borderStyleValue = BorderStyle.Solid;
|
|
548
|
-
this.borderDashedValue = false;
|
|
549
590
|
}
|
|
550
591
|
if (!this.shadowOverridden) {
|
|
551
592
|
this.shadowColorValue = 0x00000000;
|
|
@@ -563,7 +604,6 @@ export class Button extends FlexBox {
|
|
|
563
604
|
this.paddingBottomValue = paddingY;
|
|
564
605
|
}
|
|
565
606
|
if (!this.fontOverridden) {
|
|
566
|
-
this.hasFontIdOverride = false;
|
|
567
607
|
this.fontFamilyValue = theme.fonts.bodyFamily;
|
|
568
608
|
this.fontWeightValue = FontWeight.Regular;
|
|
569
609
|
this.fontStyleValue = FontStyle.Normal;
|
|
@@ -590,9 +630,6 @@ export class Button extends FlexBox {
|
|
|
590
630
|
this.borderWidthValue,
|
|
591
631
|
this.borderColorValue,
|
|
592
632
|
this.borderStyleValue,
|
|
593
|
-
this.borderDashOnValue,
|
|
594
|
-
this.borderDashOffValue,
|
|
595
|
-
this.borderDashedValue,
|
|
596
633
|
this.shadowOverridden,
|
|
597
634
|
this.shadowColorValue,
|
|
598
635
|
this.shadowOffsetXValue,
|
|
@@ -617,9 +654,6 @@ export class Button extends FlexBox {
|
|
|
617
654
|
this.borderWidthValue = presenterHostState.borderWidthValue;
|
|
618
655
|
this.borderColorValue = presenterHostState.borderColorValue;
|
|
619
656
|
this.borderStyleValue = presenterHostState.borderStyleValue;
|
|
620
|
-
this.borderDashOnValue = presenterHostState.borderDashOnValue;
|
|
621
|
-
this.borderDashOffValue = presenterHostState.borderDashOffValue;
|
|
622
|
-
this.borderDashedValue = presenterHostState.borderDashedValue;
|
|
623
657
|
this.shadowOverridden = presenterHostState.shadowOverridden;
|
|
624
658
|
this.shadowColorValue = presenterHostState.shadowColorValue;
|
|
625
659
|
this.shadowOffsetXValue = presenterHostState.shadowOffsetXValue;
|
|
@@ -723,10 +757,7 @@ export class Button extends FlexBox {
|
|
|
723
757
|
}
|
|
724
758
|
|
|
725
759
|
private applyCurrentBorder(): void {
|
|
726
|
-
super.
|
|
727
|
-
if (this.borderDashedValue) {
|
|
728
|
-
super.borderDashed(this.borderDashOnValue, this.borderDashOffValue);
|
|
729
|
-
}
|
|
760
|
+
super.borderConfig(new Border(this.borderWidthValue, this.borderColorValue, this.borderStyleValue));
|
|
730
761
|
}
|
|
731
762
|
|
|
732
763
|
private applyCurrentPadding(): void {
|
|
@@ -749,10 +780,6 @@ export class Button extends FlexBox {
|
|
|
749
780
|
}
|
|
750
781
|
|
|
751
782
|
private applyCurrentLabelTypography(): void {
|
|
752
|
-
if (this.hasFontIdOverride) {
|
|
753
|
-
this.labelNode.font(this.fontIdValue, this.fontSizeValue);
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
783
|
this.labelNode
|
|
757
784
|
.fontFamily(this.fontFamilyValue)
|
|
758
785
|
.fontWeight(this.fontWeightValue)
|
package/src/controls/Checkbox.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Callback1, Handler1 } from "../core/BoundCallback";
|
|
2
2
|
import { SemanticCheckedState, SemanticRole } from "../core/ffi";
|
|
3
|
+
import { CheckboxChangedEventArgs } from "../core/Node";
|
|
3
4
|
import { PersistedInt32Codec, PersistedValueState } from "../core/PersistedState";
|
|
4
5
|
import { bind1 } from "../core/bind";
|
|
5
6
|
import { LabeledControlSizing } from "./ControlSizing";
|
|
@@ -42,13 +43,13 @@ const CHECKBOX_PERSISTED_STATE = new PersistedCheckboxState();
|
|
|
42
43
|
|
|
43
44
|
function createIndicatorPresenter(template: CheckboxIndicatorTemplate | null, sizing: LabeledControlSizing | null = null): CheckboxIndicatorPresenter {
|
|
44
45
|
if (template !== null) {
|
|
45
|
-
return template.create();
|
|
46
|
+
return template.create(sizing);
|
|
46
47
|
}
|
|
47
48
|
const templateSet = getControlTemplates();
|
|
48
49
|
const appTemplate = templateSet !== null ? templateSet.checkboxIndicator : null;
|
|
49
50
|
return appTemplate === null
|
|
50
51
|
? createDefaultCheckboxIndicatorPresenter(sizing)
|
|
51
|
-
: appTemplate.create();
|
|
52
|
+
: appTemplate.create(sizing);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
export class Checkbox extends PressableLabeledControl {
|
|
@@ -57,8 +58,8 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
57
58
|
private sizingValue: LabeledControlSizing | null = null;
|
|
58
59
|
private checkedStateValue: SemanticCheckedState = SemanticCheckedState.False;
|
|
59
60
|
private triStateEnabled: bool = false;
|
|
60
|
-
private changedCallback: ((
|
|
61
|
-
private changedBinding: Callback1<
|
|
61
|
+
private changedCallback: ((event: CheckboxChangedEventArgs) => void) | null = null;
|
|
62
|
+
private changedBinding: Callback1<CheckboxChangedEventArgs> | null = null;
|
|
62
63
|
|
|
63
64
|
constructor(label: string) {
|
|
64
65
|
const indicatorPresenter = createIndicatorPresenter(null);
|
|
@@ -80,13 +81,13 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
80
81
|
triState(flag: bool = true): this {
|
|
81
82
|
this.triStateEnabled = flag;
|
|
82
83
|
if (!flag && this.checkedStateValue == SemanticCheckedState.Mixed) {
|
|
83
|
-
this.setCheckedState(SemanticCheckedState.False, false);
|
|
84
|
+
this.setCheckedState(SemanticCheckedState.False, true, false);
|
|
84
85
|
}
|
|
85
86
|
return this;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
check(flag: bool): this {
|
|
89
|
-
this.setCheckedState(flag ? SemanticCheckedState.True : SemanticCheckedState.False, false);
|
|
90
|
+
this.setCheckedState(flag ? SemanticCheckedState.True : SemanticCheckedState.False, true, false);
|
|
90
91
|
return this;
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -94,7 +95,7 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
94
95
|
if (!this.triStateEnabled) {
|
|
95
96
|
return this;
|
|
96
97
|
}
|
|
97
|
-
this.setCheckedState(flag ? SemanticCheckedState.Mixed : SemanticCheckedState.False, false);
|
|
98
|
+
this.setCheckedState(flag ? SemanticCheckedState.Mixed : SemanticCheckedState.False, true, false);
|
|
98
99
|
return this;
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -103,11 +104,9 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
103
104
|
this.setLabelFontSizeOverride(
|
|
104
105
|
sizing !== null && sizing.hasLabelFontSize ? sizing.labelFontSizePx : 0.0,
|
|
105
106
|
);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.syncVisualState();
|
|
110
|
-
}
|
|
107
|
+
this.indicatorPresenter = createIndicatorPresenter(this.templateOverride, this.sizingValue);
|
|
108
|
+
this.replaceIndicatorRoot(this.indicatorPresenter.root);
|
|
109
|
+
this.syncVisualState();
|
|
111
110
|
return this;
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -119,19 +118,19 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
119
118
|
return this;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
onChanged(callback: ((
|
|
121
|
+
onChanged(callback: ((event: CheckboxChangedEventArgs) => void) | null): this {
|
|
123
122
|
this.changedCallback = callback;
|
|
124
123
|
this.changedBinding = null;
|
|
125
124
|
return this;
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
bindChanged<Owner>(owner: Owner, handler: Handler1<Owner,
|
|
127
|
+
bindChanged<Owner>(owner: Owner, handler: Handler1<Owner, CheckboxChangedEventArgs>): this {
|
|
129
128
|
this.changedCallback = null;
|
|
130
|
-
this.changedBinding = bind1<Owner,
|
|
129
|
+
this.changedBinding = bind1<Owner, CheckboxChangedEventArgs>(owner, handler);
|
|
131
130
|
return this;
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
onChangedWith<Owner>(owner: Owner, handler: Handler1<Owner,
|
|
133
|
+
onChangedWith<Owner>(owner: Owner, handler: Handler1<Owner, CheckboxChangedEventArgs>): this {
|
|
135
134
|
this.bindChanged(owner, handler);
|
|
136
135
|
return this;
|
|
137
136
|
}
|
|
@@ -170,10 +169,10 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
_applyPersistedCheckedState(next: SemanticCheckedState): void {
|
|
173
|
-
this.setCheckedState(next, true);
|
|
172
|
+
this.setCheckedState(next, true, false);
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
private setCheckedState(next: SemanticCheckedState, emit: bool): void {
|
|
175
|
+
private setCheckedState(next: SemanticCheckedState, emit: bool, announce: bool = emit): void {
|
|
177
176
|
if (!this.triStateEnabled && next == SemanticCheckedState.Mixed) {
|
|
178
177
|
next = SemanticCheckedState.False;
|
|
179
178
|
}
|
|
@@ -184,14 +183,17 @@ export class Checkbox extends PressableLabeledControl {
|
|
|
184
183
|
this.semanticChecked(next);
|
|
185
184
|
this.syncVisualState();
|
|
186
185
|
if (emit) {
|
|
187
|
-
|
|
186
|
+
if (announce) {
|
|
187
|
+
this.requestSemanticAnnouncement();
|
|
188
|
+
}
|
|
189
|
+
const event = new CheckboxChangedEventArgs(next);
|
|
188
190
|
const callback = this.changedCallback;
|
|
189
191
|
if (callback !== null) {
|
|
190
|
-
callback(
|
|
192
|
+
callback(event);
|
|
191
193
|
}
|
|
192
194
|
const binding = this.changedBinding;
|
|
193
195
|
if (binding !== null) {
|
|
194
|
-
binding.invoke(
|
|
196
|
+
binding.invoke(event);
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
}
|