leafer-ui 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -57
- package/dist/web.cjs +68 -71
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +68 -71
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +303 -192
- package/dist/web.js.map +1 -1
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +303 -192
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -12
package/dist/web.js
CHANGED
|
@@ -48,7 +48,7 @@ var LeaferUI = (function (exports) {
|
|
|
48
48
|
};
|
|
49
49
|
const I$2 = IncrementId;
|
|
50
50
|
|
|
51
|
-
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
51
|
+
const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
|
|
52
52
|
const MathHelper = {
|
|
53
53
|
within(value, min, max) {
|
|
54
54
|
if (typeof min === 'object')
|
|
@@ -112,7 +112,7 @@ var LeaferUI = (function (exports) {
|
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
114
|
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
115
|
-
num = round(num * a) / a;
|
|
115
|
+
num = round$3(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
118
118
|
getScaleData(scale, size, originSize, scaleData) {
|
|
@@ -135,8 +135,15 @@ var LeaferUI = (function (exports) {
|
|
|
135
135
|
scaleData.scaleX = scale.x;
|
|
136
136
|
scaleData.scaleY = scale.y;
|
|
137
137
|
}
|
|
138
|
+
},
|
|
139
|
+
randInt,
|
|
140
|
+
randColor(opacity) {
|
|
141
|
+
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
138
142
|
}
|
|
139
143
|
};
|
|
144
|
+
function randInt(num) {
|
|
145
|
+
return Math.round(Math.random() * num);
|
|
146
|
+
}
|
|
140
147
|
const OneRadian = PI$4 / 180;
|
|
141
148
|
const PI2 = PI$4 * 2;
|
|
142
149
|
const PI_2 = PI$4 / 2;
|
|
@@ -434,7 +441,7 @@ var LeaferUI = (function (exports) {
|
|
|
434
441
|
const M$6 = MatrixHelper;
|
|
435
442
|
|
|
436
443
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
437
|
-
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
444
|
+
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
|
|
438
445
|
const PointHelper = {
|
|
439
446
|
defaultPoint: getPointData(),
|
|
440
447
|
tempPoint: {},
|
|
@@ -455,6 +462,10 @@ var LeaferUI = (function (exports) {
|
|
|
455
462
|
t.x = x;
|
|
456
463
|
t.y = y;
|
|
457
464
|
},
|
|
465
|
+
round(t, halfPixel) {
|
|
466
|
+
t.x = halfPixel ? round$2(t.x - 0.5) + 0.5 : round$2(t.x);
|
|
467
|
+
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
468
|
+
},
|
|
458
469
|
move(t, x, y) {
|
|
459
470
|
t.x += x;
|
|
460
471
|
t.y += y;
|
|
@@ -1320,6 +1331,7 @@ var LeaferUI = (function (exports) {
|
|
|
1320
1331
|
'E': 1
|
|
1321
1332
|
};
|
|
1322
1333
|
|
|
1334
|
+
const { randColor } = MathHelper;
|
|
1323
1335
|
class Debug {
|
|
1324
1336
|
constructor(name) {
|
|
1325
1337
|
this.repeatMap = {};
|
|
@@ -1334,6 +1346,19 @@ var LeaferUI = (function (exports) {
|
|
|
1334
1346
|
static set exclude(name) {
|
|
1335
1347
|
this.excludeList = getNameList(name);
|
|
1336
1348
|
}
|
|
1349
|
+
static drawRepaint(canvas, bounds) {
|
|
1350
|
+
const color = randColor();
|
|
1351
|
+
canvas.fillWorld(bounds, color.replace('1)', '.1)'));
|
|
1352
|
+
canvas.strokeWorld(bounds, color);
|
|
1353
|
+
}
|
|
1354
|
+
static drawBounds(leaf, canvas, _options) {
|
|
1355
|
+
const showHit = Debug.showBounds === 'hit', w = leaf.__nowWorld, color = randColor();
|
|
1356
|
+
if (showHit)
|
|
1357
|
+
canvas.setWorld(w), leaf.__drawHitPath(canvas), canvas.fillStyle = color.replace('1)', '.2)'), canvas.fill();
|
|
1358
|
+
canvas.resetTransform();
|
|
1359
|
+
canvas.setStroke(color, 2);
|
|
1360
|
+
showHit ? canvas.stroke() : canvas.strokeWorld(w, color);
|
|
1361
|
+
}
|
|
1337
1362
|
log(...messages) {
|
|
1338
1363
|
if (D$4.enable) {
|
|
1339
1364
|
if (D$4.filterList.length && D$4.filterList.every(name => name !== this.name))
|
|
@@ -1420,7 +1445,7 @@ var LeaferUI = (function (exports) {
|
|
|
1420
1445
|
return rs;
|
|
1421
1446
|
},
|
|
1422
1447
|
need(name) {
|
|
1423
|
-
console.error('
|
|
1448
|
+
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1424
1449
|
}
|
|
1425
1450
|
};
|
|
1426
1451
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
@@ -2020,7 +2045,7 @@ var LeaferUI = (function (exports) {
|
|
|
2020
2045
|
contextMethod()
|
|
2021
2046
|
], Canvas.prototype, "strokeText", null);
|
|
2022
2047
|
|
|
2023
|
-
const { copy: copy$9 } = MatrixHelper;
|
|
2048
|
+
const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2024
2049
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2025
2050
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2026
2051
|
class LeaferCanvasBase extends Canvas {
|
|
@@ -2029,6 +2054,8 @@ var LeaferUI = (function (exports) {
|
|
|
2029
2054
|
get pixelRatio() { return this.size.pixelRatio; }
|
|
2030
2055
|
get pixelWidth() { return this.width * this.pixelRatio; }
|
|
2031
2056
|
get pixelHeight() { return this.height * this.pixelRatio; }
|
|
2057
|
+
get pixelSnap() { return this.config.pixelSnap; }
|
|
2058
|
+
set pixelSnap(value) { this.config.pixelSnap = value; }
|
|
2032
2059
|
get allowBackgroundColor() { return this.view && this.parentView; }
|
|
2033
2060
|
constructor(config, manager) {
|
|
2034
2061
|
super();
|
|
@@ -2089,15 +2116,22 @@ var LeaferUI = (function (exports) {
|
|
|
2089
2116
|
stopAutoLayout() { }
|
|
2090
2117
|
setCursor(_cursor) { }
|
|
2091
2118
|
setWorld(matrix, parentMatrix) {
|
|
2092
|
-
const { pixelRatio } = this;
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2119
|
+
const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
|
|
2120
|
+
if (parentMatrix)
|
|
2121
|
+
multiplyParent$3(matrix, parentMatrix, w);
|
|
2122
|
+
w.a = matrix.a * pixelRatio;
|
|
2123
|
+
w.b = matrix.b * pixelRatio;
|
|
2124
|
+
w.c = matrix.c * pixelRatio;
|
|
2125
|
+
w.d = matrix.d * pixelRatio;
|
|
2126
|
+
w.e = matrix.e * pixelRatio;
|
|
2127
|
+
w.f = matrix.f * pixelRatio;
|
|
2128
|
+
if (pixelSnap) {
|
|
2129
|
+
if (matrix.half && (matrix.half * pixelRatio) % 2)
|
|
2130
|
+
w.e = round$1(w.e - 0.5) + 0.5, w.f = round$1(w.f - 0.5) + 0.5;
|
|
2131
|
+
else
|
|
2132
|
+
w.e = round$1(w.e), w.f = round$1(w.f);
|
|
2100
2133
|
}
|
|
2134
|
+
this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
|
|
2101
2135
|
}
|
|
2102
2136
|
useWorldTransform(worldTransform) {
|
|
2103
2137
|
if (worldTransform)
|
|
@@ -2240,12 +2274,13 @@ var LeaferUI = (function (exports) {
|
|
|
2240
2274
|
return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
|
|
2241
2275
|
}
|
|
2242
2276
|
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
2243
|
-
const canvas = this.manager ? this.manager.get(
|
|
2277
|
+
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2244
2278
|
canvas.save();
|
|
2245
2279
|
if (useSameWorldTransform)
|
|
2246
2280
|
copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2247
2281
|
if (useSameSmooth)
|
|
2248
2282
|
canvas.smooth = this.smooth;
|
|
2283
|
+
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
2249
2284
|
return canvas;
|
|
2250
2285
|
}
|
|
2251
2286
|
recycle(clearBounds) {
|
|
@@ -3672,7 +3707,7 @@ var LeaferUI = (function (exports) {
|
|
|
3672
3707
|
const R = Resource;
|
|
3673
3708
|
|
|
3674
3709
|
const ImageManager = {
|
|
3675
|
-
maxRecycled:
|
|
3710
|
+
maxRecycled: 10,
|
|
3676
3711
|
recycledList: [],
|
|
3677
3712
|
patternTasker: new TaskProcessor(),
|
|
3678
3713
|
get(config) {
|
|
@@ -4025,9 +4060,8 @@ var LeaferUI = (function (exports) {
|
|
|
4025
4060
|
set(value) {
|
|
4026
4061
|
if (this.__setAttr(key, value)) {
|
|
4027
4062
|
this.__layout.hitCanvasChanged = true;
|
|
4028
|
-
if (Debug.
|
|
4063
|
+
if (Debug.showBounds === 'hit')
|
|
4029
4064
|
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
4030
|
-
}
|
|
4031
4065
|
if (this.leafer)
|
|
4032
4066
|
this.leafer.updateCursor();
|
|
4033
4067
|
}
|
|
@@ -4188,7 +4222,7 @@ var LeaferUI = (function (exports) {
|
|
|
4188
4222
|
}
|
|
4189
4223
|
|
|
4190
4224
|
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4191
|
-
const matrix$1 = {};
|
|
4225
|
+
const matrix$1 = {}, { round } = Math;
|
|
4192
4226
|
const LeafHelper = {
|
|
4193
4227
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4194
4228
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4262,6 +4296,8 @@ var LeaferUI = (function (exports) {
|
|
|
4262
4296
|
y = x.y, x = x.x;
|
|
4263
4297
|
x += t.x;
|
|
4264
4298
|
y += t.y;
|
|
4299
|
+
if (t.leafer && t.leafer.config.pointSnap)
|
|
4300
|
+
x = round(x), y = round(y);
|
|
4265
4301
|
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4266
4302
|
},
|
|
4267
4303
|
zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
|
|
@@ -4500,6 +4536,7 @@ var LeaferUI = (function (exports) {
|
|
|
4500
4536
|
set contentBounds(bounds) { this._contentBounds = bounds; }
|
|
4501
4537
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4502
4538
|
get renderBounds() { return this._renderBounds || this.boxBounds; }
|
|
4539
|
+
set renderBounds(bounds) { this._renderBounds = bounds; }
|
|
4503
4540
|
get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
|
|
4504
4541
|
get localStrokeBounds() { return this._localStrokeBounds || this; }
|
|
4505
4542
|
get localRenderBounds() { return this._localRenderBounds || this; }
|
|
@@ -4518,11 +4555,13 @@ var LeaferUI = (function (exports) {
|
|
|
4518
4555
|
get height() { return this.boxBounds.height; }
|
|
4519
4556
|
constructor(leaf) {
|
|
4520
4557
|
this.leaf = leaf;
|
|
4521
|
-
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4522
4558
|
if (this.leaf.__local)
|
|
4523
4559
|
this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
|
|
4524
|
-
|
|
4525
|
-
|
|
4560
|
+
if (leaf.__world) {
|
|
4561
|
+
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4562
|
+
this.boxChange();
|
|
4563
|
+
this.matrixChange();
|
|
4564
|
+
}
|
|
4526
4565
|
}
|
|
4527
4566
|
createLocal() {
|
|
4528
4567
|
const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -4854,6 +4893,9 @@ var LeaferUI = (function (exports) {
|
|
|
4854
4893
|
}
|
|
4855
4894
|
this.old = oldSize;
|
|
4856
4895
|
}
|
|
4896
|
+
static isResizing(leaf) {
|
|
4897
|
+
return this.resizingKeys && this.resizingKeys[leaf.innerId] !== undefined;
|
|
4898
|
+
}
|
|
4857
4899
|
}
|
|
4858
4900
|
ResizeEvent.RESIZE = 'resize';
|
|
4859
4901
|
|
|
@@ -4896,6 +4938,7 @@ var LeaferUI = (function (exports) {
|
|
|
4896
4938
|
}
|
|
4897
4939
|
RenderEvent.REQUEST = 'render.request';
|
|
4898
4940
|
RenderEvent.CHILD_START = 'render.child_start';
|
|
4941
|
+
RenderEvent.CHILD_END = 'render.child_end';
|
|
4899
4942
|
RenderEvent.START = 'render.start';
|
|
4900
4943
|
RenderEvent.BEFORE = 'render.before';
|
|
4901
4944
|
RenderEvent.RENDER = 'render';
|
|
@@ -5275,24 +5318,27 @@ var LeaferUI = (function (exports) {
|
|
|
5275
5318
|
const LeafRender = {
|
|
5276
5319
|
__render(canvas, options) {
|
|
5277
5320
|
if (this.__worldOpacity) {
|
|
5321
|
+
const data = this.__;
|
|
5278
5322
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5279
|
-
canvas.opacity =
|
|
5323
|
+
canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
|
|
5280
5324
|
if (this.__.__single) {
|
|
5281
|
-
if (
|
|
5325
|
+
if (data.eraser === 'path')
|
|
5282
5326
|
return this.__renderEraser(canvas, options);
|
|
5283
5327
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5284
5328
|
this.__draw(tempCanvas, options, canvas);
|
|
5285
5329
|
if (this.__worldFlipped) {
|
|
5286
|
-
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null,
|
|
5330
|
+
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5287
5331
|
}
|
|
5288
5332
|
else {
|
|
5289
|
-
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds,
|
|
5333
|
+
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5290
5334
|
}
|
|
5291
5335
|
tempCanvas.recycle(this.__nowWorld);
|
|
5292
5336
|
}
|
|
5293
5337
|
else {
|
|
5294
5338
|
this.__draw(canvas, options);
|
|
5295
5339
|
}
|
|
5340
|
+
if (Debug.showBounds)
|
|
5341
|
+
Debug.drawBounds(this, canvas, options);
|
|
5296
5342
|
}
|
|
5297
5343
|
},
|
|
5298
5344
|
__clip(canvas, options) {
|
|
@@ -5322,14 +5368,19 @@ var LeaferUI = (function (exports) {
|
|
|
5322
5368
|
__render(canvas, options) {
|
|
5323
5369
|
this.__nowWorld = this.__getNowWorld(options);
|
|
5324
5370
|
if (this.__worldOpacity) {
|
|
5325
|
-
|
|
5326
|
-
|
|
5371
|
+
const data = this.__;
|
|
5372
|
+
if (data.dim)
|
|
5373
|
+
options.dimOpacity = data.dim === true ? 0.2 : data.dim;
|
|
5374
|
+
else if (data.dimskip)
|
|
5375
|
+
options.dimOpacity && (options.dimOpacity = 0);
|
|
5376
|
+
if (data.__single) {
|
|
5377
|
+
if (data.eraser === 'path')
|
|
5327
5378
|
return this.__renderEraser(canvas, options);
|
|
5328
5379
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5329
5380
|
this.__renderBranch(tempCanvas, options);
|
|
5330
5381
|
const nowWorld = this.__nowWorld;
|
|
5331
|
-
canvas.opacity =
|
|
5332
|
-
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld,
|
|
5382
|
+
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
5383
|
+
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
5333
5384
|
tempCanvas.recycle(nowWorld);
|
|
5334
5385
|
}
|
|
5335
5386
|
else {
|
|
@@ -5404,9 +5455,11 @@ var LeaferUI = (function (exports) {
|
|
|
5404
5455
|
reset(data) {
|
|
5405
5456
|
if (this.leafer)
|
|
5406
5457
|
this.leafer.forceRender(this.__world);
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5458
|
+
if (data !== 0) {
|
|
5459
|
+
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
|
|
5460
|
+
if (data !== null)
|
|
5461
|
+
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
5462
|
+
}
|
|
5410
5463
|
this.__worldOpacity = 1;
|
|
5411
5464
|
this.__ = new this.__DataProcessor(this);
|
|
5412
5465
|
this.__layout = new this.__LayoutProcessor(this);
|
|
@@ -5542,9 +5595,10 @@ var LeaferUI = (function (exports) {
|
|
|
5542
5595
|
if (options.matrix) {
|
|
5543
5596
|
if (!this.__cameraWorld)
|
|
5544
5597
|
this.__cameraWorld = {};
|
|
5545
|
-
const cameraWorld = this.__cameraWorld;
|
|
5546
|
-
multiplyParent(
|
|
5598
|
+
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5599
|
+
multiplyParent(world, options.matrix, cameraWorld, undefined, world);
|
|
5547
5600
|
toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5601
|
+
cameraWorld.half !== world.half && (cameraWorld.half = world.half);
|
|
5548
5602
|
return cameraWorld;
|
|
5549
5603
|
}
|
|
5550
5604
|
else {
|
|
@@ -5704,7 +5758,7 @@ var LeaferUI = (function (exports) {
|
|
|
5704
5758
|
__updateHitCanvas() { }
|
|
5705
5759
|
__render(_canvas, _options) { }
|
|
5706
5760
|
__drawFast(_canvas, _options) { }
|
|
5707
|
-
__draw(_canvas, _options) { }
|
|
5761
|
+
__draw(_canvas, _options, _originCanvas) { }
|
|
5708
5762
|
__clip(_canvas, _options) { }
|
|
5709
5763
|
__renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
|
|
5710
5764
|
__updateWorldOpacity() { }
|
|
@@ -6074,7 +6128,7 @@ var LeaferUI = (function (exports) {
|
|
|
6074
6128
|
}
|
|
6075
6129
|
}
|
|
6076
6130
|
|
|
6077
|
-
const version = "1.
|
|
6131
|
+
const version = "1.6.0";
|
|
6078
6132
|
|
|
6079
6133
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
6080
6134
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6495,7 +6549,6 @@ var LeaferUI = (function (exports) {
|
|
|
6495
6549
|
}
|
|
6496
6550
|
|
|
6497
6551
|
const { worldBounds } = LeafBoundsHelper;
|
|
6498
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
6499
6552
|
class LayoutBlockData {
|
|
6500
6553
|
constructor(list) {
|
|
6501
6554
|
this.updatedBounds = new Bounds();
|
|
@@ -6509,13 +6562,7 @@ var LeaferUI = (function (exports) {
|
|
|
6509
6562
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
6510
6563
|
}
|
|
6511
6564
|
setAfter() {
|
|
6512
|
-
|
|
6513
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
6514
|
-
this.afterBounds.set(bigBounds);
|
|
6515
|
-
}
|
|
6516
|
-
else {
|
|
6517
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
6518
|
-
}
|
|
6565
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
6519
6566
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
6520
6567
|
}
|
|
6521
6568
|
merge(data) {
|
|
@@ -6717,6 +6764,13 @@ var LeaferUI = (function (exports) {
|
|
|
6717
6764
|
requestLayout() {
|
|
6718
6765
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6719
6766
|
}
|
|
6767
|
+
checkRender() {
|
|
6768
|
+
if (this.running) {
|
|
6769
|
+
if (this.changed && this.canvas.view)
|
|
6770
|
+
this.render();
|
|
6771
|
+
this.target.emit(RenderEvent.NEXT);
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6720
6774
|
render(callback) {
|
|
6721
6775
|
if (!(this.running && this.canvas.view))
|
|
6722
6776
|
return this.update();
|
|
@@ -6725,8 +6779,6 @@ var LeaferUI = (function (exports) {
|
|
|
6725
6779
|
this.totalBounds = new Bounds();
|
|
6726
6780
|
debug$3.log(target.innerName, '--->');
|
|
6727
6781
|
try {
|
|
6728
|
-
if (!target.isApp)
|
|
6729
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6730
6782
|
this.emitRender(RenderEvent.START);
|
|
6731
6783
|
this.renderOnce(callback);
|
|
6732
6784
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6794,20 +6846,12 @@ var LeaferUI = (function (exports) {
|
|
|
6794
6846
|
}
|
|
6795
6847
|
clipRender(block) {
|
|
6796
6848
|
const t = Run.start('PartRender');
|
|
6797
|
-
const { canvas } = this;
|
|
6798
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
6799
|
-
const includes = block.includes(this.target.__world);
|
|
6800
|
-
const realBounds = new Bounds(bounds);
|
|
6849
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
6801
6850
|
canvas.save();
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
6807
|
-
canvas.clearWorld(bounds, true);
|
|
6808
|
-
canvas.clipWorld(bounds, true);
|
|
6809
|
-
}
|
|
6810
|
-
this.__render(bounds, includes, realBounds);
|
|
6851
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
6852
|
+
canvas.clearWorld(bounds, true);
|
|
6853
|
+
canvas.clipWorld(bounds, true);
|
|
6854
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
6811
6855
|
canvas.restore();
|
|
6812
6856
|
Run.end(t);
|
|
6813
6857
|
}
|
|
@@ -6821,23 +6865,17 @@ var LeaferUI = (function (exports) {
|
|
|
6821
6865
|
Run.end(t);
|
|
6822
6866
|
}
|
|
6823
6867
|
__render(bounds, includes, realBounds) {
|
|
6824
|
-
const options =
|
|
6868
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
6825
6869
|
if (this.needFill)
|
|
6826
|
-
|
|
6870
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
6827
6871
|
if (Debug.showRepaint)
|
|
6828
|
-
|
|
6829
|
-
this.target.__render(
|
|
6872
|
+
Debug.drawRepaint(canvas, bounds);
|
|
6873
|
+
this.target.__render(canvas, options);
|
|
6830
6874
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
6831
6875
|
this.renderOptions = options;
|
|
6832
6876
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
if (Debug.showBoundsView)
|
|
6836
|
-
this.renderBoundsView(options);
|
|
6837
|
-
this.canvas.updateRender(realBounds);
|
|
6838
|
-
}
|
|
6839
|
-
renderHitView(_options) { }
|
|
6840
|
-
renderBoundsView(_options) { }
|
|
6877
|
+
canvas.updateRender(realBounds);
|
|
6878
|
+
}
|
|
6841
6879
|
addBlock(block) {
|
|
6842
6880
|
if (!this.updateBlocks)
|
|
6843
6881
|
this.updateBlocks = [];
|
|
@@ -6853,17 +6891,24 @@ var LeaferUI = (function (exports) {
|
|
|
6853
6891
|
}
|
|
6854
6892
|
}
|
|
6855
6893
|
__requestRender() {
|
|
6894
|
+
const target = this.target;
|
|
6895
|
+
if (target.parentApp)
|
|
6896
|
+
return target.parentApp.renderer.update(false);
|
|
6856
6897
|
if (this.requestTime)
|
|
6857
6898
|
return;
|
|
6858
6899
|
const requestTime = this.requestTime = Date.now();
|
|
6859
6900
|
Platform.requestRender(() => {
|
|
6860
6901
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6861
6902
|
this.requestTime = 0;
|
|
6862
|
-
if (
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6903
|
+
if (target.isApp) {
|
|
6904
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
6905
|
+
target.children.forEach(leafer => {
|
|
6906
|
+
leafer.renderer.FPS = this.FPS;
|
|
6907
|
+
leafer.renderer.checkRender();
|
|
6908
|
+
});
|
|
6909
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
6866
6910
|
}
|
|
6911
|
+
this.checkRender();
|
|
6867
6912
|
});
|
|
6868
6913
|
}
|
|
6869
6914
|
__onResize(e) {
|
|
@@ -6921,6 +6966,7 @@ var LeaferUI = (function (exports) {
|
|
|
6921
6966
|
}
|
|
6922
6967
|
}
|
|
6923
6968
|
}
|
|
6969
|
+
Renderer.clipSpread = 10;
|
|
6924
6970
|
|
|
6925
6971
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6926
6972
|
class Picker {
|
|
@@ -7166,6 +7212,7 @@ var LeaferUI = (function (exports) {
|
|
|
7166
7212
|
return strokeWidth;
|
|
7167
7213
|
}
|
|
7168
7214
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7215
|
+
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7169
7216
|
get __hasMultiPaint() {
|
|
7170
7217
|
const t = this;
|
|
7171
7218
|
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
@@ -7210,14 +7257,14 @@ var LeaferUI = (function (exports) {
|
|
|
7210
7257
|
this.__removeInput('fill');
|
|
7211
7258
|
PaintImage.recycleImage('fill', this);
|
|
7212
7259
|
this.__isFills = false;
|
|
7213
|
-
|
|
7214
|
-
this.__pixelFill = false;
|
|
7260
|
+
this.__pixelFill && (this.__pixelFill = false);
|
|
7215
7261
|
}
|
|
7216
7262
|
this._fill = value;
|
|
7217
7263
|
}
|
|
7218
7264
|
else if (typeof value === 'object') {
|
|
7219
7265
|
this.__setInput('fill', value);
|
|
7220
|
-
|
|
7266
|
+
const layout = this.__leaf.__layout;
|
|
7267
|
+
layout.boxChanged || layout.boxChange();
|
|
7221
7268
|
this.__isFills = true;
|
|
7222
7269
|
this._fill || (this._fill = emptyPaint);
|
|
7223
7270
|
}
|
|
@@ -7228,14 +7275,14 @@ var LeaferUI = (function (exports) {
|
|
|
7228
7275
|
this.__removeInput('stroke');
|
|
7229
7276
|
PaintImage.recycleImage('stroke', this);
|
|
7230
7277
|
this.__isStrokes = false;
|
|
7231
|
-
|
|
7232
|
-
this.__pixelStroke = false;
|
|
7278
|
+
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7233
7279
|
}
|
|
7234
7280
|
this._stroke = value;
|
|
7235
7281
|
}
|
|
7236
7282
|
else if (typeof value === 'object') {
|
|
7237
7283
|
this.__setInput('stroke', value);
|
|
7238
|
-
|
|
7284
|
+
const layout = this.__leaf.__layout;
|
|
7285
|
+
layout.boxChanged || layout.boxChange();
|
|
7239
7286
|
this.__isStrokes = true;
|
|
7240
7287
|
this._stroke || (this._stroke = emptyPaint);
|
|
7241
7288
|
}
|
|
@@ -7350,6 +7397,31 @@ var LeaferUI = (function (exports) {
|
|
|
7350
7397
|
this._fontWeight = value;
|
|
7351
7398
|
}
|
|
7352
7399
|
}
|
|
7400
|
+
setBoxStyle(value) {
|
|
7401
|
+
let t = this.__leaf, box = t.__box;
|
|
7402
|
+
if (value) {
|
|
7403
|
+
const { boxStyle } = this;
|
|
7404
|
+
if (box)
|
|
7405
|
+
for (let key in boxStyle)
|
|
7406
|
+
box[key] = undefined;
|
|
7407
|
+
else
|
|
7408
|
+
box = t.__box = UICreator.get('Rect', 0);
|
|
7409
|
+
const layout = t.__layout, boxLayout = box.__layout;
|
|
7410
|
+
if (!boxStyle)
|
|
7411
|
+
box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
7412
|
+
box.set(value);
|
|
7413
|
+
if (boxLayout.strokeChanged)
|
|
7414
|
+
layout.strokeChange();
|
|
7415
|
+
if (boxLayout.renderChanged)
|
|
7416
|
+
layout.renderChange();
|
|
7417
|
+
box.__updateChange();
|
|
7418
|
+
}
|
|
7419
|
+
else if (box) {
|
|
7420
|
+
t.__box = box.parent = null;
|
|
7421
|
+
box.destroy();
|
|
7422
|
+
}
|
|
7423
|
+
this._boxStyle = value;
|
|
7424
|
+
}
|
|
7353
7425
|
}
|
|
7354
7426
|
|
|
7355
7427
|
class ImageData extends RectData {
|
|
@@ -7387,7 +7459,7 @@ var LeaferUI = (function (exports) {
|
|
|
7387
7459
|
const UIBounds = {
|
|
7388
7460
|
__updateStrokeSpread() {
|
|
7389
7461
|
let width = 0, boxWidth = 0;
|
|
7390
|
-
const data = this.__, { strokeAlign, strokeWidth } = data;
|
|
7462
|
+
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
7391
7463
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
7392
7464
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
7393
7465
|
if (!data.__boxStroke) {
|
|
@@ -7398,6 +7470,10 @@ var LeaferUI = (function (exports) {
|
|
|
7398
7470
|
}
|
|
7399
7471
|
if (data.__useArrow)
|
|
7400
7472
|
width += strokeWidth * 5;
|
|
7473
|
+
if (box) {
|
|
7474
|
+
width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
|
|
7475
|
+
boxWidth = box.__layout.strokeBoxSpread;
|
|
7476
|
+
}
|
|
7401
7477
|
this.__layout.strokeBoxSpread = boxWidth;
|
|
7402
7478
|
return width;
|
|
7403
7479
|
},
|
|
@@ -7416,25 +7492,26 @@ var LeaferUI = (function (exports) {
|
|
|
7416
7492
|
if (backgroundBlur)
|
|
7417
7493
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
7418
7494
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
7419
|
-
|
|
7495
|
+
width += this.__layout.strokeSpread || 0;
|
|
7496
|
+
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
7420
7497
|
}
|
|
7421
7498
|
};
|
|
7422
7499
|
|
|
7423
7500
|
const UIRender = {
|
|
7424
7501
|
__updateChange() {
|
|
7425
|
-
const data = this.__;
|
|
7502
|
+
const data = this.__, w = this.__world;
|
|
7426
7503
|
if (data.__useEffect) {
|
|
7427
7504
|
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
7428
7505
|
data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
|
|
7429
7506
|
}
|
|
7507
|
+
const half = data.__hasHalf;
|
|
7508
|
+
w.half !== half && (w.half = half);
|
|
7430
7509
|
data.__checkSingle();
|
|
7431
7510
|
const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
|
|
7432
|
-
if (complex)
|
|
7511
|
+
if (complex)
|
|
7433
7512
|
data.__complex = true;
|
|
7434
|
-
|
|
7435
|
-
else {
|
|
7513
|
+
else
|
|
7436
7514
|
data.__complex && (data.__complex = false);
|
|
7437
|
-
}
|
|
7438
7515
|
},
|
|
7439
7516
|
__drawFast(canvas, options) {
|
|
7440
7517
|
drawFast(this, canvas, options);
|
|
@@ -7521,10 +7598,11 @@ var LeaferUI = (function (exports) {
|
|
|
7521
7598
|
|
|
7522
7599
|
const RectRender = {
|
|
7523
7600
|
__drawFast(canvas, options) {
|
|
7524
|
-
let {
|
|
7601
|
+
let { x, y, width, height } = this.__layout.boxBounds;
|
|
7602
|
+
const { fill, stroke, __drawAfterFill } = this.__;
|
|
7525
7603
|
if (fill) {
|
|
7526
7604
|
canvas.fillStyle = fill;
|
|
7527
|
-
canvas.fillRect(
|
|
7605
|
+
canvas.fillRect(x, y, width, height);
|
|
7528
7606
|
}
|
|
7529
7607
|
if (__drawAfterFill)
|
|
7530
7608
|
this.__drawAfterFill(canvas, options);
|
|
@@ -7543,14 +7621,14 @@ var LeaferUI = (function (exports) {
|
|
|
7543
7621
|
if (width < 0 || height < 0) {
|
|
7544
7622
|
canvas.save();
|
|
7545
7623
|
this.__clip(canvas, options);
|
|
7546
|
-
canvas.strokeRect(half, half, width, height);
|
|
7624
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7547
7625
|
canvas.restore();
|
|
7548
7626
|
}
|
|
7549
7627
|
else
|
|
7550
|
-
canvas.strokeRect(half, half, width, height);
|
|
7628
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7551
7629
|
break;
|
|
7552
7630
|
case 'outside':
|
|
7553
|
-
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
7631
|
+
canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
|
|
7554
7632
|
break;
|
|
7555
7633
|
}
|
|
7556
7634
|
}
|
|
@@ -7706,6 +7784,12 @@ var LeaferUI = (function (exports) {
|
|
|
7706
7784
|
__decorate([
|
|
7707
7785
|
surfaceType(false)
|
|
7708
7786
|
], exports.UI.prototype, "locked", void 0);
|
|
7787
|
+
__decorate([
|
|
7788
|
+
surfaceType(false)
|
|
7789
|
+
], exports.UI.prototype, "dim", void 0);
|
|
7790
|
+
__decorate([
|
|
7791
|
+
surfaceType(false)
|
|
7792
|
+
], exports.UI.prototype, "dimskip", void 0);
|
|
7709
7793
|
__decorate([
|
|
7710
7794
|
sortType(0)
|
|
7711
7795
|
], exports.UI.prototype, "zIndex", void 0);
|
|
@@ -7967,7 +8051,7 @@ var LeaferUI = (function (exports) {
|
|
|
7967
8051
|
start: true,
|
|
7968
8052
|
hittable: true,
|
|
7969
8053
|
smooth: true,
|
|
7970
|
-
lazySpeard: 100
|
|
8054
|
+
lazySpeard: 100,
|
|
7971
8055
|
};
|
|
7972
8056
|
this.leafs = 0;
|
|
7973
8057
|
this.__eventIds = [];
|
|
@@ -8391,13 +8475,13 @@ var LeaferUI = (function (exports) {
|
|
|
8391
8475
|
super.__updateRenderBounds();
|
|
8392
8476
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8393
8477
|
this.__updateRectRenderBounds();
|
|
8394
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8478
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
|
|
8395
8479
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8396
8480
|
add(renderBounds, childrenRenderBounds);
|
|
8397
8481
|
}
|
|
8398
8482
|
else
|
|
8399
8483
|
this.__updateRectRenderBounds();
|
|
8400
|
-
|
|
8484
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8401
8485
|
}
|
|
8402
8486
|
__updateRectRenderBounds() { }
|
|
8403
8487
|
__updateRectChange() { }
|
|
@@ -8805,33 +8889,13 @@ var LeaferUI = (function (exports) {
|
|
|
8805
8889
|
registerUI()
|
|
8806
8890
|
], exports.Canvas);
|
|
8807
8891
|
|
|
8808
|
-
const { copyAndSpread, includes,
|
|
8892
|
+
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
8809
8893
|
exports.Text = class Text extends exports.UI {
|
|
8810
8894
|
get __tag() { return 'Text'; }
|
|
8811
|
-
get textDrawData() {
|
|
8812
|
-
this.__layout.update();
|
|
8813
|
-
return this.__.__textDrawData;
|
|
8814
|
-
}
|
|
8895
|
+
get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
|
|
8815
8896
|
constructor(data) {
|
|
8816
8897
|
super(data);
|
|
8817
8898
|
}
|
|
8818
|
-
__drawHitPath(canvas) {
|
|
8819
|
-
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8820
|
-
canvas.beginPath();
|
|
8821
|
-
if (this.__.__letterSpacing < 0) {
|
|
8822
|
-
this.__drawPathByData(canvas);
|
|
8823
|
-
}
|
|
8824
|
-
else {
|
|
8825
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8826
|
-
}
|
|
8827
|
-
}
|
|
8828
|
-
__drawPathByData(drawer, _data) {
|
|
8829
|
-
const { x, y, width, height } = this.__layout.boxBounds;
|
|
8830
|
-
drawer.rect(x, y, width, height);
|
|
8831
|
-
}
|
|
8832
|
-
__drawRenderPath(canvas) {
|
|
8833
|
-
canvas.font = this.__.__font;
|
|
8834
|
-
}
|
|
8835
8899
|
__updateTextDrawData() {
|
|
8836
8900
|
const data = this.__;
|
|
8837
8901
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
@@ -8848,15 +8912,16 @@ var LeaferUI = (function (exports) {
|
|
|
8848
8912
|
const layout = this.__layout;
|
|
8849
8913
|
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8850
8914
|
this.__updateTextDrawData();
|
|
8851
|
-
const { bounds } = data.__textDrawData;
|
|
8915
|
+
const { bounds: contentBounds } = data.__textDrawData;
|
|
8852
8916
|
const b = layout.boxBounds;
|
|
8917
|
+
layout.contentBounds = contentBounds;
|
|
8853
8918
|
if (data.__lineHeight < fontSize)
|
|
8854
|
-
spread(
|
|
8919
|
+
spread(contentBounds, fontSize / 2);
|
|
8855
8920
|
if (autoWidth || autoHeight) {
|
|
8856
|
-
b.x = autoWidth ?
|
|
8857
|
-
b.y = autoHeight ?
|
|
8858
|
-
b.width = autoWidth ?
|
|
8859
|
-
b.height = autoHeight ?
|
|
8921
|
+
b.x = autoWidth ? contentBounds.x : 0;
|
|
8922
|
+
b.y = autoHeight ? contentBounds.y : 0;
|
|
8923
|
+
b.width = autoWidth ? contentBounds.width : data.width;
|
|
8924
|
+
b.height = autoHeight ? contentBounds.height : data.height;
|
|
8860
8925
|
if (padding) {
|
|
8861
8926
|
const [top, right, bottom, left] = data.__padding;
|
|
8862
8927
|
if (autoWidth)
|
|
@@ -8870,23 +8935,45 @@ var LeaferUI = (function (exports) {
|
|
|
8870
8935
|
super.__updateBoxBounds();
|
|
8871
8936
|
if (italic)
|
|
8872
8937
|
b.width += fontSize * 0.16;
|
|
8873
|
-
const
|
|
8874
|
-
if (
|
|
8875
|
-
|
|
8876
|
-
layout.renderChanged = true;
|
|
8877
|
-
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8878
|
-
}
|
|
8938
|
+
const isOverflow = !includes(b, contentBounds) || undefined;
|
|
8939
|
+
if (isOverflow)
|
|
8940
|
+
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8879
8941
|
else
|
|
8880
|
-
data.__textBoxBounds =
|
|
8942
|
+
data.__textBoxBounds = b;
|
|
8943
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8944
|
+
}
|
|
8945
|
+
__onUpdateSize() {
|
|
8946
|
+
if (this.__box)
|
|
8947
|
+
this.__box.__onUpdateSize();
|
|
8948
|
+
super.__onUpdateSize();
|
|
8881
8949
|
}
|
|
8882
8950
|
__updateRenderSpread() {
|
|
8883
8951
|
let width = super.__updateRenderSpread();
|
|
8884
8952
|
if (!width)
|
|
8885
|
-
width = this.
|
|
8953
|
+
width = this.isOverflow ? 1 : 0;
|
|
8886
8954
|
return width;
|
|
8887
8955
|
}
|
|
8888
8956
|
__updateRenderBounds() {
|
|
8889
|
-
|
|
8957
|
+
const { renderBounds, renderSpread } = this.__layout;
|
|
8958
|
+
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8959
|
+
if (this.__box)
|
|
8960
|
+
this.__box.__layout.renderBounds = renderBounds;
|
|
8961
|
+
}
|
|
8962
|
+
__drawRenderPath(canvas) {
|
|
8963
|
+
canvas.font = this.__.__font;
|
|
8964
|
+
}
|
|
8965
|
+
__draw(canvas, options, originCanvas) {
|
|
8966
|
+
const box = this.__box;
|
|
8967
|
+
if (box)
|
|
8968
|
+
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8969
|
+
if (this.textEditing && !Export.running)
|
|
8970
|
+
return;
|
|
8971
|
+
super.__draw(canvas, options, originCanvas);
|
|
8972
|
+
}
|
|
8973
|
+
destroy() {
|
|
8974
|
+
if (this.boxStyle)
|
|
8975
|
+
this.boxStyle = null;
|
|
8976
|
+
super.destroy();
|
|
8890
8977
|
}
|
|
8891
8978
|
};
|
|
8892
8979
|
__decorate([
|
|
@@ -8898,6 +8985,9 @@ var LeaferUI = (function (exports) {
|
|
|
8898
8985
|
__decorate([
|
|
8899
8986
|
boundsType(0)
|
|
8900
8987
|
], exports.Text.prototype, "height", void 0);
|
|
8988
|
+
__decorate([
|
|
8989
|
+
surfaceType()
|
|
8990
|
+
], exports.Text.prototype, "boxStyle", void 0);
|
|
8901
8991
|
__decorate([
|
|
8902
8992
|
dataType(false)
|
|
8903
8993
|
], exports.Text.prototype, "resizeFontSize", void 0);
|
|
@@ -9061,26 +9151,25 @@ var LeaferUI = (function (exports) {
|
|
|
9061
9151
|
this.leafer = this;
|
|
9062
9152
|
this.watcher.disable();
|
|
9063
9153
|
this.layouter.disable();
|
|
9064
|
-
this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
9065
9154
|
}
|
|
9066
9155
|
start() {
|
|
9067
9156
|
super.start();
|
|
9068
|
-
this.
|
|
9157
|
+
this.forEach(leafer => leafer.start());
|
|
9069
9158
|
}
|
|
9070
9159
|
stop() {
|
|
9071
|
-
this.
|
|
9160
|
+
this.forEach(leafer => leafer.stop());
|
|
9072
9161
|
super.stop();
|
|
9073
9162
|
}
|
|
9074
9163
|
unlockLayout() {
|
|
9075
9164
|
super.unlockLayout();
|
|
9076
|
-
this.
|
|
9165
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9077
9166
|
}
|
|
9078
9167
|
lockLayout() {
|
|
9079
9168
|
super.lockLayout();
|
|
9080
|
-
this.
|
|
9169
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9081
9170
|
}
|
|
9082
9171
|
forceRender(bounds, sync) {
|
|
9083
|
-
this.
|
|
9172
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9084
9173
|
}
|
|
9085
9174
|
addLeafer(merge) {
|
|
9086
9175
|
const leafer = new exports.Leafer(merge);
|
|
@@ -9100,9 +9189,8 @@ var LeaferUI = (function (exports) {
|
|
|
9100
9189
|
leafer.canvas.childIndex = index;
|
|
9101
9190
|
this.__listenChildEvents(leafer);
|
|
9102
9191
|
}
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
9192
|
+
forEach(fn) {
|
|
9193
|
+
this.children.forEach(fn);
|
|
9106
9194
|
}
|
|
9107
9195
|
__onCreated() {
|
|
9108
9196
|
this.created = this.children.every(child => child.created);
|
|
@@ -9125,18 +9213,18 @@ var LeaferUI = (function (exports) {
|
|
|
9125
9213
|
const m = options.matrix;
|
|
9126
9214
|
if (m)
|
|
9127
9215
|
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
9128
|
-
this.
|
|
9216
|
+
this.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
9129
9217
|
}
|
|
9130
9218
|
}
|
|
9131
9219
|
__onResize(event) {
|
|
9132
|
-
this.
|
|
9220
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9133
9221
|
super.__onResize(event);
|
|
9134
9222
|
}
|
|
9135
9223
|
updateLayout() {
|
|
9136
|
-
this.
|
|
9224
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9137
9225
|
}
|
|
9138
9226
|
__getChildConfig(userConfig) {
|
|
9139
|
-
|
|
9227
|
+
const config = Object.assign({}, this.config);
|
|
9140
9228
|
config.hittable = config.realCanvas = undefined;
|
|
9141
9229
|
if (userConfig)
|
|
9142
9230
|
DataHelper.assign(config, userConfig);
|
|
@@ -9695,6 +9783,7 @@ var LeaferUI = (function (exports) {
|
|
|
9695
9783
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9696
9784
|
},
|
|
9697
9785
|
pointer: {
|
|
9786
|
+
snap: true,
|
|
9698
9787
|
hitRadius: 5,
|
|
9699
9788
|
tapTime: 120,
|
|
9700
9789
|
longPressTime: 800,
|
|
@@ -9789,7 +9878,7 @@ var LeaferUI = (function (exports) {
|
|
|
9789
9878
|
if (this.downData) {
|
|
9790
9879
|
const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
|
|
9791
9880
|
if (canDrag) {
|
|
9792
|
-
if (this.waitTap)
|
|
9881
|
+
if (this.waitTap || this.longPressTimer)
|
|
9793
9882
|
this.pointerWaitCancel();
|
|
9794
9883
|
this.waitRightTap = false;
|
|
9795
9884
|
}
|
|
@@ -10050,7 +10139,10 @@ var LeaferUI = (function (exports) {
|
|
|
10050
10139
|
}
|
|
10051
10140
|
getLocal(clientPoint, updateClient) {
|
|
10052
10141
|
const clientBounds = this.canvas.getClientBounds(updateClient);
|
|
10053
|
-
|
|
10142
|
+
const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
|
|
10143
|
+
if (this.p.snap)
|
|
10144
|
+
PointHelper.round(point);
|
|
10145
|
+
return point;
|
|
10054
10146
|
}
|
|
10055
10147
|
emitTap(data) {
|
|
10056
10148
|
this.emit(exports.PointerEvent.TAP, data);
|
|
@@ -10182,25 +10274,26 @@ var LeaferUI = (function (exports) {
|
|
|
10182
10274
|
const inner = {};
|
|
10183
10275
|
const leaf = exports.Leaf.prototype;
|
|
10184
10276
|
leaf.__hitWorld = function (point) {
|
|
10185
|
-
|
|
10277
|
+
const data = this.__;
|
|
10278
|
+
if (!data.hitSelf)
|
|
10186
10279
|
return false;
|
|
10187
|
-
|
|
10280
|
+
const world = this.__world, layout = this.__layout;
|
|
10281
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
10282
|
+
if (data.hitRadius) {
|
|
10188
10283
|
copy$2(inner, point), point = inner;
|
|
10189
|
-
setRadius(point,
|
|
10284
|
+
setRadius(point, data.hitRadius);
|
|
10190
10285
|
}
|
|
10191
|
-
toInnerRadiusPointOf(point,
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
if (this.__.hitBox || isSmall) {
|
|
10195
|
-
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
10286
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
10287
|
+
if (data.hitBox || isSmall) {
|
|
10288
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
10196
10289
|
return true;
|
|
10197
10290
|
if (isSmall)
|
|
10198
10291
|
return false;
|
|
10199
10292
|
}
|
|
10200
|
-
if (
|
|
10293
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
10201
10294
|
this.__updateHitCanvas();
|
|
10202
|
-
if (!
|
|
10203
|
-
|
|
10295
|
+
if (!layout.boundsChanged)
|
|
10296
|
+
layout.hitCanvasChanged = false;
|
|
10204
10297
|
}
|
|
10205
10298
|
return this.__hit(inner);
|
|
10206
10299
|
};
|
|
@@ -10213,7 +10306,9 @@ var LeaferUI = (function (exports) {
|
|
|
10213
10306
|
const matrix = new Matrix();
|
|
10214
10307
|
const ui$1 = exports.UI.prototype;
|
|
10215
10308
|
ui$1.__updateHitCanvas = function () {
|
|
10216
|
-
|
|
10309
|
+
if (this.__box)
|
|
10310
|
+
this.__box.__updateHitCanvas();
|
|
10311
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
10217
10312
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10218
10313
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10219
10314
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -10240,6 +10335,8 @@ var LeaferUI = (function (exports) {
|
|
|
10240
10335
|
h.setStrokeOptions(data);
|
|
10241
10336
|
};
|
|
10242
10337
|
ui$1.__hit = function (inner) {
|
|
10338
|
+
if (this.__box && this.__box.__hit(inner))
|
|
10339
|
+
return true;
|
|
10243
10340
|
const data = this.__;
|
|
10244
10341
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10245
10342
|
return true;
|
|
@@ -10288,6 +10385,15 @@ var LeaferUI = (function (exports) {
|
|
|
10288
10385
|
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10289
10386
|
};
|
|
10290
10387
|
|
|
10388
|
+
exports.Text.prototype.__drawHitPath = function (canvas) {
|
|
10389
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
10390
|
+
canvas.beginPath();
|
|
10391
|
+
if (__letterSpacing < 0)
|
|
10392
|
+
this.__drawPathByBox(canvas);
|
|
10393
|
+
else
|
|
10394
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
10395
|
+
};
|
|
10396
|
+
|
|
10291
10397
|
function getSelector(ui) {
|
|
10292
10398
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10293
10399
|
}
|
|
@@ -10979,9 +11085,11 @@ var LeaferUI = (function (exports) {
|
|
|
10979
11085
|
const tempPoint = {};
|
|
10980
11086
|
const tempScaleData = {};
|
|
10981
11087
|
function createData(leafPaint, image, paint, box) {
|
|
10982
|
-
const { blendMode, sync } = paint;
|
|
11088
|
+
const { blendMode, changeful, sync } = paint;
|
|
10983
11089
|
if (blendMode)
|
|
10984
11090
|
leafPaint.blendMode = blendMode;
|
|
11091
|
+
if (changeful)
|
|
11092
|
+
leafPaint.changeful = changeful;
|
|
10985
11093
|
if (sync)
|
|
10986
11094
|
leafPaint.sync = sync;
|
|
10987
11095
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -11214,40 +11322,32 @@ var LeaferUI = (function (exports) {
|
|
|
11214
11322
|
}
|
|
11215
11323
|
|
|
11216
11324
|
const { abs } = Math;
|
|
11217
|
-
function checkImage(ui, canvas, paint,
|
|
11325
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
11218
11326
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11219
|
-
const { pixelRatio } = canvas;
|
|
11220
|
-
if (!
|
|
11327
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
11328
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
11221
11329
|
return false;
|
|
11222
11330
|
}
|
|
11223
11331
|
else {
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
let { width, height } = data;
|
|
11228
|
-
width *= abs(scaleX) * pixelRatio;
|
|
11229
|
-
height *= abs(scaleY) * pixelRatio;
|
|
11230
|
-
if (data.scaleX) {
|
|
11231
|
-
width *= data.scaleX;
|
|
11232
|
-
height *= data.scaleY;
|
|
11233
|
-
}
|
|
11234
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
11332
|
+
if (allowDraw) {
|
|
11333
|
+
if (data.repeat) {
|
|
11334
|
+
allowDraw = false;
|
|
11235
11335
|
}
|
|
11236
11336
|
else {
|
|
11237
|
-
|
|
11337
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
11338
|
+
let { width, height } = data;
|
|
11339
|
+
width *= abs(scaleX) * pixelRatio;
|
|
11340
|
+
height *= abs(scaleY) * pixelRatio;
|
|
11341
|
+
if (data.scaleX) {
|
|
11342
|
+
width *= data.scaleX;
|
|
11343
|
+
height *= data.scaleY;
|
|
11344
|
+
}
|
|
11345
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
11346
|
+
}
|
|
11238
11347
|
}
|
|
11239
11348
|
}
|
|
11240
|
-
if (
|
|
11241
|
-
canvas
|
|
11242
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
11243
|
-
if (paint.blendMode)
|
|
11244
|
-
canvas.blendMode = paint.blendMode;
|
|
11245
|
-
if (data.opacity)
|
|
11246
|
-
canvas.opacity *= data.opacity;
|
|
11247
|
-
if (data.transform)
|
|
11248
|
-
canvas.transform(data.transform);
|
|
11249
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
11250
|
-
canvas.restore();
|
|
11349
|
+
if (allowDraw) {
|
|
11350
|
+
drawImage(ui, canvas, paint, data);
|
|
11251
11351
|
return true;
|
|
11252
11352
|
}
|
|
11253
11353
|
else {
|
|
@@ -11268,13 +11368,26 @@ var LeaferUI = (function (exports) {
|
|
|
11268
11368
|
}
|
|
11269
11369
|
}
|
|
11270
11370
|
}
|
|
11371
|
+
function drawImage(ui, canvas, paint, data) {
|
|
11372
|
+
canvas.save();
|
|
11373
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
11374
|
+
if (paint.blendMode)
|
|
11375
|
+
canvas.blendMode = paint.blendMode;
|
|
11376
|
+
if (data.opacity)
|
|
11377
|
+
canvas.opacity *= data.opacity;
|
|
11378
|
+
if (data.transform)
|
|
11379
|
+
canvas.transform(data.transform);
|
|
11380
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
11381
|
+
canvas.restore();
|
|
11382
|
+
}
|
|
11271
11383
|
|
|
11272
11384
|
function recycleImage(attrName, data) {
|
|
11273
11385
|
const paints = data['_' + attrName];
|
|
11274
11386
|
if (paints instanceof Array) {
|
|
11275
|
-
let image, recycleMap, input, url;
|
|
11387
|
+
let paint, image, recycleMap, input, url;
|
|
11276
11388
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
11277
|
-
|
|
11389
|
+
paint = paints[i];
|
|
11390
|
+
image = paint.image;
|
|
11278
11391
|
url = image && image.url;
|
|
11279
11392
|
if (url) {
|
|
11280
11393
|
if (!recycleMap)
|
|
@@ -11289,8 +11402,6 @@ var LeaferUI = (function (exports) {
|
|
|
11289
11402
|
}
|
|
11290
11403
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
11291
11404
|
}
|
|
11292
|
-
else
|
|
11293
|
-
paints[i].style = null;
|
|
11294
11405
|
}
|
|
11295
11406
|
}
|
|
11296
11407
|
return recycleMap;
|
|
@@ -11469,7 +11580,7 @@ var LeaferUI = (function (exports) {
|
|
|
11469
11580
|
const offsetOutBounds = {};
|
|
11470
11581
|
function innerShadow(ui, current, shape) {
|
|
11471
11582
|
let copyBounds, spreadScale;
|
|
11472
|
-
const { __nowWorld: nowWorld, __layout
|
|
11583
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
11473
11584
|
const { innerShadow } = ui.__;
|
|
11474
11585
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
11475
11586
|
const other = current.getSameCanvas();
|