@yft-design/engine 0.0.2 → 0.0.3
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/dist/EngineCanvas.d.ts +7 -0
- package/dist/EngineCanvas.js +4 -0
- package/dist/interact/pointer.d.ts +6 -0
- package/dist/interact/pointer.js +43 -2
- package/dist/interact/pointerTypes.d.ts +5 -0
- package/dist/render/frameOverlay.d.ts +3 -0
- package/dist/render/frameOverlay.js +1 -1
- package/dist/render/framePipeline.d.ts +3 -0
- package/dist/render/framePipeline.js +1 -0
- package/dist/render/selectionOverlay.d.ts +36 -2
- package/dist/render/selectionOverlay.js +82 -2
- package/package.json +1 -1
package/dist/EngineCanvas.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export interface EngineCanvasOptions {
|
|
|
46
46
|
background?: [number, number, number, number];
|
|
47
47
|
/** 设备像素比;e2e parity 模式固定 1 */
|
|
48
48
|
dpr?: number;
|
|
49
|
+
/** 移动端控件面(批次 354):true 时单选常规族选区右中出移动图标柄
|
|
50
|
+
* (fabric moveControls 的 move 控件——app fabricConf hasMobile 门引擎面;
|
|
51
|
+
* 宿主按 isMobile() 判定传入,引擎零 UA 耦合) */
|
|
52
|
+
mobileControls?: boolean;
|
|
49
53
|
}
|
|
50
54
|
/** 摘要类型随实现体迁至 debug/canvasInspection(批次 224),转口保持原导入路径 */
|
|
51
55
|
export type { SceneNodeSummary } from './debug/canvasInspection';
|
|
@@ -86,6 +90,9 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
86
90
|
private readonly bus;
|
|
87
91
|
private readonly doc;
|
|
88
92
|
readonly dpr: number;
|
|
93
|
+
/** 移动端控件面(批次 354):public——PointerHost/OverlayTailHost 双面消费
|
|
94
|
+
* (pointer hitMoveControl + frameOverlay 选区覆盖层),构造期定死 */
|
|
95
|
+
readonly mobileControls: boolean;
|
|
89
96
|
private vpt;
|
|
90
97
|
private cssWidth;
|
|
91
98
|
private cssHeight;
|
package/dist/EngineCanvas.js
CHANGED
|
@@ -95,6 +95,9 @@ export class EngineCanvas {
|
|
|
95
95
|
bus = new EventBus();
|
|
96
96
|
doc = new EngineDocument();
|
|
97
97
|
dpr;
|
|
98
|
+
/** 移动端控件面(批次 354):public——PointerHost/OverlayTailHost 双面消费
|
|
99
|
+
* (pointer hitMoveControl + frameOverlay 选区覆盖层),构造期定死 */
|
|
100
|
+
mobileControls;
|
|
98
101
|
vpt = [1, 0, 0, 1, 0, 0];
|
|
99
102
|
cssWidth = 300;
|
|
100
103
|
cssHeight = 150;
|
|
@@ -172,6 +175,7 @@ export class EngineCanvas {
|
|
|
172
175
|
// family 集 → 宿主补齐排版/度量/烘焙失效(见 fontInvalidation 的 pendingSettle)
|
|
173
176
|
this.glyphAtlas = new GlyphAtlas(handle.gl, () => this.requestRenderAll(), (families) => this.fontInvalidation.queueSettle(families));
|
|
174
177
|
this.dpr = options.dpr ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);
|
|
178
|
+
this.mobileControls = options.mobileControls ?? false;
|
|
175
179
|
this.background = options.background ?? [0, 0, 0, 0];
|
|
176
180
|
this.sources = new SourceManager(this);
|
|
177
181
|
this.textRenderer = new TextRenderer(handle.gl, this.batch, this.glyphAtlas);
|
|
@@ -65,6 +65,12 @@ export declare class PointerController {
|
|
|
65
65
|
* 锁定分支的 quad.br(app getHornControl 锁图标分支:br 且非组内),半径沿
|
|
66
66
|
* 用 HANDLE_HIT_PX。命中即返回锁定节点供 fire unlock 事件 */
|
|
67
67
|
hitLockControl(cssX: number, cssY: number): SceneNode | null;
|
|
68
|
+
/** 移动端移动控件命中(批次 354;app moveControls 的 move 控件引擎面):
|
|
69
|
+
* 宿主 mobileControls 门 + moveControlTarget 族判定(单选常规族/未锁),
|
|
70
|
+
* 位置与渲染共源 moveControlPosition(选区右中 +24 屏幕px 随姿态),命中
|
|
71
|
+
* 半径 MOVE_CONTROL_HIT_PX(finger 友好目标)。桌面态(mobileControls 缺席
|
|
72
|
+
* /false)恒 false——既有命中链零扰动 */
|
|
73
|
+
hitMoveControl(cssX: number, cssY: number): boolean;
|
|
68
74
|
/** 四角隐形旋转区命中(批次 88;fabric baseControls tlr/trr/brr/blr +
|
|
69
75
|
* Control.calcCornerCoords):每区=角点沿本地对角外偏 4 屏幕px 的中心、
|
|
70
76
|
* 16×16 方形命中盒随对象角度旋转(point-in-polygon 的逆旋转回盒本地系
|
package/dist/interact/pointer.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
import { createNode, createReferenceLineRaw, GroupNode, isReferenceLineNode, PuzzleNode, TableNode } from '../model/scene';
|
|
29
29
|
import { RULER_SIZE } from '../render/ruler';
|
|
30
30
|
import { buildSelectionRange, getBorderCursor, selectionBounds } from '../model/tableEdit';
|
|
31
|
-
import { CORNER_ROTATE_CURSOR_OFFSET, CORNER_ROTATE_ZONE_PX, cornerOffsetToRadius, getActiveChildHandles, getAdaptiveSelectionHandles, getCornerRotateZones, HANDLE_HIT_PX, isImageRadiusHandleNode, isRadiusHandleNode, isUserLockedNode, radiusHandleTarget, rectCornerMaxRadius, rotateControlSpecByAngle, selectionQuadCoords } from '../render/selectionOverlay';
|
|
31
|
+
import { CORNER_ROTATE_CURSOR_OFFSET, CORNER_ROTATE_ZONE_PX, cornerOffsetToRadius, getActiveChildHandles, getAdaptiveSelectionHandles, getCornerRotateZones, HANDLE_HIT_PX, isImageRadiusHandleNode, isRadiusHandleNode, isUserLockedNode, MOVE_CONTROL_HIT_PX, moveControlPosition, moveControlTarget, radiusHandleTarget, rectCornerMaxRadius, rotateControlSpecByAngle, selectionQuadCoords } from '../render/selectionOverlay';
|
|
32
32
|
import { EDGE_HANDLE_AXIS, isEdgeHandle, isRadiusHandle, RADIUS_HANDLE_CORNER } from '../model/handles';
|
|
33
33
|
import { CLICK_THRESHOLD, CORNER_HANDLES, deg, DRAG_START_THRESHOLD, HANDLE_BASE_ANGLE, quadCenter, quadDims, SCALE_CURSORS } from './pointerTypes';
|
|
34
34
|
import { applyMultiRotate, applyMultiScale, applyScale, buildMultiScaleSnapshot, buildScaleSnapshot } from './pointerTransform';
|
|
@@ -219,6 +219,23 @@ export class PointerController {
|
|
|
219
219
|
const screen = this.host.toScreen(layout.quad.br.x, layout.quad.br.y);
|
|
220
220
|
return Math.hypot(screen.x - cssX, screen.y - cssY) <= HANDLE_HIT_PX ? doc.selection[0] : null;
|
|
221
221
|
}
|
|
222
|
+
/** 移动端移动控件命中(批次 354;app moveControls 的 move 控件引擎面):
|
|
223
|
+
* 宿主 mobileControls 门 + moveControlTarget 族判定(单选常规族/未锁),
|
|
224
|
+
* 位置与渲染共源 moveControlPosition(选区右中 +24 屏幕px 随姿态),命中
|
|
225
|
+
* 半径 MOVE_CONTROL_HIT_PX(finger 友好目标)。桌面态(mobileControls 缺席
|
|
226
|
+
* /false)恒 false——既有命中链零扰动 */
|
|
227
|
+
hitMoveControl(cssX, cssY) {
|
|
228
|
+
if (this.host.mobileControls !== true)
|
|
229
|
+
return false;
|
|
230
|
+
if (!moveControlTarget(this.host.document))
|
|
231
|
+
return false;
|
|
232
|
+
const layout = selectionQuadCoords(this.host.document);
|
|
233
|
+
if (!layout)
|
|
234
|
+
return false;
|
|
235
|
+
const pos = moveControlPosition(layout.quad, layout.angle, this.host.zoom);
|
|
236
|
+
const screen = this.host.toScreen(pos.x, pos.y);
|
|
237
|
+
return Math.hypot(screen.x - cssX, screen.y - cssY) <= MOVE_CONTROL_HIT_PX;
|
|
238
|
+
}
|
|
222
239
|
/** 四角隐形旋转区命中(批次 88;fabric baseControls tlr/trr/brr/blr +
|
|
223
240
|
* Control.calcCornerCoords):每区=角点沿本地对角外偏 4 屏幕px 的中心、
|
|
224
241
|
* 16×16 方形命中盒随对象角度旋转(point-in-polygon 的逆旋转回盒本地系
|
|
@@ -364,6 +381,10 @@ export class PointerController {
|
|
|
364
381
|
return SCALE_CURSORS[((Math.round(a / 45) % 4) + 4) % 4];
|
|
365
382
|
}
|
|
366
383
|
}
|
|
384
|
+
// 移动端移动控件光标(批次 354;app moveControls cursorStyleHandler 'move')
|
|
385
|
+
// ——命中序与 onPointerDown 一致(先于普通手柄;桌面态恒不命中)
|
|
386
|
+
if (this.hitMoveControl(cssX, cssY))
|
|
387
|
+
return 'move';
|
|
367
388
|
const handle = this.hitHandle(cssX, cssY);
|
|
368
389
|
// mtr 悬停光标 = 随对象角度转动的旋转箭头(app rotateControl
|
|
369
390
|
// cursorStyleHandler 的 rotateIcon(angle+225);多选取合并框角度 = fabric AS 角度)
|
|
@@ -460,7 +481,9 @@ export class PointerController {
|
|
|
460
481
|
// 蒙版会话是引擎侧选择:分割线手柄域不叠对象边框)
|
|
461
482
|
const maskSession = doc.nodes.find((n) => n instanceof PuzzleNode && n.editingMask) ?? null;
|
|
462
483
|
const sessionActive = !!this.host.cropSession || !!this.host.expandSession || !!this.host.pathSession || !!this.host.warpSession || !!maskSession;
|
|
463
|
-
|
|
484
|
+
// 手柄/移动控件命中域不进悬停(app fabric findControl 命中即 target=活动
|
|
485
|
+
// 对象——其它对象 hover 边框不出;批次 354 move 控件并入同门)
|
|
486
|
+
const handleFree = !this.hitHandle(cssX, cssY) && !this.hitMoveControl(cssX, cssY);
|
|
464
487
|
if (!sessionActive && handleFree) {
|
|
465
488
|
const target = doc.findTarget(p.x, p.y);
|
|
466
489
|
if (target instanceof GroupNode && !(target instanceof TableNode) && !(target instanceof PuzzleNode)) {
|
|
@@ -820,6 +843,24 @@ export class PointerController {
|
|
|
820
843
|
}
|
|
821
844
|
}
|
|
822
845
|
}
|
|
846
|
+
// 1.01) 移动端移动控件(批次 354;app baseControls 的 moveControls——
|
|
847
|
+
// fabricConf hasMobile 门注入的常规族控件):单选常规族选区右中
|
|
848
|
+
// +24 屏幕px 的圆形移动图标柄,按下即起整选区 move 手势(app
|
|
849
|
+
// actionHandler=dragHandler 同语义——拖它=拖本体;move 手势自带
|
|
850
|
+
// 启动阈值+performed 门,纯点击零位移无提交)。命中先于普通手柄:
|
|
851
|
+
// fabric findControl 倒序里 move 排在缩放手柄后、mtr 前——mtr 与
|
|
852
|
+
// move 同位冲突(对象角 45°~135° 时 mtr 吸附到本地右缘=move 同位)
|
|
853
|
+
// move 赢(此处先判即同效);与 mr 的贴边 4px 重叠带(两心距 24、
|
|
854
|
+
// 半径和 28)引擎取 move——控件视觉在框外,让 mr 半径内贴边点
|
|
855
|
+
// 仍可拖本体语义无损。激活子手柄优先不变(1) 子柄块在前)
|
|
856
|
+
if (!exitedEditing && groupHandlesLive && this.hitMoveControl(cssX, cssY)) {
|
|
857
|
+
const node = doc.selection[0];
|
|
858
|
+
const snapshot = new Map();
|
|
859
|
+
snapshot.set(node, { left: node.raw.left ?? 0, top: node.raw.top ?? 0 });
|
|
860
|
+
this.gesture = { type: 'move', start: p, startCss: { x: cssX, y: cssY }, snapshot, historyBefore: captureHistoryBefore([node]) };
|
|
861
|
+
this.host.requestRenderAll();
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
823
864
|
const handle = exitedEditing || !groupHandlesLive ? null : this.hitHandle(cssX, cssY);
|
|
824
865
|
if (handle) {
|
|
825
866
|
if (doc.selection.length === 1) {
|
|
@@ -97,6 +97,11 @@ export interface PointerHost {
|
|
|
97
97
|
};
|
|
98
98
|
/** 旋转主体是激活子(覆盖只钉子手柄集,见 RotateGestureOverlay) */ onChild?: boolean;
|
|
99
99
|
} | null;
|
|
100
|
+
/** 移动端控件面(批次 354):true 时单选常规族选区右中出移动图标柄
|
|
101
|
+
* (hitMoveControl/hoverCursor 消费——fabric moveControls 的 move 控件;
|
|
102
|
+
* EngineCanvasOptions.mobileControls 直通)。可选=单测桩宿主免实现
|
|
103
|
+
* (缺省无移动控件交互,桌面行为零变化) */
|
|
104
|
+
mobileControls?: boolean;
|
|
100
105
|
}
|
|
101
106
|
/** B3 扩图会话在 pointer 侧的消费面(ExpandSessionController 实现) */
|
|
102
107
|
export interface ExpandSessionHandle {
|
|
@@ -41,6 +41,9 @@ export interface FrameOverlayInput {
|
|
|
41
41
|
/** 旋转手势覆盖态(pointer 手势期写宿主 rotateDrag 转发):mtr 冻结位 +
|
|
42
42
|
* 角度气泡中心——null = 非旋转手势期,常规手柄布局 */
|
|
43
43
|
rotate?: RotateGestureOverlay | null;
|
|
44
|
+
/** 移动端控件面(批次 354):true 时单选常规族选区右中出移动图标柄
|
|
45
|
+
* (fabric moveControls 的 move 控件——app fabricConf hasMobile 门引擎面) */
|
|
46
|
+
mobileControls?: boolean;
|
|
44
47
|
/** 标尺参数(P5-3;null = 关);referenceLine=拖拽中的线位气泡态(批次 72) */
|
|
45
48
|
ruler: {
|
|
46
49
|
vpt: Mat;
|
|
@@ -69,7 +69,7 @@ export const buildFrameOverlay = (input) => {
|
|
|
69
69
|
? buildMarqueeOverlay(marquee, zoom)
|
|
70
70
|
: maskEditPuzzle?.editingMask
|
|
71
71
|
? buildPuzzleMaskEditOverlay(maskEditPuzzle, zoom, rotate)
|
|
72
|
-
: buildSelectionOverlay(doc, zoom, rotate);
|
|
72
|
+
: buildSelectionOverlay(doc, zoom, rotate, input.mobileControls === true);
|
|
73
73
|
// 组内子文本编辑中:顶组虚线框保持可见(app renderTopGroupControls 在编辑态
|
|
74
74
|
// 仍绘制——activeObject 仍在组内;守卫用「编辑节点=单选组后代」不依赖
|
|
75
75
|
// activeGroupChild(enterEditing 直入路径不设激活子))
|
|
@@ -57,6 +57,9 @@ export interface OverlayTailHost {
|
|
|
57
57
|
y: number;
|
|
58
58
|
};
|
|
59
59
|
} | null;
|
|
60
|
+
/** 移动端控件面(批次 354):EngineCanvasOptions.mobileControls 直通——选区
|
|
61
|
+
* 右中移动图标柄(渲染/命中共源,pointer 侧读 PointerHost.mobileControls) */
|
|
62
|
+
readonly mobileControls: boolean;
|
|
60
63
|
readonly rulerVisible: boolean;
|
|
61
64
|
readonly referenceLineDrag: {
|
|
62
65
|
axis: 'horizontal' | 'vertical';
|
|
@@ -71,6 +71,7 @@ export function finishFrameOverlay(host) {
|
|
|
71
71
|
cellEditOverlayOnly: editingNode !== null && host.tableCellEditing.isOverlay(editingNode),
|
|
72
72
|
snapOverlay: host.snapGuide.buildOverlay(host.zoom),
|
|
73
73
|
rotate: host.rotateDrag,
|
|
74
|
+
mobileControls: host.mobileControls,
|
|
74
75
|
ruler: host.rulerVisible ? { vpt: host.vpt, cssWidth: host.cssWidth, cssHeight: host.cssHeight, referenceLine: host.referenceLineDrag } : null
|
|
75
76
|
});
|
|
76
77
|
pushOverlayAndContinue(host, overlay);
|
|
@@ -38,6 +38,37 @@ export declare const getRotateControlSprite: () => HTMLCanvasElement;
|
|
|
38
38
|
* 角度转动,但按 90° 轴位回正(|sin|>|cos| 轴位 ±90、否则 0/180),净效果
|
|
39
39
|
* 图标最多倾斜 ±45°、箭头读向稳定不倒置 */
|
|
40
40
|
export declare const rotateIconTilt: (angleDeg: number) => number;
|
|
41
|
+
/** —— 移动端移动控件(批次 354;app controls/common moveControls 的 move 控件引擎面)——
|
|
42
|
+
* fabric 语义(fabricConf hasMobile 门逐类注入 baseControls 族):仅移动端装配,
|
|
43
|
+
* 选区右中外偏 24 屏幕px 的白圆底十字箭头图标柄,actionHandler=dragHandler
|
|
44
|
+
* (拖它=拖本体同款 move 手势),cursorStyleHandler='move',图标不随对象角度
|
|
45
|
+
* 旋转(app renderMoveControl 无 ctx.rotate——与锁图标随角度旋转不同) */
|
|
46
|
+
/** 控件本地规格(app moveControls Control 原值):x=0.5/y=0(右中)+ offsetX 24 */
|
|
47
|
+
export declare const MOVE_CONTROL_OFFSET_PX = 24;
|
|
48
|
+
/** 图标 sprite 逻辑边长(px):白圆 r=8(app renderMoveControl 的
|
|
49
|
+
* radius=cornerSize=8,fabricConf ownDefaults 全局口径)+ 两侧描边余量 */
|
|
50
|
+
export declare const MOVE_CONTROL_PX = 20;
|
|
51
|
+
/** 命中半径(px):finger 友好目标(app Control sizeX/sizeY=20 方形 + fabric 触摸
|
|
52
|
+
* padding 的口径),大于视觉半径 9——控件中心距 mr 手柄中心恒 24px,与
|
|
53
|
+
* HANDLE_HIT_PX=12 存在 4px 重叠带(命中优先序见 pointer onPointerDown 1.01) */
|
|
54
|
+
export declare const MOVE_CONTROL_HIT_PX = 16;
|
|
55
|
+
/** 移动图标 sprite(app renderMoveControl 图标段同口径:白圆 r=8 + #2c2c2c
|
|
56
|
+
* lineWidth 2 描边 + 十字箭头 1024 viewBox 缩到 16×16 填 #2c2c2c;2× 采样抗
|
|
57
|
+
* 放大糊。jsdom 无 2D 上下文时退化为空图,单测只断言几何/贴图挂载) */
|
|
58
|
+
export declare const getMoveControlSprite: () => HTMLCanvasElement;
|
|
59
|
+
/** 控件宿主判定(渲染/命中共源):单选常规族——线族(app lineControls 的
|
|
60
|
+
* defaultControls 展开不透传 isMobile)、表格/拼图(tableControls/
|
|
61
|
+
* puzzleControls=baseControls(true,false) 自制集无 move)、蒙版(maskControls)
|
|
62
|
+
* 与用户锁单选不进;多选不进(fabric ActiveSelection 走原生控件集)。
|
|
63
|
+
* 组顶(groupControls 含 moveControls)正常进——组内激活会话只有顶组面,
|
|
64
|
+
* 子手柄集不加(引擎侧边界,app fabric 交互态另有子控件面不承接) */
|
|
65
|
+
export declare const moveControlTarget: (doc: EngineDocument) => SceneNode | null;
|
|
66
|
+
/** 控件位置:fabric 规格经当前姿态变换(app positionHandler 同构——offset 恒定
|
|
67
|
+
* 屏幕像素、随对象角度绕框心旋转;mtr 手势期换边但 move 恒在本地右缘) */
|
|
68
|
+
export declare const moveControlPosition: (quad: CornerPoints, angleDeg: number, zoom: number) => {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
};
|
|
41
72
|
export declare const angleBadgeCanvas: (text: string) => HTMLCanvasElement;
|
|
42
73
|
/** 旋转手势覆盖态(fabric 语义两件):手柄锚定规格快照——app 手势起始把控件
|
|
43
74
|
* 本地规格(x/y/offset,__rotateControlPosition)快照进 _currentTransform,
|
|
@@ -241,8 +272,11 @@ export declare const buildDashedBorderOverlay: (quad: CornerPoints, zoom: number
|
|
|
241
272
|
* 组内子不进)
|
|
242
273
|
* rotate 非空(旋转手势期,宿主 rotateDrag 转发):mtr 按手势起始规格贴框
|
|
243
274
|
* 随姿态转(不换边)、框中心/对象中心出角度气泡(app renderRotateControl
|
|
244
|
-
* isRotating
|
|
245
|
-
|
|
275
|
+
* isRotating 同构)。
|
|
276
|
+
* mobile(批次 354):宿主 EngineCanvasOptions.mobileControls——true 时单选
|
|
277
|
+
* 常规族在选区右中(topQuad 口径,随框转)+24 屏幕px 出移动图标柄(fabric
|
|
278
|
+
* moveControls 的 move 控件;app fabricConf hasMobile 门逐类注入的引擎面) */
|
|
279
|
+
export declare const buildSelectionOverlay: (doc: EngineDocument, zoom: number, rotate?: RotateGestureOverlay | null, mobile?: boolean) => OverlayQuad[];
|
|
246
280
|
/** 圆角手柄宿主解析(渲染/命中共用):单选矩形族或图片族(批次 101 扩档)——
|
|
247
281
|
* 组内激活态 selection[0] 是顶组(非族)自然为 null、多选不进、锁定单选在
|
|
248
282
|
* 调用方提前短路(全套手柄不出);动画/码图族在 isImageRadiusHandleNode 排除 */
|
|
@@ -118,6 +118,76 @@ export const rotateIconTilt = (angleDeg) => {
|
|
|
118
118
|
const axis = Math.abs(x) > Math.abs(y) ? Math.sign(x) * 90 : Math.sign(y) * 90 - 90;
|
|
119
119
|
return angleDeg - axis;
|
|
120
120
|
};
|
|
121
|
+
/** —— 移动端移动控件(批次 354;app controls/common moveControls 的 move 控件引擎面)——
|
|
122
|
+
* fabric 语义(fabricConf hasMobile 门逐类注入 baseControls 族):仅移动端装配,
|
|
123
|
+
* 选区右中外偏 24 屏幕px 的白圆底十字箭头图标柄,actionHandler=dragHandler
|
|
124
|
+
* (拖它=拖本体同款 move 手势),cursorStyleHandler='move',图标不随对象角度
|
|
125
|
+
* 旋转(app renderMoveControl 无 ctx.rotate——与锁图标随角度旋转不同) */
|
|
126
|
+
/** 控件本地规格(app moveControls Control 原值):x=0.5/y=0(右中)+ offsetX 24 */
|
|
127
|
+
export const MOVE_CONTROL_OFFSET_PX = 24;
|
|
128
|
+
/** 图标 sprite 逻辑边长(px):白圆 r=8(app renderMoveControl 的
|
|
129
|
+
* radius=cornerSize=8,fabricConf ownDefaults 全局口径)+ 两侧描边余量 */
|
|
130
|
+
export const MOVE_CONTROL_PX = 20;
|
|
131
|
+
/** 命中半径(px):finger 友好目标(app Control sizeX/sizeY=20 方形 + fabric 触摸
|
|
132
|
+
* padding 的口径),大于视觉半径 9——控件中心距 mr 手柄中心恒 24px,与
|
|
133
|
+
* HANDLE_HIT_PX=12 存在 4px 重叠带(命中优先序见 pointer onPointerDown 1.01) */
|
|
134
|
+
export const MOVE_CONTROL_HIT_PX = 16;
|
|
135
|
+
/** 十字箭头 path(app renderMoveControl 原样:viewBox 1024,四向三角+中心圆点) */
|
|
136
|
+
const MOVE_ICON_PATH = 'M607.573333 295.908693h-184.32l92.16-92.16zM515.413333 813.42464l-92.16-92.16h184.32l-92.16 92.16M210.57536 508.586667l92.16-92.16v184.32l-92.16-92.16M820.251307 508.586667l-92.16 92.16v-184.32l92.16 92.16M446.88384 507.405653c0 37.195093 30.153387 67.345067 67.345067 67.345067 37.198507 0 67.351893-30.149973 67.351893-67.345067s-30.153387-67.345067-67.34848-67.345066c-37.195093 0-67.345067 30.149973-67.345067 67.345066z';
|
|
137
|
+
let moveSpriteCache = null;
|
|
138
|
+
/** 移动图标 sprite(app renderMoveControl 图标段同口径:白圆 r=8 + #2c2c2c
|
|
139
|
+
* lineWidth 2 描边 + 十字箭头 1024 viewBox 缩到 16×16 填 #2c2c2c;2× 采样抗
|
|
140
|
+
* 放大糊。jsdom 无 2D 上下文时退化为空图,单测只断言几何/贴图挂载) */
|
|
141
|
+
export const getMoveControlSprite = () => {
|
|
142
|
+
if (moveSpriteCache)
|
|
143
|
+
return moveSpriteCache;
|
|
144
|
+
const canvas = document.createElement('canvas');
|
|
145
|
+
canvas.width = MOVE_CONTROL_PX * 2;
|
|
146
|
+
canvas.height = MOVE_CONTROL_PX * 2;
|
|
147
|
+
const ctx = canvas.getContext('2d');
|
|
148
|
+
if (ctx) {
|
|
149
|
+
ctx.scale(2, 2);
|
|
150
|
+
const center = MOVE_CONTROL_PX / 2;
|
|
151
|
+
ctx.beginPath();
|
|
152
|
+
ctx.arc(center, center, 8, 0, Math.PI * 2);
|
|
153
|
+
ctx.strokeStyle = '#2c2c2c';
|
|
154
|
+
ctx.lineWidth = 2;
|
|
155
|
+
ctx.stroke();
|
|
156
|
+
ctx.fillStyle = '#ffffff';
|
|
157
|
+
ctx.fill();
|
|
158
|
+
if (typeof Path2D !== 'undefined') {
|
|
159
|
+
// app:translate(-radius,-radius) + scale(2·radius/1024)——图标盒 16×16 贴圆心
|
|
160
|
+
ctx.translate(center - 8, center - 8);
|
|
161
|
+
ctx.scale(16 / 1024, 16 / 1024);
|
|
162
|
+
ctx.fillStyle = '#2c2c2c';
|
|
163
|
+
ctx.fill(new Path2D(MOVE_ICON_PATH));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
moveSpriteCache = canvas;
|
|
167
|
+
return canvas;
|
|
168
|
+
};
|
|
169
|
+
/** 控件宿主判定(渲染/命中共源):单选常规族——线族(app lineControls 的
|
|
170
|
+
* defaultControls 展开不透传 isMobile)、表格/拼图(tableControls/
|
|
171
|
+
* puzzleControls=baseControls(true,false) 自制集无 move)、蒙版(maskControls)
|
|
172
|
+
* 与用户锁单选不进;多选不进(fabric ActiveSelection 走原生控件集)。
|
|
173
|
+
* 组顶(groupControls 含 moveControls)正常进——组内激活会话只有顶组面,
|
|
174
|
+
* 子手柄集不加(引擎侧边界,app fabric 交互态另有子控件面不承接) */
|
|
175
|
+
export const moveControlTarget = (doc) => {
|
|
176
|
+
if (doc.selection.length !== 1)
|
|
177
|
+
return null;
|
|
178
|
+
const node = doc.selection[0];
|
|
179
|
+
if (node instanceof TableNode || node instanceof PuzzleNode)
|
|
180
|
+
return null;
|
|
181
|
+
const type = String(node.raw.type ?? '');
|
|
182
|
+
if (LINE_TYPES.has(type) || MASK_TYPES.has(type))
|
|
183
|
+
return null;
|
|
184
|
+
if (isUserLockedNode(node))
|
|
185
|
+
return null;
|
|
186
|
+
return node;
|
|
187
|
+
};
|
|
188
|
+
/** 控件位置:fabric 规格经当前姿态变换(app positionHandler 同构——offset 恒定
|
|
189
|
+
* 屏幕像素、随对象角度绕框心旋转;mtr 手势期换边但 move 恒在本地右缘) */
|
|
190
|
+
export const moveControlPosition = (quad, angleDeg, zoom) => rotateControlScenePos(quad, angleDeg, zoom, { x: 0.5, y: 0, offsetX: MOVE_CONTROL_OFFSET_PX, offsetY: 0 });
|
|
121
191
|
/** 角度气泡超采样倍率(同标尺位图口径) */
|
|
122
192
|
const ANGLE_BADGE_SUPERSAMPLE = 3;
|
|
123
193
|
/** 角度气泡位图(app renderRotateControl isRotating 分支同构):rgba(44,44,44,0.9)
|
|
@@ -657,8 +727,11 @@ const pushHandlesWithRotate = (quads, handles, quad, angleDeg, zoom, rotate) =>
|
|
|
657
727
|
* 组内子不进)
|
|
658
728
|
* rotate 非空(旋转手势期,宿主 rotateDrag 转发):mtr 按手势起始规格贴框
|
|
659
729
|
* 随姿态转(不换边)、框中心/对象中心出角度气泡(app renderRotateControl
|
|
660
|
-
* isRotating
|
|
661
|
-
|
|
730
|
+
* isRotating 同构)。
|
|
731
|
+
* mobile(批次 354):宿主 EngineCanvasOptions.mobileControls——true 时单选
|
|
732
|
+
* 常规族在选区右中(topQuad 口径,随框转)+24 屏幕px 出移动图标柄(fabric
|
|
733
|
+
* moveControls 的 move 控件;app fabricConf hasMobile 门逐类注入的引擎面) */
|
|
734
|
+
export const buildSelectionOverlay = (doc, zoom, rotate = null, mobile = false) => {
|
|
662
735
|
// 参考线选中不画选区覆盖(批次 71):±999999 包围盒的边框/手柄全在视口外,
|
|
663
736
|
// 单键 lockMovement 是轴锁非用户锁——fabric 净视觉 = 无可见控件(锁图标落
|
|
664
737
|
// 在 2M 单位 bbox 的 br 角=屏外),引擎按同一净视觉返回空
|
|
@@ -712,6 +785,13 @@ export const buildSelectionOverlay = (doc, zoom, rotate = null) => {
|
|
|
712
785
|
if (activeChild && doc.groupEditing) {
|
|
713
786
|
pushHandlesWithRotate(quads, getActiveChildHandles(activeChild, zoom), activeChild.aCoords, activeChild.worldAngle, zoom, rotate?.onChild ? rotate : null);
|
|
714
787
|
}
|
|
788
|
+
// 移动端移动控件(批次 354):置于手柄之上(框外域与手柄无叠层,绘制序无
|
|
789
|
+
// 语义差);位置贴 topQuad 当前姿态(拖动/旋转中逐帧跟随),sprite 不随
|
|
790
|
+
// 角度旋转(app renderMoveControl 无 ctx.rotate——十字箭头恒屏幕正向)
|
|
791
|
+
if (mobile && moveControlTarget(doc)) {
|
|
792
|
+
const pos = moveControlPosition(topQuad, angle, zoom);
|
|
793
|
+
quads.push({ ...squareQuad(pos, MOVE_CONTROL_PX / zoom, [1, 1, 1, 1], 0), texture: getMoveControlSprite() });
|
|
794
|
+
}
|
|
715
795
|
return quads;
|
|
716
796
|
};
|
|
717
797
|
/** 圆角手柄宿主解析(渲染/命中共用):单选矩形族或图片族(批次 101 扩档)——
|