@effindomv2/fui-as 0.1.37 → 0.1.41
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 +3 -0
- package/package.json +23 -13
- package/scripts/build.sh +70 -46
- package/scripts/check-runtime-dependency.sh +0 -19
- 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 +65 -5
- package/src/FuiExports.ts +12 -1
- package/src/bindings/ui.ts +157 -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 +17 -8
- package/src/core/Bitmap.ts +192 -3
- 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 +104 -5
- 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 -865
- 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 +17 -1
- package/src/drawing/DrawContext.ts +140 -32
- package/src/nodes/CustomDrawable.ts +8 -1
- package/src/nodes/FlexBox.ts +40 -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 +1 -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-canvas-host.ts +0 -72
- 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 -1472
- 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 -206
- package/browser/src/common-harness/ui-chrome.ts +0 -206
- package/browser/src/common-harness/ui-imports.ts +0 -559
- 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/Dialog.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as ui from "../bindings/ui";
|
|
2
|
-
import { Callback0, Handler0 } from "../core/BoundCallback";
|
|
2
|
+
import { Callback0, Callback1, Handler0, Handler1 } from "../core/BoundCallback";
|
|
3
|
+
import { ClickEventArgs, Node, PointerClickEventArgs, PointerEventArgs } from "../core/Node";
|
|
3
4
|
import { AlignItems, BorderStyle, FlexDirection, JustifyContent, SemanticRole, Unit } from "../core/ffi";
|
|
4
|
-
import { bind0 } from "../core/bind";
|
|
5
|
+
import { bind0, bind1 } from "../core/bind";
|
|
5
6
|
import { HandlerAction } from "../core/Action";
|
|
6
7
|
import { Disposable, disposeAll } from "../core/Disposable";
|
|
8
|
+
import { afterNextCommitWith } from "../core/FrameScheduler";
|
|
7
9
|
import { Theme, activeTheme } from "../core/Theme";
|
|
8
|
-
import { FlexBox, Portal, TextCore } from "../nodes";
|
|
10
|
+
import { Border, FlexBox, Portal, TextCore } from "../nodes";
|
|
9
11
|
import { Button } from "./Button";
|
|
10
12
|
import { Form } from "./Form";
|
|
11
13
|
|
|
@@ -16,19 +18,23 @@ const DIALOG_SHADOW_OFFSET_Y: f32 = 8.0;
|
|
|
16
18
|
const DIALOG_SHADOW_BLUR: f32 = 10.0;
|
|
17
19
|
const DIALOG_SHADOW_SPREAD: f32 = 0.0;
|
|
18
20
|
|
|
19
|
-
function
|
|
20
|
-
Dialog.cancelActiveDialog();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function handleDialogAcceptAction(): void {
|
|
21
|
+
function handleDialogAcceptAction(_event: ClickEventArgs): void {
|
|
24
22
|
Dialog.acceptActiveDialog();
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
function handleDialogCancelAction(): void {
|
|
25
|
+
function handleDialogCancelAction(_event: ClickEventArgs): void {
|
|
28
26
|
Dialog.cancelActiveDialog();
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
function absorbDialogCardPointer(
|
|
29
|
+
function absorbDialogCardPointer(_event: PointerEventArgs): void {}
|
|
30
|
+
|
|
31
|
+
function handleDialogShownAfterCommit(dialog: Dialog): void {
|
|
32
|
+
dialog.fireShownAfterCommit();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class DialogShownEventArgs {
|
|
36
|
+
static readonly Empty: DialogShownEventArgs = new DialogShownEventArgs();
|
|
37
|
+
}
|
|
32
38
|
|
|
33
39
|
export class Dialog extends Portal {
|
|
34
40
|
private static activeInstance: Dialog | null = null;
|
|
@@ -39,6 +45,9 @@ export class Dialog extends Portal {
|
|
|
39
45
|
private readonly bodyNode: TextCore = new TextCore("")
|
|
40
46
|
.selectable(false)
|
|
41
47
|
.semanticRole(SemanticRole.StaticText) as TextCore;
|
|
48
|
+
private readonly contentHost: FlexBox = new FlexBox()
|
|
49
|
+
.width(100.0, Unit.Percent)
|
|
50
|
+
.flexDirection(FlexDirection.Column) as FlexBox;
|
|
42
51
|
private readonly cancelButton: Button = new Button("Cancel")
|
|
43
52
|
.onClick(handleDialogCancelAction)
|
|
44
53
|
.width(108.0, Unit.Pixel) as Button;
|
|
@@ -64,6 +73,8 @@ export class Dialog extends Portal {
|
|
|
64
73
|
.child(this.titleNode)
|
|
65
74
|
.child(new FlexBox().width(100.0, Unit.Percent).height(12.0, Unit.Pixel))
|
|
66
75
|
.child(this.bodyNode)
|
|
76
|
+
.child(new FlexBox().width(100.0, Unit.Percent).height(16.0, Unit.Pixel))
|
|
77
|
+
.child(this.contentHost)
|
|
67
78
|
.child(new FlexBox().width(100.0, Unit.Percent).height(24.0, Unit.Pixel))
|
|
68
79
|
.child(this.form)
|
|
69
80
|
.onPointerDown(absorbDialogCardPointer)
|
|
@@ -74,12 +85,14 @@ export class Dialog extends Portal {
|
|
|
74
85
|
.justifyContent(JustifyContent.Center)
|
|
75
86
|
.alignItems(AlignItems.Center)
|
|
76
87
|
.child(this.card)
|
|
77
|
-
.
|
|
88
|
+
.onPointerClickWith(this, (dialog, event): void => dialog.handleBackdropClick(event)) as FlexBox;
|
|
78
89
|
private isDialogVisible: bool = false;
|
|
79
90
|
private acceptCallback: (() => void) | null = null;
|
|
80
91
|
private acceptBinding: Callback0 | null = null;
|
|
81
92
|
private cancelCallback: (() => void) | null = null;
|
|
82
93
|
private cancelBinding: Callback0 | null = null;
|
|
94
|
+
private shownCallback: ((event: DialogShownEventArgs) => void) | null = null;
|
|
95
|
+
private shownBinding: Callback1<DialogShownEventArgs> | null = null;
|
|
83
96
|
private semanticScopeToken: u32 = 0;
|
|
84
97
|
private readonly disposables: Array<Disposable> = new Array<Disposable>();
|
|
85
98
|
private backdropColorValue: u32 = activeTheme.value.colors.dialogBackdrop;
|
|
@@ -163,6 +176,23 @@ export class Dialog extends Portal {
|
|
|
163
176
|
return this;
|
|
164
177
|
}
|
|
165
178
|
|
|
179
|
+
onShown(cb: (event: DialogShownEventArgs) => void): this {
|
|
180
|
+
this.shownCallback = cb;
|
|
181
|
+
this.shownBinding = null;
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
bindShown<Owner>(owner: Owner, handler: Handler1<Owner, DialogShownEventArgs>): this {
|
|
186
|
+
this.shownCallback = null;
|
|
187
|
+
this.shownBinding = bind1<Owner, DialogShownEventArgs>(owner, handler);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
onShownWith<Owner>(owner: Owner, handler: Handler1<Owner, DialogShownEventArgs>): this {
|
|
192
|
+
this.bindShown(owner, handler);
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
|
|
166
196
|
get titleText(): TextCore {
|
|
167
197
|
return this.titleNode;
|
|
168
198
|
}
|
|
@@ -210,11 +240,20 @@ export class Dialog extends Portal {
|
|
|
210
240
|
return this;
|
|
211
241
|
}
|
|
212
242
|
|
|
213
|
-
cardBorder(width: f32, color: u32
|
|
243
|
+
cardBorder(width: f32, color: u32): this {
|
|
214
244
|
this.cardBorderOverridden = true;
|
|
215
245
|
this.cardBorderWidthValue = width;
|
|
216
246
|
this.cardBorderColorValue = color;
|
|
217
|
-
this.cardBorderStyleValue =
|
|
247
|
+
this.cardBorderStyleValue = BorderStyle.Solid;
|
|
248
|
+
this.applyTheme();
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
cardBorderConfig(border: Border): this {
|
|
253
|
+
this.cardBorderOverridden = true;
|
|
254
|
+
this.cardBorderWidthValue = border.width;
|
|
255
|
+
this.cardBorderColorValue = border.color;
|
|
256
|
+
this.cardBorderStyleValue = border.style;
|
|
218
257
|
this.applyTheme();
|
|
219
258
|
return this;
|
|
220
259
|
}
|
|
@@ -235,6 +274,15 @@ export class Dialog extends Portal {
|
|
|
235
274
|
return this;
|
|
236
275
|
}
|
|
237
276
|
|
|
277
|
+
bodyContent(node: Node | null): this {
|
|
278
|
+
const children = new Array<Node>();
|
|
279
|
+
if (node !== null) {
|
|
280
|
+
children.push(node);
|
|
281
|
+
}
|
|
282
|
+
this.contentHost.children(children);
|
|
283
|
+
return this;
|
|
284
|
+
}
|
|
285
|
+
|
|
238
286
|
show(): void {
|
|
239
287
|
this.applyTheme();
|
|
240
288
|
if (this.overlay.parentNode === null) {
|
|
@@ -244,9 +292,9 @@ export class Dialog extends Portal {
|
|
|
244
292
|
this.semanticScopeToken = ui.pushSemanticScope(this.overlay.builtHandle);
|
|
245
293
|
}
|
|
246
294
|
this.form.activate();
|
|
247
|
-
this.acceptButton.focusNow();
|
|
248
295
|
this.isDialogVisible = true;
|
|
249
296
|
Dialog.activeInstance = this;
|
|
297
|
+
afterNextCommitWith<Dialog>(this, handleDialogShownAfterCommit);
|
|
250
298
|
}
|
|
251
299
|
|
|
252
300
|
hide(): void {
|
|
@@ -307,6 +355,20 @@ export class Dialog extends Portal {
|
|
|
307
355
|
}
|
|
308
356
|
}
|
|
309
357
|
|
|
358
|
+
fireShownAfterCommit(): void {
|
|
359
|
+
if (!this.isDialogVisible || this.overlay.parentNode === null) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const callback = this.shownCallback;
|
|
363
|
+
if (callback !== null) {
|
|
364
|
+
callback(DialogShownEventArgs.Empty);
|
|
365
|
+
}
|
|
366
|
+
const binding = this.shownBinding;
|
|
367
|
+
if (binding !== null) {
|
|
368
|
+
binding.invoke(DialogShownEventArgs.Empty);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
310
372
|
private handleThemeChanged(theme: Theme): void {
|
|
311
373
|
if (!this.backdropColorOverridden) {
|
|
312
374
|
this.backdropColorValue = theme.colors.dialogBackdrop;
|
|
@@ -334,7 +396,7 @@ export class Dialog extends Portal {
|
|
|
334
396
|
this.overlay.backgroundBlur(this.dialogBackgroundBlurSigmaValue);
|
|
335
397
|
this.card.bgColor(this.cardBackgroundColorValue);
|
|
336
398
|
this.card.cornerRadius(this.cardCornerRadiusValue);
|
|
337
|
-
this.card.
|
|
399
|
+
this.card.borderConfig(new Border(this.cardBorderWidthValue, this.cardBorderColorValue, this.cardBorderStyleValue));
|
|
338
400
|
this.card.dropShadow(
|
|
339
401
|
this.shadowColorValue,
|
|
340
402
|
this.shadowOffsetXValue,
|
|
@@ -343,12 +405,24 @@ export class Dialog extends Portal {
|
|
|
343
405
|
this.shadowSpreadValue,
|
|
344
406
|
);
|
|
345
407
|
this.card.padding(24.0, 24.0, 24.0, 24.0);
|
|
346
|
-
this.titleNode.
|
|
408
|
+
this.titleNode.fontFamily(theme.fonts.headingFamily).fontSize(theme.fonts.sizeHeading);
|
|
347
409
|
this.titleNode.textColor(theme.colors.textPrimary);
|
|
348
|
-
this.bodyNode.
|
|
410
|
+
this.bodyNode.fontFamily(theme.fonts.bodyFamily).fontSize(theme.fonts.sizeBody);
|
|
349
411
|
this.bodyNode.textColor(theme.colors.textMuted);
|
|
350
412
|
}
|
|
351
413
|
|
|
414
|
+
private handleBackdropClick(event: PointerClickEventArgs): void {
|
|
415
|
+
const bounds = this.card.getBounds();
|
|
416
|
+
const left = bounds[0];
|
|
417
|
+
const top = bounds[1];
|
|
418
|
+
const right = left + bounds[2];
|
|
419
|
+
const bottom = top + bounds[3];
|
|
420
|
+
if (event.sceneX >= left && event.sceneX <= right && event.sceneY >= top && event.sceneY <= bottom) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
this.cancel();
|
|
424
|
+
}
|
|
425
|
+
|
|
352
426
|
private track(disposable: Disposable): void {
|
|
353
427
|
this.disposables.push(disposable);
|
|
354
428
|
}
|