leafer-ui 1.0.3 → 1.0.5
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 +30 -12
- package/dist/web.cjs +33 -25
- package/dist/web.esm.js +33 -25
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +97 -79
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +97 -79
- package/dist/web.module.min.js +1 -1
- package/package.json +14 -14
- package/src/index.ts +0 -2
- package/types/index.d.ts +0 -1
package/dist/web.module.js
CHANGED
|
@@ -4483,15 +4483,16 @@ class LeafLayout {
|
|
|
4483
4483
|
}
|
|
4484
4484
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
4485
4485
|
const { leaf } = this;
|
|
4486
|
-
let point, matrix, bounds = this.getInnerBounds(type);
|
|
4486
|
+
let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
|
|
4487
4487
|
switch (relative) {
|
|
4488
4488
|
case 'world':
|
|
4489
4489
|
point = leaf.getWorldPoint(bounds);
|
|
4490
4490
|
matrix = leaf.__world;
|
|
4491
4491
|
break;
|
|
4492
4492
|
case 'local':
|
|
4493
|
+
const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
|
|
4494
|
+
layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
|
|
4493
4495
|
point = leaf.getLocalPointByInner(bounds);
|
|
4494
|
-
matrix = leaf.__localMatrix;
|
|
4495
4496
|
break;
|
|
4496
4497
|
case 'inner':
|
|
4497
4498
|
point = bounds;
|
|
@@ -4503,7 +4504,8 @@ class LeafLayout {
|
|
|
4503
4504
|
point = leaf.getWorldPoint(bounds, relative);
|
|
4504
4505
|
matrix = getRelativeWorld$1(leaf, relative, true);
|
|
4505
4506
|
}
|
|
4506
|
-
|
|
4507
|
+
if (!layoutBounds)
|
|
4508
|
+
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4507
4509
|
copy$6(layoutBounds, bounds);
|
|
4508
4510
|
PointHelper.copy(layoutBounds, point);
|
|
4509
4511
|
if (unscale) {
|
|
@@ -4753,6 +4755,7 @@ class RenderEvent extends Event {
|
|
|
4753
4755
|
}
|
|
4754
4756
|
}
|
|
4755
4757
|
RenderEvent.REQUEST = 'render.request';
|
|
4758
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4756
4759
|
RenderEvent.START = 'render.start';
|
|
4757
4760
|
RenderEvent.BEFORE = 'render.before';
|
|
4758
4761
|
RenderEvent.RENDER = 'render';
|
|
@@ -4928,7 +4931,7 @@ const { isFinite } = Number;
|
|
|
4928
4931
|
const debug$8 = Debug.get('setAttr');
|
|
4929
4932
|
const LeafDataProxy = {
|
|
4930
4933
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4931
|
-
if (this.
|
|
4934
|
+
if (this.leaferIsCreated) {
|
|
4932
4935
|
const oldValue = this.__.__getInput(name);
|
|
4933
4936
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4934
4937
|
debug$8.warn(this.innerName, name, newValue);
|
|
@@ -5000,7 +5003,7 @@ const LeafMatrix = {
|
|
|
5000
5003
|
|
|
5001
5004
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5002
5005
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5003
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5006
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5004
5007
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5005
5008
|
const LeafBounds = {
|
|
5006
5009
|
__updateWorldBounds() {
|
|
@@ -5083,7 +5086,7 @@ const LeafBounds = {
|
|
|
5083
5086
|
const b = this.__layout.boxBounds;
|
|
5084
5087
|
const data = this.__;
|
|
5085
5088
|
if (data.__pathInputed) {
|
|
5086
|
-
toBounds$2(data.
|
|
5089
|
+
toBounds$2(data.path, b);
|
|
5087
5090
|
}
|
|
5088
5091
|
else {
|
|
5089
5092
|
b.x = 0;
|
|
@@ -5095,7 +5098,7 @@ const LeafBounds = {
|
|
|
5095
5098
|
__updateAutoLayout() {
|
|
5096
5099
|
this.__layout.matrixChanged = true;
|
|
5097
5100
|
if (this.isBranch) {
|
|
5098
|
-
if (this.
|
|
5101
|
+
if (this.leaferIsReady)
|
|
5099
5102
|
this.leafer.layouter.addExtra(this);
|
|
5100
5103
|
if (this.__.flow) {
|
|
5101
5104
|
if (this.__layout.boxChanged)
|
|
@@ -5121,11 +5124,11 @@ const LeafBounds = {
|
|
|
5121
5124
|
},
|
|
5122
5125
|
__updateStrokeBounds() {
|
|
5123
5126
|
const layout = this.__layout;
|
|
5124
|
-
copyAndSpread$
|
|
5127
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5125
5128
|
},
|
|
5126
5129
|
__updateRenderBounds() {
|
|
5127
5130
|
const layout = this.__layout;
|
|
5128
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5131
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5129
5132
|
}
|
|
5130
5133
|
};
|
|
5131
5134
|
|
|
@@ -5230,6 +5233,8 @@ let Leaf = class Leaf {
|
|
|
5230
5233
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5231
5234
|
get __DataProcessor() { return LeafData; }
|
|
5232
5235
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5236
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5237
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5233
5238
|
get isLeafer() { return false; }
|
|
5234
5239
|
get isBranch() { return false; }
|
|
5235
5240
|
get isBranchLeaf() { return false; }
|
|
@@ -5671,6 +5676,7 @@ let Branch = class Branch extends Leaf {
|
|
|
5671
5676
|
add(child, index) {
|
|
5672
5677
|
if (child === this)
|
|
5673
5678
|
return;
|
|
5679
|
+
child.__ || (child = UICreator.get(child.tag, child));
|
|
5674
5680
|
if (child.parent)
|
|
5675
5681
|
child.parent.remove(child);
|
|
5676
5682
|
child.parent = this;
|
|
@@ -5693,10 +5699,14 @@ let Branch = class Branch extends Leaf {
|
|
|
5693
5699
|
}
|
|
5694
5700
|
remove(child, destroy) {
|
|
5695
5701
|
if (child) {
|
|
5696
|
-
if (child.
|
|
5697
|
-
|
|
5702
|
+
if (child.__) {
|
|
5703
|
+
if (child.animationOut)
|
|
5704
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5705
|
+
else
|
|
5706
|
+
this.__remove(child, destroy);
|
|
5707
|
+
}
|
|
5698
5708
|
else
|
|
5699
|
-
this.
|
|
5709
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5700
5710
|
}
|
|
5701
5711
|
else if (child === undefined) {
|
|
5702
5712
|
super.remove(null, destroy);
|
|
@@ -5914,7 +5924,7 @@ class LeafLevelList {
|
|
|
5914
5924
|
}
|
|
5915
5925
|
}
|
|
5916
5926
|
|
|
5917
|
-
const version = "1.0.
|
|
5927
|
+
const version = "1.0.5";
|
|
5918
5928
|
|
|
5919
5929
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5920
5930
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6556,6 +6566,7 @@ class Renderer {
|
|
|
6556
6566
|
this.totalBounds = new Bounds();
|
|
6557
6567
|
debug$5.log(target.innerName, '--->');
|
|
6558
6568
|
try {
|
|
6569
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6559
6570
|
this.emitRender(RenderEvent.START);
|
|
6560
6571
|
this.renderOnce(callback);
|
|
6561
6572
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6853,7 +6864,7 @@ class Picker {
|
|
|
6853
6864
|
if (child.isBranch) {
|
|
6854
6865
|
if (hit || child.__ignoreHitWorld) {
|
|
6855
6866
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
6856
|
-
if (child.isBranchLeaf
|
|
6867
|
+
if (child.isBranchLeaf)
|
|
6857
6868
|
this.hitChild(child, point);
|
|
6858
6869
|
}
|
|
6859
6870
|
}
|
|
@@ -7563,12 +7574,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7563
7574
|
this.__drawPathByData(canvas, this.__.path);
|
|
7564
7575
|
}
|
|
7565
7576
|
__drawPathByData(drawer, data) {
|
|
7566
|
-
|
|
7567
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7568
|
-
}
|
|
7569
|
-
else {
|
|
7570
|
-
this.__drawPathByBox(drawer);
|
|
7571
|
-
}
|
|
7577
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7572
7578
|
}
|
|
7573
7579
|
__drawPathByBox(drawer) {
|
|
7574
7580
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7576,9 +7582,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7576
7582
|
const { cornerRadius } = this.__;
|
|
7577
7583
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7578
7584
|
}
|
|
7579
|
-
else
|
|
7585
|
+
else
|
|
7580
7586
|
drawer.rect(x, y, width, height);
|
|
7581
|
-
}
|
|
7582
7587
|
}
|
|
7583
7588
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7584
7589
|
return needPlugin('animate');
|
|
@@ -7587,10 +7592,10 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7587
7592
|
export(filename, options) {
|
|
7588
7593
|
return Export.export(this, filename, options);
|
|
7589
7594
|
}
|
|
7590
|
-
clone(
|
|
7595
|
+
clone(data) {
|
|
7591
7596
|
const json = this.toJSON();
|
|
7592
|
-
if (
|
|
7593
|
-
Object.assign(json,
|
|
7597
|
+
if (data)
|
|
7598
|
+
Object.assign(json, data);
|
|
7594
7599
|
return UI_1.one(json);
|
|
7595
7600
|
}
|
|
7596
7601
|
static one(data, x, y, width, height) {
|
|
@@ -8261,10 +8266,9 @@ Rect = __decorate([
|
|
|
8261
8266
|
registerUI()
|
|
8262
8267
|
], Rect);
|
|
8263
8268
|
|
|
8264
|
-
const
|
|
8265
|
-
const group$1 = Group.prototype;
|
|
8269
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8270
|
+
const rect$1 = Rect.prototype, group$1 = Group.prototype;
|
|
8266
8271
|
const childrenRenderBounds = {};
|
|
8267
|
-
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8268
8272
|
let Box = class Box extends Group {
|
|
8269
8273
|
get __tag() { return 'Box'; }
|
|
8270
8274
|
get isBranchLeaf() { return true; }
|
|
@@ -8278,29 +8282,27 @@ let Box = class Box extends Group {
|
|
|
8278
8282
|
return this.__updateRectRenderSpread() || -1;
|
|
8279
8283
|
}
|
|
8280
8284
|
__updateRectBoxBounds() { }
|
|
8281
|
-
__updateBoxBounds(
|
|
8285
|
+
__updateBoxBounds(_secondLayout) {
|
|
8282
8286
|
const data = this.__;
|
|
8283
8287
|
if (this.children.length) {
|
|
8284
8288
|
if (data.__autoSide) {
|
|
8285
|
-
if (this.leafer && this.leafer.ready)
|
|
8286
|
-
this.leafer.layouter.addExtra(this);
|
|
8287
8289
|
super.__updateBoxBounds();
|
|
8288
8290
|
const { boxBounds } = this.__layout;
|
|
8289
8291
|
if (!data.__autoSize) {
|
|
8290
|
-
if (data.__autoWidth)
|
|
8291
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8292
|
-
|
|
8293
|
-
|
|
8292
|
+
if (data.__autoWidth) {
|
|
8293
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8294
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8295
|
+
}
|
|
8296
|
+
else {
|
|
8297
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8298
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8299
|
+
}
|
|
8294
8300
|
}
|
|
8295
|
-
if (secondLayout && data.flow && data.padding)
|
|
8296
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8297
8301
|
this.__updateNaturalSize();
|
|
8298
8302
|
}
|
|
8299
8303
|
else {
|
|
8300
8304
|
this.__updateRectBoxBounds();
|
|
8301
8305
|
}
|
|
8302
|
-
if (data.flow)
|
|
8303
|
-
this.__updateContentBounds();
|
|
8304
8306
|
}
|
|
8305
8307
|
else {
|
|
8306
8308
|
this.__updateRectBoxBounds();
|
|
@@ -8366,6 +8368,9 @@ __decorate([
|
|
|
8366
8368
|
__decorate([
|
|
8367
8369
|
dataType(false)
|
|
8368
8370
|
], Box.prototype, "resizeChildren", void 0);
|
|
8371
|
+
__decorate([
|
|
8372
|
+
dataType(false)
|
|
8373
|
+
], Box.prototype, "textBox", void 0);
|
|
8369
8374
|
__decorate([
|
|
8370
8375
|
affectRenderBoundsType('show')
|
|
8371
8376
|
], Box.prototype, "overflow", void 0);
|
|
@@ -8895,6 +8900,9 @@ __decorate([
|
|
|
8895
8900
|
__decorate([
|
|
8896
8901
|
boundsType('top')
|
|
8897
8902
|
], Text.prototype, "verticalAlign", void 0);
|
|
8903
|
+
__decorate([
|
|
8904
|
+
boundsType(true)
|
|
8905
|
+
], Text.prototype, "autoSizeAlign", void 0);
|
|
8898
8906
|
__decorate([
|
|
8899
8907
|
boundsType('normal')
|
|
8900
8908
|
], Text.prototype, "textWrap", void 0);
|
|
@@ -9615,9 +9623,10 @@ class Dragger {
|
|
|
9615
9623
|
this.dragData = getDragEventData(data, data, data);
|
|
9616
9624
|
this.canAnimate = this.canDragOut = true;
|
|
9617
9625
|
}
|
|
9618
|
-
getList() {
|
|
9626
|
+
getList(realDraggable, hover) {
|
|
9619
9627
|
const { proxy } = this.interaction.selector;
|
|
9620
|
-
|
|
9628
|
+
const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
|
|
9629
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
|
|
9621
9630
|
}
|
|
9622
9631
|
checkDrag(data, canDrag) {
|
|
9623
9632
|
const { interaction } = this;
|
|
@@ -9642,8 +9651,8 @@ class Dragger {
|
|
|
9642
9651
|
this.dragging = canDrag && PointerButton.left(data);
|
|
9643
9652
|
if (this.dragging) {
|
|
9644
9653
|
this.interaction.emit(DragEvent.START, this.dragData);
|
|
9645
|
-
this.
|
|
9646
|
-
this.setDragStartPoints(this.
|
|
9654
|
+
this.getDraggableList(this.dragData.path);
|
|
9655
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true));
|
|
9647
9656
|
}
|
|
9648
9657
|
}
|
|
9649
9658
|
}
|
|
@@ -9651,12 +9660,12 @@ class Dragger {
|
|
|
9651
9660
|
this.dragStartPoints = {};
|
|
9652
9661
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
|
|
9653
9662
|
}
|
|
9654
|
-
|
|
9663
|
+
getDraggableList(path) {
|
|
9655
9664
|
let leaf;
|
|
9656
9665
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
9657
9666
|
leaf = path.list[i];
|
|
9658
|
-
if ((leaf.
|
|
9659
|
-
this.
|
|
9667
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
9668
|
+
this.draggableList = new LeafList(leaf);
|
|
9660
9669
|
break;
|
|
9661
9670
|
}
|
|
9662
9671
|
}
|
|
@@ -9681,7 +9690,7 @@ class Dragger {
|
|
|
9681
9690
|
}
|
|
9682
9691
|
dragReal() {
|
|
9683
9692
|
const { running } = this.interaction;
|
|
9684
|
-
const list = this.
|
|
9693
|
+
const list = this.realDraggableList;
|
|
9685
9694
|
if (list.length && running) {
|
|
9686
9695
|
const { totalX, totalY } = this.dragData;
|
|
9687
9696
|
list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
|
|
@@ -9770,7 +9779,7 @@ class Dragger {
|
|
|
9770
9779
|
this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
|
|
9771
9780
|
}
|
|
9772
9781
|
dragReset() {
|
|
9773
|
-
DragEvent.list = DragEvent.data = this.
|
|
9782
|
+
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9774
9783
|
}
|
|
9775
9784
|
checkDragOut(data) {
|
|
9776
9785
|
const { interaction } = this;
|
|
@@ -9911,6 +9920,7 @@ const config = {
|
|
|
9911
9920
|
touch: {
|
|
9912
9921
|
preventDefault: true
|
|
9913
9922
|
},
|
|
9923
|
+
multiTouch: {},
|
|
9914
9924
|
cursor: true,
|
|
9915
9925
|
keyEvent: true
|
|
9916
9926
|
};
|
|
@@ -10037,6 +10047,8 @@ class InteractionBase {
|
|
|
10037
10047
|
this.pointerUp(data);
|
|
10038
10048
|
}
|
|
10039
10049
|
multiTouch(data, list) {
|
|
10050
|
+
if (this.config.multiTouch.disabled)
|
|
10051
|
+
return;
|
|
10040
10052
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
10041
10053
|
this.rotate(getRotateEventData$1(center, angle, data));
|
|
10042
10054
|
this.zoom(getZoomEventData$1(center, scale, data));
|
|
@@ -10226,7 +10238,7 @@ class InteractionBase {
|
|
|
10226
10238
|
data = this.hoverData;
|
|
10227
10239
|
if (!data)
|
|
10228
10240
|
return;
|
|
10229
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
|
|
10241
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
|
|
10230
10242
|
this.hoverData = data;
|
|
10231
10243
|
}
|
|
10232
10244
|
updateCursor(data) {
|
|
@@ -10248,7 +10260,7 @@ class InteractionBase {
|
|
|
10248
10260
|
const { path } = data;
|
|
10249
10261
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
10250
10262
|
leaf = path.list[i];
|
|
10251
|
-
cursor = leaf.syncEventer
|
|
10263
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
|
|
10252
10264
|
if (cursor)
|
|
10253
10265
|
break;
|
|
10254
10266
|
}
|
|
@@ -10430,7 +10442,7 @@ ui$2.__updateHitCanvas = function () {
|
|
|
10430
10442
|
if (isHitPixel) {
|
|
10431
10443
|
const { renderBounds } = this.__layout;
|
|
10432
10444
|
const size = Platform.image.hitCanvasSize;
|
|
10433
|
-
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds
|
|
10445
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10434
10446
|
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
10435
10447
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10436
10448
|
h.clear();
|
|
@@ -10486,15 +10498,14 @@ ui$2.__hit = function (inner) {
|
|
|
10486
10498
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10487
10499
|
};
|
|
10488
10500
|
|
|
10489
|
-
const ui$1 =
|
|
10490
|
-
|
|
10491
|
-
rect.__updateHitCanvas = function () {
|
|
10501
|
+
const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
|
|
10502
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10492
10503
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10493
10504
|
ui$1.__updateHitCanvas.call(this);
|
|
10494
10505
|
else if (this.__hitCanvas)
|
|
10495
10506
|
this.__hitCanvas = null;
|
|
10496
10507
|
};
|
|
10497
|
-
rect.__hitFill = function (inner) {
|
|
10508
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10498
10509
|
return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10499
10510
|
};
|
|
10500
10511
|
|
|
@@ -11345,9 +11356,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
11345
11356
|
onLoadError(ui, event, image.error);
|
|
11346
11357
|
}
|
|
11347
11358
|
else {
|
|
11348
|
-
|
|
11349
|
-
|
|
11359
|
+
if (firstUse) {
|
|
11360
|
+
ignoreRender(ui, true);
|
|
11350
11361
|
onLoad(ui, event);
|
|
11362
|
+
}
|
|
11351
11363
|
leafPaint.loadId = image.load(() => {
|
|
11352
11364
|
ignoreRender(ui, false);
|
|
11353
11365
|
if (!ui.destroyed) {
|
|
@@ -11959,11 +11971,12 @@ const { trimRight } = TextRowHelper;
|
|
|
11959
11971
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
11960
11972
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
11961
11973
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
11962
|
-
let textDrawData, rows = [], bounds;
|
|
11974
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
11963
11975
|
function createRows(drawData, content, style) {
|
|
11964
11976
|
textDrawData = drawData;
|
|
11965
11977
|
rows = drawData.rows;
|
|
11966
11978
|
bounds = drawData.bounds;
|
|
11979
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
11967
11980
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
11968
11981
|
const { canvas } = Platform;
|
|
11969
11982
|
const { width, height } = bounds;
|
|
@@ -12048,7 +12061,10 @@ function createRows(drawData, content, style) {
|
|
|
12048
12061
|
else {
|
|
12049
12062
|
content.split('\n').forEach(content => {
|
|
12050
12063
|
textDrawData.paraNumber++;
|
|
12051
|
-
|
|
12064
|
+
rowWidth = canvas.measureText(content).width;
|
|
12065
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
12066
|
+
if (findMaxWidth)
|
|
12067
|
+
setMaxWidth();
|
|
12052
12068
|
});
|
|
12053
12069
|
}
|
|
12054
12070
|
}
|
|
@@ -12079,10 +12095,16 @@ function addRow() {
|
|
|
12079
12095
|
row.width = rowWidth;
|
|
12080
12096
|
if (bounds.width)
|
|
12081
12097
|
trimRight(row);
|
|
12098
|
+
else if (findMaxWidth)
|
|
12099
|
+
setMaxWidth();
|
|
12082
12100
|
rows.push(row);
|
|
12083
12101
|
row = { words: [] };
|
|
12084
12102
|
rowWidth = 0;
|
|
12085
12103
|
}
|
|
12104
|
+
function setMaxWidth() {
|
|
12105
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
12106
|
+
textDrawData.maxWidth = rowWidth;
|
|
12107
|
+
}
|
|
12086
12108
|
|
|
12087
12109
|
const CharMode = 0;
|
|
12088
12110
|
const WordMode = 1;
|
|
@@ -12154,34 +12176,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
12154
12176
|
|
|
12155
12177
|
function layoutText(drawData, style) {
|
|
12156
12178
|
const { rows, bounds } = drawData;
|
|
12157
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
12179
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
12158
12180
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
12159
12181
|
let starY = __baseLine;
|
|
12160
12182
|
if (__clipText && realHeight > height) {
|
|
12161
12183
|
realHeight = Math.max(height, __lineHeight);
|
|
12162
12184
|
drawData.overflow = rows.length;
|
|
12163
12185
|
}
|
|
12164
|
-
else {
|
|
12186
|
+
else if (height || autoSizeAlign) {
|
|
12165
12187
|
switch (verticalAlign) {
|
|
12166
12188
|
case 'middle':
|
|
12167
12189
|
y += (height - realHeight) / 2;
|
|
12168
12190
|
break;
|
|
12169
|
-
case 'bottom':
|
|
12170
|
-
y += (height - realHeight);
|
|
12191
|
+
case 'bottom': y += (height - realHeight);
|
|
12171
12192
|
}
|
|
12172
12193
|
}
|
|
12173
12194
|
starY += y;
|
|
12174
|
-
let row, rowX, rowWidth;
|
|
12195
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
12175
12196
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
12176
12197
|
row = rows[i];
|
|
12177
12198
|
row.x = x;
|
|
12178
12199
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
12179
12200
|
switch (textAlign) {
|
|
12180
12201
|
case 'center':
|
|
12181
|
-
row.x += (
|
|
12202
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
12182
12203
|
break;
|
|
12183
|
-
case 'right':
|
|
12184
|
-
row.x += width - row.width;
|
|
12204
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
12185
12205
|
}
|
|
12186
12206
|
}
|
|
12187
12207
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -12286,14 +12306,14 @@ function getDrawData(content, style) {
|
|
|
12286
12306
|
let height = style.__getInput('height') || 0;
|
|
12287
12307
|
const { textDecoration, __font, __padding: padding } = style;
|
|
12288
12308
|
if (padding) {
|
|
12289
|
-
if (width)
|
|
12309
|
+
if (width)
|
|
12310
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
12311
|
+
else if (!style.autoSizeAlign)
|
|
12290
12312
|
x = padding[left];
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
if (
|
|
12313
|
+
if (height)
|
|
12314
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
12315
|
+
else if (!style.autoSizeAlign)
|
|
12294
12316
|
y = padding[top];
|
|
12295
|
-
height -= (padding[top] + padding[bottom]);
|
|
12296
|
-
}
|
|
12297
12317
|
}
|
|
12298
12318
|
const drawData = {
|
|
12299
12319
|
bounds: { x, y, width, height },
|
|
@@ -12313,22 +12333,20 @@ function getDrawData(content, style) {
|
|
|
12313
12333
|
return drawData;
|
|
12314
12334
|
}
|
|
12315
12335
|
function padAutoText(padding, drawData, style, width, height) {
|
|
12316
|
-
if (!width) {
|
|
12336
|
+
if (!width && style.autoSizeAlign) {
|
|
12317
12337
|
switch (style.textAlign) {
|
|
12318
12338
|
case 'left':
|
|
12319
12339
|
offsetText(drawData, 'x', padding[left]);
|
|
12320
12340
|
break;
|
|
12321
|
-
case 'right':
|
|
12322
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
12341
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
12323
12342
|
}
|
|
12324
12343
|
}
|
|
12325
|
-
if (!height) {
|
|
12344
|
+
if (!height && style.autoSizeAlign) {
|
|
12326
12345
|
switch (style.verticalAlign) {
|
|
12327
12346
|
case 'top':
|
|
12328
12347
|
offsetText(drawData, 'y', padding[top]);
|
|
12329
12348
|
break;
|
|
12330
|
-
case 'bottom':
|
|
12331
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
12349
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
12332
12350
|
}
|
|
12333
12351
|
}
|
|
12334
12352
|
}
|