@effindomv2/fui-as 0.1.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/LICENSE.md +7 -0
- package/browser/src/common-harness/host-imports.ts +430 -0
- package/browser/src/common-harness/interop.ts +39 -0
- package/browser/src/common-harness/managed-harness-bitmap-host.ts +92 -0
- package/browser/src/common-harness/managed-harness-fetch-host.ts +201 -0
- package/browser/src/common-harness/managed-harness-file-host.ts +1101 -0
- package/browser/src/common-harness/managed-harness-file-payloads.ts +143 -0
- package/browser/src/common-harness/managed-harness-file-types.ts +106 -0
- package/browser/src/common-harness/managed-harness-session.ts +15 -0
- package/browser/src/common-harness/managed-harness.ts +1323 -0
- package/browser/src/common-harness/managed-history.ts +168 -0
- package/browser/src/common-harness/persisted-restore-policy.ts +50 -0
- package/browser/src/common-harness/persisted-ui-state-controller.ts +309 -0
- package/browser/src/common-harness/text-session-bridge.ts +452 -0
- package/browser/src/common-harness/types.ts +205 -0
- package/browser/src/common-harness/ui-chrome.ts +191 -0
- package/browser/src/common-harness/ui-imports.ts +529 -0
- package/browser/src/common-harness/wasm-module-cache.ts +47 -0
- package/browser/src/common-harness.ts +27 -0
- package/browser/src/file-processing-worker.ts +89 -0
- package/browser/src/host-events.ts +97 -0
- package/browser/src/host-services.ts +203 -0
- package/browser/src/index.ts +62 -0
- package/browser/src/persisted-ui-state.ts +206 -0
- package/browser/src/routed-harness.ts +198 -0
- package/browser/src/worker-bootstrap.ts +483 -0
- package/browser/src/worker-manager.ts +230 -0
- package/browser/src/worker-types.ts +50 -0
- package/package.json +89 -0
- package/scripts/build-demo-as.sh +91 -0
- package/scripts/build.sh +325 -0
- package/scripts/generate-host-events.ts +175 -0
- package/scripts/generate-host-services.ts +157 -0
- package/src/Fui.ts +205 -0
- package/src/FuiExports.ts +55 -0
- package/src/FuiPrimitives.ts +15 -0
- package/src/FuiWorker.ts +3 -0
- package/src/FuiWorkerExports.ts +6 -0
- package/src/bindings/ui.ts +531 -0
- package/src/color.ts +86 -0
- package/src/controls/AntiSelectionArea.ts +23 -0
- package/src/controls/Button.ts +750 -0
- package/src/controls/Checkbox.ts +181 -0
- package/src/controls/ContextMenu.ts +885 -0
- package/src/controls/ControlTemplateSet.ts +37 -0
- package/src/controls/Dialog.ts +355 -0
- package/src/controls/Dropdown.ts +856 -0
- package/src/controls/Form.ts +110 -0
- package/src/controls/NavLink.ts +211 -0
- package/src/controls/Popup.ts +129 -0
- package/src/controls/ProgressBar.ts +180 -0
- package/src/controls/RadioButton.ts +135 -0
- package/src/controls/RadioGroup.ts +244 -0
- package/src/controls/SelectionArea.ts +75 -0
- package/src/controls/Slider.ts +471 -0
- package/src/controls/Switch.ts +132 -0
- package/src/controls/TextArea.ts +20 -0
- package/src/controls/TextInput.ts +7 -0
- package/src/controls/index.ts +18 -0
- package/src/controls/internal/ButtonPresenter.ts +95 -0
- package/src/controls/internal/CheckboxIndicatorPresenter.ts +93 -0
- package/src/controls/internal/DropdownChevronPresenter.ts +67 -0
- package/src/controls/internal/DropdownFieldPresenter.ts +110 -0
- package/src/controls/internal/DropdownOptionRowPresenter.ts +82 -0
- package/src/controls/internal/PopupPresenter.ts +198 -0
- package/src/controls/internal/PressableIndicatorPresenter.ts +32 -0
- package/src/controls/internal/PressableLabeledControl.ts +221 -0
- package/src/controls/internal/RadioIndicatorPresenter.ts +73 -0
- package/src/controls/internal/SliderPresenter.ts +157 -0
- package/src/controls/internal/SwitchIndicatorPresenter.ts +72 -0
- package/src/controls/internal/TextInputCore.ts +695 -0
- package/src/controls/internal/TextInputPresenter.ts +72 -0
- package/src/controls/templating.ts +54 -0
- package/src/core/Action.ts +94 -0
- package/src/core/Actions.ts +37 -0
- package/src/core/Animation.ts +412 -0
- package/src/core/Application.ts +328 -0
- package/src/core/Assets.ts +264 -0
- package/src/core/AttachedProperties.ts +32 -0
- package/src/core/Bitmap.ts +70 -0
- package/src/core/BoundCallback.ts +104 -0
- package/src/core/Callbacks.ts +17 -0
- package/src/core/ContextMenuManager.ts +466 -0
- package/src/core/DebugApi.ts +30 -0
- package/src/core/Disposable.ts +10 -0
- package/src/core/DragDropManager.ts +179 -0
- package/src/core/DragGesture.ts +184 -0
- package/src/core/DynamicAssetIds.ts +24 -0
- package/src/core/Errors.ts +48 -0
- package/src/core/EventRouter.ts +408 -0
- package/src/core/ExternalDropManager.ts +122 -0
- package/src/core/Fetch.ts +264 -0
- package/src/core/FetchFfi.ts +15 -0
- package/src/core/File.ts +1002 -0
- package/src/core/FocusAdornerManager.ts +263 -0
- package/src/core/FocusVisibility.ts +36 -0
- package/src/core/FrameScheduler.ts +28 -0
- package/src/core/KeyboardScroll.ts +161 -0
- package/src/core/KeyboardScrollTracker.ts +386 -0
- package/src/core/Logger.ts +80 -0
- package/src/core/Navigation.ts +13 -0
- package/src/core/Node.ts +1708 -0
- package/src/core/PersistedState.ts +102 -0
- package/src/core/PersistedUiState.ts +142 -0
- package/src/core/Platform.ts +219 -0
- package/src/core/Signal.ts +89 -0
- package/src/core/Theme.ts +365 -0
- package/src/core/Timers.ts +129 -0
- package/src/core/ToolTip.ts +122 -0
- package/src/core/ToolTipManager.ts +459 -0
- package/src/core/Transitions.ts +34 -0
- package/src/core/Typography.ts +204 -0
- package/src/core/Worker.ts +196 -0
- package/src/core/bind.ts +37 -0
- package/src/core/event_exports.ts +596 -0
- package/src/core/ffi.ts +728 -0
- package/src/host-services/runtime.ts +25 -0
- package/src/nodes/FlexBox.ts +789 -0
- package/src/nodes/GradientStop.ts +9 -0
- package/src/nodes/Grid.ts +183 -0
- package/src/nodes/Image.ts +189 -0
- package/src/nodes/Portal.ts +14 -0
- package/src/nodes/RichText.ts +312 -0
- package/src/nodes/ScrollBar.ts +570 -0
- package/src/nodes/ScrollBox.ts +415 -0
- package/src/nodes/ScrollState.ts +10 -0
- package/src/nodes/ScrollView.ts +511 -0
- package/src/nodes/Svg.ts +142 -0
- package/src/nodes/Text.ts +145 -0
- package/src/nodes/TextCore.ts +558 -0
- package/src/nodes/VirtualList.ts +431 -0
- package/src/nodes/helpers.ts +25 -0
- package/src/nodes/index.ts +14 -0
- package/src/tsconfig.json +7 -0
- package/src/worker/Worker.ts +169 -0
- package/src/worker/WorkerJob.ts +65 -0
- package/src/worker/ffi.ts +23 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { CursorStyle, PointerEventType } from "./ffi";
|
|
2
|
+
import { DragDropEffects, DragEventArgs, DragSession, DropProposal, Node } from "./Node";
|
|
3
|
+
|
|
4
|
+
function normalizeEffect(candidate: DragDropEffects, allowed: DragDropEffects): DragDropEffects {
|
|
5
|
+
const masked = <i32>candidate & <i32>allowed;
|
|
6
|
+
if (masked == <i32>DragDropEffects.None) {
|
|
7
|
+
return DragDropEffects.None;
|
|
8
|
+
}
|
|
9
|
+
if ((masked & <i32>DragDropEffects.Move) != 0) {
|
|
10
|
+
return DragDropEffects.Move;
|
|
11
|
+
}
|
|
12
|
+
if ((masked & <i32>DragDropEffects.Copy) != 0) {
|
|
13
|
+
return DragDropEffects.Copy;
|
|
14
|
+
}
|
|
15
|
+
if ((masked & <i32>DragDropEffects.Link) != 0) {
|
|
16
|
+
return DragDropEffects.Link;
|
|
17
|
+
}
|
|
18
|
+
return DragDropEffects.None;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isDefaultProposal(proposal: DropProposal): bool {
|
|
22
|
+
return proposal.effect == DragDropEffects.None && !proposal.showInsertionMarker;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class DragDropManager {
|
|
26
|
+
private static activeSession: DragSession | null = null;
|
|
27
|
+
private static activeTarget: Node | null = null;
|
|
28
|
+
|
|
29
|
+
static cursorOverrideStyle(): CursorStyle {
|
|
30
|
+
const session = this.activeSession;
|
|
31
|
+
if (session === null || !session.isActive) {
|
|
32
|
+
return CursorStyle.Default;
|
|
33
|
+
}
|
|
34
|
+
return session.currentEffect == DragDropEffects.None ? CursorStyle.Grabbing : CursorStyle.Move;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static beginSession(source: Node): bool {
|
|
38
|
+
const existing = this.activeSession;
|
|
39
|
+
if (existing !== null) {
|
|
40
|
+
this.finishSession(existing, DragDropEffects.None, 0.0, 0.0, 0, true);
|
|
41
|
+
}
|
|
42
|
+
if (!source._hasDragSource()) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const data = source._createDragDataObject();
|
|
46
|
+
if (data === null) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const allowed = source._getDragAllowedEffects();
|
|
50
|
+
if (<i32>allowed == 0) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
this.activeTarget = null;
|
|
54
|
+
this.activeSession = new DragSession(source, data, allowed);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static cancelSession(session: DragSession): void {
|
|
59
|
+
if (this.activeSession !== session) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.finishSession(session, DragDropEffects.None, 0.0, 0.0, 0, true);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static cancelSessionForSource(source: Node): void {
|
|
66
|
+
const session = this.activeSession;
|
|
67
|
+
if (session === null || session.source !== source) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.finishSession(session, DragDropEffects.None, 0.0, 0.0, 0, true);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static handleNodeDestroyed(node: Node): void {
|
|
74
|
+
const session = this.activeSession;
|
|
75
|
+
if (session !== null && session.source === node) {
|
|
76
|
+
this.finishSession(session, DragDropEffects.None, 0.0, 0.0, 0, true);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.activeTarget === node) {
|
|
80
|
+
this.activeTarget = null;
|
|
81
|
+
if (session !== null) {
|
|
82
|
+
session._setCurrentEffect(DragDropEffects.None);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static handlePointerEvent(pointedNode: Node | null, eventType: PointerEventType, x: f32, y: f32, modifiers: u32): void {
|
|
88
|
+
const session = this.activeSession;
|
|
89
|
+
if (session === null || !session.isActive) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (
|
|
93
|
+
eventType == PointerEventType.Down ||
|
|
94
|
+
eventType == PointerEventType.Enter ||
|
|
95
|
+
eventType == PointerEventType.Move ||
|
|
96
|
+
eventType == PointerEventType.Leave
|
|
97
|
+
) {
|
|
98
|
+
this.updateTarget(pointedNode, session, x, y, modifiers);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (eventType != PointerEventType.Up) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const effect = this.updateTarget(pointedNode, session, x, y, modifiers);
|
|
105
|
+
const target = this.activeTarget;
|
|
106
|
+
if (target !== null && effect != DragDropEffects.None) {
|
|
107
|
+
target._handleDropEvent(new DragEventArgs(session, x, y, modifiers));
|
|
108
|
+
}
|
|
109
|
+
if (this.activeSession === session && session.isActive) {
|
|
110
|
+
this.finishSession(session, effect, x, y, modifiers, true);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static reset(): void {
|
|
115
|
+
this.activeSession = null;
|
|
116
|
+
this.activeTarget = null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private static updateTarget(pointedNode: Node | null, session: DragSession, x: f32, y: f32, modifiers: u32): DragDropEffects {
|
|
120
|
+
const target = this.resolveDropTarget(pointedNode);
|
|
121
|
+
const args = new DragEventArgs(session, x, y, modifiers);
|
|
122
|
+
let proposal = DropProposal.none();
|
|
123
|
+
if (target !== this.activeTarget) {
|
|
124
|
+
const previousTarget = this.activeTarget;
|
|
125
|
+
if (previousTarget !== null) {
|
|
126
|
+
previousTarget._handleDragLeave(args);
|
|
127
|
+
}
|
|
128
|
+
this.activeTarget = target;
|
|
129
|
+
if (target !== null && target._hasDragEnterHandler()) {
|
|
130
|
+
proposal = target._handleDragEnter(args);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (target === null) {
|
|
134
|
+
session._setCurrentEffect(DragDropEffects.None);
|
|
135
|
+
return DragDropEffects.None;
|
|
136
|
+
}
|
|
137
|
+
if (target._hasDragOverHandler()) {
|
|
138
|
+
proposal = target._handleDragOver(args);
|
|
139
|
+
} else if (target === this.activeTarget && isDefaultProposal(proposal)) {
|
|
140
|
+
return session.currentEffect;
|
|
141
|
+
}
|
|
142
|
+
const effect = normalizeEffect(proposal.effect, session.allowedEffects);
|
|
143
|
+
session._setCurrentEffect(effect);
|
|
144
|
+
return effect;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private static resolveDropTarget(pointedNode: Node | null): Node | null {
|
|
148
|
+
let current = pointedNode;
|
|
149
|
+
while (current !== null) {
|
|
150
|
+
if (current._allowsDrop()) {
|
|
151
|
+
return current;
|
|
152
|
+
}
|
|
153
|
+
current = current.parentNode;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static finishSession(
|
|
159
|
+
session: DragSession,
|
|
160
|
+
effect: DragDropEffects,
|
|
161
|
+
x: f32,
|
|
162
|
+
y: f32,
|
|
163
|
+
modifiers: u32,
|
|
164
|
+
notifyTargetLeave: bool,
|
|
165
|
+
): void {
|
|
166
|
+
if (this.activeSession !== session) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const target = this.activeTarget;
|
|
170
|
+
this.activeSession = null;
|
|
171
|
+
this.activeTarget = null;
|
|
172
|
+
session._setCurrentEffect(effect);
|
|
173
|
+
if (notifyTargetLeave && target !== null) {
|
|
174
|
+
target._handleDragLeave(new DragEventArgs(session, x, y, modifiers));
|
|
175
|
+
}
|
|
176
|
+
session._complete(effect);
|
|
177
|
+
session.source._notifyDragCompleted(effect);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Signal } from "./Signal";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_DRAG_THRESHOLD: f32 = 4.0;
|
|
4
|
+
|
|
5
|
+
export interface DragGestureHost {
|
|
6
|
+
_captureDragPointer(): void;
|
|
7
|
+
_releaseDragPointer(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class DragStartedEvent {
|
|
11
|
+
constructor(
|
|
12
|
+
readonly x: f32 = 0.0,
|
|
13
|
+
readonly y: f32 = 0.0,
|
|
14
|
+
readonly modifiers: u32 = 0,
|
|
15
|
+
) {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DragDeltaEvent {
|
|
19
|
+
constructor(
|
|
20
|
+
readonly x: f32 = 0.0,
|
|
21
|
+
readonly y: f32 = 0.0,
|
|
22
|
+
readonly deltaX: f32 = 0.0,
|
|
23
|
+
readonly deltaY: f32 = 0.0,
|
|
24
|
+
readonly totalDeltaX: f32 = 0.0,
|
|
25
|
+
readonly totalDeltaY: f32 = 0.0,
|
|
26
|
+
readonly modifiers: u32 = 0,
|
|
27
|
+
) {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class DragCompletedEvent {
|
|
31
|
+
constructor(
|
|
32
|
+
readonly x: f32 = 0.0,
|
|
33
|
+
readonly y: f32 = 0.0,
|
|
34
|
+
readonly totalDeltaX: f32 = 0.0,
|
|
35
|
+
readonly totalDeltaY: f32 = 0.0,
|
|
36
|
+
readonly modifiers: u32 = 0,
|
|
37
|
+
readonly cancelled: bool = false,
|
|
38
|
+
) {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class DragGesture {
|
|
42
|
+
readonly dragging: Signal<bool> = new Signal<bool>(false);
|
|
43
|
+
readonly started: Signal<DragStartedEvent> = new Signal<DragStartedEvent>(new DragStartedEvent());
|
|
44
|
+
readonly delta: Signal<DragDeltaEvent> = new Signal<DragDeltaEvent>(new DragDeltaEvent());
|
|
45
|
+
readonly completed: Signal<DragCompletedEvent> = new Signal<DragCompletedEvent>(new DragCompletedEvent());
|
|
46
|
+
|
|
47
|
+
private thresholdValue: f32 = DEFAULT_DRAG_THRESHOLD;
|
|
48
|
+
private pointerDownValue: bool = false;
|
|
49
|
+
private dragStartedValue: bool = false;
|
|
50
|
+
private startX: f32 = 0.0;
|
|
51
|
+
private startY: f32 = 0.0;
|
|
52
|
+
private lastPointerX: f32 = 0.0;
|
|
53
|
+
private lastPointerY: f32 = 0.0;
|
|
54
|
+
private lastDispatchedX: f32 = 0.0;
|
|
55
|
+
private lastDispatchedY: f32 = 0.0;
|
|
56
|
+
private lastModifiers: u32 = 0;
|
|
57
|
+
|
|
58
|
+
constructor(private readonly host: DragGestureHost) {}
|
|
59
|
+
|
|
60
|
+
get isDragging(): bool {
|
|
61
|
+
return this.dragging.value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
threshold(value: f32): this {
|
|
65
|
+
this.thresholdValue = value > 0.0 ? value : 0.0;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
handlePointerDown(x: f32, y: f32, modifiers: u32 = 0): void {
|
|
70
|
+
if (this.pointerDownValue) {
|
|
71
|
+
this.cancel();
|
|
72
|
+
}
|
|
73
|
+
this.pointerDownValue = true;
|
|
74
|
+
this.dragStartedValue = false;
|
|
75
|
+
this.startX = x;
|
|
76
|
+
this.startY = y;
|
|
77
|
+
this.lastPointerX = x;
|
|
78
|
+
this.lastPointerY = y;
|
|
79
|
+
this.lastDispatchedX = x;
|
|
80
|
+
this.lastDispatchedY = y;
|
|
81
|
+
this.lastModifiers = modifiers;
|
|
82
|
+
this.host._captureDragPointer();
|
|
83
|
+
if (this.thresholdValue <= 0.0) {
|
|
84
|
+
this.beginDrag(x, y, modifiers);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
handlePointerMove(x: f32, y: f32, modifiers: u32 = 0): void {
|
|
89
|
+
if (!this.pointerDownValue) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.lastPointerX = x;
|
|
93
|
+
this.lastPointerY = y;
|
|
94
|
+
this.lastModifiers = modifiers;
|
|
95
|
+
if (!this.dragStartedValue) {
|
|
96
|
+
if (!this.hasExceededThreshold(x - this.startX, y - this.startY)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.beginDrag(x, y, modifiers);
|
|
100
|
+
}
|
|
101
|
+
this.emitDelta(x, y, modifiers);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
handlePointerUp(x: f32, y: f32, modifiers: u32 = 0): void {
|
|
105
|
+
if (!this.pointerDownValue) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.lastPointerX = x;
|
|
109
|
+
this.lastPointerY = y;
|
|
110
|
+
this.lastModifiers = modifiers;
|
|
111
|
+
if (this.dragStartedValue) {
|
|
112
|
+
this.emitDelta(x, y, modifiers);
|
|
113
|
+
this.dragging.value = false;
|
|
114
|
+
this.completed.value = new DragCompletedEvent(
|
|
115
|
+
x,
|
|
116
|
+
y,
|
|
117
|
+
x - this.startX,
|
|
118
|
+
y - this.startY,
|
|
119
|
+
modifiers,
|
|
120
|
+
false,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
this.pointerDownValue = false;
|
|
124
|
+
this.dragStartedValue = false;
|
|
125
|
+
this.host._releaseDragPointer();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
cancel(): void {
|
|
129
|
+
if (!this.pointerDownValue) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (this.dragStartedValue) {
|
|
133
|
+
this.dragging.value = false;
|
|
134
|
+
this.completed.value = new DragCompletedEvent(
|
|
135
|
+
this.lastPointerX,
|
|
136
|
+
this.lastPointerY,
|
|
137
|
+
this.lastPointerX - this.startX,
|
|
138
|
+
this.lastPointerY - this.startY,
|
|
139
|
+
this.lastModifiers,
|
|
140
|
+
true,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
this.pointerDownValue = false;
|
|
144
|
+
this.dragStartedValue = false;
|
|
145
|
+
this.host._releaseDragPointer();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private beginDrag(x: f32, y: f32, modifiers: u32): void {
|
|
149
|
+
if (this.dragStartedValue) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.dragStartedValue = true;
|
|
153
|
+
this.lastDispatchedX = this.startX;
|
|
154
|
+
this.lastDispatchedY = this.startY;
|
|
155
|
+
this.dragging.value = true;
|
|
156
|
+
this.started.value = new DragStartedEvent(x, y, modifiers);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private emitDelta(x: f32, y: f32, modifiers: u32): void {
|
|
160
|
+
if (x == this.lastDispatchedX && y == this.lastDispatchedY) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const deltaX = x - this.lastDispatchedX;
|
|
164
|
+
const deltaY = y - this.lastDispatchedY;
|
|
165
|
+
this.lastDispatchedX = x;
|
|
166
|
+
this.lastDispatchedY = y;
|
|
167
|
+
this.delta.value = new DragDeltaEvent(
|
|
168
|
+
x,
|
|
169
|
+
y,
|
|
170
|
+
deltaX,
|
|
171
|
+
deltaY,
|
|
172
|
+
x - this.startX,
|
|
173
|
+
y - this.startY,
|
|
174
|
+
modifiers,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private hasExceededThreshold(totalDeltaX: f32, totalDeltaY: f32): bool {
|
|
179
|
+
if (this.thresholdValue <= 0.0) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return ((totalDeltaX * totalDeltaX) + (totalDeltaY * totalDeltaY)) >= (this.thresholdValue * this.thresholdValue);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const FIRST_DYNAMIC_SVG_ID: u32 = 0x10000000;
|
|
2
|
+
const FIRST_DYNAMIC_TEXTURE_ID: u32 = 0x20000000;
|
|
3
|
+
const MAX_DYNAMIC_ASSET_ID: u32 = 0xffffffff;
|
|
4
|
+
|
|
5
|
+
let nextDynamicSvgId: u32 = FIRST_DYNAMIC_SVG_ID;
|
|
6
|
+
let nextDynamicTextureId: u32 = FIRST_DYNAMIC_TEXTURE_ID;
|
|
7
|
+
|
|
8
|
+
export function allocateDynamicSvgId(): u32 {
|
|
9
|
+
if (nextDynamicSvgId == MAX_DYNAMIC_ASSET_ID) {
|
|
10
|
+
throw new Error("Dynamic SVG asset id space exhausted.");
|
|
11
|
+
}
|
|
12
|
+
const allocated = nextDynamicSvgId;
|
|
13
|
+
nextDynamicSvgId += 1;
|
|
14
|
+
return allocated;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function allocateDynamicTextureId(): u32 {
|
|
18
|
+
if (nextDynamicTextureId == MAX_DYNAMIC_ASSET_ID) {
|
|
19
|
+
throw new Error("Dynamic texture asset id space exhausted.");
|
|
20
|
+
}
|
|
21
|
+
const allocated = nextDynamicTextureId;
|
|
22
|
+
nextDynamicTextureId += 1;
|
|
23
|
+
return allocated;
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { error } from "./Logger";
|
|
2
|
+
|
|
3
|
+
export class ObjectDisposedError extends Error {
|
|
4
|
+
constructor(functionName: string, objectName: string) {
|
|
5
|
+
const message = functionName + ": " + objectName + " was disposed";
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ObjectDisposedError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function throwNullArgument(functionName: string, argumentName: string): void {
|
|
12
|
+
error("Validation", functionName + ": " + argumentName + " must not be null");
|
|
13
|
+
throw new TypeError(functionName + ": " + argumentName + " must not be null");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function throwRangeError(functionName: string, argumentName: string, index: i32, min: i32, max: i32): void {
|
|
17
|
+
error(
|
|
18
|
+
"Validation",
|
|
19
|
+
functionName +
|
|
20
|
+
": " +
|
|
21
|
+
argumentName +
|
|
22
|
+
" must be between " +
|
|
23
|
+
min.toString() +
|
|
24
|
+
" and " +
|
|
25
|
+
max.toString() +
|
|
26
|
+
" (received " +
|
|
27
|
+
index.toString() +
|
|
28
|
+
")",
|
|
29
|
+
);
|
|
30
|
+
throw new RangeError(
|
|
31
|
+
functionName +
|
|
32
|
+
": " +
|
|
33
|
+
argumentName +
|
|
34
|
+
" must be between " +
|
|
35
|
+
min.toString() +
|
|
36
|
+
" and " +
|
|
37
|
+
max.toString() +
|
|
38
|
+
" (received " +
|
|
39
|
+
index.toString() +
|
|
40
|
+
")",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function throwObjectDisposed(functionName: string, objectName: string): void {
|
|
45
|
+
const message = functionName + ": " + objectName + " was disposed";
|
|
46
|
+
error("Lifecycle", message);
|
|
47
|
+
throw new ObjectDisposedError(functionName, objectName);
|
|
48
|
+
}
|