@idraw/core 0.4.0-beta.17 → 0.4.0-beta.19
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/esm/config.d.ts +1 -0
- package/dist/esm/config.js +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/middleware/info/draw-info.d.ts +31 -0
- package/dist/esm/middleware/info/draw-info.js +110 -0
- package/dist/esm/middleware/info/index.d.ts +3 -0
- package/dist/esm/middleware/info/index.js +110 -0
- package/dist/esm/middleware/info/types.d.ts +3 -0
- package/dist/esm/middleware/info/types.js +1 -0
- package/dist/esm/middleware/layout-selector/config.d.ts +6 -0
- package/dist/esm/middleware/layout-selector/config.js +6 -0
- package/dist/esm/middleware/layout-selector/index.d.ts +3 -0
- package/dist/esm/middleware/layout-selector/index.js +251 -0
- package/dist/esm/middleware/layout-selector/types.d.ts +12 -0
- package/dist/esm/middleware/layout-selector/types.js +2 -0
- package/dist/esm/middleware/layout-selector/util.d.ts +5 -0
- package/dist/esm/middleware/layout-selector/util.js +93 -0
- package/dist/esm/middleware/ruler/index.d.ts +2 -1
- package/dist/esm/middleware/ruler/index.js +3 -2
- package/dist/esm/middleware/ruler/types.d.ts +3 -0
- package/dist/esm/middleware/ruler/types.js +1 -0
- package/dist/esm/middleware/ruler/util.d.ts +6 -1
- package/dist/esm/middleware/ruler/util.js +55 -1
- package/dist/esm/middleware/scroller/index.d.ts +2 -1
- package/dist/esm/middleware/scroller/types.d.ts +9 -0
- package/dist/esm/middleware/scroller/types.js +1 -0
- package/dist/esm/middleware/scroller/util.js +1 -1
- package/dist/esm/middleware/selector/index.d.ts +4 -1
- package/dist/esm/middleware/selector/index.js +17 -9
- package/dist/index.global.js +825 -99
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -316,7 +316,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
316
316
|
function textAlign(value) {
|
|
317
317
|
return ["center", "left", "right"].includes(value);
|
|
318
318
|
}
|
|
319
|
-
function fontFamily$
|
|
319
|
+
function fontFamily$2(value) {
|
|
320
320
|
return typeof value === "string" && value.length > 0;
|
|
321
321
|
}
|
|
322
322
|
function fontWeight$1(value) {
|
|
@@ -345,7 +345,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
345
345
|
fontSize: fontSize$1,
|
|
346
346
|
lineHeight,
|
|
347
347
|
textAlign,
|
|
348
|
-
fontFamily: fontFamily$
|
|
348
|
+
fontFamily: fontFamily$2,
|
|
349
349
|
fontWeight: fontWeight$1,
|
|
350
350
|
strokeWidth
|
|
351
351
|
};
|
|
@@ -1261,17 +1261,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1261
1261
|
_loop(elements);
|
|
1262
1262
|
return result;
|
|
1263
1263
|
}
|
|
1264
|
-
function checkRectIntersect(rect1, rect2) {
|
|
1265
|
-
const rect1MinX = rect1.x;
|
|
1266
|
-
const rect1MinY = rect1.y;
|
|
1267
|
-
const rect1MaxX = rect1.x + rect1.w;
|
|
1268
|
-
const rect1MaxY = rect1.y + rect1.h;
|
|
1269
|
-
const rect2MinX = rect2.x;
|
|
1270
|
-
const rect2MinY = rect2.y;
|
|
1271
|
-
const rect2MaxX = rect2.x + rect2.w;
|
|
1272
|
-
const rect2MaxY = rect2.y + rect2.h;
|
|
1273
|
-
return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
|
|
1274
|
-
}
|
|
1275
1264
|
function getElementVertexes(elemSize) {
|
|
1276
1265
|
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
1277
1266
|
return [
|
|
@@ -1429,9 +1418,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1429
1418
|
];
|
|
1430
1419
|
}
|
|
1431
1420
|
function isViewPointInElement(p, opts) {
|
|
1432
|
-
const { context2d: ctx, element: elem, viewScaleInfo
|
|
1421
|
+
const { context2d: ctx, element: elem, viewScaleInfo } = opts;
|
|
1433
1422
|
const { angle: angle2 = 0 } = elem;
|
|
1434
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
1423
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
1435
1424
|
const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1436
1425
|
if (vertexes.length >= 2) {
|
|
1437
1426
|
ctx.beginPath();
|
|
@@ -1446,6 +1435,21 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1446
1435
|
}
|
|
1447
1436
|
return false;
|
|
1448
1437
|
}
|
|
1438
|
+
function isViewPointInVertexes(p, vertexes, opts) {
|
|
1439
|
+
const xList = [vertexes[0].x, vertexes[1].x, vertexes[2].x, vertexes[3].x];
|
|
1440
|
+
const yList = [vertexes[0].y, vertexes[1].y, vertexes[2].y, vertexes[3].y];
|
|
1441
|
+
const mixX = Math.min(...xList);
|
|
1442
|
+
const maxX = Math.max(...xList);
|
|
1443
|
+
const mixY = Math.min(...yList);
|
|
1444
|
+
const maxY = Math.max(...yList);
|
|
1445
|
+
if (p.x > mixX && p.x < maxX && p.y > mixY && p.y < maxY) {
|
|
1446
|
+
return true;
|
|
1447
|
+
}
|
|
1448
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.includeBorder) === true && (p.x === mixX || p.x === maxX || p.y === mixY || p.y === maxY)) {
|
|
1449
|
+
return true;
|
|
1450
|
+
}
|
|
1451
|
+
return false;
|
|
1452
|
+
}
|
|
1449
1453
|
function getViewPointAtElement(p, opts) {
|
|
1450
1454
|
var _a, _b, _c;
|
|
1451
1455
|
const { context2d: ctx, data, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
|
|
@@ -1512,20 +1516,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1512
1516
|
}
|
|
1513
1517
|
return result;
|
|
1514
1518
|
}
|
|
1515
|
-
function isElementInView(elem, opts) {
|
|
1516
|
-
const { viewSizeInfo, viewScaleInfo } = opts;
|
|
1517
|
-
const { width, height } = viewSizeInfo;
|
|
1518
|
-
const { angle: angle2 } = elem;
|
|
1519
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
|
|
1520
|
-
const ves = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1521
|
-
const viewSize = { x: 0, y: 0, w: width, h: height };
|
|
1522
|
-
const elemStartX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
1523
|
-
const elemStartY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
1524
|
-
const elemEndX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
1525
|
-
const elemEndY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
1526
|
-
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
1527
|
-
return checkRectIntersect(viewSize, elemSize);
|
|
1528
|
-
}
|
|
1529
1519
|
function calcElementOriginRectInfo(elemSize, opts) {
|
|
1530
1520
|
const { groupQueue } = opts;
|
|
1531
1521
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
@@ -1816,6 +1806,103 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1816
1806
|
};
|
|
1817
1807
|
return sizeController;
|
|
1818
1808
|
}
|
|
1809
|
+
function calcLayoutSizeController(layoutSize, opts) {
|
|
1810
|
+
const { controllerSize: controllerSize2, viewScaleInfo } = opts;
|
|
1811
|
+
const ctrlSize = controllerSize2 && controllerSize2 > 0 ? controllerSize2 : 8;
|
|
1812
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(layoutSize, { viewScaleInfo });
|
|
1813
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
1814
|
+
const topCenter = { x: center.x, y: y2 };
|
|
1815
|
+
const rightCenter = { x: x2 + w2, y: center.y };
|
|
1816
|
+
const bottomCenter = { x: center.x, y: y2 + h2 };
|
|
1817
|
+
const leftCenter = { x: x2, y: center.y };
|
|
1818
|
+
const topLeftCenter = { x: x2, y: y2 };
|
|
1819
|
+
const topRightCenter = { x: x2 + w2, y: y2 };
|
|
1820
|
+
const bottomRightCenter = { x: x2 + w2, y: y2 + h2 };
|
|
1821
|
+
const bottomLeftCenter = { x: x2, y: y2 + h2 };
|
|
1822
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: 0 });
|
|
1823
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: 0 });
|
|
1824
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: 0 });
|
|
1825
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: 0 });
|
|
1826
|
+
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: 0 });
|
|
1827
|
+
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: 0 });
|
|
1828
|
+
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: 0 });
|
|
1829
|
+
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: 0 });
|
|
1830
|
+
const topLeftVertexes = calcElementVertexes(topLeftSize);
|
|
1831
|
+
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
1832
|
+
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
1833
|
+
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
1834
|
+
const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
|
|
1835
|
+
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
1836
|
+
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
1837
|
+
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
1838
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
1839
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
1840
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
1841
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
1842
|
+
const sizeController = {
|
|
1843
|
+
left: {
|
|
1844
|
+
type: "left",
|
|
1845
|
+
vertexes: leftVertexes,
|
|
1846
|
+
center: leftCenter
|
|
1847
|
+
},
|
|
1848
|
+
right: {
|
|
1849
|
+
type: "right",
|
|
1850
|
+
vertexes: rightVertexes,
|
|
1851
|
+
center: rightCenter
|
|
1852
|
+
},
|
|
1853
|
+
top: {
|
|
1854
|
+
type: "top",
|
|
1855
|
+
vertexes: topVertexes,
|
|
1856
|
+
center: topCenter
|
|
1857
|
+
},
|
|
1858
|
+
bottom: {
|
|
1859
|
+
type: "bottom",
|
|
1860
|
+
vertexes: bottomVertexes,
|
|
1861
|
+
center: bottomCenter
|
|
1862
|
+
},
|
|
1863
|
+
topLeft: {
|
|
1864
|
+
type: "top-left",
|
|
1865
|
+
vertexes: topLeftVertexes,
|
|
1866
|
+
center: topLeftCenter
|
|
1867
|
+
},
|
|
1868
|
+
topRight: {
|
|
1869
|
+
type: "top-right",
|
|
1870
|
+
vertexes: topRightVertexes,
|
|
1871
|
+
center: topRightCenter
|
|
1872
|
+
},
|
|
1873
|
+
bottomLeft: {
|
|
1874
|
+
type: "bottom-left",
|
|
1875
|
+
vertexes: bottomLeftVertexes,
|
|
1876
|
+
center: bottomLeftCenter
|
|
1877
|
+
},
|
|
1878
|
+
bottomRight: {
|
|
1879
|
+
type: "bottom-right",
|
|
1880
|
+
vertexes: bottomRightVertexes,
|
|
1881
|
+
center: bottomRightCenter
|
|
1882
|
+
},
|
|
1883
|
+
leftMiddle: {
|
|
1884
|
+
type: "left-middle",
|
|
1885
|
+
vertexes: leftMiddleVertexes,
|
|
1886
|
+
center: leftCenter
|
|
1887
|
+
},
|
|
1888
|
+
rightMiddle: {
|
|
1889
|
+
type: "right-middle",
|
|
1890
|
+
vertexes: rightMiddleVertexes,
|
|
1891
|
+
center: rightCenter
|
|
1892
|
+
},
|
|
1893
|
+
topMiddle: {
|
|
1894
|
+
type: "top-middle",
|
|
1895
|
+
vertexes: topMiddleVertexes,
|
|
1896
|
+
center: topCenter
|
|
1897
|
+
},
|
|
1898
|
+
bottomMiddle: {
|
|
1899
|
+
type: "bottom-middle",
|
|
1900
|
+
vertexes: bottomMiddleVertexes,
|
|
1901
|
+
center: bottomCenter
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
return sizeController;
|
|
1905
|
+
}
|
|
1819
1906
|
function generateSVGPath(commands) {
|
|
1820
1907
|
let path = "";
|
|
1821
1908
|
commands.forEach((item) => {
|
|
@@ -1846,7 +1933,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1846
1933
|
textAlign: "left",
|
|
1847
1934
|
verticalAlign: "top",
|
|
1848
1935
|
fontSize: 16,
|
|
1849
|
-
lineHeight: 20,
|
|
1850
1936
|
fontFamily: "sans-serif",
|
|
1851
1937
|
fontWeight: 400,
|
|
1852
1938
|
overflow: "hidden"
|
|
@@ -2474,7 +2560,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2474
2560
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2475
2561
|
function drawText(ctx, elem, opts) {
|
|
2476
2562
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2477
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2563
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
2478
2564
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2479
2565
|
rotateElement$1(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2480
2566
|
drawBox(ctx, viewElem, {
|
|
@@ -2485,8 +2571,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2485
2571
|
parentOpacity,
|
|
2486
2572
|
renderContent: () => {
|
|
2487
2573
|
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
2488
|
-
const
|
|
2489
|
-
const
|
|
2574
|
+
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
2575
|
+
const fontSize2 = originFontSize * viewScaleInfo.scale;
|
|
2576
|
+
const originLineHeight = detail.lineHeight || originFontSize;
|
|
2577
|
+
const lineHeight2 = originLineHeight * viewScaleInfo.scale;
|
|
2490
2578
|
ctx.fillStyle = elem.detail.color || detailConfig.color;
|
|
2491
2579
|
ctx.textBaseline = "top";
|
|
2492
2580
|
ctx.$setFont({
|
|
@@ -2503,7 +2591,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2503
2591
|
let lineText = "";
|
|
2504
2592
|
if (tempText.length > 0) {
|
|
2505
2593
|
for (let i = 0; i < tempText.length; i++) {
|
|
2506
|
-
if (ctx.measureText(lineText + (tempText[i] || "")).width
|
|
2594
|
+
if (ctx.measureText(lineText + (tempText[i] || "")).width <= ctx.$doPixelRatio(w2)) {
|
|
2507
2595
|
lineText += tempText[i] || "";
|
|
2508
2596
|
} else {
|
|
2509
2597
|
lines.push({
|
|
@@ -2517,7 +2605,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2517
2605
|
break;
|
|
2518
2606
|
}
|
|
2519
2607
|
if (tempText.length - 1 === i) {
|
|
2520
|
-
if ((lineNum + 1) * fontHeight
|
|
2608
|
+
if ((lineNum + 1) * fontHeight <= h2) {
|
|
2521
2609
|
lines.push({
|
|
2522
2610
|
text: lineText,
|
|
2523
2611
|
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
@@ -2726,7 +2814,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2726
2814
|
y: newParentSize.y + child.y
|
|
2727
2815
|
});
|
|
2728
2816
|
if (opts.forceDrawAll !== true) {
|
|
2729
|
-
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.
|
|
2817
|
+
if (!(calculator === null || calculator === void 0 ? void 0 : calculator.needRender(child))) {
|
|
2730
2818
|
continue;
|
|
2731
2819
|
}
|
|
2732
2820
|
}
|
|
@@ -2758,7 +2846,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2758
2846
|
detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
|
|
2759
2847
|
});
|
|
2760
2848
|
if (opts.forceDrawAll !== true) {
|
|
2761
|
-
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.
|
|
2849
|
+
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.needRender(elem))) {
|
|
2762
2850
|
continue;
|
|
2763
2851
|
}
|
|
2764
2852
|
}
|
|
@@ -2771,27 +2859,47 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2771
2859
|
}
|
|
2772
2860
|
}
|
|
2773
2861
|
}
|
|
2774
|
-
function
|
|
2862
|
+
function drawLayout(ctx, layout, opts, renderContent) {
|
|
2775
2863
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2776
|
-
const elem = Object.assign({ uuid: "
|
|
2864
|
+
const elem = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2777
2865
|
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
|
|
2778
2866
|
const angle2 = 0;
|
|
2779
2867
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2868
|
+
ctx.globalAlpha = 1;
|
|
2780
2869
|
drawBoxShadow(ctx, viewElem, {
|
|
2781
2870
|
viewScaleInfo,
|
|
2782
2871
|
viewSizeInfo,
|
|
2783
2872
|
renderContent: () => {
|
|
2784
|
-
|
|
2785
|
-
originElem: elem,
|
|
2786
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2787
|
-
viewScaleInfo,
|
|
2788
|
-
viewSizeInfo,
|
|
2789
|
-
parentOpacity,
|
|
2790
|
-
renderContent: () => {
|
|
2791
|
-
}
|
|
2792
|
-
});
|
|
2873
|
+
drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2793
2874
|
}
|
|
2794
2875
|
});
|
|
2876
|
+
if (layout.detail.overflow === "hidden") {
|
|
2877
|
+
const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
|
|
2878
|
+
const elem2 = Object.assign({ uuid: "layout", type: "group" }, layout);
|
|
2879
|
+
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 }) || elem2;
|
|
2880
|
+
const viewElem2 = Object.assign(Object.assign({}, elem2), viewElemSize);
|
|
2881
|
+
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem2, {
|
|
2882
|
+
viewScaleInfo: viewScaleInfo2,
|
|
2883
|
+
viewSizeInfo: viewSizeInfo2
|
|
2884
|
+
});
|
|
2885
|
+
ctx.save();
|
|
2886
|
+
ctx.fillStyle = "transparent";
|
|
2887
|
+
ctx.beginPath();
|
|
2888
|
+
ctx.moveTo(x3 + radiusList[0], y3);
|
|
2889
|
+
ctx.arcTo(x3 + w3, y3, x3 + w3, y3 + h3, radiusList[1]);
|
|
2890
|
+
ctx.arcTo(x3 + w3, y3 + h3, x3, y3 + h3, radiusList[2]);
|
|
2891
|
+
ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
|
|
2892
|
+
ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
|
|
2893
|
+
ctx.closePath();
|
|
2894
|
+
ctx.fill();
|
|
2895
|
+
ctx.clip();
|
|
2896
|
+
}
|
|
2897
|
+
renderContent(ctx);
|
|
2898
|
+
if (layout.detail.overflow === "hidden") {
|
|
2899
|
+
ctx.restore();
|
|
2900
|
+
}
|
|
2901
|
+
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
2902
|
+
ctx.globalAlpha = parentOpacity;
|
|
2795
2903
|
}
|
|
2796
2904
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2797
2905
|
function adopt(value) {
|
|
@@ -3068,21 +3176,20 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3068
3176
|
w: opts.viewSizeInfo.width,
|
|
3069
3177
|
h: opts.viewSizeInfo.height
|
|
3070
3178
|
};
|
|
3071
|
-
|
|
3072
|
-
drawUnderlay(viewContext, data.underlay, Object.assign({
|
|
3073
|
-
loader,
|
|
3074
|
-
calculator,
|
|
3075
|
-
parentElementSize,
|
|
3076
|
-
parentOpacity: 1
|
|
3077
|
-
}, opts));
|
|
3078
|
-
}
|
|
3079
|
-
drawElementList(viewContext, data, Object.assign({
|
|
3179
|
+
const drawOpts = Object.assign({
|
|
3080
3180
|
loader,
|
|
3081
3181
|
calculator,
|
|
3082
3182
|
parentElementSize,
|
|
3083
3183
|
elementAssets: data.assets,
|
|
3084
3184
|
parentOpacity: 1
|
|
3085
|
-
}, opts)
|
|
3185
|
+
}, opts);
|
|
3186
|
+
if (data.layout) {
|
|
3187
|
+
drawLayout(viewContext, data.layout, drawOpts, () => {
|
|
3188
|
+
drawElementList(viewContext, data, drawOpts);
|
|
3189
|
+
});
|
|
3190
|
+
} else {
|
|
3191
|
+
drawElementList(viewContext, data, drawOpts);
|
|
3192
|
+
}
|
|
3086
3193
|
}
|
|
3087
3194
|
scale(num) {
|
|
3088
3195
|
const { sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
@@ -3158,14 +3265,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3158
3265
|
}
|
|
3159
3266
|
}), "f");
|
|
3160
3267
|
}
|
|
3161
|
-
toGridNum(num) {
|
|
3268
|
+
toGridNum(num, opts) {
|
|
3269
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.ignore) === true) {
|
|
3270
|
+
return num;
|
|
3271
|
+
}
|
|
3162
3272
|
return Math.round(num);
|
|
3163
3273
|
}
|
|
3164
3274
|
destroy() {
|
|
3165
3275
|
__classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
|
|
3166
3276
|
}
|
|
3167
|
-
|
|
3168
|
-
|
|
3277
|
+
needRender(elem) {
|
|
3278
|
+
const viewVisibleInfoMap = __classPrivateFieldGet$4(this, _Calculator_store, "f").get("viewVisibleInfoMap");
|
|
3279
|
+
const info = viewVisibleInfoMap[elem.uuid];
|
|
3280
|
+
if (!info) {
|
|
3281
|
+
return true;
|
|
3282
|
+
}
|
|
3283
|
+
return info.isVisibleInView;
|
|
3169
3284
|
}
|
|
3170
3285
|
isPointInElement(p, elem, viewScaleInfo, viewSizeInfo) {
|
|
3171
3286
|
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
@@ -4218,22 +4333,23 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4218
4333
|
}
|
|
4219
4334
|
return key2;
|
|
4220
4335
|
};
|
|
4221
|
-
const
|
|
4222
|
-
const
|
|
4223
|
-
const
|
|
4224
|
-
const
|
|
4225
|
-
const
|
|
4226
|
-
const
|
|
4227
|
-
const
|
|
4228
|
-
const
|
|
4229
|
-
const
|
|
4230
|
-
const
|
|
4231
|
-
const
|
|
4232
|
-
const
|
|
4233
|
-
const
|
|
4234
|
-
const
|
|
4235
|
-
const
|
|
4236
|
-
const
|
|
4336
|
+
const eventChange = "change";
|
|
4337
|
+
const key$3 = "SELECT";
|
|
4338
|
+
const keyActionType = Symbol(`${key$3}_actionType`);
|
|
4339
|
+
const keyResizeType = Symbol(`${key$3}_resizeType`);
|
|
4340
|
+
const keyAreaStart = Symbol(`${key$3}_areaStart`);
|
|
4341
|
+
const keyAreaEnd = Symbol(`${key$3}_areaEnd`);
|
|
4342
|
+
const keyHoverElement = Symbol(`${key$3}_hoverElement`);
|
|
4343
|
+
const keyHoverElementVertexes = Symbol(`${key$3}_hoverElementVertexes`);
|
|
4344
|
+
const keySelectedElementList = Symbol(`${key$3}_selectedElementList`);
|
|
4345
|
+
const keySelectedElementListVertexes = Symbol(`${key$3}_selectedElementListVertexes`);
|
|
4346
|
+
const keySelectedElementController = Symbol(`${key$3}_selectedElementController`);
|
|
4347
|
+
const keySelectedElementPosition = Symbol(`${key$3}_selectedElementPosition`);
|
|
4348
|
+
const keySelectedReferenceXLines = Symbol(`${key$3}_selectedReferenceXLines`);
|
|
4349
|
+
const keySelectedReferenceYLines = Symbol(`${key$3}_selectedReferenceYLines`);
|
|
4350
|
+
const keyGroupQueue = Symbol(`${key$3}_groupQueue`);
|
|
4351
|
+
const keyGroupQueueVertexesList = Symbol(`${key$3}_groupQueueVertexesList`);
|
|
4352
|
+
const keyIsMoving = Symbol(`${key$3}_isMoving`);
|
|
4237
4353
|
const selectWrapperBorderWidth = 2;
|
|
4238
4354
|
const resizeControllerBorderWidth = 4;
|
|
4239
4355
|
const areaBorderWidth = 1;
|
|
@@ -5880,6 +5996,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5880
5996
|
});
|
|
5881
5997
|
triggerCursor(target);
|
|
5882
5998
|
if (target.type === null) {
|
|
5999
|
+
if (sharer.getSharedStorage(keyHoverElement) || sharer.getSharedStorage(keyHoverElementVertexes)) {
|
|
6000
|
+
sharer.setSharedStorage(keyHoverElement, null);
|
|
6001
|
+
sharer.setSharedStorage(keyHoverElementVertexes, null);
|
|
6002
|
+
viewer.drawFrame();
|
|
6003
|
+
}
|
|
5883
6004
|
return;
|
|
5884
6005
|
}
|
|
5885
6006
|
if (target.type === "over-element" && sharer.getSharedStorage(keyActionType) === "select" && target.elements.length === 1 && target.elements[0].uuid === ((_c = (_b = getActiveElements()) == null ? void 0 : _b[0]) == null ? void 0 : _c.uuid)) {
|
|
@@ -6035,7 +6156,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6035
6156
|
type: "updateElement",
|
|
6036
6157
|
content: {
|
|
6037
6158
|
element: elem,
|
|
6038
|
-
position:
|
|
6159
|
+
position: getElementPositionFromList(elem.uuid, data.elements) || []
|
|
6039
6160
|
}
|
|
6040
6161
|
},
|
|
6041
6162
|
viewSizeInfo,
|
|
@@ -6084,19 +6205,20 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6084
6205
|
resizeType,
|
|
6085
6206
|
sharer
|
|
6086
6207
|
});
|
|
6087
|
-
elems[0].angle = resizedElemSize.angle;
|
|
6208
|
+
elems[0].angle = calculator.toGridNum(resizedElemSize.angle || 0);
|
|
6088
6209
|
} else {
|
|
6089
6210
|
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
6090
|
-
elems[0].
|
|
6091
|
-
elems[0].
|
|
6211
|
+
const calcOpts = { ignore: !!elems[0].angle };
|
|
6212
|
+
elems[0].x = calculator.toGridNum(resizedElemSize.x, calcOpts);
|
|
6213
|
+
elems[0].y = calculator.toGridNum(resizedElemSize.y, calcOpts);
|
|
6092
6214
|
if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
|
|
6093
6215
|
deepResizeGroupElement(elems[0], {
|
|
6094
|
-
w: calculator.toGridNum(resizedElemSize.w),
|
|
6095
|
-
h: calculator.toGridNum(resizedElemSize.h)
|
|
6216
|
+
w: calculator.toGridNum(resizedElemSize.w, calcOpts),
|
|
6217
|
+
h: calculator.toGridNum(resizedElemSize.h, calcOpts)
|
|
6096
6218
|
});
|
|
6097
6219
|
} else {
|
|
6098
|
-
elems[0].w = calculator.toGridNum(resizedElemSize.w);
|
|
6099
|
-
elems[0].h = calculator.toGridNum(resizedElemSize.h);
|
|
6220
|
+
elems[0].w = calculator.toGridNum(resizedElemSize.w, calcOpts);
|
|
6221
|
+
elems[0].h = calculator.toGridNum(resizedElemSize.h, calcOpts);
|
|
6100
6222
|
}
|
|
6101
6223
|
}
|
|
6102
6224
|
updateSelectedElementList([elems[0]]);
|
|
@@ -6185,7 +6307,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6185
6307
|
}
|
|
6186
6308
|
if (data && ["drag", "drag-list", "drag-list-end", "resize"].includes(actionType)) {
|
|
6187
6309
|
let type = "dragElement";
|
|
6188
|
-
eventHub.trigger(
|
|
6310
|
+
eventHub.trigger(eventChange, { data, type });
|
|
6189
6311
|
}
|
|
6190
6312
|
viewer.drawFrame();
|
|
6191
6313
|
};
|
|
@@ -6323,15 +6445,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6323
6445
|
}
|
|
6324
6446
|
};
|
|
6325
6447
|
};
|
|
6326
|
-
const key$
|
|
6327
|
-
const keyXThumbRect = Symbol(`${key$
|
|
6328
|
-
const keyYThumbRect = Symbol(`${key$
|
|
6329
|
-
const keyPrevPoint$1 = Symbol(`${key$
|
|
6330
|
-
const keyActivePoint = Symbol(`${key$
|
|
6331
|
-
const keyActiveThumbType = Symbol(`${key$
|
|
6448
|
+
const key$2 = "SCROLL";
|
|
6449
|
+
const keyXThumbRect = Symbol(`${key$2}_xThumbRect`);
|
|
6450
|
+
const keyYThumbRect = Symbol(`${key$2}_yThumbRect`);
|
|
6451
|
+
const keyPrevPoint$1 = Symbol(`${key$2}_prevPoint`);
|
|
6452
|
+
const keyActivePoint = Symbol(`${key$2}_activePoint`);
|
|
6453
|
+
const keyActiveThumbType = Symbol(`${key$2}_activeThumbType`);
|
|
6332
6454
|
const minScrollerWidth = 12;
|
|
6333
6455
|
const scrollerLineWidth = 16;
|
|
6334
|
-
const scrollerThumbAlpha = 0.
|
|
6456
|
+
const scrollerThumbAlpha = 0.3;
|
|
6335
6457
|
const scrollConfig = {
|
|
6336
6458
|
width: minScrollerWidth,
|
|
6337
6459
|
thumbColor: "#000000AA",
|
|
@@ -6641,12 +6763,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6641
6763
|
const borderColor = "#00000080";
|
|
6642
6764
|
const scaleColor = "#000000";
|
|
6643
6765
|
const textColor = "#00000080";
|
|
6644
|
-
const fontFamily = "monospace";
|
|
6766
|
+
const fontFamily$1 = "monospace";
|
|
6645
6767
|
const fontSize = 10;
|
|
6646
6768
|
const fontWeight = 100;
|
|
6647
6769
|
const gridColor = "#AAAAAA20";
|
|
6648
6770
|
const gridKeyColor = "#AAAAAA40";
|
|
6649
6771
|
const lineSize = 1;
|
|
6772
|
+
const selectedAreaColor = "#196097";
|
|
6650
6773
|
function calcRulerScaleList(opts) {
|
|
6651
6774
|
const { scale, viewLength, viewOffset } = opts;
|
|
6652
6775
|
const list = [];
|
|
@@ -6725,7 +6848,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6725
6848
|
ctx.$setFont({
|
|
6726
6849
|
fontWeight,
|
|
6727
6850
|
fontSize,
|
|
6728
|
-
fontFamily
|
|
6851
|
+
fontFamily: fontFamily$1
|
|
6729
6852
|
});
|
|
6730
6853
|
ctx.fillText(`${item.num}`, item.position + fontStart, fontStart);
|
|
6731
6854
|
}
|
|
@@ -6761,7 +6884,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6761
6884
|
ctx.$setFont({
|
|
6762
6885
|
fontWeight,
|
|
6763
6886
|
fontSize,
|
|
6764
|
-
fontFamily
|
|
6887
|
+
fontFamily: fontFamily$1
|
|
6765
6888
|
});
|
|
6766
6889
|
ctx.fillText(numText, fontStart + fontSize, item.position + fontStart);
|
|
6767
6890
|
});
|
|
@@ -6820,9 +6943,61 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6820
6943
|
ctx.stroke();
|
|
6821
6944
|
}
|
|
6822
6945
|
}
|
|
6946
|
+
function drawScrollerSelectedArea(ctx, opts) {
|
|
6947
|
+
const { snapshot, calculator } = opts;
|
|
6948
|
+
const { sharedStore } = snapshot;
|
|
6949
|
+
const selectedElementList = sharedStore[keySelectedElementList];
|
|
6950
|
+
const actionType = sharedStore[keyActionType];
|
|
6951
|
+
if (["select", "drag", "drag-list", "drag-list-end"].includes(actionType) && selectedElementList.length > 0) {
|
|
6952
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
6953
|
+
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
6954
|
+
const rangeRectInfoList = [];
|
|
6955
|
+
const xAreaStartList = [];
|
|
6956
|
+
const xAreaEndList = [];
|
|
6957
|
+
const yAreaStartList = [];
|
|
6958
|
+
const yAreaEndList = [];
|
|
6959
|
+
selectedElementList.forEach((elem) => {
|
|
6960
|
+
const rectInfo = calculator.calcViewRectInfoFromRange(elem.uuid, {
|
|
6961
|
+
viewScaleInfo,
|
|
6962
|
+
viewSizeInfo
|
|
6963
|
+
});
|
|
6964
|
+
if (rectInfo) {
|
|
6965
|
+
rangeRectInfoList.push(rectInfo);
|
|
6966
|
+
xAreaStartList.push(rectInfo.left.x);
|
|
6967
|
+
xAreaEndList.push(rectInfo.right.x);
|
|
6968
|
+
yAreaStartList.push(rectInfo.top.y);
|
|
6969
|
+
yAreaEndList.push(rectInfo.bottom.y);
|
|
6970
|
+
}
|
|
6971
|
+
});
|
|
6972
|
+
if (!(rangeRectInfoList.length > 0)) {
|
|
6973
|
+
return;
|
|
6974
|
+
}
|
|
6975
|
+
const xAreaStart = Math.min(...xAreaStartList);
|
|
6976
|
+
const xAreaEnd = Math.max(...xAreaEndList);
|
|
6977
|
+
const yAreaStart = Math.min(...yAreaStartList);
|
|
6978
|
+
const yAreaEnd = Math.max(...yAreaEndList);
|
|
6979
|
+
ctx.globalAlpha = 1;
|
|
6980
|
+
ctx.beginPath();
|
|
6981
|
+
ctx.moveTo(xAreaStart, 0);
|
|
6982
|
+
ctx.lineTo(xAreaEnd, 0);
|
|
6983
|
+
ctx.lineTo(xAreaEnd, rulerSize);
|
|
6984
|
+
ctx.lineTo(xAreaStart, rulerSize);
|
|
6985
|
+
ctx.fillStyle = selectedAreaColor;
|
|
6986
|
+
ctx.closePath();
|
|
6987
|
+
ctx.fill();
|
|
6988
|
+
ctx.beginPath();
|
|
6989
|
+
ctx.moveTo(0, yAreaStart);
|
|
6990
|
+
ctx.lineTo(rulerSize, yAreaStart);
|
|
6991
|
+
ctx.lineTo(rulerSize, yAreaEnd);
|
|
6992
|
+
ctx.lineTo(0, yAreaEnd);
|
|
6993
|
+
ctx.fillStyle = selectedAreaColor;
|
|
6994
|
+
ctx.closePath();
|
|
6995
|
+
ctx.fill();
|
|
6996
|
+
}
|
|
6997
|
+
}
|
|
6823
6998
|
const middlewareEventRuler = "@middleware/show-ruler";
|
|
6824
6999
|
const MiddlewareRuler = (opts) => {
|
|
6825
|
-
const { boardContent, viewer, eventHub } = opts;
|
|
7000
|
+
const { boardContent, viewer, eventHub, calculator } = opts;
|
|
6826
7001
|
const { helperContext, underContext } = boardContent;
|
|
6827
7002
|
let show = true;
|
|
6828
7003
|
let showGrid = true;
|
|
@@ -6849,6 +7024,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6849
7024
|
if (show === true) {
|
|
6850
7025
|
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
6851
7026
|
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
7027
|
+
drawScrollerSelectedArea(helperContext, { snapshot, calculator });
|
|
6852
7028
|
drawRulerBackground(helperContext, { viewScaleInfo, viewSizeInfo });
|
|
6853
7029
|
const xList = calcXRulerScaleList({ viewScaleInfo, viewSizeInfo });
|
|
6854
7030
|
drawXRuler(helperContext, { scaleList: xList });
|
|
@@ -6866,8 +7042,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6866
7042
|
}
|
|
6867
7043
|
};
|
|
6868
7044
|
};
|
|
6869
|
-
const key = "DRAG";
|
|
6870
|
-
const keyPrevPoint = Symbol(`${key}_prevPoint`);
|
|
7045
|
+
const key$1 = "DRAG";
|
|
7046
|
+
const keyPrevPoint = Symbol(`${key$1}_prevPoint`);
|
|
6871
7047
|
const MiddlewareDragger = (opts) => {
|
|
6872
7048
|
const { eventHub, sharer, viewer } = opts;
|
|
6873
7049
|
let isDragging = false;
|
|
@@ -6909,6 +7085,553 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6909
7085
|
}
|
|
6910
7086
|
};
|
|
6911
7087
|
};
|
|
7088
|
+
const fontFamily = "monospace";
|
|
7089
|
+
function drawSizeInfoText(ctx, opts) {
|
|
7090
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
7091
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
7092
|
+
ctx.$setFont({
|
|
7093
|
+
fontWeight: "300",
|
|
7094
|
+
fontSize: fontSize2,
|
|
7095
|
+
fontFamily
|
|
7096
|
+
});
|
|
7097
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
7098
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
7099
|
+
const bgStart = {
|
|
7100
|
+
x: point.x - textWidth / 2 - padding,
|
|
7101
|
+
y: point.y
|
|
7102
|
+
};
|
|
7103
|
+
const bgEnd = {
|
|
7104
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
7105
|
+
y: bgStart.y + fontSize2 + padding
|
|
7106
|
+
};
|
|
7107
|
+
const textStart = {
|
|
7108
|
+
x: point.x - textWidth / 2,
|
|
7109
|
+
y: point.y
|
|
7110
|
+
};
|
|
7111
|
+
ctx.setLineDash([]);
|
|
7112
|
+
ctx.fillStyle = background2;
|
|
7113
|
+
ctx.beginPath();
|
|
7114
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
7115
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
7116
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
7117
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
7118
|
+
ctx.closePath();
|
|
7119
|
+
ctx.fill();
|
|
7120
|
+
ctx.fillStyle = color2;
|
|
7121
|
+
ctx.textBaseline = "top";
|
|
7122
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7123
|
+
});
|
|
7124
|
+
}
|
|
7125
|
+
function drawPositionInfoText(ctx, opts) {
|
|
7126
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
7127
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
7128
|
+
ctx.$setFont({
|
|
7129
|
+
fontWeight: "300",
|
|
7130
|
+
fontSize: fontSize2,
|
|
7131
|
+
fontFamily
|
|
7132
|
+
});
|
|
7133
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
7134
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
7135
|
+
const bgStart = {
|
|
7136
|
+
x: point.x,
|
|
7137
|
+
y: point.y
|
|
7138
|
+
};
|
|
7139
|
+
const bgEnd = {
|
|
7140
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
7141
|
+
y: bgStart.y + fontSize2 + padding
|
|
7142
|
+
};
|
|
7143
|
+
const textStart = {
|
|
7144
|
+
x: point.x + padding,
|
|
7145
|
+
y: point.y
|
|
7146
|
+
};
|
|
7147
|
+
ctx.setLineDash([]);
|
|
7148
|
+
ctx.fillStyle = background2;
|
|
7149
|
+
ctx.beginPath();
|
|
7150
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
7151
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
7152
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
7153
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
7154
|
+
ctx.closePath();
|
|
7155
|
+
ctx.fill();
|
|
7156
|
+
ctx.fillStyle = color2;
|
|
7157
|
+
ctx.textBaseline = "top";
|
|
7158
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7159
|
+
});
|
|
7160
|
+
}
|
|
7161
|
+
function drawAngleInfoText(ctx, opts) {
|
|
7162
|
+
const { point, rotateCenter, angle: angle2, text: text2, color: color2, background: background2, fontSize: fontSize2, lineHeight: lineHeight2 } = opts;
|
|
7163
|
+
rotateByCenter(ctx, angle2, rotateCenter, () => {
|
|
7164
|
+
ctx.$setFont({
|
|
7165
|
+
fontWeight: "300",
|
|
7166
|
+
fontSize: fontSize2,
|
|
7167
|
+
fontFamily
|
|
7168
|
+
});
|
|
7169
|
+
const padding = (lineHeight2 - fontSize2) / 2;
|
|
7170
|
+
const textWidth = ctx.$undoPixelRatio(ctx.measureText(text2).width);
|
|
7171
|
+
const bgStart = {
|
|
7172
|
+
x: point.x,
|
|
7173
|
+
y: point.y
|
|
7174
|
+
};
|
|
7175
|
+
const bgEnd = {
|
|
7176
|
+
x: bgStart.x + textWidth + padding * 2,
|
|
7177
|
+
y: bgStart.y + fontSize2 + padding
|
|
7178
|
+
};
|
|
7179
|
+
const textStart = {
|
|
7180
|
+
x: point.x + padding,
|
|
7181
|
+
y: point.y
|
|
7182
|
+
};
|
|
7183
|
+
ctx.setLineDash([]);
|
|
7184
|
+
ctx.fillStyle = background2;
|
|
7185
|
+
ctx.beginPath();
|
|
7186
|
+
ctx.moveTo(bgStart.x, bgStart.y);
|
|
7187
|
+
ctx.lineTo(bgEnd.x, bgStart.y);
|
|
7188
|
+
ctx.lineTo(bgEnd.x, bgEnd.y);
|
|
7189
|
+
ctx.lineTo(bgStart.x, bgEnd.y);
|
|
7190
|
+
ctx.closePath();
|
|
7191
|
+
ctx.fill();
|
|
7192
|
+
ctx.fillStyle = color2;
|
|
7193
|
+
ctx.textBaseline = "top";
|
|
7194
|
+
ctx.fillText(text2, textStart.x, textStart.y + padding);
|
|
7195
|
+
});
|
|
7196
|
+
}
|
|
7197
|
+
const infoBackground = "#1973bac6";
|
|
7198
|
+
const infoTextColor = "#ffffff";
|
|
7199
|
+
const infoFontSize = 10;
|
|
7200
|
+
const infoLineHeight = 16;
|
|
7201
|
+
const MiddlewareInfo = (opts) => {
|
|
7202
|
+
const { boardContent, calculator } = opts;
|
|
7203
|
+
const { helperContext } = boardContent;
|
|
7204
|
+
return {
|
|
7205
|
+
name: "@middleware/info",
|
|
7206
|
+
beforeDrawFrame({ snapshot }) {
|
|
7207
|
+
const { sharedStore } = snapshot;
|
|
7208
|
+
const selectedElementList = sharedStore[keySelectedElementList];
|
|
7209
|
+
const actionType = sharedStore[keyActionType];
|
|
7210
|
+
const groupQueue = sharedStore[keyGroupQueue] || [];
|
|
7211
|
+
if (selectedElementList.length === 1) {
|
|
7212
|
+
const elem = selectedElementList[0];
|
|
7213
|
+
if (elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
7214
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
7215
|
+
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
7216
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = elem;
|
|
7217
|
+
const totalGroupQueue = [
|
|
7218
|
+
...groupQueue,
|
|
7219
|
+
...[
|
|
7220
|
+
{
|
|
7221
|
+
uuid: createUUID(),
|
|
7222
|
+
x: x2,
|
|
7223
|
+
y: y2,
|
|
7224
|
+
w: w2,
|
|
7225
|
+
h: h2,
|
|
7226
|
+
angle: angle2,
|
|
7227
|
+
type: "group",
|
|
7228
|
+
detail: { children: [] }
|
|
7229
|
+
}
|
|
7230
|
+
]
|
|
7231
|
+
];
|
|
7232
|
+
const calcOpts = { viewScaleInfo, viewSizeInfo };
|
|
7233
|
+
const rangeRectInfo = calculator.calcViewRectInfoFromOrigin(elem.uuid, calcOpts);
|
|
7234
|
+
let totalAngle = 0;
|
|
7235
|
+
totalGroupQueue.forEach((group) => {
|
|
7236
|
+
totalAngle += group.angle || 0;
|
|
7237
|
+
});
|
|
7238
|
+
const totalRadian = parseAngleToRadian(limitAngle(0 - totalAngle));
|
|
7239
|
+
if (rangeRectInfo) {
|
|
7240
|
+
const elemCenter = rangeRectInfo == null ? void 0 : rangeRectInfo.center;
|
|
7241
|
+
const rectInfo = {
|
|
7242
|
+
topLeft: rotatePoint(elemCenter, rangeRectInfo.topLeft, totalRadian),
|
|
7243
|
+
topRight: rotatePoint(elemCenter, rangeRectInfo.topRight, totalRadian),
|
|
7244
|
+
bottomRight: rotatePoint(elemCenter, rangeRectInfo.bottomRight, totalRadian),
|
|
7245
|
+
bottomLeft: rotatePoint(elemCenter, rangeRectInfo.bottomLeft, totalRadian),
|
|
7246
|
+
center: rotatePoint(elemCenter, rangeRectInfo.center, totalRadian),
|
|
7247
|
+
top: rotatePoint(elemCenter, rangeRectInfo.top, totalRadian),
|
|
7248
|
+
right: rotatePoint(elemCenter, rangeRectInfo.right, totalRadian),
|
|
7249
|
+
bottom: rotatePoint(elemCenter, rangeRectInfo.bottom, totalRadian),
|
|
7250
|
+
left: rotatePoint(elemCenter, rangeRectInfo.left, totalRadian)
|
|
7251
|
+
};
|
|
7252
|
+
const x22 = formatNumber(elem.x, { decimalPlaces: 2 });
|
|
7253
|
+
const y22 = formatNumber(elem.y, { decimalPlaces: 2 });
|
|
7254
|
+
const w22 = formatNumber(elem.w, { decimalPlaces: 2 });
|
|
7255
|
+
const h22 = formatNumber(elem.h, { decimalPlaces: 2 });
|
|
7256
|
+
const xyText = `${formatNumber(x22, { decimalPlaces: 0 })},${formatNumber(y22, { decimalPlaces: 0 })}`;
|
|
7257
|
+
const whText = `${formatNumber(w22, { decimalPlaces: 0 })}x${formatNumber(h22, { decimalPlaces: 0 })}`;
|
|
7258
|
+
const angleText = `${formatNumber(elem.angle || 0, { decimalPlaces: 0 })}°`;
|
|
7259
|
+
drawSizeInfoText(helperContext, {
|
|
7260
|
+
point: {
|
|
7261
|
+
x: rectInfo.bottom.x,
|
|
7262
|
+
y: rectInfo.bottom.y + infoFontSize
|
|
7263
|
+
},
|
|
7264
|
+
rotateCenter: rectInfo.center,
|
|
7265
|
+
angle: totalAngle,
|
|
7266
|
+
text: whText,
|
|
7267
|
+
fontSize: infoFontSize,
|
|
7268
|
+
lineHeight: infoLineHeight,
|
|
7269
|
+
color: infoTextColor,
|
|
7270
|
+
background: infoBackground
|
|
7271
|
+
});
|
|
7272
|
+
drawPositionInfoText(helperContext, {
|
|
7273
|
+
point: {
|
|
7274
|
+
x: rectInfo.topLeft.x,
|
|
7275
|
+
y: rectInfo.topLeft.y - infoFontSize * 2
|
|
7276
|
+
},
|
|
7277
|
+
rotateCenter: rectInfo.center,
|
|
7278
|
+
angle: totalAngle,
|
|
7279
|
+
text: xyText,
|
|
7280
|
+
fontSize: infoFontSize,
|
|
7281
|
+
lineHeight: infoLineHeight,
|
|
7282
|
+
color: infoTextColor,
|
|
7283
|
+
background: infoBackground
|
|
7284
|
+
});
|
|
7285
|
+
drawAngleInfoText(helperContext, {
|
|
7286
|
+
point: {
|
|
7287
|
+
x: rectInfo.top.x + infoFontSize,
|
|
7288
|
+
y: rectInfo.top.y - infoFontSize * 2
|
|
7289
|
+
},
|
|
7290
|
+
rotateCenter: rectInfo.center,
|
|
7291
|
+
angle: totalAngle,
|
|
7292
|
+
text: angleText,
|
|
7293
|
+
fontSize: infoFontSize,
|
|
7294
|
+
lineHeight: infoLineHeight,
|
|
7295
|
+
color: infoTextColor,
|
|
7296
|
+
background: infoBackground
|
|
7297
|
+
});
|
|
7298
|
+
}
|
|
7299
|
+
}
|
|
7300
|
+
}
|
|
7301
|
+
}
|
|
7302
|
+
};
|
|
7303
|
+
};
|
|
7304
|
+
const key = "LAYOUT_SELECT";
|
|
7305
|
+
const keyLayoutActionType = Symbol(`${key}_layoutActionType`);
|
|
7306
|
+
const keyLayoutControlType = Symbol(`${key}_layoutControlType`);
|
|
7307
|
+
const keyLayoutController = Symbol(`${key}_layoutController`);
|
|
7308
|
+
const selectColor = "#1973ba";
|
|
7309
|
+
const disableColor = "#5b5959b5";
|
|
7310
|
+
function drawControllerBox(ctx, boxVertexes) {
|
|
7311
|
+
ctx.setLineDash([]);
|
|
7312
|
+
ctx.fillStyle = "#FFFFFF";
|
|
7313
|
+
ctx.beginPath();
|
|
7314
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
7315
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
7316
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
7317
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
7318
|
+
ctx.closePath();
|
|
7319
|
+
ctx.fill();
|
|
7320
|
+
ctx.strokeStyle = selectColor;
|
|
7321
|
+
ctx.lineWidth = 2;
|
|
7322
|
+
ctx.beginPath();
|
|
7323
|
+
ctx.moveTo(boxVertexes[0].x, boxVertexes[0].y);
|
|
7324
|
+
ctx.lineTo(boxVertexes[1].x, boxVertexes[1].y);
|
|
7325
|
+
ctx.lineTo(boxVertexes[2].x, boxVertexes[2].y);
|
|
7326
|
+
ctx.lineTo(boxVertexes[3].x, boxVertexes[3].y);
|
|
7327
|
+
ctx.closePath();
|
|
7328
|
+
ctx.stroke();
|
|
7329
|
+
}
|
|
7330
|
+
function drawControllerCross(ctx, opts) {
|
|
7331
|
+
const { vertexes, strokeStyle, lineWidth } = opts;
|
|
7332
|
+
ctx.setLineDash([]);
|
|
7333
|
+
ctx.strokeStyle = strokeStyle;
|
|
7334
|
+
ctx.lineWidth = lineWidth;
|
|
7335
|
+
ctx.beginPath();
|
|
7336
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
7337
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
7338
|
+
ctx.closePath();
|
|
7339
|
+
ctx.stroke();
|
|
7340
|
+
ctx.beginPath();
|
|
7341
|
+
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
7342
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
7343
|
+
ctx.closePath();
|
|
7344
|
+
ctx.stroke();
|
|
7345
|
+
}
|
|
7346
|
+
function drawControllerLine(ctx, opts) {
|
|
7347
|
+
const { start, end, centerVertexes, disabled } = opts;
|
|
7348
|
+
const lineWidth = disabled === true ? 1 : 2;
|
|
7349
|
+
const strokeStyle = disabled === true ? disableColor : selectColor;
|
|
7350
|
+
ctx.setLineDash([]);
|
|
7351
|
+
ctx.strokeStyle = strokeStyle;
|
|
7352
|
+
ctx.lineWidth = lineWidth;
|
|
7353
|
+
ctx.beginPath();
|
|
7354
|
+
ctx.moveTo(start.x, start.y);
|
|
7355
|
+
ctx.lineTo(end.x, end.y);
|
|
7356
|
+
ctx.closePath();
|
|
7357
|
+
ctx.stroke();
|
|
7358
|
+
if (disabled === true) {
|
|
7359
|
+
drawControllerCross(ctx, {
|
|
7360
|
+
vertexes: centerVertexes,
|
|
7361
|
+
lineWidth,
|
|
7362
|
+
strokeStyle
|
|
7363
|
+
});
|
|
7364
|
+
}
|
|
7365
|
+
}
|
|
7366
|
+
function drawLayoutController(ctx, opts) {
|
|
7367
|
+
const { controller, operations } = opts;
|
|
7368
|
+
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, rightMiddle, bottomMiddle, leftMiddle } = controller;
|
|
7369
|
+
drawControllerLine(ctx, { start: topLeft.center, end: topRight.center, centerVertexes: topMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disableTop) });
|
|
7370
|
+
drawControllerLine(ctx, { start: topRight.center, end: bottomRight.center, centerVertexes: rightMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disableRight) });
|
|
7371
|
+
drawControllerLine(ctx, { start: bottomRight.center, end: bottomLeft.center, centerVertexes: bottomMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disableBottom) });
|
|
7372
|
+
drawControllerLine(ctx, { start: bottomLeft.center, end: topLeft.center, centerVertexes: leftMiddle.vertexes, disabled: !!(operations == null ? void 0 : operations.disableLeft) });
|
|
7373
|
+
const disabledOpts = {
|
|
7374
|
+
lineWidth: 1,
|
|
7375
|
+
strokeStyle: disableColor
|
|
7376
|
+
};
|
|
7377
|
+
if ((operations == null ? void 0 : operations.disableTopLeft) === true) {
|
|
7378
|
+
drawControllerCross(ctx, { vertexes: topLeft.vertexes, ...disabledOpts });
|
|
7379
|
+
} else {
|
|
7380
|
+
drawControllerBox(ctx, topLeft.vertexes);
|
|
7381
|
+
}
|
|
7382
|
+
if ((operations == null ? void 0 : operations.disableTopRight) === true) {
|
|
7383
|
+
drawControllerCross(ctx, { vertexes: topRight.vertexes, ...disabledOpts });
|
|
7384
|
+
} else {
|
|
7385
|
+
drawControllerBox(ctx, topRight.vertexes);
|
|
7386
|
+
}
|
|
7387
|
+
if ((operations == null ? void 0 : operations.disableBottomRight) === true) {
|
|
7388
|
+
drawControllerCross(ctx, { vertexes: bottomRight.vertexes, ...disabledOpts });
|
|
7389
|
+
} else {
|
|
7390
|
+
drawControllerBox(ctx, bottomRight.vertexes);
|
|
7391
|
+
}
|
|
7392
|
+
if ((operations == null ? void 0 : operations.disableBottomLeft) === true) {
|
|
7393
|
+
drawControllerCross(ctx, { vertexes: bottomLeft.vertexes, ...disabledOpts });
|
|
7394
|
+
} else {
|
|
7395
|
+
drawControllerBox(ctx, bottomLeft.vertexes);
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7398
|
+
const MiddlewareLayoutSelector = (opts) => {
|
|
7399
|
+
const { sharer, boardContent, calculator, viewer, eventHub } = opts;
|
|
7400
|
+
const { helperContext } = boardContent;
|
|
7401
|
+
let prevPoint = null;
|
|
7402
|
+
const clear = () => {
|
|
7403
|
+
prevPoint = null;
|
|
7404
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
7405
|
+
sharer.setSharedStorage(keyLayoutControlType, null);
|
|
7406
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
7407
|
+
};
|
|
7408
|
+
const isInElementAction = () => {
|
|
7409
|
+
const elementType = sharer.getSharedStorage(keyActionType);
|
|
7410
|
+
if (elementType) {
|
|
7411
|
+
return true;
|
|
7412
|
+
}
|
|
7413
|
+
return false;
|
|
7414
|
+
};
|
|
7415
|
+
const isDisbaledControl = (controlType) => {
|
|
7416
|
+
var _a;
|
|
7417
|
+
const data = sharer.getActiveStorage("data");
|
|
7418
|
+
if ((_a = data == null ? void 0 : data.layout) == null ? void 0 : _a.operations) {
|
|
7419
|
+
const operations = data.layout.operations;
|
|
7420
|
+
if (controlType === "left" && operations.disableLeft === true) {
|
|
7421
|
+
return true;
|
|
7422
|
+
}
|
|
7423
|
+
if (controlType === "top" && operations.disableTop === true) {
|
|
7424
|
+
return true;
|
|
7425
|
+
}
|
|
7426
|
+
if (controlType === "right" && operations.disableRight === true) {
|
|
7427
|
+
return true;
|
|
7428
|
+
}
|
|
7429
|
+
if (controlType === "bottom" && operations.disableBottom === true) {
|
|
7430
|
+
return true;
|
|
7431
|
+
}
|
|
7432
|
+
if (controlType === "top-left" && operations.disableTopLeft === true) {
|
|
7433
|
+
return true;
|
|
7434
|
+
}
|
|
7435
|
+
if (controlType === "top-right" && operations.disableTopRight === true) {
|
|
7436
|
+
return true;
|
|
7437
|
+
}
|
|
7438
|
+
if (controlType === "bottom-left" && operations.disableBottomLeft === true) {
|
|
7439
|
+
return true;
|
|
7440
|
+
}
|
|
7441
|
+
if (controlType === "bottom-right" && operations.disableBottomRight === true) {
|
|
7442
|
+
return true;
|
|
7443
|
+
}
|
|
7444
|
+
}
|
|
7445
|
+
return false;
|
|
7446
|
+
};
|
|
7447
|
+
const getLayoutSize = () => {
|
|
7448
|
+
const data = sharer.getActiveStorage("data");
|
|
7449
|
+
if (data == null ? void 0 : data.layout) {
|
|
7450
|
+
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
7451
|
+
return { x: x2, y: y2, w: w2, h: h2 };
|
|
7452
|
+
}
|
|
7453
|
+
return null;
|
|
7454
|
+
};
|
|
7455
|
+
const resetController = () => {
|
|
7456
|
+
const viewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
7457
|
+
const size = getLayoutSize();
|
|
7458
|
+
if (size) {
|
|
7459
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
7460
|
+
sharer.setSharedStorage(keyLayoutController, controller);
|
|
7461
|
+
} else {
|
|
7462
|
+
sharer.setSharedStorage(keyLayoutController, null);
|
|
7463
|
+
}
|
|
7464
|
+
};
|
|
7465
|
+
const resetControlType = (e) => {
|
|
7466
|
+
const data = sharer.getActiveStorage("data");
|
|
7467
|
+
const controller = sharer.getSharedStorage(keyLayoutController);
|
|
7468
|
+
if (controller && (data == null ? void 0 : data.layout) && (e == null ? void 0 : e.point)) {
|
|
7469
|
+
let layoutControlType = null;
|
|
7470
|
+
if (controller) {
|
|
7471
|
+
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = controller;
|
|
7472
|
+
const list = [topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left];
|
|
7473
|
+
for (let i = 0; i < list.length; i++) {
|
|
7474
|
+
const item = list[i];
|
|
7475
|
+
if (isViewPointInVertexes(e.point, item.vertexes)) {
|
|
7476
|
+
layoutControlType = `${item.type}`;
|
|
7477
|
+
break;
|
|
7478
|
+
}
|
|
7479
|
+
}
|
|
7480
|
+
if (layoutControlType) {
|
|
7481
|
+
sharer.setSharedStorage(keyLayoutControlType, layoutControlType);
|
|
7482
|
+
eventHub.trigger(middlewareEventSelectClear, {});
|
|
7483
|
+
return layoutControlType;
|
|
7484
|
+
}
|
|
7485
|
+
}
|
|
7486
|
+
}
|
|
7487
|
+
return null;
|
|
7488
|
+
};
|
|
7489
|
+
return {
|
|
7490
|
+
name: "@middleware/layout-selector",
|
|
7491
|
+
use: () => {
|
|
7492
|
+
clear();
|
|
7493
|
+
resetController();
|
|
7494
|
+
},
|
|
7495
|
+
hover: (e) => {
|
|
7496
|
+
if (isInElementAction()) {
|
|
7497
|
+
return;
|
|
7498
|
+
}
|
|
7499
|
+
const prevLayoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7500
|
+
const data = sharer.getActiveStorage("data");
|
|
7501
|
+
if ((data == null ? void 0 : data.layout) && prevLayoutActionType !== "resize") {
|
|
7502
|
+
resetController();
|
|
7503
|
+
const layoutControlType = resetControlType(e);
|
|
7504
|
+
if (layoutControlType) {
|
|
7505
|
+
sharer.setSharedStorage(keyLayoutActionType, "hover");
|
|
7506
|
+
if (!isDisbaledControl(layoutControlType)) {
|
|
7507
|
+
eventHub.trigger("cursor", {
|
|
7508
|
+
type: `resize-${layoutControlType}`,
|
|
7509
|
+
groupQueue: [],
|
|
7510
|
+
element: getLayoutSize()
|
|
7511
|
+
});
|
|
7512
|
+
}
|
|
7513
|
+
viewer.drawFrame();
|
|
7514
|
+
} else {
|
|
7515
|
+
sharer.setSharedStorage(keyLayoutActionType, null);
|
|
7516
|
+
}
|
|
7517
|
+
}
|
|
7518
|
+
if (["hover", "resize"].includes(sharer.getSharedStorage(keyLayoutActionType))) {
|
|
7519
|
+
return false;
|
|
7520
|
+
}
|
|
7521
|
+
if (prevLayoutActionType === "hover" && !sharer.getSharedStorage(keyLayoutActionType)) {
|
|
7522
|
+
viewer.drawFrame();
|
|
7523
|
+
}
|
|
7524
|
+
},
|
|
7525
|
+
pointStart: (e) => {
|
|
7526
|
+
if (isInElementAction()) {
|
|
7527
|
+
return;
|
|
7528
|
+
}
|
|
7529
|
+
resetController();
|
|
7530
|
+
const layoutControlType = resetControlType(e);
|
|
7531
|
+
prevPoint = e.point;
|
|
7532
|
+
if (layoutControlType) {
|
|
7533
|
+
if (isDisbaledControl(layoutControlType)) {
|
|
7534
|
+
return;
|
|
7535
|
+
}
|
|
7536
|
+
sharer.setSharedStorage(keyLayoutActionType, "resize");
|
|
7537
|
+
return false;
|
|
7538
|
+
}
|
|
7539
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7540
|
+
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7541
|
+
return false;
|
|
7542
|
+
}
|
|
7543
|
+
},
|
|
7544
|
+
pointMove: (e) => {
|
|
7545
|
+
if (isInElementAction()) {
|
|
7546
|
+
return;
|
|
7547
|
+
}
|
|
7548
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7549
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
7550
|
+
const data = sharer.getActiveStorage("data");
|
|
7551
|
+
if (layoutControlType && isDisbaledControl(layoutControlType)) {
|
|
7552
|
+
return;
|
|
7553
|
+
}
|
|
7554
|
+
if (layoutActionType === "resize" && layoutControlType && (data == null ? void 0 : data.layout)) {
|
|
7555
|
+
if (prevPoint) {
|
|
7556
|
+
const scale = sharer.getActiveStorage("scale");
|
|
7557
|
+
const moveX = (e.point.x - prevPoint.x) / scale;
|
|
7558
|
+
const moveY = (e.point.y - prevPoint.y) / scale;
|
|
7559
|
+
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
7560
|
+
if (layoutControlType === "top") {
|
|
7561
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7562
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7563
|
+
} else if (layoutControlType === "right") {
|
|
7564
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7565
|
+
} else if (layoutControlType === "bottom") {
|
|
7566
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7567
|
+
} else if (layoutControlType === "left") {
|
|
7568
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7569
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7570
|
+
} else if (layoutControlType === "top-left") {
|
|
7571
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7572
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7573
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7574
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7575
|
+
} else if (layoutControlType === "top-right") {
|
|
7576
|
+
data.layout.y = calculator.toGridNum(y2 + moveY);
|
|
7577
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7578
|
+
data.layout.h = calculator.toGridNum(h2 - moveY);
|
|
7579
|
+
} else if (layoutControlType === "bottom-right") {
|
|
7580
|
+
data.layout.w = calculator.toGridNum(w2 + moveX);
|
|
7581
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7582
|
+
} else if (layoutControlType === "bottom-left") {
|
|
7583
|
+
data.layout.x = calculator.toGridNum(x2 + moveX);
|
|
7584
|
+
data.layout.w = calculator.toGridNum(w2 - moveX);
|
|
7585
|
+
data.layout.h = calculator.toGridNum(h2 + moveY);
|
|
7586
|
+
}
|
|
7587
|
+
}
|
|
7588
|
+
prevPoint = e.point;
|
|
7589
|
+
resetController();
|
|
7590
|
+
viewer.drawFrame();
|
|
7591
|
+
return false;
|
|
7592
|
+
}
|
|
7593
|
+
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7594
|
+
return false;
|
|
7595
|
+
}
|
|
7596
|
+
},
|
|
7597
|
+
pointEnd: () => {
|
|
7598
|
+
const layoutActionType = sharer.getSharedStorage(keyLayoutActionType);
|
|
7599
|
+
const layoutControlType = sharer.getSharedStorage(keyLayoutControlType);
|
|
7600
|
+
const data = sharer.getActiveStorage("data");
|
|
7601
|
+
if (data && layoutActionType === "resize" && layoutControlType && !isDisbaledControl(layoutControlType)) {
|
|
7602
|
+
eventHub.trigger(eventChange, {
|
|
7603
|
+
type: "changeLayout",
|
|
7604
|
+
data
|
|
7605
|
+
});
|
|
7606
|
+
}
|
|
7607
|
+
clear();
|
|
7608
|
+
},
|
|
7609
|
+
beforeDrawFrame: ({ snapshot }) => {
|
|
7610
|
+
var _a;
|
|
7611
|
+
const { sharedStore, activeStore } = snapshot;
|
|
7612
|
+
const layoutActionType = sharedStore[keyLayoutActionType];
|
|
7613
|
+
const layoutControlType = sharedStore[keyLayoutControlType];
|
|
7614
|
+
if (((_a = activeStore.data) == null ? void 0 : _a.layout) && layoutActionType && layoutControlType) {
|
|
7615
|
+
if (["hover", "resize"].includes(layoutActionType)) {
|
|
7616
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
7617
|
+
const { x: x2, y: y2, w: w2, h: h2 } = activeStore.data.layout;
|
|
7618
|
+
const size = { x: x2, y: y2, w: w2, h: h2 };
|
|
7619
|
+
const controller = calcLayoutSizeController(size, { viewScaleInfo, controllerSize: 10 });
|
|
7620
|
+
drawLayoutController(helperContext, { controller, operations: activeStore.data.layout.operations || {} });
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7623
|
+
},
|
|
7624
|
+
scrollX: () => {
|
|
7625
|
+
clear();
|
|
7626
|
+
},
|
|
7627
|
+
scrollY: () => {
|
|
7628
|
+
clear();
|
|
7629
|
+
},
|
|
7630
|
+
wheelScale: () => {
|
|
7631
|
+
clear();
|
|
7632
|
+
}
|
|
7633
|
+
};
|
|
7634
|
+
};
|
|
6912
7635
|
class Core {
|
|
6913
7636
|
constructor(container, opts) {
|
|
6914
7637
|
__privateAdd(this, _initContainer);
|
|
@@ -7024,11 +7747,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
7024
7747
|
};
|
|
7025
7748
|
exports.Core = Core;
|
|
7026
7749
|
exports.MiddlewareDragger = MiddlewareDragger;
|
|
7750
|
+
exports.MiddlewareInfo = MiddlewareInfo;
|
|
7751
|
+
exports.MiddlewareLayoutSelector = MiddlewareLayoutSelector;
|
|
7027
7752
|
exports.MiddlewareRuler = MiddlewareRuler;
|
|
7028
7753
|
exports.MiddlewareScaler = MiddlewareScaler;
|
|
7029
7754
|
exports.MiddlewareScroller = MiddlewareScroller;
|
|
7030
7755
|
exports.MiddlewareSelector = MiddlewareSelector;
|
|
7031
7756
|
exports.MiddlewareTextEditor = MiddlewareTextEditor;
|
|
7757
|
+
exports.eventChange = eventChange;
|
|
7032
7758
|
exports.middlewareEventRuler = middlewareEventRuler;
|
|
7033
7759
|
exports.middlewareEventScale = middlewareEventScale;
|
|
7034
7760
|
exports.middlewareEventSelect = middlewareEventSelect;
|