@yuzhouu/canvas-kit 0.1.2
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/README.md +145 -0
- package/_vendor/canvas-core/bindings/BindingUtil.ts +92 -0
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.ts +22 -0
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.ts +52 -0
- package/_vendor/canvas-core/contextMenu.ts +85 -0
- package/_vendor/canvas-core/editor/Editor.ts +2614 -0
- package/_vendor/canvas-core/editor/HistoryManager.ts +83 -0
- package/_vendor/canvas-core/editor/StateNode.ts +162 -0
- package/_vendor/canvas-core/editor/camera.ts +6 -0
- package/_vendor/canvas-core/editor/clipboard.ts +478 -0
- package/_vendor/canvas-core/editor/commands.ts +833 -0
- package/_vendor/canvas-core/editor/edgeScroll.ts +37 -0
- package/_vendor/canvas-core/editor/editorComputedHelpers.ts +257 -0
- package/_vendor/canvas-core/editor/editorSelectionTransforms.ts +116 -0
- package/_vendor/canvas-core/editor/events.ts +93 -0
- package/_vendor/canvas-core/editor/index.ts +12 -0
- package/_vendor/canvas-core/editor/interactions.ts +101 -0
- package/_vendor/canvas-core/editor/internal.ts +22 -0
- package/_vendor/canvas-core/editor/managers/BindingManager.ts +262 -0
- package/_vendor/canvas-core/editor/managers/CameraManager.ts +147 -0
- package/_vendor/canvas-core/editor/managers/ClipboardManager.ts +32 -0
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.ts +256 -0
- package/_vendor/canvas-core/editor/managers/InputsManager.ts +319 -0
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.ts +218 -0
- package/_vendor/canvas-core/editor/managers/QueryManager.ts +837 -0
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.ts +347 -0
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.ts +196 -0
- package/_vendor/canvas-core/editor/managers/SelectionManager.ts +98 -0
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.ts +308 -0
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.ts +226 -0
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.ts +162 -0
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.ts +797 -0
- package/_vendor/canvas-core/editor/managers/SideEffectManager.ts +83 -0
- package/_vendor/canvas-core/editor/managers/SnapManager.ts +433 -0
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.ts +430 -0
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.ts +354 -0
- package/_vendor/canvas-core/editor/managers/ToolManager.ts +81 -0
- package/_vendor/canvas-core/editor/managers/queryState.ts +583 -0
- package/_vendor/canvas-core/editor/managers/selectionGeometry.ts +287 -0
- package/_vendor/canvas-core/editor/managers/shapeOrder.ts +350 -0
- package/_vendor/canvas-core/editor/managers/shapeReparenting.ts +160 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.ts +412 -0
- package/_vendor/canvas-core/editor/managers/snapGeometry.ts +202 -0
- package/_vendor/canvas-core/editor/managers/snapIndicators.ts +403 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.ts +122 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.ts +171 -0
- package/_vendor/canvas-core/editor/renderWindow.ts +439 -0
- package/_vendor/canvas-core/editor/resizeGeometry.ts +654 -0
- package/_vendor/canvas-core/editor/selection.ts +489 -0
- package/_vendor/canvas-core/editor/selectionHandleInteractions.ts +43 -0
- package/_vendor/canvas-core/editor/selectionOverlay.ts +567 -0
- package/_vendor/canvas-core/exports/integrity.ts +174 -0
- package/_vendor/canvas-core/exports/svg.ts +494 -0
- package/_vendor/canvas-core/geometry/Box.ts +80 -0
- package/_vendor/canvas-core/geometry/Ellipse2d.ts +67 -0
- package/_vendor/canvas-core/geometry/Geometry2d.ts +52 -0
- package/_vendor/canvas-core/geometry/Mat.ts +92 -0
- package/_vendor/canvas-core/geometry/Polyline2d.ts +63 -0
- package/_vendor/canvas-core/geometry/Rectangle2d.ts +64 -0
- package/_vendor/canvas-core/geometry/Vec.ts +123 -0
- package/_vendor/canvas-core/geometry/index.ts +13 -0
- package/_vendor/canvas-core/geometry/segments.ts +65 -0
- package/_vendor/canvas-core/index.ts +391 -0
- package/_vendor/canvas-core/plugins/index.ts +5 -0
- package/_vendor/canvas-core/plugins/types.ts +53 -0
- package/_vendor/canvas-core/reactivity.ts +16 -0
- package/_vendor/canvas-core/schema/records.ts +221 -0
- package/_vendor/canvas-core/schema/snapshots.ts +527 -0
- package/_vendor/canvas-core/shapes/ShapeUtil.ts +516 -0
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.ts +26 -0
- package/_vendor/canvas-core/shapes/capabilities.ts +67 -0
- package/_vendor/canvas-core/shapes/types.ts +20 -0
- package/_vendor/canvas-core/toolbar.ts +148 -0
- package/_vendor/canvas-core/tools/hand/HandTool.ts +75 -0
- package/_vendor/canvas-core/tools/index.ts +2 -0
- package/_vendor/canvas-core/tools/select/SelectTool.ts +33 -0
- package/_vendor/canvas-core/tools/select/selectContainment.ts +104 -0
- package/_vendor/canvas-core/tools/select/selectToolHelpers.ts +801 -0
- package/_vendor/canvas-core/tools/select/states/BrushingState.ts +145 -0
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.ts +116 -0
- package/_vendor/canvas-core/tools/select/states/IdleState.ts +159 -0
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.ts +41 -0
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.ts +78 -0
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.ts +64 -0
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.ts +34 -0
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.ts +140 -0
- package/_vendor/canvas-core/tools/select/states/ResizingState.ts +171 -0
- package/_vendor/canvas-core/tools/select/states/RotatingState.ts +124 -0
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.ts +128 -0
- package/_vendor/canvas-core/tools/select/states/TranslatingState.ts +139 -0
- package/_vendor/canvas-core/tools/select/states/index.ts +11 -0
- package/_vendor/canvas-plugin-api/feature.ts +204 -0
- package/_vendor/canvas-plugin-api/index.ts +142 -0
- package/_vendor/canvas-product-react/api/apiRegistry.ts +35 -0
- package/_vendor/canvas-product-react/api/canvasProductApi.ts +422 -0
- package/_vendor/canvas-product-react/api/index.ts +31 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.ts +36 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.ts +245 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.ts +396 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.ts +59 -0
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.ts +156 -0
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.ts +23 -0
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.ts +41 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.ts +490 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.ts +92 -0
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.ts +27 -0
- package/_vendor/canvas-product-react/index.ts +84 -0
- package/_vendor/canvas-product-react/persistence/index.ts +18 -0
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.ts +294 -0
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.tsx +250 -0
- package/_vendor/canvas-product-react/runtime/productDefinition.ts +72 -0
- package/_vendor/canvas-product-react/runtime/productServices.ts +96 -0
- package/_vendor/canvas-react/components/CanvasView.tsx +796 -0
- package/_vendor/canvas-react/components/OverlayLayer.tsx +879 -0
- package/_vendor/canvas-react/components/PageSpace.tsx +34 -0
- package/_vendor/canvas-react/components/ShapeLayer.tsx +428 -0
- package/_vendor/canvas-react/components/index.ts +4 -0
- package/_vendor/canvas-react/hooks/useEditor.ts +11 -0
- package/_vendor/canvas-react/hooks/useValue.ts +14 -0
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.tsx +14 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.ts +61 -0
- package/_vendor/canvas-react/host/domEventGuards.ts +61 -0
- package/_vendor/canvas-react/host/index.ts +38 -0
- package/_vendor/canvas-react/host/pluginHost.ts +635 -0
- package/_vendor/canvas-react/host/rendererRegistry.tsx +58 -0
- package/_vendor/canvas-react/host/toolbarRegistry.ts +100 -0
- package/_vendor/canvas-react/index.ts +3 -0
- package/_vendor/plugin-arrow/ArrowBindingUtil.ts +239 -0
- package/_vendor/plugin-arrow/ArrowShapeUtil.ts +311 -0
- package/_vendor/plugin-arrow/ArrowTool.ts +208 -0
- package/_vendor/plugin-arrow/arrowGeometry.ts +441 -0
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.ts +253 -0
- package/_vendor/plugin-arrow/arrowTerminalCommands.ts +230 -0
- package/_vendor/plugin-arrow/canvas.tsx +92 -0
- package/_vendor/plugin-arrow/core.ts +409 -0
- package/_vendor/plugin-arrow/feature.ts +20 -0
- package/_vendor/plugin-arrow/index.ts +28 -0
- package/_vendor/plugin-arrow/selectionHandleInteractions.ts +154 -0
- package/_vendor/plugin-arrow/types.ts +63 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.tsx +60 -0
- package/_vendor/plugin-draw/DrawShapeUtil.ts +372 -0
- package/_vendor/plugin-draw/DrawTool.ts +444 -0
- package/_vendor/plugin-draw/canvas.tsx +24 -0
- package/_vendor/plugin-draw/core.ts +515 -0
- package/_vendor/plugin-draw/drawGeometry.ts +491 -0
- package/_vendor/plugin-draw/drawHitTest.ts +271 -0
- package/_vendor/plugin-draw/drawInterpolation.ts +250 -0
- package/_vendor/plugin-draw/drawPath.ts +550 -0
- package/_vendor/plugin-draw/drawSegments.ts +106 -0
- package/_vendor/plugin-draw/drawSelectionTransform.ts +67 -0
- package/_vendor/plugin-draw/drawShapeGeometry.ts +307 -0
- package/_vendor/plugin-draw/drawStrokeGeometry.ts +454 -0
- package/_vendor/plugin-draw/feature.ts +20 -0
- package/_vendor/plugin-draw/index.ts +31 -0
- package/_vendor/plugin-draw/types.ts +36 -0
- package/_vendor/plugin-eraser/EraserTool.ts +297 -0
- package/_vendor/plugin-eraser/canvas.tsx +616 -0
- package/_vendor/plugin-eraser/core.ts +49 -0
- package/_vendor/plugin-eraser/feature.ts +20 -0
- package/_vendor/plugin-eraser/index.ts +4 -0
- package/_vendor/plugin-frame/FrameShapeUtil.ts +173 -0
- package/_vendor/plugin-frame/FrameTool.ts +225 -0
- package/_vendor/plugin-frame/canvas.tsx +75 -0
- package/_vendor/plugin-frame/core.ts +534 -0
- package/_vendor/plugin-frame/feature.ts +20 -0
- package/_vendor/plugin-frame/index.ts +6 -0
- package/_vendor/plugin-geo/GeoShapeUtil.ts +463 -0
- package/_vendor/plugin-geo/GeoTools.ts +247 -0
- package/_vendor/plugin-geo/canvas.tsx +90 -0
- package/_vendor/plugin-geo/core.ts +495 -0
- package/_vendor/plugin-geo/feature.ts +20 -0
- package/_vendor/plugin-geo/index.ts +7 -0
- package/_vendor/plugin-geo/types.ts +27 -0
- package/_vendor/plugin-group/GroupShapeUtil.ts +59 -0
- package/_vendor/plugin-group/canvas.tsx +59 -0
- package/_vendor/plugin-group/core.ts +40 -0
- package/_vendor/plugin-group/feature.ts +20 -0
- package/_vendor/plugin-group/index.ts +5 -0
- package/_vendor/plugin-image/ImageShapeUtil.ts +95 -0
- package/_vendor/plugin-image/canvas.tsx +212 -0
- package/_vendor/plugin-image/core.ts +542 -0
- package/_vendor/plugin-image/crop.ts +770 -0
- package/_vendor/plugin-image/cropInteractions.ts +350 -0
- package/_vendor/plugin-image/cropSession.ts +38 -0
- package/_vendor/plugin-image/feature.ts +20 -0
- package/_vendor/plugin-image/index.ts +29 -0
- package/_vendor/plugin-image/types.ts +55 -0
- package/_vendor/plugin-image-product-react/ImageImportController.tsx +143 -0
- package/_vendor/plugin-image-product-react/imageAssetService.ts +52 -0
- package/_vendor/plugin-image-product-react/imageBlobStore.ts +315 -0
- package/_vendor/plugin-image-product-react/imageHostActions.ts +438 -0
- package/_vendor/plugin-image-product-react/imageProductApi.ts +88 -0
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.ts +48 -0
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.ts +21 -0
- package/_vendor/plugin-image-product-react/index.ts +60 -0
- package/_vendor/plugin-image-product-react/snapshotGuards.ts +33 -0
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.ts +54 -0
- package/_vendor/plugin-image-product-react/useImageImport.ts +64 -0
- package/_vendor/plugin-laser/LaserTool.ts +154 -0
- package/_vendor/plugin-laser/canvas.tsx +645 -0
- package/_vendor/plugin-laser/core.ts +49 -0
- package/_vendor/plugin-laser/feature.ts +20 -0
- package/_vendor/plugin-laser/index.ts +4 -0
- package/_vendor/plugin-text/ArrowLabelBindingUtil.ts +336 -0
- package/_vendor/plugin-text/GeoLabelBindingUtil.ts +391 -0
- package/_vendor/plugin-text/TextShapeSvgExporter.ts +101 -0
- package/_vendor/plugin-text/TextShapeUtil.ts +284 -0
- package/_vendor/plugin-text/TextTool.ts +228 -0
- package/_vendor/plugin-text/canvas.tsx +115 -0
- package/_vendor/plugin-text/core.ts +422 -0
- package/_vendor/plugin-text/feature.ts +20 -0
- package/_vendor/plugin-text/host/RichTextEditingBox.tsx +144 -0
- package/_vendor/plugin-text/host/RichTextToolbar.tsx +266 -0
- package/_vendor/plugin-text/host/TiptapTextEditor.tsx +191 -0
- package/_vendor/plugin-text/host/richTextRendering.tsx +49 -0
- package/_vendor/plugin-text/host/textDomSelection.ts +93 -0
- package/_vendor/plugin-text/host/textEditingBoxStyle.ts +36 -0
- package/_vendor/plugin-text/host/textEntryFocus.ts +307 -0
- package/_vendor/plugin-text/host/textFontLoader.ts +149 -0
- package/_vendor/plugin-text/host/textMeasurement.ts +258 -0
- package/_vendor/plugin-text/host/textMeasurementSync.ts +77 -0
- package/_vendor/plugin-text/host/textRangeSelection.ts +134 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.tsx +89 -0
- package/_vendor/plugin-text/host/textShapeSync.ts +173 -0
- package/_vendor/plugin-text/host/tiptapTextEditorController.ts +148 -0
- package/_vendor/plugin-text/index.ts +18 -0
- package/_vendor/plugin-text/richTextUtils.ts +259 -0
- package/_vendor/plugin-text/textInteractions.ts +366 -0
- package/_vendor/plugin-text/textLabelHelpers.ts +235 -0
- package/_vendor/plugin-text/textShapeHelpers.ts +123 -0
- package/_vendor/plugin-text/textStyle.ts +96 -0
- package/_vendor/plugin-text/textTypes.ts +48 -0
- package/_vendor/signals/atom.ts +74 -0
- package/_vendor/signals/computed.ts +132 -0
- package/_vendor/signals/core.ts +130 -0
- package/_vendor/signals/effect.ts +117 -0
- package/_vendor/signals/index.ts +9 -0
- package/_vendor/signals/types.ts +17 -0
- package/_vendor/store/Store.ts +171 -0
- package/_vendor/store/diff.ts +229 -0
- package/_vendor/store/history.ts +177 -0
- package/_vendor/store/index.ts +32 -0
- package/_vendor/store/types.ts +37 -0
- package/api/canvasKitApi.d.ts +29 -0
- package/index.css +3 -0
- package/index.d.ts +16 -0
- package/index.mjs +1 -0
- package/internal-modules.d.ts +187 -0
- package/package.json +48 -0
- package/product/Shell.d.ts +19 -0
- package/product/chromeContext.d.ts +70 -0
- package/product/createCanvasKitEditor.d.ts +6 -0
- package/product/index.d.ts +7 -0
- package/product/persistence.d.ts +3 -0
- package/product/product.d.ts +22 -0
- package/product/useCanvasClipboardShortcuts.d.ts +6 -0
- package/product-iyBbEPIs.mjs +4 -0
- package/product.mjs +1 -0
- package/standard/extensions.d.ts +1 -0
- package/standard/index.d.ts +3 -0
- package/standard/standardApi.d.ts +91 -0
- package/standard-BmrxwqpJ.mjs +44 -0
- package/standard.mjs +1 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { Vec } from "../../../geometry/Vec";
|
|
3
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
4
|
+
import type {
|
|
5
|
+
PointerEditorEvent,
|
|
6
|
+
TickEditorEvent,
|
|
7
|
+
} from "../../../editor/events";
|
|
8
|
+
import {
|
|
9
|
+
applySelectionDragFromCurrentInputs,
|
|
10
|
+
createBrushBounds,
|
|
11
|
+
getOutermostSelectableShapeIds,
|
|
12
|
+
getSelectionDragInputForTick,
|
|
13
|
+
isAdditiveSelectionActive,
|
|
14
|
+
isBrushWrappingSelection,
|
|
15
|
+
shouldSelectShapeWithBrush,
|
|
16
|
+
toggleIds,
|
|
17
|
+
type BrushInfo,
|
|
18
|
+
} from "../selectToolHelpers";
|
|
19
|
+
import { InfoStateNode } from "./SelectStateNode";
|
|
20
|
+
|
|
21
|
+
export class BrushingState extends InfoStateNode<BrushInfo> {
|
|
22
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
23
|
+
super(editor, "brushing", parent);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected onInfoEnter(): void {
|
|
27
|
+
if (!this.info) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const inputs = this.editor.inputs.state.get();
|
|
31
|
+
this.updateBrush(
|
|
32
|
+
this.info.originPagePoint,
|
|
33
|
+
this.info.additiveSelection,
|
|
34
|
+
isBrushWrappingSelection(inputs),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected onPointerMove(event: PointerEditorEvent): void {
|
|
39
|
+
if (!this.info) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.updateBrush(
|
|
43
|
+
event.pagePoint,
|
|
44
|
+
isAdditiveSelectionActive(event),
|
|
45
|
+
isBrushWrappingSelection(event),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected onTick(event: TickEditorEvent): void {
|
|
50
|
+
if (!this.info) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const input = getSelectionDragInputForTick(
|
|
55
|
+
this.editor,
|
|
56
|
+
event,
|
|
57
|
+
"apply_after_scroll_or_without_screen_point",
|
|
58
|
+
);
|
|
59
|
+
if (!input) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.updateBrush(
|
|
63
|
+
input.pagePoint,
|
|
64
|
+
isAdditiveSelectionActive(input),
|
|
65
|
+
isBrushWrappingSelection(input),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected onKeyDown(): void {
|
|
70
|
+
this.updateBrushFromInputs();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected onKeyUp(): void {
|
|
74
|
+
this.updateBrushFromInputs();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected onPointerUp(event: PointerEditorEvent): void {
|
|
78
|
+
if (this.info) {
|
|
79
|
+
this.updateBrush(
|
|
80
|
+
event.pagePoint,
|
|
81
|
+
isAdditiveSelectionActive(event),
|
|
82
|
+
isBrushWrappingSelection(event),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
this.complete();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected onCancel(): void {
|
|
89
|
+
if (this.info) {
|
|
90
|
+
this.editor.commands.setSelectedShapeIds(this.info.previousSelection, {
|
|
91
|
+
source: "system",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
this.cancel();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private updateBrush(
|
|
98
|
+
pagePoint: Vec,
|
|
99
|
+
additiveSelection: boolean,
|
|
100
|
+
isWrapping: boolean,
|
|
101
|
+
): void {
|
|
102
|
+
if (!this.info) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const brushBounds = createBrushBounds(this.info.originPagePoint, pagePoint);
|
|
107
|
+
const hitIds = getOutermostSelectableShapeIds(
|
|
108
|
+
this.editor,
|
|
109
|
+
this.editor.getShapeIdsInBounds(brushBounds).filter((shapeId) =>
|
|
110
|
+
shouldSelectShapeWithBrush(
|
|
111
|
+
this.editor,
|
|
112
|
+
brushBounds,
|
|
113
|
+
shapeId,
|
|
114
|
+
isWrapping,
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
const nextSelection = additiveSelection
|
|
119
|
+
? toggleIds(this.info.previousSelection, hitIds)
|
|
120
|
+
: hitIds;
|
|
121
|
+
|
|
122
|
+
this.editor.setBrushBox(brushBounds);
|
|
123
|
+
this.editor.commands.setSelectedShapeIds(nextSelection, {
|
|
124
|
+
source: "system",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private updateBrushFromInputs(): void {
|
|
129
|
+
applySelectionDragFromCurrentInputs(this.editor, (input) =>
|
|
130
|
+
this.updateBrush(
|
|
131
|
+
input.pagePoint,
|
|
132
|
+
isAdditiveSelectionActive(input),
|
|
133
|
+
isBrushWrappingSelection(input),
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private complete(): void {
|
|
139
|
+
this.transition("idle");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private cancel(): void {
|
|
143
|
+
this.transition("idle");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { transact } from "@land/signals";
|
|
2
|
+
import type { Editor } from "../../../editor/Editor";
|
|
3
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
4
|
+
import type { PointerEditorEvent } from "../../../editor/events";
|
|
5
|
+
import {
|
|
6
|
+
HANDLE_SNAP_DISTANCE_SCREEN,
|
|
7
|
+
arePagePointsApproximatelyEqual,
|
|
8
|
+
type DraggingSelectionHandleInteractionInfo,
|
|
9
|
+
} from "../selectToolHelpers";
|
|
10
|
+
import { DraggingStateNode, type DragApplyInput } from "./SelectStateNode";
|
|
11
|
+
|
|
12
|
+
export class DraggingSelectionHandleInteractionState extends DraggingStateNode<DraggingSelectionHandleInteractionInfo> {
|
|
13
|
+
protected readonly tickMode = "apply_after_scroll" as const;
|
|
14
|
+
|
|
15
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
16
|
+
super(editor, "dragging_selection_handle_interaction", parent);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected getHistoryMark(info: DraggingSelectionHandleInteractionInfo): string {
|
|
20
|
+
return info.session.historyMark;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected onPointerUp(event: PointerEditorEvent): void {
|
|
24
|
+
this.apply(event);
|
|
25
|
+
this.complete();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected onCancel(): void {
|
|
29
|
+
const previousSelection = this.info?.previousSelection;
|
|
30
|
+
transact(() => {
|
|
31
|
+
if (previousSelection) {
|
|
32
|
+
this.editor.commands.setSelectedShapeIds(previousSelection, {
|
|
33
|
+
source: "system",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (this.info) {
|
|
37
|
+
this.editor.clearSelectionTransients();
|
|
38
|
+
this.editor.history.bailToMark(this.info.session.historyMark);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.transition("idle");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected onInfoExit(): void {
|
|
45
|
+
if (this.info?.session.shouldClearBindingPreviewOnExit) {
|
|
46
|
+
this.editor.setBindingPreview(null);
|
|
47
|
+
}
|
|
48
|
+
this.editor.setSnapIndicators(null);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected apply({ pagePoint, accelKey }: DragApplyInput): void {
|
|
52
|
+
if (!this.info) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
pagePoint.x === this.info.lastPagePointX &&
|
|
58
|
+
pagePoint.y === this.info.lastPagePointY &&
|
|
59
|
+
accelKey === this.info.lastAccelKey
|
|
60
|
+
) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.info.lastPagePointX = pagePoint.x;
|
|
64
|
+
this.info.lastPagePointY = pagePoint.y;
|
|
65
|
+
this.info.lastAccelKey = accelKey;
|
|
66
|
+
|
|
67
|
+
const snapMode = this.info.session.handleSnapMode ?? "none";
|
|
68
|
+
const snapSnapshot = this.info.snapSnapshot;
|
|
69
|
+
const canSnap = !accelKey && snapMode !== "none" && snapSnapshot !== null;
|
|
70
|
+
const snapResult =
|
|
71
|
+
canSnap && snapSnapshot
|
|
72
|
+
? this.editor.snaps.snapHandle({
|
|
73
|
+
mode: snapMode,
|
|
74
|
+
pagePoint,
|
|
75
|
+
snapshot: snapSnapshot,
|
|
76
|
+
threshold:
|
|
77
|
+
HANDLE_SNAP_DISTANCE_SCREEN / this.editor.getCurrentCamera().z,
|
|
78
|
+
})
|
|
79
|
+
: null;
|
|
80
|
+
|
|
81
|
+
if (!canSnap) {
|
|
82
|
+
this.editor.snaps.clearIndicators();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const snappedPagePoint = snapResult?.snappedPagePoint ?? pagePoint;
|
|
86
|
+
const result = this.info.session.update({
|
|
87
|
+
editor: this.editor,
|
|
88
|
+
pagePoint: snappedPagePoint,
|
|
89
|
+
accelKey,
|
|
90
|
+
source: "user",
|
|
91
|
+
});
|
|
92
|
+
const status = typeof result === "string" ? result : result.status;
|
|
93
|
+
const finalPagePoint =
|
|
94
|
+
typeof result === "string" ? snappedPagePoint : result.finalPagePoint;
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
snapResult &&
|
|
98
|
+
finalPagePoint &&
|
|
99
|
+
!arePagePointsApproximatelyEqual(finalPagePoint, snapResult.snappedPagePoint)
|
|
100
|
+
) {
|
|
101
|
+
this.editor.snaps.clearIndicators();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (status === "stop") {
|
|
105
|
+
this.transition("idle");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private complete(): void {
|
|
110
|
+
if (this.info) {
|
|
111
|
+
this.editor.setSnapIndicators(null);
|
|
112
|
+
this.editor.history.squashToMark(this.info.session.historyMark);
|
|
113
|
+
}
|
|
114
|
+
this.transition("idle");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
3
|
+
import type { PointerEditorEvent } from "../../../editor/events";
|
|
4
|
+
import {
|
|
5
|
+
getSelectableShapeIdForHit,
|
|
6
|
+
getSelectedTransformAncestorIdForHit,
|
|
7
|
+
isAdditiveSelectionActive,
|
|
8
|
+
type PointingCanvasInfo,
|
|
9
|
+
type PointingResizeHandleInfo,
|
|
10
|
+
type PointingRotateHandleInfo,
|
|
11
|
+
type PointingSelectionHandleInteractionInfo,
|
|
12
|
+
type PointingShapeInfo,
|
|
13
|
+
} from "../selectToolHelpers";
|
|
14
|
+
|
|
15
|
+
export class IdleState extends StateNode {
|
|
16
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
17
|
+
super(editor, "idle", parent);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected onEnter(): void {
|
|
21
|
+
this.editor.clearSelectionTransients();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected onPointerDown(event: PointerEditorEvent): void {
|
|
25
|
+
const previousSelection = this.editor.getSelectedShapeIds();
|
|
26
|
+
const handle = this.editor.hitTestSelectionHandle(event.pagePoint);
|
|
27
|
+
if (handle?.kind === "rotate") {
|
|
28
|
+
this.transition("pointing_rotate_handle", {
|
|
29
|
+
originPagePoint: event.pagePoint.clone(),
|
|
30
|
+
previousSelection,
|
|
31
|
+
} satisfies PointingRotateHandleInfo);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (handle?.kind === "resize") {
|
|
36
|
+
this.transition("pointing_resize_handle", {
|
|
37
|
+
handleId: handle.id,
|
|
38
|
+
originPagePoint: event.pagePoint.clone(),
|
|
39
|
+
cursorHandleOffset: event.pagePoint.sub(handle.point),
|
|
40
|
+
previousSelection,
|
|
41
|
+
} satisfies PointingResizeHandleInfo);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (handle) {
|
|
46
|
+
const selectedShape = this.editor.getSelectedShapes()[0] ?? null;
|
|
47
|
+
if (selectedShape) {
|
|
48
|
+
const session = this.editor.selectionHandleInteractions.createSession(
|
|
49
|
+
this.editor,
|
|
50
|
+
{
|
|
51
|
+
handle,
|
|
52
|
+
shape: selectedShape,
|
|
53
|
+
originPagePoint: event.pagePoint.clone(),
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
if (session) {
|
|
57
|
+
const snapMode = session.handleSnapMode ?? "none";
|
|
58
|
+
this.transition("pointing_selection_handle_interaction", {
|
|
59
|
+
originPagePoint: event.pagePoint.clone(),
|
|
60
|
+
previousSelection,
|
|
61
|
+
session,
|
|
62
|
+
snapSnapshot:
|
|
63
|
+
snapMode === "none"
|
|
64
|
+
? null
|
|
65
|
+
: this.editor.snaps.createHandleSnapshot({
|
|
66
|
+
context: session.handleSnapContext ?? {
|
|
67
|
+
shapeId: session.shapeId,
|
|
68
|
+
handle,
|
|
69
|
+
},
|
|
70
|
+
currentPagePoint: event.pagePoint,
|
|
71
|
+
allowSelfSnap: session.allowSelfSnap ?? false,
|
|
72
|
+
excludedShapeIds: session.excludedSnapShapeIds,
|
|
73
|
+
}),
|
|
74
|
+
} satisfies PointingSelectionHandleInteractionInfo);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const hit = this.editor.hitTestShape(event.pagePoint);
|
|
81
|
+
if (hit) {
|
|
82
|
+
const rawSelectionTargetId = this.editor
|
|
83
|
+
.getShapeUtil(hit)
|
|
84
|
+
.getSelectionTargetId(hit, { editor: this.editor });
|
|
85
|
+
const rawTranslateTargetId = this.editor
|
|
86
|
+
.getShapeUtil(hit)
|
|
87
|
+
.getTranslateTargetId(hit, { editor: this.editor });
|
|
88
|
+
const additiveSelection = isAdditiveSelectionActive(event);
|
|
89
|
+
const selectionTargetId = getSelectableShapeIdForHit(
|
|
90
|
+
this.editor,
|
|
91
|
+
rawSelectionTargetId,
|
|
92
|
+
previousSelection,
|
|
93
|
+
);
|
|
94
|
+
const selectedTransformAncestorId = additiveSelection
|
|
95
|
+
? null
|
|
96
|
+
: getSelectedTransformAncestorIdForHit(
|
|
97
|
+
this.editor,
|
|
98
|
+
rawSelectionTargetId,
|
|
99
|
+
previousSelection,
|
|
100
|
+
);
|
|
101
|
+
const quickClickSelectionTargetId = additiveSelection
|
|
102
|
+
? null
|
|
103
|
+
: selectedTransformAncestorId
|
|
104
|
+
? selectionTargetId
|
|
105
|
+
: null;
|
|
106
|
+
const translateTargetId = getSelectableShapeIdForHit(
|
|
107
|
+
this.editor,
|
|
108
|
+
rawTranslateTargetId,
|
|
109
|
+
previousSelection,
|
|
110
|
+
);
|
|
111
|
+
const dragTargetId =
|
|
112
|
+
quickClickSelectionTargetId === null
|
|
113
|
+
? translateTargetId
|
|
114
|
+
: selectedTransformAncestorId ?? translateTargetId;
|
|
115
|
+
this.transition("pointing_shape", {
|
|
116
|
+
shapeId: selectionTargetId,
|
|
117
|
+
translateTargetId: dragTargetId,
|
|
118
|
+
originPagePoint: event.pagePoint.clone(),
|
|
119
|
+
originTimestamp: event.timestamp,
|
|
120
|
+
previousSelection,
|
|
121
|
+
additiveSelection,
|
|
122
|
+
wasSelected: previousSelection.includes(selectionTargetId),
|
|
123
|
+
fromSelectionBounds: false,
|
|
124
|
+
quickClickSelectionTargetId,
|
|
125
|
+
} satisfies PointingShapeInfo);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!isAdditiveSelectionActive(event) && previousSelection.length > 0) {
|
|
130
|
+
const selectedShape = this.editor.getSelectedShapes()[0];
|
|
131
|
+
if (
|
|
132
|
+
selectedShape &&
|
|
133
|
+
this.editor
|
|
134
|
+
.getShapeUtil(selectedShape)
|
|
135
|
+
.canStartTranslateFromSelectionBounds(selectedShape) &&
|
|
136
|
+
this.editor.isPointInSelectionBounds(event.pagePoint)
|
|
137
|
+
) {
|
|
138
|
+
this.transition("pointing_shape", {
|
|
139
|
+
shapeId: selectedShape.id,
|
|
140
|
+
translateTargetId: selectedShape.id,
|
|
141
|
+
originPagePoint: event.pagePoint.clone(),
|
|
142
|
+
originTimestamp: event.timestamp,
|
|
143
|
+
previousSelection,
|
|
144
|
+
additiveSelection: false,
|
|
145
|
+
wasSelected: true,
|
|
146
|
+
fromSelectionBounds: true,
|
|
147
|
+
quickClickSelectionTargetId: null,
|
|
148
|
+
} satisfies PointingShapeInfo);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.transition("pointing_canvas", {
|
|
154
|
+
originPagePoint: event.pagePoint.clone(),
|
|
155
|
+
previousSelection,
|
|
156
|
+
additiveSelection: isAdditiveSelectionActive(event),
|
|
157
|
+
} satisfies PointingCanvasInfo);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
3
|
+
import type { PointerEditorEvent } from "../../../editor/events";
|
|
4
|
+
import {
|
|
5
|
+
isAdditiveSelectionActive,
|
|
6
|
+
type BrushInfo,
|
|
7
|
+
type PointingCanvasInfo,
|
|
8
|
+
} from "../selectToolHelpers";
|
|
9
|
+
import { PointingStateNode } from "./SelectStateNode";
|
|
10
|
+
|
|
11
|
+
export class PointingCanvasState extends PointingStateNode<PointingCanvasInfo> {
|
|
12
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
13
|
+
super(editor, "pointing_canvas", parent);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected onDragThresholdExceeded(event: PointerEditorEvent): void {
|
|
17
|
+
if (!this.info) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.transition("brushing", {
|
|
21
|
+
...this.info,
|
|
22
|
+
additiveSelection: isAdditiveSelectionActive(event),
|
|
23
|
+
} satisfies BrushInfo);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected onPointerUp(event: PointerEditorEvent): void {
|
|
27
|
+
if (!isAdditiveSelectionActive(event)) {
|
|
28
|
+
this.editor.commands.setSelectedShapeIds([], { source: "system" });
|
|
29
|
+
}
|
|
30
|
+
this.transition("idle");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected onCancel(): void {
|
|
34
|
+
if (this.info) {
|
|
35
|
+
this.editor.commands.setSelectedShapeIds(this.info.previousSelection, {
|
|
36
|
+
source: "system",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
this.transition("idle");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
3
|
+
import { getSelectionResizeSnapshot } from "../../../editor/selection";
|
|
4
|
+
import {
|
|
5
|
+
createResizingUpdates,
|
|
6
|
+
getSelectionResizeAspectRatioLockOverride,
|
|
7
|
+
getShapeSelectionResizePageOutlineVertices,
|
|
8
|
+
type PointingResizeHandleInfo,
|
|
9
|
+
type ResizingInfo,
|
|
10
|
+
} from "../selectToolHelpers";
|
|
11
|
+
import { PointingStateNode } from "./SelectStateNode";
|
|
12
|
+
|
|
13
|
+
export class PointingResizeHandleState extends PointingStateNode<PointingResizeHandleInfo> {
|
|
14
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
15
|
+
super(editor, "pointing_resize_handle", parent);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected onDragThresholdExceeded(): void {
|
|
19
|
+
if (!this.info) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const selectionFrame = this.editor.getSelectionFrame();
|
|
24
|
+
if (!selectionFrame) {
|
|
25
|
+
this.transition("idle");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const selectedShapes = this.editor.getSelectionTransformTargetShapes();
|
|
30
|
+
const resizeSnapshot = getSelectionResizeSnapshot({
|
|
31
|
+
shapes: selectedShapes,
|
|
32
|
+
selectionFrame,
|
|
33
|
+
getShapeSelectionResizePageOutlineVertices: (shape) =>
|
|
34
|
+
getShapeSelectionResizePageOutlineVertices(this.editor, shape),
|
|
35
|
+
getShapeSelectionPagePoints: (shape) =>
|
|
36
|
+
this.editor.getShapeUtil(shape).getSelectionPagePoints(shape),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
this.transition("resizing", {
|
|
40
|
+
...this.info,
|
|
41
|
+
startBounds: resizeSnapshot.startBounds,
|
|
42
|
+
rotation: resizeSnapshot.rotation,
|
|
43
|
+
rotationCenter: resizeSnapshot.rotationCenter,
|
|
44
|
+
aspectRatio: resizeSnapshot.aspectRatio,
|
|
45
|
+
snapSnapshot: this.editor.snaps.createResizeSnapshot({
|
|
46
|
+
resizingShapeIds: selectedShapes.map((shape) => shape.id),
|
|
47
|
+
coordinateSpace: {
|
|
48
|
+
rotation: resizeSnapshot.rotation,
|
|
49
|
+
rotationCenter: resizeSnapshot.rotationCenter,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
shapes: resizeSnapshot.shapes,
|
|
53
|
+
pointShapes: resizeSnapshot.pointShapes,
|
|
54
|
+
updates: createResizingUpdates(
|
|
55
|
+
resizeSnapshot.shapes,
|
|
56
|
+
resizeSnapshot.pointShapes,
|
|
57
|
+
),
|
|
58
|
+
aspectRatioLockOverride: getSelectionResizeAspectRatioLockOverride(
|
|
59
|
+
this.editor,
|
|
60
|
+
selectedShapes,
|
|
61
|
+
this.info.handleId,
|
|
62
|
+
),
|
|
63
|
+
lastPagePointX: Number.NaN,
|
|
64
|
+
lastPagePointY: Number.NaN,
|
|
65
|
+
lastShiftKey: false,
|
|
66
|
+
lastAltKey: false,
|
|
67
|
+
lastAccelKey: false,
|
|
68
|
+
} satisfies ResizingInfo);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected onPointerUp(): void {
|
|
72
|
+
this.transition("idle");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected onCancel(): void {
|
|
76
|
+
this.transition("idle");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { Vec } from "../../../geometry/Vec";
|
|
3
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
4
|
+
import { getSelectionRotateSnapshot } from "../../../editor/selection";
|
|
5
|
+
import {
|
|
6
|
+
createRotatingUpdates,
|
|
7
|
+
type PointingRotateHandleInfo,
|
|
8
|
+
type RotatingInfo,
|
|
9
|
+
} from "../selectToolHelpers";
|
|
10
|
+
import { PointingStateNode } from "./SelectStateNode";
|
|
11
|
+
|
|
12
|
+
export class PointingRotateHandleState extends PointingStateNode<PointingRotateHandleInfo> {
|
|
13
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
14
|
+
super(editor, "pointing_rotate_handle", parent);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected onDragThresholdExceeded(): void {
|
|
18
|
+
if (!this.info) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const selectionFrame = this.editor.getSelectionFrame();
|
|
23
|
+
if (!selectionFrame) {
|
|
24
|
+
this.transition("idle");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const rotateSnapshot = getSelectionRotateSnapshot({
|
|
29
|
+
shapes: this.editor.getSelectionRotationTargetShapes(),
|
|
30
|
+
selectionFrame,
|
|
31
|
+
getShapeLocalBounds: (shape) => this.editor.computeShapeLocalBounds(shape),
|
|
32
|
+
getShapeSelectionPagePoints: (shape) =>
|
|
33
|
+
this.editor.getShapeUtil(shape).getSelectionPagePoints(shape),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
this.transition("rotating", {
|
|
37
|
+
...this.info,
|
|
38
|
+
center: rotateSnapshot.center,
|
|
39
|
+
startAngle: Vec.Angle(
|
|
40
|
+
rotateSnapshot.center,
|
|
41
|
+
this.info.originPagePoint,
|
|
42
|
+
),
|
|
43
|
+
initialSelectionRotation: rotateSnapshot.initialSelectionRotation,
|
|
44
|
+
shapes: rotateSnapshot.shapes,
|
|
45
|
+
pointShapes: rotateSnapshot.pointShapes,
|
|
46
|
+
updates: createRotatingUpdates(
|
|
47
|
+
rotateSnapshot.shapes,
|
|
48
|
+
rotateSnapshot.pointShapes,
|
|
49
|
+
),
|
|
50
|
+
lastPointerX: Number.NaN,
|
|
51
|
+
lastPointerY: Number.NaN,
|
|
52
|
+
lastShiftKey: false,
|
|
53
|
+
lastAccelKey: false,
|
|
54
|
+
} satisfies RotatingInfo);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected onPointerUp(): void {
|
|
58
|
+
this.transition("idle");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected onCancel(): void {
|
|
62
|
+
this.transition("idle");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Editor } from "../../../editor/Editor";
|
|
2
|
+
import { StateNode } from "../../../editor/StateNode";
|
|
3
|
+
import {
|
|
4
|
+
type DraggingSelectionHandleInteractionInfo,
|
|
5
|
+
type PointingSelectionHandleInteractionInfo,
|
|
6
|
+
} from "../selectToolHelpers";
|
|
7
|
+
import { PointingStateNode } from "./SelectStateNode";
|
|
8
|
+
|
|
9
|
+
export class PointingSelectionHandleInteractionState extends PointingStateNode<PointingSelectionHandleInteractionInfo> {
|
|
10
|
+
constructor(editor: Editor, parent: StateNode) {
|
|
11
|
+
super(editor, "pointing_selection_handle_interaction", parent);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
protected onDragThresholdExceeded(): void {
|
|
15
|
+
if (!this.info) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.transition("dragging_selection_handle_interaction", {
|
|
20
|
+
...this.info,
|
|
21
|
+
lastPagePointX: Number.NaN,
|
|
22
|
+
lastPagePointY: Number.NaN,
|
|
23
|
+
lastAccelKey: false,
|
|
24
|
+
} satisfies DraggingSelectionHandleInteractionInfo);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected onPointerUp(): void {
|
|
28
|
+
this.transition("idle");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected onCancel(): void {
|
|
32
|
+
this.transition("idle");
|
|
33
|
+
}
|
|
34
|
+
}
|