leafer-ui 1.5.3 → 1.6.1
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 -1
- package/dist/web.cjs +73 -75
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +73 -75
- 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 +317 -202
- 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 +317 -202
- 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.1";
|
|
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,22 @@ var LeaferUI = (function (exports) {
|
|
|
6717
6764
|
requestLayout() {
|
|
6718
6765
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6719
6766
|
}
|
|
6767
|
+
checkRender() {
|
|
6768
|
+
if (this.running) {
|
|
6769
|
+
const { target } = this;
|
|
6770
|
+
if (target.isApp) {
|
|
6771
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
6772
|
+
target.children.forEach(leafer => {
|
|
6773
|
+
leafer.renderer.FPS = this.FPS;
|
|
6774
|
+
leafer.renderer.checkRender();
|
|
6775
|
+
});
|
|
6776
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
6777
|
+
}
|
|
6778
|
+
if (this.changed && this.canvas.view)
|
|
6779
|
+
this.render();
|
|
6780
|
+
this.target.emit(RenderEvent.NEXT);
|
|
6781
|
+
}
|
|
6782
|
+
}
|
|
6720
6783
|
render(callback) {
|
|
6721
6784
|
if (!(this.running && this.canvas.view))
|
|
6722
6785
|
return this.update();
|
|
@@ -6725,8 +6788,6 @@ var LeaferUI = (function (exports) {
|
|
|
6725
6788
|
this.totalBounds = new Bounds();
|
|
6726
6789
|
debug$3.log(target.innerName, '--->');
|
|
6727
6790
|
try {
|
|
6728
|
-
if (!target.isApp)
|
|
6729
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6730
6791
|
this.emitRender(RenderEvent.START);
|
|
6731
6792
|
this.renderOnce(callback);
|
|
6732
6793
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6794,20 +6855,12 @@ var LeaferUI = (function (exports) {
|
|
|
6794
6855
|
}
|
|
6795
6856
|
clipRender(block) {
|
|
6796
6857
|
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);
|
|
6858
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
6801
6859
|
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);
|
|
6860
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
6861
|
+
canvas.clearWorld(bounds, true);
|
|
6862
|
+
canvas.clipWorld(bounds, true);
|
|
6863
|
+
this.__render(bounds, realBounds);
|
|
6811
6864
|
canvas.restore();
|
|
6812
6865
|
Run.end(t);
|
|
6813
6866
|
}
|
|
@@ -6816,28 +6869,22 @@ var LeaferUI = (function (exports) {
|
|
|
6816
6869
|
const { canvas } = this;
|
|
6817
6870
|
canvas.save();
|
|
6818
6871
|
canvas.clear();
|
|
6819
|
-
this.__render(canvas.bounds
|
|
6872
|
+
this.__render(canvas.bounds);
|
|
6820
6873
|
canvas.restore();
|
|
6821
6874
|
Run.end(t);
|
|
6822
6875
|
}
|
|
6823
|
-
__render(bounds,
|
|
6824
|
-
const
|
|
6876
|
+
__render(bounds, realBounds) {
|
|
6877
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
6825
6878
|
if (this.needFill)
|
|
6826
|
-
|
|
6879
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
6827
6880
|
if (Debug.showRepaint)
|
|
6828
|
-
|
|
6829
|
-
this.target.__render(
|
|
6881
|
+
Debug.drawRepaint(canvas, bounds);
|
|
6882
|
+
this.target.__render(canvas, options);
|
|
6830
6883
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
6831
6884
|
this.renderOptions = options;
|
|
6832
6885
|
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) { }
|
|
6886
|
+
canvas.updateRender(realBounds);
|
|
6887
|
+
}
|
|
6841
6888
|
addBlock(block) {
|
|
6842
6889
|
if (!this.updateBlocks)
|
|
6843
6890
|
this.updateBlocks = [];
|
|
@@ -6853,17 +6900,16 @@ var LeaferUI = (function (exports) {
|
|
|
6853
6900
|
}
|
|
6854
6901
|
}
|
|
6855
6902
|
__requestRender() {
|
|
6856
|
-
|
|
6903
|
+
const target = this.target;
|
|
6904
|
+
if (this.requestTime || !target)
|
|
6857
6905
|
return;
|
|
6906
|
+
if (target.parentApp)
|
|
6907
|
+
return target.parentApp.requestRender(false);
|
|
6858
6908
|
const requestTime = this.requestTime = Date.now();
|
|
6859
6909
|
Platform.requestRender(() => {
|
|
6860
6910
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6861
6911
|
this.requestTime = 0;
|
|
6862
|
-
|
|
6863
|
-
if (this.changed && this.canvas.view)
|
|
6864
|
-
this.render();
|
|
6865
|
-
this.target.emit(RenderEvent.NEXT);
|
|
6866
|
-
}
|
|
6912
|
+
this.checkRender();
|
|
6867
6913
|
});
|
|
6868
6914
|
}
|
|
6869
6915
|
__onResize(e) {
|
|
@@ -6921,6 +6967,7 @@ var LeaferUI = (function (exports) {
|
|
|
6921
6967
|
}
|
|
6922
6968
|
}
|
|
6923
6969
|
}
|
|
6970
|
+
Renderer.clipSpread = 10;
|
|
6924
6971
|
|
|
6925
6972
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6926
6973
|
class Picker {
|
|
@@ -7166,6 +7213,7 @@ var LeaferUI = (function (exports) {
|
|
|
7166
7213
|
return strokeWidth;
|
|
7167
7214
|
}
|
|
7168
7215
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7216
|
+
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7169
7217
|
get __hasMultiPaint() {
|
|
7170
7218
|
const t = this;
|
|
7171
7219
|
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
@@ -7210,14 +7258,14 @@ var LeaferUI = (function (exports) {
|
|
|
7210
7258
|
this.__removeInput('fill');
|
|
7211
7259
|
PaintImage.recycleImage('fill', this);
|
|
7212
7260
|
this.__isFills = false;
|
|
7213
|
-
|
|
7214
|
-
this.__pixelFill = false;
|
|
7261
|
+
this.__pixelFill && (this.__pixelFill = false);
|
|
7215
7262
|
}
|
|
7216
7263
|
this._fill = value;
|
|
7217
7264
|
}
|
|
7218
7265
|
else if (typeof value === 'object') {
|
|
7219
7266
|
this.__setInput('fill', value);
|
|
7220
|
-
|
|
7267
|
+
const layout = this.__leaf.__layout;
|
|
7268
|
+
layout.boxChanged || layout.boxChange();
|
|
7221
7269
|
this.__isFills = true;
|
|
7222
7270
|
this._fill || (this._fill = emptyPaint);
|
|
7223
7271
|
}
|
|
@@ -7228,14 +7276,14 @@ var LeaferUI = (function (exports) {
|
|
|
7228
7276
|
this.__removeInput('stroke');
|
|
7229
7277
|
PaintImage.recycleImage('stroke', this);
|
|
7230
7278
|
this.__isStrokes = false;
|
|
7231
|
-
|
|
7232
|
-
this.__pixelStroke = false;
|
|
7279
|
+
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7233
7280
|
}
|
|
7234
7281
|
this._stroke = value;
|
|
7235
7282
|
}
|
|
7236
7283
|
else if (typeof value === 'object') {
|
|
7237
7284
|
this.__setInput('stroke', value);
|
|
7238
|
-
|
|
7285
|
+
const layout = this.__leaf.__layout;
|
|
7286
|
+
layout.boxChanged || layout.boxChange();
|
|
7239
7287
|
this.__isStrokes = true;
|
|
7240
7288
|
this._stroke || (this._stroke = emptyPaint);
|
|
7241
7289
|
}
|
|
@@ -7350,6 +7398,31 @@ var LeaferUI = (function (exports) {
|
|
|
7350
7398
|
this._fontWeight = value;
|
|
7351
7399
|
}
|
|
7352
7400
|
}
|
|
7401
|
+
setBoxStyle(value) {
|
|
7402
|
+
let t = this.__leaf, box = t.__box;
|
|
7403
|
+
if (value) {
|
|
7404
|
+
const { boxStyle } = this;
|
|
7405
|
+
if (box)
|
|
7406
|
+
for (let key in boxStyle)
|
|
7407
|
+
box[key] = undefined;
|
|
7408
|
+
else
|
|
7409
|
+
box = t.__box = UICreator.get('Rect', 0);
|
|
7410
|
+
const layout = t.__layout, boxLayout = box.__layout;
|
|
7411
|
+
if (!boxStyle)
|
|
7412
|
+
box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
7413
|
+
box.set(value);
|
|
7414
|
+
if (boxLayout.strokeChanged)
|
|
7415
|
+
layout.strokeChange();
|
|
7416
|
+
if (boxLayout.renderChanged)
|
|
7417
|
+
layout.renderChange();
|
|
7418
|
+
box.__updateChange();
|
|
7419
|
+
}
|
|
7420
|
+
else if (box) {
|
|
7421
|
+
t.__box = box.parent = null;
|
|
7422
|
+
box.destroy();
|
|
7423
|
+
}
|
|
7424
|
+
this._boxStyle = value;
|
|
7425
|
+
}
|
|
7353
7426
|
}
|
|
7354
7427
|
|
|
7355
7428
|
class ImageData extends RectData {
|
|
@@ -7387,7 +7460,7 @@ var LeaferUI = (function (exports) {
|
|
|
7387
7460
|
const UIBounds = {
|
|
7388
7461
|
__updateStrokeSpread() {
|
|
7389
7462
|
let width = 0, boxWidth = 0;
|
|
7390
|
-
const data = this.__, { strokeAlign, strokeWidth } = data;
|
|
7463
|
+
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
7391
7464
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
7392
7465
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
7393
7466
|
if (!data.__boxStroke) {
|
|
@@ -7398,6 +7471,10 @@ var LeaferUI = (function (exports) {
|
|
|
7398
7471
|
}
|
|
7399
7472
|
if (data.__useArrow)
|
|
7400
7473
|
width += strokeWidth * 5;
|
|
7474
|
+
if (box) {
|
|
7475
|
+
width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
|
|
7476
|
+
boxWidth = box.__layout.strokeBoxSpread;
|
|
7477
|
+
}
|
|
7401
7478
|
this.__layout.strokeBoxSpread = boxWidth;
|
|
7402
7479
|
return width;
|
|
7403
7480
|
},
|
|
@@ -7416,25 +7493,26 @@ var LeaferUI = (function (exports) {
|
|
|
7416
7493
|
if (backgroundBlur)
|
|
7417
7494
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
7418
7495
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
7419
|
-
|
|
7496
|
+
width += this.__layout.strokeSpread || 0;
|
|
7497
|
+
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
7420
7498
|
}
|
|
7421
7499
|
};
|
|
7422
7500
|
|
|
7423
7501
|
const UIRender = {
|
|
7424
7502
|
__updateChange() {
|
|
7425
|
-
const data = this.__;
|
|
7503
|
+
const data = this.__, w = this.__world;
|
|
7426
7504
|
if (data.__useEffect) {
|
|
7427
7505
|
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
7428
7506
|
data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
|
|
7429
7507
|
}
|
|
7508
|
+
const half = data.__hasHalf;
|
|
7509
|
+
w.half !== half && (w.half = half);
|
|
7430
7510
|
data.__checkSingle();
|
|
7431
7511
|
const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
|
|
7432
|
-
if (complex)
|
|
7512
|
+
if (complex)
|
|
7433
7513
|
data.__complex = true;
|
|
7434
|
-
|
|
7435
|
-
else {
|
|
7514
|
+
else
|
|
7436
7515
|
data.__complex && (data.__complex = false);
|
|
7437
|
-
}
|
|
7438
7516
|
},
|
|
7439
7517
|
__drawFast(canvas, options) {
|
|
7440
7518
|
drawFast(this, canvas, options);
|
|
@@ -7521,10 +7599,11 @@ var LeaferUI = (function (exports) {
|
|
|
7521
7599
|
|
|
7522
7600
|
const RectRender = {
|
|
7523
7601
|
__drawFast(canvas, options) {
|
|
7524
|
-
let {
|
|
7602
|
+
let { x, y, width, height } = this.__layout.boxBounds;
|
|
7603
|
+
const { fill, stroke, __drawAfterFill } = this.__;
|
|
7525
7604
|
if (fill) {
|
|
7526
7605
|
canvas.fillStyle = fill;
|
|
7527
|
-
canvas.fillRect(
|
|
7606
|
+
canvas.fillRect(x, y, width, height);
|
|
7528
7607
|
}
|
|
7529
7608
|
if (__drawAfterFill)
|
|
7530
7609
|
this.__drawAfterFill(canvas, options);
|
|
@@ -7543,14 +7622,14 @@ var LeaferUI = (function (exports) {
|
|
|
7543
7622
|
if (width < 0 || height < 0) {
|
|
7544
7623
|
canvas.save();
|
|
7545
7624
|
this.__clip(canvas, options);
|
|
7546
|
-
canvas.strokeRect(half, half, width, height);
|
|
7625
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7547
7626
|
canvas.restore();
|
|
7548
7627
|
}
|
|
7549
7628
|
else
|
|
7550
|
-
canvas.strokeRect(half, half, width, height);
|
|
7629
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7551
7630
|
break;
|
|
7552
7631
|
case 'outside':
|
|
7553
|
-
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
7632
|
+
canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
|
|
7554
7633
|
break;
|
|
7555
7634
|
}
|
|
7556
7635
|
}
|
|
@@ -7706,6 +7785,12 @@ var LeaferUI = (function (exports) {
|
|
|
7706
7785
|
__decorate([
|
|
7707
7786
|
surfaceType(false)
|
|
7708
7787
|
], exports.UI.prototype, "locked", void 0);
|
|
7788
|
+
__decorate([
|
|
7789
|
+
surfaceType(false)
|
|
7790
|
+
], exports.UI.prototype, "dim", void 0);
|
|
7791
|
+
__decorate([
|
|
7792
|
+
surfaceType(false)
|
|
7793
|
+
], exports.UI.prototype, "dimskip", void 0);
|
|
7709
7794
|
__decorate([
|
|
7710
7795
|
sortType(0)
|
|
7711
7796
|
], exports.UI.prototype, "zIndex", void 0);
|
|
@@ -7967,7 +8052,7 @@ var LeaferUI = (function (exports) {
|
|
|
7967
8052
|
start: true,
|
|
7968
8053
|
hittable: true,
|
|
7969
8054
|
smooth: true,
|
|
7970
|
-
lazySpeard: 100
|
|
8055
|
+
lazySpeard: 100,
|
|
7971
8056
|
};
|
|
7972
8057
|
this.leafs = 0;
|
|
7973
8058
|
this.__eventIds = [];
|
|
@@ -8391,13 +8476,13 @@ var LeaferUI = (function (exports) {
|
|
|
8391
8476
|
super.__updateRenderBounds();
|
|
8392
8477
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8393
8478
|
this.__updateRectRenderBounds();
|
|
8394
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8479
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
|
|
8395
8480
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8396
8481
|
add(renderBounds, childrenRenderBounds);
|
|
8397
8482
|
}
|
|
8398
8483
|
else
|
|
8399
8484
|
this.__updateRectRenderBounds();
|
|
8400
|
-
|
|
8485
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8401
8486
|
}
|
|
8402
8487
|
__updateRectRenderBounds() { }
|
|
8403
8488
|
__updateRectChange() { }
|
|
@@ -8805,33 +8890,13 @@ var LeaferUI = (function (exports) {
|
|
|
8805
8890
|
registerUI()
|
|
8806
8891
|
], exports.Canvas);
|
|
8807
8892
|
|
|
8808
|
-
const { copyAndSpread, includes,
|
|
8893
|
+
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
8809
8894
|
exports.Text = class Text extends exports.UI {
|
|
8810
8895
|
get __tag() { return 'Text'; }
|
|
8811
|
-
get textDrawData() {
|
|
8812
|
-
this.__layout.update();
|
|
8813
|
-
return this.__.__textDrawData;
|
|
8814
|
-
}
|
|
8896
|
+
get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
|
|
8815
8897
|
constructor(data) {
|
|
8816
8898
|
super(data);
|
|
8817
8899
|
}
|
|
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
8900
|
__updateTextDrawData() {
|
|
8836
8901
|
const data = this.__;
|
|
8837
8902
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
@@ -8848,15 +8913,16 @@ var LeaferUI = (function (exports) {
|
|
|
8848
8913
|
const layout = this.__layout;
|
|
8849
8914
|
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8850
8915
|
this.__updateTextDrawData();
|
|
8851
|
-
const { bounds } = data.__textDrawData;
|
|
8916
|
+
const { bounds: contentBounds } = data.__textDrawData;
|
|
8852
8917
|
const b = layout.boxBounds;
|
|
8918
|
+
layout.contentBounds = contentBounds;
|
|
8853
8919
|
if (data.__lineHeight < fontSize)
|
|
8854
|
-
spread(
|
|
8920
|
+
spread(contentBounds, fontSize / 2);
|
|
8855
8921
|
if (autoWidth || autoHeight) {
|
|
8856
|
-
b.x = autoWidth ?
|
|
8857
|
-
b.y = autoHeight ?
|
|
8858
|
-
b.width = autoWidth ?
|
|
8859
|
-
b.height = autoHeight ?
|
|
8922
|
+
b.x = autoWidth ? contentBounds.x : 0;
|
|
8923
|
+
b.y = autoHeight ? contentBounds.y : 0;
|
|
8924
|
+
b.width = autoWidth ? contentBounds.width : data.width;
|
|
8925
|
+
b.height = autoHeight ? contentBounds.height : data.height;
|
|
8860
8926
|
if (padding) {
|
|
8861
8927
|
const [top, right, bottom, left] = data.__padding;
|
|
8862
8928
|
if (autoWidth)
|
|
@@ -8870,23 +8936,45 @@ var LeaferUI = (function (exports) {
|
|
|
8870
8936
|
super.__updateBoxBounds();
|
|
8871
8937
|
if (italic)
|
|
8872
8938
|
b.width += fontSize * 0.16;
|
|
8873
|
-
const
|
|
8874
|
-
if (
|
|
8875
|
-
|
|
8876
|
-
layout.renderChanged = true;
|
|
8877
|
-
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8878
|
-
}
|
|
8939
|
+
const isOverflow = !includes(b, contentBounds) || undefined;
|
|
8940
|
+
if (isOverflow)
|
|
8941
|
+
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8879
8942
|
else
|
|
8880
|
-
data.__textBoxBounds =
|
|
8943
|
+
data.__textBoxBounds = b;
|
|
8944
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8945
|
+
}
|
|
8946
|
+
__onUpdateSize() {
|
|
8947
|
+
if (this.__box)
|
|
8948
|
+
this.__box.__onUpdateSize();
|
|
8949
|
+
super.__onUpdateSize();
|
|
8881
8950
|
}
|
|
8882
8951
|
__updateRenderSpread() {
|
|
8883
8952
|
let width = super.__updateRenderSpread();
|
|
8884
8953
|
if (!width)
|
|
8885
|
-
width = this.
|
|
8954
|
+
width = this.isOverflow ? 1 : 0;
|
|
8886
8955
|
return width;
|
|
8887
8956
|
}
|
|
8888
8957
|
__updateRenderBounds() {
|
|
8889
|
-
|
|
8958
|
+
const { renderBounds, renderSpread } = this.__layout;
|
|
8959
|
+
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8960
|
+
if (this.__box)
|
|
8961
|
+
this.__box.__layout.renderBounds = renderBounds;
|
|
8962
|
+
}
|
|
8963
|
+
__drawRenderPath(canvas) {
|
|
8964
|
+
canvas.font = this.__.__font;
|
|
8965
|
+
}
|
|
8966
|
+
__draw(canvas, options, originCanvas) {
|
|
8967
|
+
const box = this.__box;
|
|
8968
|
+
if (box)
|
|
8969
|
+
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8970
|
+
if (this.textEditing && !Export.running)
|
|
8971
|
+
return;
|
|
8972
|
+
super.__draw(canvas, options, originCanvas);
|
|
8973
|
+
}
|
|
8974
|
+
destroy() {
|
|
8975
|
+
if (this.boxStyle)
|
|
8976
|
+
this.boxStyle = null;
|
|
8977
|
+
super.destroy();
|
|
8890
8978
|
}
|
|
8891
8979
|
};
|
|
8892
8980
|
__decorate([
|
|
@@ -8898,6 +8986,9 @@ var LeaferUI = (function (exports) {
|
|
|
8898
8986
|
__decorate([
|
|
8899
8987
|
boundsType(0)
|
|
8900
8988
|
], exports.Text.prototype, "height", void 0);
|
|
8989
|
+
__decorate([
|
|
8990
|
+
surfaceType()
|
|
8991
|
+
], exports.Text.prototype, "boxStyle", void 0);
|
|
8901
8992
|
__decorate([
|
|
8902
8993
|
dataType(false)
|
|
8903
8994
|
], exports.Text.prototype, "resizeFontSize", void 0);
|
|
@@ -9061,26 +9152,25 @@ var LeaferUI = (function (exports) {
|
|
|
9061
9152
|
this.leafer = this;
|
|
9062
9153
|
this.watcher.disable();
|
|
9063
9154
|
this.layouter.disable();
|
|
9064
|
-
this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
9065
9155
|
}
|
|
9066
9156
|
start() {
|
|
9067
9157
|
super.start();
|
|
9068
|
-
this.
|
|
9158
|
+
this.forEach(leafer => leafer.start());
|
|
9069
9159
|
}
|
|
9070
9160
|
stop() {
|
|
9071
|
-
this.
|
|
9161
|
+
this.forEach(leafer => leafer.stop());
|
|
9072
9162
|
super.stop();
|
|
9073
9163
|
}
|
|
9074
9164
|
unlockLayout() {
|
|
9075
9165
|
super.unlockLayout();
|
|
9076
|
-
this.
|
|
9166
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9077
9167
|
}
|
|
9078
9168
|
lockLayout() {
|
|
9079
9169
|
super.lockLayout();
|
|
9080
|
-
this.
|
|
9170
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9081
9171
|
}
|
|
9082
9172
|
forceRender(bounds, sync) {
|
|
9083
|
-
this.
|
|
9173
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9084
9174
|
}
|
|
9085
9175
|
addLeafer(merge) {
|
|
9086
9176
|
const leafer = new exports.Leafer(merge);
|
|
@@ -9100,9 +9190,8 @@ var LeaferUI = (function (exports) {
|
|
|
9100
9190
|
leafer.canvas.childIndex = index;
|
|
9101
9191
|
this.__listenChildEvents(leafer);
|
|
9102
9192
|
}
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
9193
|
+
forEach(fn) {
|
|
9194
|
+
this.children.forEach(fn);
|
|
9106
9195
|
}
|
|
9107
9196
|
__onCreated() {
|
|
9108
9197
|
this.created = this.children.every(child => child.created);
|
|
@@ -9125,18 +9214,18 @@ var LeaferUI = (function (exports) {
|
|
|
9125
9214
|
const m = options.matrix;
|
|
9126
9215
|
if (m)
|
|
9127
9216
|
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
9128
|
-
this.
|
|
9217
|
+
this.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
9129
9218
|
}
|
|
9130
9219
|
}
|
|
9131
9220
|
__onResize(event) {
|
|
9132
|
-
this.
|
|
9221
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9133
9222
|
super.__onResize(event);
|
|
9134
9223
|
}
|
|
9135
9224
|
updateLayout() {
|
|
9136
|
-
this.
|
|
9225
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9137
9226
|
}
|
|
9138
9227
|
__getChildConfig(userConfig) {
|
|
9139
|
-
|
|
9228
|
+
const config = Object.assign({}, this.config);
|
|
9140
9229
|
config.hittable = config.realCanvas = undefined;
|
|
9141
9230
|
if (userConfig)
|
|
9142
9231
|
DataHelper.assign(config, userConfig);
|
|
@@ -9695,6 +9784,7 @@ var LeaferUI = (function (exports) {
|
|
|
9695
9784
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9696
9785
|
},
|
|
9697
9786
|
pointer: {
|
|
9787
|
+
snap: true,
|
|
9698
9788
|
hitRadius: 5,
|
|
9699
9789
|
tapTime: 120,
|
|
9700
9790
|
longPressTime: 800,
|
|
@@ -9789,8 +9879,7 @@ var LeaferUI = (function (exports) {
|
|
|
9789
9879
|
if (this.downData) {
|
|
9790
9880
|
const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
|
|
9791
9881
|
if (canDrag) {
|
|
9792
|
-
|
|
9793
|
-
this.pointerWaitCancel();
|
|
9882
|
+
this.pointerWaitCancel();
|
|
9794
9883
|
this.waitRightTap = false;
|
|
9795
9884
|
}
|
|
9796
9885
|
this.dragger.checkDrag(data, canDrag);
|
|
@@ -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);
|
|
@@ -10069,9 +10161,11 @@ var LeaferUI = (function (exports) {
|
|
|
10069
10161
|
this.waitTap = true;
|
|
10070
10162
|
}
|
|
10071
10163
|
tapWaitCancel() {
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10164
|
+
if (this.waitTap) {
|
|
10165
|
+
clearTimeout(this.tapTimer);
|
|
10166
|
+
this.waitTap = false;
|
|
10167
|
+
this.tapCount = 0;
|
|
10168
|
+
}
|
|
10075
10169
|
}
|
|
10076
10170
|
longPressWait(data) {
|
|
10077
10171
|
clearTimeout(this.longPressTimer);
|
|
@@ -10091,8 +10185,10 @@ var LeaferUI = (function (exports) {
|
|
|
10091
10185
|
return hasLong;
|
|
10092
10186
|
}
|
|
10093
10187
|
longPressWaitCancel() {
|
|
10094
|
-
|
|
10095
|
-
|
|
10188
|
+
if (this.longPressTimer) {
|
|
10189
|
+
clearTimeout(this.longPressTimer);
|
|
10190
|
+
this.longPressed = false;
|
|
10191
|
+
}
|
|
10096
10192
|
}
|
|
10097
10193
|
__onResize() {
|
|
10098
10194
|
const { dragOut } = this.m;
|
|
@@ -10182,25 +10278,26 @@ var LeaferUI = (function (exports) {
|
|
|
10182
10278
|
const inner = {};
|
|
10183
10279
|
const leaf = exports.Leaf.prototype;
|
|
10184
10280
|
leaf.__hitWorld = function (point) {
|
|
10185
|
-
|
|
10281
|
+
const data = this.__;
|
|
10282
|
+
if (!data.hitSelf)
|
|
10186
10283
|
return false;
|
|
10187
|
-
|
|
10284
|
+
const world = this.__world, layout = this.__layout;
|
|
10285
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
10286
|
+
if (data.hitRadius) {
|
|
10188
10287
|
copy$2(inner, point), point = inner;
|
|
10189
|
-
setRadius(point,
|
|
10288
|
+
setRadius(point, data.hitRadius);
|
|
10190
10289
|
}
|
|
10191
|
-
toInnerRadiusPointOf(point,
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
if (this.__.hitBox || isSmall) {
|
|
10195
|
-
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
10290
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
10291
|
+
if (data.hitBox || isSmall) {
|
|
10292
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
10196
10293
|
return true;
|
|
10197
10294
|
if (isSmall)
|
|
10198
10295
|
return false;
|
|
10199
10296
|
}
|
|
10200
|
-
if (
|
|
10297
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
10201
10298
|
this.__updateHitCanvas();
|
|
10202
|
-
if (!
|
|
10203
|
-
|
|
10299
|
+
if (!layout.boundsChanged)
|
|
10300
|
+
layout.hitCanvasChanged = false;
|
|
10204
10301
|
}
|
|
10205
10302
|
return this.__hit(inner);
|
|
10206
10303
|
};
|
|
@@ -10213,7 +10310,9 @@ var LeaferUI = (function (exports) {
|
|
|
10213
10310
|
const matrix = new Matrix();
|
|
10214
10311
|
const ui$1 = exports.UI.prototype;
|
|
10215
10312
|
ui$1.__updateHitCanvas = function () {
|
|
10216
|
-
|
|
10313
|
+
if (this.__box)
|
|
10314
|
+
this.__box.__updateHitCanvas();
|
|
10315
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
10217
10316
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10218
10317
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10219
10318
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -10240,6 +10339,8 @@ var LeaferUI = (function (exports) {
|
|
|
10240
10339
|
h.setStrokeOptions(data);
|
|
10241
10340
|
};
|
|
10242
10341
|
ui$1.__hit = function (inner) {
|
|
10342
|
+
if (this.__box && this.__box.__hit(inner))
|
|
10343
|
+
return true;
|
|
10243
10344
|
const data = this.__;
|
|
10244
10345
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10245
10346
|
return true;
|
|
@@ -10288,6 +10389,15 @@ var LeaferUI = (function (exports) {
|
|
|
10288
10389
|
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10289
10390
|
};
|
|
10290
10391
|
|
|
10392
|
+
exports.Text.prototype.__drawHitPath = function (canvas) {
|
|
10393
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
10394
|
+
canvas.beginPath();
|
|
10395
|
+
if (__letterSpacing < 0)
|
|
10396
|
+
this.__drawPathByBox(canvas);
|
|
10397
|
+
else
|
|
10398
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
10399
|
+
};
|
|
10400
|
+
|
|
10291
10401
|
function getSelector(ui) {
|
|
10292
10402
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10293
10403
|
}
|
|
@@ -10979,9 +11089,11 @@ var LeaferUI = (function (exports) {
|
|
|
10979
11089
|
const tempPoint = {};
|
|
10980
11090
|
const tempScaleData = {};
|
|
10981
11091
|
function createData(leafPaint, image, paint, box) {
|
|
10982
|
-
const { blendMode, sync } = paint;
|
|
11092
|
+
const { blendMode, changeful, sync } = paint;
|
|
10983
11093
|
if (blendMode)
|
|
10984
11094
|
leafPaint.blendMode = blendMode;
|
|
11095
|
+
if (changeful)
|
|
11096
|
+
leafPaint.changeful = changeful;
|
|
10985
11097
|
if (sync)
|
|
10986
11098
|
leafPaint.sync = sync;
|
|
10987
11099
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -11214,40 +11326,32 @@ var LeaferUI = (function (exports) {
|
|
|
11214
11326
|
}
|
|
11215
11327
|
|
|
11216
11328
|
const { abs } = Math;
|
|
11217
|
-
function checkImage(ui, canvas, paint,
|
|
11329
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
11218
11330
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11219
|
-
const { pixelRatio } = canvas;
|
|
11220
|
-
if (!
|
|
11331
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
11332
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
11221
11333
|
return false;
|
|
11222
11334
|
}
|
|
11223
11335
|
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;
|
|
11336
|
+
if (allowDraw) {
|
|
11337
|
+
if (data.repeat) {
|
|
11338
|
+
allowDraw = false;
|
|
11235
11339
|
}
|
|
11236
11340
|
else {
|
|
11237
|
-
|
|
11341
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
11342
|
+
let { width, height } = data;
|
|
11343
|
+
width *= abs(scaleX) * pixelRatio;
|
|
11344
|
+
height *= abs(scaleY) * pixelRatio;
|
|
11345
|
+
if (data.scaleX) {
|
|
11346
|
+
width *= data.scaleX;
|
|
11347
|
+
height *= data.scaleY;
|
|
11348
|
+
}
|
|
11349
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
11350
|
+
}
|
|
11238
11351
|
}
|
|
11239
11352
|
}
|
|
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();
|
|
11353
|
+
if (allowDraw) {
|
|
11354
|
+
drawImage(ui, canvas, paint, data);
|
|
11251
11355
|
return true;
|
|
11252
11356
|
}
|
|
11253
11357
|
else {
|
|
@@ -11268,13 +11372,26 @@ var LeaferUI = (function (exports) {
|
|
|
11268
11372
|
}
|
|
11269
11373
|
}
|
|
11270
11374
|
}
|
|
11375
|
+
function drawImage(ui, canvas, paint, data) {
|
|
11376
|
+
canvas.save();
|
|
11377
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
11378
|
+
if (paint.blendMode)
|
|
11379
|
+
canvas.blendMode = paint.blendMode;
|
|
11380
|
+
if (data.opacity)
|
|
11381
|
+
canvas.opacity *= data.opacity;
|
|
11382
|
+
if (data.transform)
|
|
11383
|
+
canvas.transform(data.transform);
|
|
11384
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
11385
|
+
canvas.restore();
|
|
11386
|
+
}
|
|
11271
11387
|
|
|
11272
11388
|
function recycleImage(attrName, data) {
|
|
11273
11389
|
const paints = data['_' + attrName];
|
|
11274
11390
|
if (paints instanceof Array) {
|
|
11275
|
-
let image, recycleMap, input, url;
|
|
11391
|
+
let paint, image, recycleMap, input, url;
|
|
11276
11392
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
11277
|
-
|
|
11393
|
+
paint = paints[i];
|
|
11394
|
+
image = paint.image;
|
|
11278
11395
|
url = image && image.url;
|
|
11279
11396
|
if (url) {
|
|
11280
11397
|
if (!recycleMap)
|
|
@@ -11289,8 +11406,6 @@ var LeaferUI = (function (exports) {
|
|
|
11289
11406
|
}
|
|
11290
11407
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
11291
11408
|
}
|
|
11292
|
-
else
|
|
11293
|
-
paints[i].style = null;
|
|
11294
11409
|
}
|
|
11295
11410
|
}
|
|
11296
11411
|
return recycleMap;
|
|
@@ -11469,7 +11584,7 @@ var LeaferUI = (function (exports) {
|
|
|
11469
11584
|
const offsetOutBounds = {};
|
|
11470
11585
|
function innerShadow(ui, current, shape) {
|
|
11471
11586
|
let copyBounds, spreadScale;
|
|
11472
|
-
const { __nowWorld: nowWorld, __layout
|
|
11587
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
11473
11588
|
const { innerShadow } = ui.__;
|
|
11474
11589
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
11475
11590
|
const other = current.getSameCanvas();
|