@leafer-ui/core 1.0.0-rc.6 → 1.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +266 -147
- package/dist/core.esm.js +252 -149
- package/dist/core.esm.min.js +1 -1
- package/dist/core.min.cjs +1 -1
- package/package.json +8 -8
package/dist/core.cjs
CHANGED
|
@@ -40,7 +40,7 @@ function design(leafer) {
|
|
|
40
40
|
if (leafer.isApp)
|
|
41
41
|
return;
|
|
42
42
|
leafer.__eventIds.push(leafer.on_(core.MoveEvent.BEFORE_MOVE, (e) => { core.LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(core.ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
43
|
-
const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
|
|
43
|
+
const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
|
|
44
44
|
let { scale } = e;
|
|
45
45
|
if (scale * Math.abs(scaleX) < min)
|
|
46
46
|
scale = min / scaleX;
|
|
@@ -87,6 +87,9 @@ const Export = {};
|
|
|
87
87
|
const emptyPaint = {};
|
|
88
88
|
const debug$1 = core.Debug.get('UIData');
|
|
89
89
|
class UIData extends core.LeafData {
|
|
90
|
+
get __autoWidth() { return !this._width; }
|
|
91
|
+
get __autoHeight() { return !this._height; }
|
|
92
|
+
get __autoBounds() { return !this._width && !this._height; }
|
|
90
93
|
setVisible(value) {
|
|
91
94
|
if (this.__leaf.leafer)
|
|
92
95
|
this.__leaf.leafer.watcher.hasVisible = true;
|
|
@@ -263,6 +266,9 @@ class TextData extends UIData {
|
|
|
263
266
|
class ImageData extends RectData {
|
|
264
267
|
}
|
|
265
268
|
|
|
269
|
+
class CanvasData extends RectData {
|
|
270
|
+
}
|
|
271
|
+
|
|
266
272
|
function effectType(defaultValue) {
|
|
267
273
|
return (target, key) => {
|
|
268
274
|
core.defineLeafAttr(target, key, defaultValue, {
|
|
@@ -473,6 +479,7 @@ const RectRender = {
|
|
|
473
479
|
|
|
474
480
|
var UI_1;
|
|
475
481
|
exports.UI = UI_1 = class UI extends core.Leaf {
|
|
482
|
+
get app() { return this.leafer && this.leafer.app; }
|
|
476
483
|
set scale(value) {
|
|
477
484
|
if (typeof value === 'number') {
|
|
478
485
|
this.scaleX = this.scaleY = value;
|
|
@@ -486,22 +493,25 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
486
493
|
const { scaleX, scaleY } = this;
|
|
487
494
|
return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
|
|
488
495
|
}
|
|
496
|
+
constructor(data) {
|
|
497
|
+
super(data);
|
|
498
|
+
}
|
|
489
499
|
reset(_data) { }
|
|
490
500
|
set(data) {
|
|
491
501
|
Object.assign(this, data);
|
|
492
502
|
}
|
|
493
|
-
get(
|
|
494
|
-
return this.__.__getInputData(
|
|
503
|
+
get() {
|
|
504
|
+
return this.__.__getInputData();
|
|
495
505
|
}
|
|
496
|
-
|
|
497
|
-
find(condition) {
|
|
498
|
-
return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
|
|
506
|
+
createProxyData() { return undefined; }
|
|
507
|
+
find(condition, options) {
|
|
508
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
|
|
499
509
|
}
|
|
500
|
-
findOne(condition) {
|
|
501
|
-
return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
|
|
510
|
+
findOne(condition, options) {
|
|
511
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
502
512
|
}
|
|
503
513
|
getPath(curve) {
|
|
504
|
-
const path = this.__
|
|
514
|
+
const { path } = this.__;
|
|
505
515
|
if (!path)
|
|
506
516
|
return [];
|
|
507
517
|
return curve ? core.PathConvert.toCanvasData(path, true) : path;
|
|
@@ -533,6 +543,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
533
543
|
this.__drawPathByData(canvas, this.__.path);
|
|
534
544
|
}
|
|
535
545
|
__drawPathByData(_drawer, _data) { }
|
|
546
|
+
__drawPathByBox(drawer) {
|
|
547
|
+
const { x, y, width, height } = this.__layout.boxBounds;
|
|
548
|
+
if (this.__.cornerRadius) {
|
|
549
|
+
drawer.roundRect(x, y, width, height, this.__.cornerRadius);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
drawer.rect(x, y, width, height);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
536
555
|
export(filename, options) {
|
|
537
556
|
return Export.export(this, filename, options);
|
|
538
557
|
}
|
|
@@ -574,12 +593,12 @@ __decorate([
|
|
|
574
593
|
__decorate([
|
|
575
594
|
core.eraserType(false)
|
|
576
595
|
], exports.UI.prototype, "isEraser", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
core.dataType(false)
|
|
598
|
+
], exports.UI.prototype, "locked", void 0);
|
|
577
599
|
__decorate([
|
|
578
600
|
core.sortType(0)
|
|
579
601
|
], exports.UI.prototype, "zIndex", void 0);
|
|
580
|
-
__decorate([
|
|
581
|
-
core.dataType()
|
|
582
|
-
], exports.UI.prototype, "locked", void 0);
|
|
583
602
|
__decorate([
|
|
584
603
|
core.positionType(0)
|
|
585
604
|
], exports.UI.prototype, "x", void 0);
|
|
@@ -608,11 +627,17 @@ __decorate([
|
|
|
608
627
|
core.rotationType(0)
|
|
609
628
|
], exports.UI.prototype, "skewY", void 0);
|
|
610
629
|
__decorate([
|
|
611
|
-
core.
|
|
630
|
+
core.autoLayoutType()
|
|
612
631
|
], exports.UI.prototype, "around", void 0);
|
|
613
632
|
__decorate([
|
|
614
633
|
core.dataType(false)
|
|
615
634
|
], exports.UI.prototype, "draggable", void 0);
|
|
635
|
+
__decorate([
|
|
636
|
+
core.dataType(false)
|
|
637
|
+
], exports.UI.prototype, "editable", void 0);
|
|
638
|
+
__decorate([
|
|
639
|
+
core.dataType('size')
|
|
640
|
+
], exports.UI.prototype, "editSize", void 0);
|
|
616
641
|
__decorate([
|
|
617
642
|
core.hitType(true)
|
|
618
643
|
], exports.UI.prototype, "hittable", void 0);
|
|
@@ -665,7 +690,7 @@ __decorate([
|
|
|
665
690
|
core.strokeType(10)
|
|
666
691
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
667
692
|
__decorate([
|
|
668
|
-
core.pathType()
|
|
693
|
+
core.pathType(0)
|
|
669
694
|
], exports.UI.prototype, "cornerRadius", void 0);
|
|
670
695
|
__decorate([
|
|
671
696
|
core.pathType()
|
|
@@ -698,9 +723,9 @@ exports.UI = UI_1 = __decorate([
|
|
|
698
723
|
core.rewriteAble()
|
|
699
724
|
], exports.UI);
|
|
700
725
|
|
|
726
|
+
const matrix = core.MatrixHelper.get();
|
|
701
727
|
exports.Group = class Group extends exports.UI {
|
|
702
728
|
get __tag() { return 'Group'; }
|
|
703
|
-
get resizeable() { return false; }
|
|
704
729
|
set mask(child) {
|
|
705
730
|
if (this.__hasMask)
|
|
706
731
|
this.__removeMask();
|
|
@@ -748,6 +773,14 @@ exports.Group = class Group extends exports.UI {
|
|
|
748
773
|
data.children = this.children.map(child => child.toJSON());
|
|
749
774
|
return data;
|
|
750
775
|
}
|
|
776
|
+
__scaleResize(scaleX, scaleY) {
|
|
777
|
+
const { children } = this;
|
|
778
|
+
for (let i = 0; i < children.length; i++) {
|
|
779
|
+
matrix.a = scaleX;
|
|
780
|
+
matrix.d = scaleY;
|
|
781
|
+
children[i].transform(matrix, true);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
751
784
|
addAt(child, index) {
|
|
752
785
|
this.add(child, index);
|
|
753
786
|
}
|
|
@@ -775,21 +808,17 @@ exports.Rect = class Rect extends exports.UI {
|
|
|
775
808
|
constructor(data) {
|
|
776
809
|
super(data);
|
|
777
810
|
}
|
|
778
|
-
__drawPathByData(
|
|
779
|
-
const { width, height, cornerRadius } = this.__;
|
|
780
|
-
if (cornerRadius) {
|
|
781
|
-
drawer.roundRect(0, 0, width, height, cornerRadius);
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
drawer.rect(0, 0, width, height);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
811
|
+
__drawPathByData(_drawer, _data) { }
|
|
787
812
|
};
|
|
788
813
|
__decorate([
|
|
789
814
|
core.dataProcessor(RectData)
|
|
790
815
|
], exports.Rect.prototype, "__", void 0);
|
|
816
|
+
__decorate([
|
|
817
|
+
core.rewrite(exports.UI.prototype.__drawPathByBox)
|
|
818
|
+
], exports.Rect.prototype, "__drawPathByData", null);
|
|
791
819
|
exports.Rect = __decorate([
|
|
792
820
|
core.useModule(RectRender),
|
|
821
|
+
core.rewriteAble(),
|
|
793
822
|
core.registerUI()
|
|
794
823
|
], exports.Rect);
|
|
795
824
|
|
|
@@ -799,12 +828,20 @@ const bounds = {};
|
|
|
799
828
|
const { copy, add } = core.BoundsHelper;
|
|
800
829
|
exports.Box = class Box extends exports.Group {
|
|
801
830
|
get __tag() { return 'Box'; }
|
|
802
|
-
get resizeable() { return true; }
|
|
803
831
|
constructor(data) {
|
|
804
832
|
super(data);
|
|
805
833
|
this.isBranchLeaf = true;
|
|
806
834
|
this.__layout.renderChanged || this.__layout.renderChange();
|
|
807
835
|
}
|
|
836
|
+
__scaleResize(scaleX, scaleY) {
|
|
837
|
+
if (this.__.__autoBounds && this.children.length) {
|
|
838
|
+
super.__scaleResize(scaleX, scaleY);
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
this.width *= scaleX;
|
|
842
|
+
this.height *= scaleY;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
808
845
|
__updateStrokeSpread() { return 0; }
|
|
809
846
|
__updateRectRenderSpread() { return 0; }
|
|
810
847
|
__updateRenderSpread() {
|
|
@@ -814,7 +851,15 @@ exports.Box = class Box extends exports.Group {
|
|
|
814
851
|
width = this.__.__drawAfterFill ? 0 : 1;
|
|
815
852
|
return width;
|
|
816
853
|
}
|
|
817
|
-
|
|
854
|
+
__updateRectBoxBounds() { }
|
|
855
|
+
__updateBoxBounds() {
|
|
856
|
+
if (this.__.__autoBounds && this.children.length) {
|
|
857
|
+
super.__updateBoxBounds();
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
this.__updateRectBoxBounds();
|
|
861
|
+
}
|
|
862
|
+
}
|
|
818
863
|
__updateStrokeBounds() { }
|
|
819
864
|
__updateRenderBounds() {
|
|
820
865
|
this.__updateRectRenderBounds();
|
|
@@ -866,7 +911,7 @@ __decorate([
|
|
|
866
911
|
], exports.Box.prototype, "__updateRectRenderSpread", null);
|
|
867
912
|
__decorate([
|
|
868
913
|
core.rewrite(rect.__updateBoxBounds)
|
|
869
|
-
], exports.Box.prototype, "
|
|
914
|
+
], exports.Box.prototype, "__updateRectBoxBounds", null);
|
|
870
915
|
__decorate([
|
|
871
916
|
core.rewrite(rect.__updateStrokeBounds)
|
|
872
917
|
], exports.Box.prototype, "__updateStrokeBounds", null);
|
|
@@ -894,6 +939,7 @@ exports.Frame = class Frame extends exports.Box {
|
|
|
894
939
|
get __tag() { return 'Frame'; }
|
|
895
940
|
constructor(data) {
|
|
896
941
|
super(data);
|
|
942
|
+
this.isFrame = true;
|
|
897
943
|
if (!this.__.fill)
|
|
898
944
|
this.__.fill = '#FFFFFF';
|
|
899
945
|
}
|
|
@@ -934,7 +980,7 @@ exports.Ellipse = class Ellipse extends exports.UI {
|
|
|
934
980
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
935
981
|
}
|
|
936
982
|
if (core.Platform.ellipseToCurve)
|
|
937
|
-
this.__.path =
|
|
983
|
+
this.__.path = this.getPath(true);
|
|
938
984
|
}
|
|
939
985
|
else {
|
|
940
986
|
if (startAngle || endAngle) {
|
|
@@ -964,47 +1010,118 @@ exports.Ellipse = __decorate([
|
|
|
964
1010
|
core.registerUI()
|
|
965
1011
|
], exports.Ellipse);
|
|
966
1012
|
|
|
967
|
-
const {
|
|
968
|
-
const {
|
|
969
|
-
const { toBounds: toBounds$
|
|
970
|
-
exports.
|
|
971
|
-
get __tag() { return '
|
|
972
|
-
get
|
|
1013
|
+
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = core.PathCommandDataHelper;
|
|
1014
|
+
const { rotate, getAngle, getDistance, defaultPoint } = core.PointHelper;
|
|
1015
|
+
const { toBounds: toBounds$1 } = core.PathBounds;
|
|
1016
|
+
exports.Line = class Line extends exports.UI {
|
|
1017
|
+
get __tag() { return 'Line'; }
|
|
1018
|
+
get toPoint() {
|
|
1019
|
+
const { width, rotation } = this.__;
|
|
1020
|
+
const to = { x: 0, y: 0 };
|
|
1021
|
+
if (width)
|
|
1022
|
+
to.x = width;
|
|
1023
|
+
if (rotation)
|
|
1024
|
+
rotate(to, rotation);
|
|
1025
|
+
return to;
|
|
1026
|
+
}
|
|
1027
|
+
set toPoint(value) {
|
|
1028
|
+
this.width = getDistance(defaultPoint, value);
|
|
1029
|
+
this.rotation = getAngle(defaultPoint, value);
|
|
1030
|
+
if (this.height)
|
|
1031
|
+
this.height = 0;
|
|
1032
|
+
}
|
|
973
1033
|
constructor(data) {
|
|
974
1034
|
super(data);
|
|
975
1035
|
}
|
|
976
1036
|
__updatePath() {
|
|
977
1037
|
const path = this.__.path = [];
|
|
978
1038
|
if (this.__.points) {
|
|
979
|
-
drawPoints$1(path, this.__.points, false
|
|
1039
|
+
drawPoints$1(path, this.__.points, false);
|
|
980
1040
|
}
|
|
981
1041
|
else {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
moveTo$2(path, rx, 0);
|
|
985
|
-
for (let i = 1; i < sides; i++) {
|
|
986
|
-
lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
987
|
-
}
|
|
1042
|
+
moveTo$2(path, 0, 0);
|
|
1043
|
+
lineTo$2(path, this.width, 0);
|
|
988
1044
|
}
|
|
989
|
-
closePath$1(path);
|
|
990
1045
|
}
|
|
991
1046
|
__updateRenderPath() {
|
|
992
1047
|
if (this.__.points && this.__.curve) {
|
|
993
|
-
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve,
|
|
1048
|
+
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
|
|
994
1049
|
}
|
|
995
1050
|
else {
|
|
996
1051
|
super.__updateRenderPath();
|
|
997
1052
|
}
|
|
998
1053
|
}
|
|
999
1054
|
__updateBoxBounds() {
|
|
1000
|
-
if (this.
|
|
1001
|
-
toBounds$
|
|
1002
|
-
this.__updateNaturalSize();
|
|
1055
|
+
if (this.points) {
|
|
1056
|
+
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1003
1057
|
}
|
|
1004
1058
|
else {
|
|
1005
1059
|
super.__updateBoxBounds();
|
|
1006
1060
|
}
|
|
1007
1061
|
}
|
|
1062
|
+
__scaleResize(scaleX, scaleY) {
|
|
1063
|
+
if (this.points) {
|
|
1064
|
+
core.PathScaler.scalePoints(this.__.points, scaleX, scaleY);
|
|
1065
|
+
this.points = this.__.points;
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
if (this.__tag === 'Line') {
|
|
1069
|
+
const point = this.toPoint;
|
|
1070
|
+
point.x *= scaleX;
|
|
1071
|
+
point.y *= scaleY;
|
|
1072
|
+
this.toPoint = point;
|
|
1073
|
+
}
|
|
1074
|
+
else {
|
|
1075
|
+
super.__scaleResize(scaleX, scaleY);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
__decorate([
|
|
1081
|
+
core.dataProcessor(LineData)
|
|
1082
|
+
], exports.Line.prototype, "__", void 0);
|
|
1083
|
+
__decorate([
|
|
1084
|
+
core.affectStrokeBoundsType('center')
|
|
1085
|
+
], exports.Line.prototype, "strokeAlign", void 0);
|
|
1086
|
+
__decorate([
|
|
1087
|
+
core.boundsType(0)
|
|
1088
|
+
], exports.Line.prototype, "height", void 0);
|
|
1089
|
+
__decorate([
|
|
1090
|
+
core.pathType()
|
|
1091
|
+
], exports.Line.prototype, "points", void 0);
|
|
1092
|
+
__decorate([
|
|
1093
|
+
core.pathType(0)
|
|
1094
|
+
], exports.Line.prototype, "curve", void 0);
|
|
1095
|
+
exports.Line = __decorate([
|
|
1096
|
+
core.registerUI()
|
|
1097
|
+
], exports.Line);
|
|
1098
|
+
|
|
1099
|
+
const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
|
|
1100
|
+
const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = core.PathCommandDataHelper;
|
|
1101
|
+
const line = exports.Line.prototype;
|
|
1102
|
+
exports.Polygon = class Polygon extends exports.UI {
|
|
1103
|
+
get __tag() { return 'Polygon'; }
|
|
1104
|
+
constructor(data) {
|
|
1105
|
+
super(data);
|
|
1106
|
+
}
|
|
1107
|
+
__updatePath() {
|
|
1108
|
+
const path = this.__.path = [];
|
|
1109
|
+
if (this.__.points) {
|
|
1110
|
+
drawPoints(path, this.__.points, false, true);
|
|
1111
|
+
}
|
|
1112
|
+
else {
|
|
1113
|
+
const { width, height, sides } = this.__;
|
|
1114
|
+
const rx = width / 2, ry = height / 2;
|
|
1115
|
+
moveTo$1(path, rx, 0);
|
|
1116
|
+
for (let i = 1; i < sides; i++) {
|
|
1117
|
+
lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
closePath$1(path);
|
|
1121
|
+
}
|
|
1122
|
+
__updateRenderPath() { }
|
|
1123
|
+
__updateBoxBounds() { }
|
|
1124
|
+
__scaleResize(_scaleX, _scaleY) { }
|
|
1008
1125
|
};
|
|
1009
1126
|
__decorate([
|
|
1010
1127
|
core.dataProcessor(PolygonData)
|
|
@@ -1018,12 +1135,22 @@ __decorate([
|
|
|
1018
1135
|
__decorate([
|
|
1019
1136
|
core.pathType(0)
|
|
1020
1137
|
], exports.Polygon.prototype, "curve", void 0);
|
|
1138
|
+
__decorate([
|
|
1139
|
+
core.rewrite(line.__updateRenderPath)
|
|
1140
|
+
], exports.Polygon.prototype, "__updateRenderPath", null);
|
|
1141
|
+
__decorate([
|
|
1142
|
+
core.rewrite(line.__updateBoxBounds)
|
|
1143
|
+
], exports.Polygon.prototype, "__updateBoxBounds", null);
|
|
1144
|
+
__decorate([
|
|
1145
|
+
core.rewrite(line.__scaleResize)
|
|
1146
|
+
], exports.Polygon.prototype, "__scaleResize", null);
|
|
1021
1147
|
exports.Polygon = __decorate([
|
|
1148
|
+
core.rewriteAble(),
|
|
1022
1149
|
core.registerUI()
|
|
1023
1150
|
], exports.Polygon);
|
|
1024
1151
|
|
|
1025
1152
|
const { sin, cos, PI } = Math;
|
|
1026
|
-
const { moveTo
|
|
1153
|
+
const { moveTo, lineTo, closePath } = core.PathCommandDataHelper;
|
|
1027
1154
|
exports.Star = class Star extends exports.UI {
|
|
1028
1155
|
get __tag() { return 'Star'; }
|
|
1029
1156
|
constructor(data) {
|
|
@@ -1033,9 +1160,9 @@ exports.Star = class Star extends exports.UI {
|
|
|
1033
1160
|
const { width, height, corners, innerRadius } = this.__;
|
|
1034
1161
|
const rx = width / 2, ry = height / 2;
|
|
1035
1162
|
const path = this.__.path = [];
|
|
1036
|
-
moveTo
|
|
1163
|
+
moveTo(path, rx, 0);
|
|
1037
1164
|
for (let i = 1; i < corners * 2; i++) {
|
|
1038
|
-
lineTo
|
|
1165
|
+
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
|
|
1039
1166
|
}
|
|
1040
1167
|
closePath(path);
|
|
1041
1168
|
}
|
|
@@ -1053,77 +1180,6 @@ exports.Star = __decorate([
|
|
|
1053
1180
|
core.registerUI()
|
|
1054
1181
|
], exports.Star);
|
|
1055
1182
|
|
|
1056
|
-
const { moveTo, lineTo, drawPoints } = core.PathCommandDataHelper;
|
|
1057
|
-
const { rotate, getAngle, getDistance, defaultPoint } = core.PointHelper;
|
|
1058
|
-
const { toBounds: toBounds$1 } = core.PathBounds;
|
|
1059
|
-
exports.Line = class Line extends exports.UI {
|
|
1060
|
-
get __tag() { return 'Line'; }
|
|
1061
|
-
get resizeable() { return !this.points; }
|
|
1062
|
-
get toPoint() {
|
|
1063
|
-
const { width, rotation } = this.__;
|
|
1064
|
-
const to = { x: 0, y: 0 };
|
|
1065
|
-
if (width)
|
|
1066
|
-
to.x = width;
|
|
1067
|
-
if (rotation)
|
|
1068
|
-
rotate(to, rotation);
|
|
1069
|
-
return to;
|
|
1070
|
-
}
|
|
1071
|
-
set toPoint(value) {
|
|
1072
|
-
this.width = getDistance(defaultPoint, value);
|
|
1073
|
-
this.rotation = getAngle(defaultPoint, value);
|
|
1074
|
-
if (this.height)
|
|
1075
|
-
this.height = 0;
|
|
1076
|
-
}
|
|
1077
|
-
constructor(data) {
|
|
1078
|
-
super(data);
|
|
1079
|
-
}
|
|
1080
|
-
__updatePath() {
|
|
1081
|
-
const path = this.__.path = [];
|
|
1082
|
-
if (this.__.points) {
|
|
1083
|
-
drawPoints(path, this.__.points, false);
|
|
1084
|
-
}
|
|
1085
|
-
else {
|
|
1086
|
-
moveTo(path, 0, 0);
|
|
1087
|
-
lineTo(path, this.width, 0);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
__updateRenderPath() {
|
|
1091
|
-
if (this.__.points && this.__.curve) {
|
|
1092
|
-
drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
|
|
1093
|
-
}
|
|
1094
|
-
else {
|
|
1095
|
-
super.__updateRenderPath();
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
__updateBoxBounds() {
|
|
1099
|
-
if (this.points) {
|
|
1100
|
-
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1101
|
-
this.__updateNaturalSize();
|
|
1102
|
-
}
|
|
1103
|
-
else {
|
|
1104
|
-
super.__updateBoxBounds();
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
__decorate([
|
|
1109
|
-
core.dataProcessor(LineData)
|
|
1110
|
-
], exports.Line.prototype, "__", void 0);
|
|
1111
|
-
__decorate([
|
|
1112
|
-
core.affectStrokeBoundsType('center')
|
|
1113
|
-
], exports.Line.prototype, "strokeAlign", void 0);
|
|
1114
|
-
__decorate([
|
|
1115
|
-
core.boundsType(0)
|
|
1116
|
-
], exports.Line.prototype, "height", void 0);
|
|
1117
|
-
__decorate([
|
|
1118
|
-
core.pathType()
|
|
1119
|
-
], exports.Line.prototype, "points", void 0);
|
|
1120
|
-
__decorate([
|
|
1121
|
-
core.pathType(0)
|
|
1122
|
-
], exports.Line.prototype, "curve", void 0);
|
|
1123
|
-
exports.Line = __decorate([
|
|
1124
|
-
core.registerUI()
|
|
1125
|
-
], exports.Line);
|
|
1126
|
-
|
|
1127
1183
|
exports.Image = class Image extends exports.Rect {
|
|
1128
1184
|
get __tag() { return 'Image'; }
|
|
1129
1185
|
get ready() { return this.image ? this.image.ready : false; }
|
|
@@ -1174,7 +1230,7 @@ exports.Canvas = class Canvas extends exports.Rect {
|
|
|
1174
1230
|
this.__.__drawAfterFill = true;
|
|
1175
1231
|
}
|
|
1176
1232
|
draw(ui, offset, scale, rotation) {
|
|
1177
|
-
ui.__layout.
|
|
1233
|
+
ui.__layout.update();
|
|
1178
1234
|
const matrix = new core.Matrix(ui.__world);
|
|
1179
1235
|
matrix.invert();
|
|
1180
1236
|
const m = new core.Matrix();
|
|
@@ -1184,7 +1240,7 @@ exports.Canvas = class Canvas extends exports.Rect {
|
|
|
1184
1240
|
typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
|
|
1185
1241
|
if (rotation)
|
|
1186
1242
|
m.rotate(rotation);
|
|
1187
|
-
matrix.
|
|
1243
|
+
matrix.multiplyParent(m);
|
|
1188
1244
|
ui.__render(this.canvas, { matrix });
|
|
1189
1245
|
this.paint();
|
|
1190
1246
|
}
|
|
@@ -1244,11 +1300,11 @@ exports.Canvas = __decorate([
|
|
|
1244
1300
|
core.registerUI()
|
|
1245
1301
|
], exports.Canvas);
|
|
1246
1302
|
|
|
1247
|
-
const { copyAndSpread, includes, spread,
|
|
1303
|
+
const { copyAndSpread, includes, spread, setList } = core.BoundsHelper;
|
|
1248
1304
|
exports.Text = class Text extends exports.UI {
|
|
1249
1305
|
get __tag() { return 'Text'; }
|
|
1250
1306
|
get textDrawData() {
|
|
1251
|
-
this.__layout.
|
|
1307
|
+
this.__layout.update();
|
|
1252
1308
|
return this.__.__textDrawData;
|
|
1253
1309
|
}
|
|
1254
1310
|
constructor(data) {
|
|
@@ -1279,33 +1335,45 @@ exports.Text = class Text extends exports.UI {
|
|
|
1279
1335
|
const data = this.__;
|
|
1280
1336
|
const layout = this.__layout;
|
|
1281
1337
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
1282
|
-
const
|
|
1283
|
-
const
|
|
1338
|
+
const autoWidth = data.__autoWidth;
|
|
1339
|
+
const autoHeight = data.__autoHeight;
|
|
1284
1340
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
1285
1341
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
1286
1342
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
1287
1343
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
1288
|
-
data.__clipText = textOverflow !== 'show' &&
|
|
1344
|
+
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
1289
1345
|
this.__updateTextDrawData();
|
|
1290
1346
|
const { bounds } = data.__textDrawData;
|
|
1291
1347
|
const b = layout.boxBounds;
|
|
1292
1348
|
if (data.__lineHeight < fontSize)
|
|
1293
1349
|
spread(bounds, fontSize / 2);
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1350
|
+
if (autoWidth || autoHeight) {
|
|
1351
|
+
b.x = autoWidth ? bounds.x : 0;
|
|
1352
|
+
b.y = autoHeight ? bounds.y : 0;
|
|
1353
|
+
b.width = autoWidth ? bounds.width : data.width;
|
|
1354
|
+
b.height = autoHeight ? bounds.height : data.height;
|
|
1355
|
+
const { padding } = data;
|
|
1356
|
+
if (padding) {
|
|
1357
|
+
const [top, right, bottom, left] = core.MathHelper.fourNumber(padding);
|
|
1358
|
+
if (autoWidth) {
|
|
1359
|
+
b.x -= left;
|
|
1360
|
+
b.width += (right + left);
|
|
1361
|
+
}
|
|
1362
|
+
if (autoHeight) {
|
|
1363
|
+
b.y -= top;
|
|
1364
|
+
b.height += (bottom + top);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
this.__updateNaturalSize();
|
|
1296
1368
|
}
|
|
1297
1369
|
else {
|
|
1298
|
-
|
|
1299
|
-
b.y = height ? 0 : bounds.y;
|
|
1300
|
-
b.width = width ? width : bounds.width;
|
|
1301
|
-
b.height = height ? height : bounds.height;
|
|
1302
|
-
this.__updateNaturalSize();
|
|
1370
|
+
super.__updateBoxBounds();
|
|
1303
1371
|
}
|
|
1304
1372
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1305
1373
|
if (contentBounds !== layout.contentBounds) {
|
|
1306
1374
|
layout.contentBounds = contentBounds;
|
|
1307
1375
|
layout.renderChanged = true;
|
|
1308
|
-
|
|
1376
|
+
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
1309
1377
|
}
|
|
1310
1378
|
else {
|
|
1311
1379
|
data.__textBoxBounds = contentBounds;
|
|
@@ -1333,6 +1401,9 @@ __decorate([
|
|
|
1333
1401
|
__decorate([
|
|
1334
1402
|
core.boundsType(0)
|
|
1335
1403
|
], exports.Text.prototype, "padding", void 0);
|
|
1404
|
+
__decorate([
|
|
1405
|
+
core.surfaceType('#000000')
|
|
1406
|
+
], exports.Text.prototype, "fill", void 0);
|
|
1336
1407
|
__decorate([
|
|
1337
1408
|
core.affectStrokeBoundsType('outside')
|
|
1338
1409
|
], exports.Text.prototype, "strokeAlign", void 0);
|
|
@@ -1391,13 +1462,15 @@ exports.Text = __decorate([
|
|
|
1391
1462
|
const { toBounds } = core.PathBounds;
|
|
1392
1463
|
exports.Path = class Path extends exports.UI {
|
|
1393
1464
|
get __tag() { return 'Path'; }
|
|
1394
|
-
get resizeable() { return false; }
|
|
1395
1465
|
constructor(data) {
|
|
1396
1466
|
super(data);
|
|
1397
1467
|
}
|
|
1468
|
+
__scaleResize(scaleX, scaleY) {
|
|
1469
|
+
core.PathScaler.scale(this.__.path, scaleX, scaleY);
|
|
1470
|
+
this.path = this.__.path;
|
|
1471
|
+
}
|
|
1398
1472
|
__updateBoxBounds() {
|
|
1399
1473
|
toBounds(this.__.path, this.__layout.boxBounds);
|
|
1400
|
-
this.__updateNaturalSize();
|
|
1401
1474
|
}
|
|
1402
1475
|
};
|
|
1403
1476
|
__decorate([
|
|
@@ -1466,6 +1539,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1466
1539
|
get __tag() { return 'Leafer'; }
|
|
1467
1540
|
get isApp() { return false; }
|
|
1468
1541
|
get app() { return this.parent || this; }
|
|
1542
|
+
get layoutLocked() { return !this.layouter.running; }
|
|
1469
1543
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
1470
1544
|
constructor(userConfig, data) {
|
|
1471
1545
|
super(data);
|
|
@@ -1558,13 +1632,18 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1558
1632
|
this.emitLeafer(core.LeaferEvent.STOP);
|
|
1559
1633
|
}
|
|
1560
1634
|
}
|
|
1635
|
+
unlockLayout() {
|
|
1636
|
+
this.layouter.start();
|
|
1637
|
+
this.updateLayout();
|
|
1638
|
+
}
|
|
1639
|
+
lockLayout() {
|
|
1640
|
+
this.updateLayout();
|
|
1641
|
+
this.layouter.stop();
|
|
1642
|
+
}
|
|
1561
1643
|
resize(size) {
|
|
1562
1644
|
const data = core.DataHelper.copyAttrs({}, size, core.canvasSizeAttrs);
|
|
1563
1645
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
1564
1646
|
}
|
|
1565
|
-
forceLayout() {
|
|
1566
|
-
this.__layout.checkUpdate(true);
|
|
1567
|
-
}
|
|
1568
1647
|
forceFullRender() {
|
|
1569
1648
|
this.renderer.addBlock(this.canvas.bounds);
|
|
1570
1649
|
if (this.viewReady)
|
|
@@ -1710,7 +1789,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1710
1789
|
}
|
|
1711
1790
|
}
|
|
1712
1791
|
__checkUpdateLayout() {
|
|
1713
|
-
this.__layout.
|
|
1792
|
+
this.__layout.update();
|
|
1714
1793
|
}
|
|
1715
1794
|
emitLeafer(type) {
|
|
1716
1795
|
this.emitEvent(new core.LeaferEvent(type, this));
|
|
@@ -1770,6 +1849,22 @@ exports.Leafer = __decorate([
|
|
|
1770
1849
|
exports.App = class App extends exports.Leafer {
|
|
1771
1850
|
get __tag() { return 'App'; }
|
|
1772
1851
|
get isApp() { return true; }
|
|
1852
|
+
constructor(userConfig, data) {
|
|
1853
|
+
super(userConfig, data);
|
|
1854
|
+
if (userConfig) {
|
|
1855
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
1856
|
+
if (ground)
|
|
1857
|
+
this.ground = this.addLeafer(ground);
|
|
1858
|
+
if (tree || editor)
|
|
1859
|
+
this.tree = this.addLeafer(tree);
|
|
1860
|
+
if (sky || editor)
|
|
1861
|
+
this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
|
|
1862
|
+
if (editor) {
|
|
1863
|
+
this.editor = core.Creator.editor(editor);
|
|
1864
|
+
this.sky.add(this.editor);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1773
1868
|
__setApp() {
|
|
1774
1869
|
const { canvas } = this;
|
|
1775
1870
|
const { realCanvas, view } = this.config;
|
|
@@ -1786,12 +1881,20 @@ exports.App = class App extends exports.Leafer {
|
|
|
1786
1881
|
}
|
|
1787
1882
|
start() {
|
|
1788
1883
|
super.start();
|
|
1789
|
-
this.children.forEach(leafer =>
|
|
1884
|
+
this.children.forEach(leafer => leafer.start());
|
|
1790
1885
|
}
|
|
1791
1886
|
stop() {
|
|
1792
|
-
this.children.forEach(leafer =>
|
|
1887
|
+
this.children.forEach(leafer => leafer.stop());
|
|
1793
1888
|
super.stop();
|
|
1794
1889
|
}
|
|
1890
|
+
unlockLayout() {
|
|
1891
|
+
super.unlockLayout();
|
|
1892
|
+
this.children.forEach(leafer => leafer.unlockLayout());
|
|
1893
|
+
}
|
|
1894
|
+
lockLayout() {
|
|
1895
|
+
super.lockLayout();
|
|
1896
|
+
this.children.forEach(leafer => leafer.lockLayout());
|
|
1897
|
+
}
|
|
1795
1898
|
addLeafer(merge) {
|
|
1796
1899
|
const leafer = new exports.Leafer(merge);
|
|
1797
1900
|
this.add(leafer);
|
|
@@ -1810,7 +1913,7 @@ exports.App = class App extends exports.Leafer {
|
|
|
1810
1913
|
}
|
|
1811
1914
|
__onPropertyChange() {
|
|
1812
1915
|
if (core.Debug.showHitView)
|
|
1813
|
-
this.children.forEach(leafer =>
|
|
1916
|
+
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
1814
1917
|
}
|
|
1815
1918
|
__onCreated() {
|
|
1816
1919
|
this.created = this.children.every(child => child.created);
|
|
@@ -1832,14 +1935,14 @@ exports.App = class App extends exports.Leafer {
|
|
|
1832
1935
|
this.renderer.update();
|
|
1833
1936
|
}
|
|
1834
1937
|
__render(canvas, _options) {
|
|
1835
|
-
this.children.forEach(leafer =>
|
|
1938
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
1836
1939
|
}
|
|
1837
1940
|
__onResize(event) {
|
|
1838
|
-
this.children.forEach(leafer =>
|
|
1941
|
+
this.children.forEach(leafer => leafer.resize(event));
|
|
1839
1942
|
super.__onResize(event);
|
|
1840
1943
|
}
|
|
1841
1944
|
__checkUpdateLayout() {
|
|
1842
|
-
this.children.forEach(leafer =>
|
|
1945
|
+
this.children.forEach(leafer => leafer.__layout.update());
|
|
1843
1946
|
}
|
|
1844
1947
|
__getChildConfig(userConfig) {
|
|
1845
1948
|
let config = Object.assign({}, this.config);
|
|
@@ -1865,16 +1968,32 @@ exports.App = __decorate([
|
|
|
1865
1968
|
], exports.App);
|
|
1866
1969
|
|
|
1867
1970
|
exports.Animate = Animate;
|
|
1971
|
+
exports.BoxData = BoxData;
|
|
1972
|
+
exports.CanvasData = CanvasData;
|
|
1868
1973
|
exports.ColorConvert = ColorConvert;
|
|
1869
1974
|
exports.Effect = Effect;
|
|
1975
|
+
exports.EllipseData = EllipseData;
|
|
1870
1976
|
exports.Export = Export;
|
|
1977
|
+
exports.FrameData = FrameData;
|
|
1978
|
+
exports.GroupData = GroupData;
|
|
1979
|
+
exports.ImageData = ImageData;
|
|
1980
|
+
exports.LeaferData = LeaferData;
|
|
1871
1981
|
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
1982
|
+
exports.LineData = LineData;
|
|
1872
1983
|
exports.Paint = Paint;
|
|
1984
|
+
exports.PathData = PathData;
|
|
1985
|
+
exports.PenData = PenData;
|
|
1986
|
+
exports.PolygonData = PolygonData;
|
|
1987
|
+
exports.RectData = RectData;
|
|
1873
1988
|
exports.RectRender = RectRender;
|
|
1989
|
+
exports.StarData = StarData;
|
|
1874
1990
|
exports.TextConvert = TextConvert;
|
|
1991
|
+
exports.TextData = TextData;
|
|
1875
1992
|
exports.UIBounds = UIBounds;
|
|
1993
|
+
exports.UIData = UIData;
|
|
1876
1994
|
exports.UIHit = UIHit;
|
|
1877
1995
|
exports.UIRender = UIRender;
|
|
1996
|
+
exports.UnitConvert = UnitConvert;
|
|
1878
1997
|
exports.effectType = effectType;
|
|
1879
1998
|
exports.resizeType = resizeType;
|
|
1880
1999
|
Object.keys(core).forEach(function (k) {
|