@leafer-ui/core 1.0.0-rc.5 → 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 +281 -141
- package/dist/core.esm.js +267 -143
- package/dist/core.esm.min.js +1 -1
- package/dist/core.min.cjs +1 -1
- package/package.json +10 -9
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,6 +493,9 @@ 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);
|
|
@@ -493,8 +503,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
493
503
|
get() {
|
|
494
504
|
return this.__.__getInputData();
|
|
495
505
|
}
|
|
506
|
+
createProxyData() { return undefined; }
|
|
507
|
+
find(condition, options) {
|
|
508
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
|
|
509
|
+
}
|
|
510
|
+
findOne(condition, options) {
|
|
511
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
512
|
+
}
|
|
496
513
|
getPath(curve) {
|
|
497
|
-
const path = this.__
|
|
514
|
+
const { path } = this.__;
|
|
498
515
|
if (!path)
|
|
499
516
|
return [];
|
|
500
517
|
return curve ? core.PathConvert.toCanvasData(path, true) : path;
|
|
@@ -526,6 +543,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
526
543
|
this.__drawPathByData(canvas, this.__.path);
|
|
527
544
|
}
|
|
528
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
|
+
}
|
|
529
555
|
export(filename, options) {
|
|
530
556
|
return Export.export(this, filename, options);
|
|
531
557
|
}
|
|
@@ -567,12 +593,12 @@ __decorate([
|
|
|
567
593
|
__decorate([
|
|
568
594
|
core.eraserType(false)
|
|
569
595
|
], exports.UI.prototype, "isEraser", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
core.dataType(false)
|
|
598
|
+
], exports.UI.prototype, "locked", void 0);
|
|
570
599
|
__decorate([
|
|
571
600
|
core.sortType(0)
|
|
572
601
|
], exports.UI.prototype, "zIndex", void 0);
|
|
573
|
-
__decorate([
|
|
574
|
-
core.dataType()
|
|
575
|
-
], exports.UI.prototype, "locked", void 0);
|
|
576
602
|
__decorate([
|
|
577
603
|
core.positionType(0)
|
|
578
604
|
], exports.UI.prototype, "x", void 0);
|
|
@@ -601,11 +627,17 @@ __decorate([
|
|
|
601
627
|
core.rotationType(0)
|
|
602
628
|
], exports.UI.prototype, "skewY", void 0);
|
|
603
629
|
__decorate([
|
|
604
|
-
core.
|
|
630
|
+
core.autoLayoutType()
|
|
605
631
|
], exports.UI.prototype, "around", void 0);
|
|
606
632
|
__decorate([
|
|
607
633
|
core.dataType(false)
|
|
608
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);
|
|
609
641
|
__decorate([
|
|
610
642
|
core.hitType(true)
|
|
611
643
|
], exports.UI.prototype, "hittable", void 0);
|
|
@@ -615,6 +647,9 @@ __decorate([
|
|
|
615
647
|
__decorate([
|
|
616
648
|
core.strokeType('path')
|
|
617
649
|
], exports.UI.prototype, "hitStroke", void 0);
|
|
650
|
+
__decorate([
|
|
651
|
+
core.hitType(false)
|
|
652
|
+
], exports.UI.prototype, "hitBox", void 0);
|
|
618
653
|
__decorate([
|
|
619
654
|
core.hitType(true)
|
|
620
655
|
], exports.UI.prototype, "hitChildren", void 0);
|
|
@@ -655,7 +690,7 @@ __decorate([
|
|
|
655
690
|
core.strokeType(10)
|
|
656
691
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
657
692
|
__decorate([
|
|
658
|
-
core.pathType()
|
|
693
|
+
core.pathType(0)
|
|
659
694
|
], exports.UI.prototype, "cornerRadius", void 0);
|
|
660
695
|
__decorate([
|
|
661
696
|
core.pathType()
|
|
@@ -688,9 +723,9 @@ exports.UI = UI_1 = __decorate([
|
|
|
688
723
|
core.rewriteAble()
|
|
689
724
|
], exports.UI);
|
|
690
725
|
|
|
726
|
+
const matrix = core.MatrixHelper.get();
|
|
691
727
|
exports.Group = class Group extends exports.UI {
|
|
692
728
|
get __tag() { return 'Group'; }
|
|
693
|
-
get resizeable() { return false; }
|
|
694
729
|
set mask(child) {
|
|
695
730
|
if (this.__hasMask)
|
|
696
731
|
this.__removeMask();
|
|
@@ -738,6 +773,14 @@ exports.Group = class Group extends exports.UI {
|
|
|
738
773
|
data.children = this.children.map(child => child.toJSON());
|
|
739
774
|
return data;
|
|
740
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
|
+
}
|
|
741
784
|
addAt(child, index) {
|
|
742
785
|
this.add(child, index);
|
|
743
786
|
}
|
|
@@ -765,21 +808,17 @@ exports.Rect = class Rect extends exports.UI {
|
|
|
765
808
|
constructor(data) {
|
|
766
809
|
super(data);
|
|
767
810
|
}
|
|
768
|
-
__drawPathByData(
|
|
769
|
-
const { width, height, cornerRadius } = this.__;
|
|
770
|
-
if (cornerRadius) {
|
|
771
|
-
drawer.roundRect(0, 0, width, height, cornerRadius);
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
drawer.rect(0, 0, width, height);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
811
|
+
__drawPathByData(_drawer, _data) { }
|
|
777
812
|
};
|
|
778
813
|
__decorate([
|
|
779
814
|
core.dataProcessor(RectData)
|
|
780
815
|
], exports.Rect.prototype, "__", void 0);
|
|
816
|
+
__decorate([
|
|
817
|
+
core.rewrite(exports.UI.prototype.__drawPathByBox)
|
|
818
|
+
], exports.Rect.prototype, "__drawPathByData", null);
|
|
781
819
|
exports.Rect = __decorate([
|
|
782
820
|
core.useModule(RectRender),
|
|
821
|
+
core.rewriteAble(),
|
|
783
822
|
core.registerUI()
|
|
784
823
|
], exports.Rect);
|
|
785
824
|
|
|
@@ -789,12 +828,20 @@ const bounds = {};
|
|
|
789
828
|
const { copy, add } = core.BoundsHelper;
|
|
790
829
|
exports.Box = class Box extends exports.Group {
|
|
791
830
|
get __tag() { return 'Box'; }
|
|
792
|
-
get resizeable() { return true; }
|
|
793
831
|
constructor(data) {
|
|
794
832
|
super(data);
|
|
795
833
|
this.isBranchLeaf = true;
|
|
796
834
|
this.__layout.renderChanged || this.__layout.renderChange();
|
|
797
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
|
+
}
|
|
798
845
|
__updateStrokeSpread() { return 0; }
|
|
799
846
|
__updateRectRenderSpread() { return 0; }
|
|
800
847
|
__updateRenderSpread() {
|
|
@@ -804,7 +851,15 @@ exports.Box = class Box extends exports.Group {
|
|
|
804
851
|
width = this.__.__drawAfterFill ? 0 : 1;
|
|
805
852
|
return width;
|
|
806
853
|
}
|
|
807
|
-
|
|
854
|
+
__updateRectBoxBounds() { }
|
|
855
|
+
__updateBoxBounds() {
|
|
856
|
+
if (this.__.__autoBounds && this.children.length) {
|
|
857
|
+
super.__updateBoxBounds();
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
this.__updateRectBoxBounds();
|
|
861
|
+
}
|
|
862
|
+
}
|
|
808
863
|
__updateStrokeBounds() { }
|
|
809
864
|
__updateRenderBounds() {
|
|
810
865
|
this.__updateRectRenderBounds();
|
|
@@ -856,7 +911,7 @@ __decorate([
|
|
|
856
911
|
], exports.Box.prototype, "__updateRectRenderSpread", null);
|
|
857
912
|
__decorate([
|
|
858
913
|
core.rewrite(rect.__updateBoxBounds)
|
|
859
|
-
], exports.Box.prototype, "
|
|
914
|
+
], exports.Box.prototype, "__updateRectBoxBounds", null);
|
|
860
915
|
__decorate([
|
|
861
916
|
core.rewrite(rect.__updateStrokeBounds)
|
|
862
917
|
], exports.Box.prototype, "__updateStrokeBounds", null);
|
|
@@ -884,6 +939,7 @@ exports.Frame = class Frame extends exports.Box {
|
|
|
884
939
|
get __tag() { return 'Frame'; }
|
|
885
940
|
constructor(data) {
|
|
886
941
|
super(data);
|
|
942
|
+
this.isFrame = true;
|
|
887
943
|
if (!this.__.fill)
|
|
888
944
|
this.__.fill = '#FFFFFF';
|
|
889
945
|
}
|
|
@@ -923,8 +979,8 @@ exports.Ellipse = class Ellipse extends exports.UI {
|
|
|
923
979
|
}
|
|
924
980
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
925
981
|
}
|
|
926
|
-
if (core.Platform.
|
|
927
|
-
this.__.path =
|
|
982
|
+
if (core.Platform.ellipseToCurve)
|
|
983
|
+
this.__.path = this.getPath(true);
|
|
928
984
|
}
|
|
929
985
|
else {
|
|
930
986
|
if (startAngle || endAngle) {
|
|
@@ -954,47 +1010,118 @@ exports.Ellipse = __decorate([
|
|
|
954
1010
|
core.registerUI()
|
|
955
1011
|
], exports.Ellipse);
|
|
956
1012
|
|
|
957
|
-
const {
|
|
958
|
-
const {
|
|
959
|
-
const { toBounds: toBounds$
|
|
960
|
-
exports.
|
|
961
|
-
get __tag() { return '
|
|
962
|
-
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
|
+
}
|
|
963
1033
|
constructor(data) {
|
|
964
1034
|
super(data);
|
|
965
1035
|
}
|
|
966
1036
|
__updatePath() {
|
|
967
1037
|
const path = this.__.path = [];
|
|
968
1038
|
if (this.__.points) {
|
|
969
|
-
drawPoints$1(path, this.__.points, false
|
|
1039
|
+
drawPoints$1(path, this.__.points, false);
|
|
970
1040
|
}
|
|
971
1041
|
else {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
moveTo$2(path, rx, 0);
|
|
975
|
-
for (let i = 1; i < sides; i++) {
|
|
976
|
-
lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
977
|
-
}
|
|
1042
|
+
moveTo$2(path, 0, 0);
|
|
1043
|
+
lineTo$2(path, this.width, 0);
|
|
978
1044
|
}
|
|
979
|
-
closePath$1(path);
|
|
980
1045
|
}
|
|
981
1046
|
__updateRenderPath() {
|
|
982
1047
|
if (this.__.points && this.__.curve) {
|
|
983
|
-
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve,
|
|
1048
|
+
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
|
|
984
1049
|
}
|
|
985
1050
|
else {
|
|
986
1051
|
super.__updateRenderPath();
|
|
987
1052
|
}
|
|
988
1053
|
}
|
|
989
1054
|
__updateBoxBounds() {
|
|
990
|
-
if (this.
|
|
991
|
-
toBounds$
|
|
992
|
-
this.__updateNaturalSize();
|
|
1055
|
+
if (this.points) {
|
|
1056
|
+
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
993
1057
|
}
|
|
994
1058
|
else {
|
|
995
1059
|
super.__updateBoxBounds();
|
|
996
1060
|
}
|
|
997
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) { }
|
|
998
1125
|
};
|
|
999
1126
|
__decorate([
|
|
1000
1127
|
core.dataProcessor(PolygonData)
|
|
@@ -1008,12 +1135,22 @@ __decorate([
|
|
|
1008
1135
|
__decorate([
|
|
1009
1136
|
core.pathType(0)
|
|
1010
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);
|
|
1011
1147
|
exports.Polygon = __decorate([
|
|
1148
|
+
core.rewriteAble(),
|
|
1012
1149
|
core.registerUI()
|
|
1013
1150
|
], exports.Polygon);
|
|
1014
1151
|
|
|
1015
1152
|
const { sin, cos, PI } = Math;
|
|
1016
|
-
const { moveTo
|
|
1153
|
+
const { moveTo, lineTo, closePath } = core.PathCommandDataHelper;
|
|
1017
1154
|
exports.Star = class Star extends exports.UI {
|
|
1018
1155
|
get __tag() { return 'Star'; }
|
|
1019
1156
|
constructor(data) {
|
|
@@ -1023,9 +1160,9 @@ exports.Star = class Star extends exports.UI {
|
|
|
1023
1160
|
const { width, height, corners, innerRadius } = this.__;
|
|
1024
1161
|
const rx = width / 2, ry = height / 2;
|
|
1025
1162
|
const path = this.__.path = [];
|
|
1026
|
-
moveTo
|
|
1163
|
+
moveTo(path, rx, 0);
|
|
1027
1164
|
for (let i = 1; i < corners * 2; i++) {
|
|
1028
|
-
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));
|
|
1029
1166
|
}
|
|
1030
1167
|
closePath(path);
|
|
1031
1168
|
}
|
|
@@ -1043,77 +1180,6 @@ exports.Star = __decorate([
|
|
|
1043
1180
|
core.registerUI()
|
|
1044
1181
|
], exports.Star);
|
|
1045
1182
|
|
|
1046
|
-
const { moveTo, lineTo, drawPoints } = core.PathCommandDataHelper;
|
|
1047
|
-
const { rotate, getAngle, getDistance, defaultPoint } = core.PointHelper;
|
|
1048
|
-
const { toBounds: toBounds$1 } = core.PathBounds;
|
|
1049
|
-
exports.Line = class Line extends exports.UI {
|
|
1050
|
-
get __tag() { return 'Line'; }
|
|
1051
|
-
get resizeable() { return !this.points; }
|
|
1052
|
-
get toPoint() {
|
|
1053
|
-
const { width, rotation } = this.__;
|
|
1054
|
-
const to = { x: 0, y: 0 };
|
|
1055
|
-
if (width)
|
|
1056
|
-
to.x = width;
|
|
1057
|
-
if (rotation)
|
|
1058
|
-
rotate(to, rotation);
|
|
1059
|
-
return to;
|
|
1060
|
-
}
|
|
1061
|
-
set toPoint(value) {
|
|
1062
|
-
this.width = getDistance(defaultPoint, value);
|
|
1063
|
-
this.rotation = getAngle(defaultPoint, value);
|
|
1064
|
-
if (this.height)
|
|
1065
|
-
this.height = 0;
|
|
1066
|
-
}
|
|
1067
|
-
constructor(data) {
|
|
1068
|
-
super(data);
|
|
1069
|
-
}
|
|
1070
|
-
__updatePath() {
|
|
1071
|
-
const path = this.__.path = [];
|
|
1072
|
-
if (this.__.points) {
|
|
1073
|
-
drawPoints(path, this.__.points, false);
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
moveTo(path, 0, 0);
|
|
1077
|
-
lineTo(path, this.width, 0);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
__updateRenderPath() {
|
|
1081
|
-
if (this.__.points && this.__.curve) {
|
|
1082
|
-
drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
|
|
1083
|
-
}
|
|
1084
|
-
else {
|
|
1085
|
-
super.__updateRenderPath();
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
__updateBoxBounds() {
|
|
1089
|
-
if (this.points) {
|
|
1090
|
-
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1091
|
-
this.__updateNaturalSize();
|
|
1092
|
-
}
|
|
1093
|
-
else {
|
|
1094
|
-
super.__updateBoxBounds();
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
__decorate([
|
|
1099
|
-
core.dataProcessor(LineData)
|
|
1100
|
-
], exports.Line.prototype, "__", void 0);
|
|
1101
|
-
__decorate([
|
|
1102
|
-
core.affectStrokeBoundsType('center')
|
|
1103
|
-
], exports.Line.prototype, "strokeAlign", void 0);
|
|
1104
|
-
__decorate([
|
|
1105
|
-
core.boundsType(0)
|
|
1106
|
-
], exports.Line.prototype, "height", void 0);
|
|
1107
|
-
__decorate([
|
|
1108
|
-
core.pathType()
|
|
1109
|
-
], exports.Line.prototype, "points", void 0);
|
|
1110
|
-
__decorate([
|
|
1111
|
-
core.pathType(0)
|
|
1112
|
-
], exports.Line.prototype, "curve", void 0);
|
|
1113
|
-
exports.Line = __decorate([
|
|
1114
|
-
core.registerUI()
|
|
1115
|
-
], exports.Line);
|
|
1116
|
-
|
|
1117
1183
|
exports.Image = class Image extends exports.Rect {
|
|
1118
1184
|
get __tag() { return 'Image'; }
|
|
1119
1185
|
get ready() { return this.image ? this.image.ready : false; }
|
|
@@ -1164,7 +1230,7 @@ exports.Canvas = class Canvas extends exports.Rect {
|
|
|
1164
1230
|
this.__.__drawAfterFill = true;
|
|
1165
1231
|
}
|
|
1166
1232
|
draw(ui, offset, scale, rotation) {
|
|
1167
|
-
ui.__layout.
|
|
1233
|
+
ui.__layout.update();
|
|
1168
1234
|
const matrix = new core.Matrix(ui.__world);
|
|
1169
1235
|
matrix.invert();
|
|
1170
1236
|
const m = new core.Matrix();
|
|
@@ -1174,7 +1240,7 @@ exports.Canvas = class Canvas extends exports.Rect {
|
|
|
1174
1240
|
typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
|
|
1175
1241
|
if (rotation)
|
|
1176
1242
|
m.rotate(rotation);
|
|
1177
|
-
matrix.
|
|
1243
|
+
matrix.multiplyParent(m);
|
|
1178
1244
|
ui.__render(this.canvas, { matrix });
|
|
1179
1245
|
this.paint();
|
|
1180
1246
|
}
|
|
@@ -1234,11 +1300,11 @@ exports.Canvas = __decorate([
|
|
|
1234
1300
|
core.registerUI()
|
|
1235
1301
|
], exports.Canvas);
|
|
1236
1302
|
|
|
1237
|
-
const { copyAndSpread, includes, spread } = core.BoundsHelper;
|
|
1303
|
+
const { copyAndSpread, includes, spread, setList } = core.BoundsHelper;
|
|
1238
1304
|
exports.Text = class Text extends exports.UI {
|
|
1239
1305
|
get __tag() { return 'Text'; }
|
|
1240
1306
|
get textDrawData() {
|
|
1241
|
-
this.__layout.
|
|
1307
|
+
this.__layout.update();
|
|
1242
1308
|
return this.__.__textDrawData;
|
|
1243
1309
|
}
|
|
1244
1310
|
constructor(data) {
|
|
@@ -1268,32 +1334,49 @@ exports.Text = class Text extends exports.UI {
|
|
|
1268
1334
|
__updateBoxBounds() {
|
|
1269
1335
|
const data = this.__;
|
|
1270
1336
|
const layout = this.__layout;
|
|
1271
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
|
|
1337
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
1338
|
+
const autoWidth = data.__autoWidth;
|
|
1339
|
+
const autoHeight = data.__autoHeight;
|
|
1272
1340
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
1273
1341
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
1274
1342
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
1275
1343
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
1344
|
+
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
1276
1345
|
this.__updateTextDrawData();
|
|
1277
1346
|
const { bounds } = data.__textDrawData;
|
|
1278
1347
|
const b = layout.boxBounds;
|
|
1279
1348
|
if (data.__lineHeight < fontSize)
|
|
1280
1349
|
spread(bounds, fontSize / 2);
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
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();
|
|
1285
1368
|
}
|
|
1286
1369
|
else {
|
|
1287
|
-
|
|
1288
|
-
b.y = height ? 0 : bounds.y;
|
|
1289
|
-
b.width = width ? width : bounds.width;
|
|
1290
|
-
b.height = height ? height : bounds.height;
|
|
1291
|
-
this.__updateNaturalSize();
|
|
1370
|
+
super.__updateBoxBounds();
|
|
1292
1371
|
}
|
|
1293
1372
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1294
1373
|
if (contentBounds !== layout.contentBounds) {
|
|
1295
1374
|
layout.contentBounds = contentBounds;
|
|
1296
1375
|
layout.renderChanged = true;
|
|
1376
|
+
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
1377
|
+
}
|
|
1378
|
+
else {
|
|
1379
|
+
data.__textBoxBounds = contentBounds;
|
|
1297
1380
|
}
|
|
1298
1381
|
}
|
|
1299
1382
|
__updateRenderSpread() {
|
|
@@ -1303,7 +1386,7 @@ exports.Text = class Text extends exports.UI {
|
|
|
1303
1386
|
return width;
|
|
1304
1387
|
}
|
|
1305
1388
|
__updateRenderBounds() {
|
|
1306
|
-
copyAndSpread(this.__layout.renderBounds, this.
|
|
1389
|
+
copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
|
|
1307
1390
|
}
|
|
1308
1391
|
};
|
|
1309
1392
|
__decorate([
|
|
@@ -1318,9 +1401,15 @@ __decorate([
|
|
|
1318
1401
|
__decorate([
|
|
1319
1402
|
core.boundsType(0)
|
|
1320
1403
|
], exports.Text.prototype, "padding", void 0);
|
|
1404
|
+
__decorate([
|
|
1405
|
+
core.surfaceType('#000000')
|
|
1406
|
+
], exports.Text.prototype, "fill", void 0);
|
|
1321
1407
|
__decorate([
|
|
1322
1408
|
core.affectStrokeBoundsType('outside')
|
|
1323
1409
|
], exports.Text.prototype, "strokeAlign", void 0);
|
|
1410
|
+
__decorate([
|
|
1411
|
+
core.hitType('all')
|
|
1412
|
+
], exports.Text.prototype, "hitFill", void 0);
|
|
1324
1413
|
__decorate([
|
|
1325
1414
|
core.boundsType('')
|
|
1326
1415
|
], exports.Text.prototype, "text", void 0);
|
|
@@ -1360,6 +1449,9 @@ __decorate([
|
|
|
1360
1449
|
__decorate([
|
|
1361
1450
|
core.boundsType('top')
|
|
1362
1451
|
], exports.Text.prototype, "verticalAlign", void 0);
|
|
1452
|
+
__decorate([
|
|
1453
|
+
core.boundsType('normal')
|
|
1454
|
+
], exports.Text.prototype, "textWrap", void 0);
|
|
1363
1455
|
__decorate([
|
|
1364
1456
|
core.boundsType('show')
|
|
1365
1457
|
], exports.Text.prototype, "textOverflow", void 0);
|
|
@@ -1370,13 +1462,15 @@ exports.Text = __decorate([
|
|
|
1370
1462
|
const { toBounds } = core.PathBounds;
|
|
1371
1463
|
exports.Path = class Path extends exports.UI {
|
|
1372
1464
|
get __tag() { return 'Path'; }
|
|
1373
|
-
get resizeable() { return false; }
|
|
1374
1465
|
constructor(data) {
|
|
1375
1466
|
super(data);
|
|
1376
1467
|
}
|
|
1468
|
+
__scaleResize(scaleX, scaleY) {
|
|
1469
|
+
core.PathScaler.scale(this.__.path, scaleX, scaleY);
|
|
1470
|
+
this.path = this.__.path;
|
|
1471
|
+
}
|
|
1377
1472
|
__updateBoxBounds() {
|
|
1378
1473
|
toBounds(this.__.path, this.__layout.boxBounds);
|
|
1379
|
-
this.__updateNaturalSize();
|
|
1380
1474
|
}
|
|
1381
1475
|
};
|
|
1382
1476
|
__decorate([
|
|
@@ -1445,6 +1539,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1445
1539
|
get __tag() { return 'Leafer'; }
|
|
1446
1540
|
get isApp() { return false; }
|
|
1447
1541
|
get app() { return this.parent || this; }
|
|
1542
|
+
get layoutLocked() { return !this.layouter.running; }
|
|
1448
1543
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
1449
1544
|
constructor(userConfig, data) {
|
|
1450
1545
|
super(data);
|
|
@@ -1537,13 +1632,18 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1537
1632
|
this.emitLeafer(core.LeaferEvent.STOP);
|
|
1538
1633
|
}
|
|
1539
1634
|
}
|
|
1635
|
+
unlockLayout() {
|
|
1636
|
+
this.layouter.start();
|
|
1637
|
+
this.updateLayout();
|
|
1638
|
+
}
|
|
1639
|
+
lockLayout() {
|
|
1640
|
+
this.updateLayout();
|
|
1641
|
+
this.layouter.stop();
|
|
1642
|
+
}
|
|
1540
1643
|
resize(size) {
|
|
1541
1644
|
const data = core.DataHelper.copyAttrs({}, size, core.canvasSizeAttrs);
|
|
1542
1645
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
1543
1646
|
}
|
|
1544
|
-
forceLayout() {
|
|
1545
|
-
this.__layout.checkUpdate(true);
|
|
1546
|
-
}
|
|
1547
1647
|
forceFullRender() {
|
|
1548
1648
|
this.renderer.addBlock(this.canvas.bounds);
|
|
1549
1649
|
if (this.viewReady)
|
|
@@ -1689,7 +1789,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1689
1789
|
}
|
|
1690
1790
|
}
|
|
1691
1791
|
__checkUpdateLayout() {
|
|
1692
|
-
this.__layout.
|
|
1792
|
+
this.__layout.update();
|
|
1693
1793
|
}
|
|
1694
1794
|
emitLeafer(type) {
|
|
1695
1795
|
this.emitEvent(new core.LeaferEvent(type, this));
|
|
@@ -1749,6 +1849,22 @@ exports.Leafer = __decorate([
|
|
|
1749
1849
|
exports.App = class App extends exports.Leafer {
|
|
1750
1850
|
get __tag() { return 'App'; }
|
|
1751
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
|
+
}
|
|
1752
1868
|
__setApp() {
|
|
1753
1869
|
const { canvas } = this;
|
|
1754
1870
|
const { realCanvas, view } = this.config;
|
|
@@ -1765,12 +1881,20 @@ exports.App = class App extends exports.Leafer {
|
|
|
1765
1881
|
}
|
|
1766
1882
|
start() {
|
|
1767
1883
|
super.start();
|
|
1768
|
-
this.children.forEach(leafer =>
|
|
1884
|
+
this.children.forEach(leafer => leafer.start());
|
|
1769
1885
|
}
|
|
1770
1886
|
stop() {
|
|
1771
|
-
this.children.forEach(leafer =>
|
|
1887
|
+
this.children.forEach(leafer => leafer.stop());
|
|
1772
1888
|
super.stop();
|
|
1773
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
|
+
}
|
|
1774
1898
|
addLeafer(merge) {
|
|
1775
1899
|
const leafer = new exports.Leafer(merge);
|
|
1776
1900
|
this.add(leafer);
|
|
@@ -1789,7 +1913,7 @@ exports.App = class App extends exports.Leafer {
|
|
|
1789
1913
|
}
|
|
1790
1914
|
__onPropertyChange() {
|
|
1791
1915
|
if (core.Debug.showHitView)
|
|
1792
|
-
this.children.forEach(leafer =>
|
|
1916
|
+
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
1793
1917
|
}
|
|
1794
1918
|
__onCreated() {
|
|
1795
1919
|
this.created = this.children.every(child => child.created);
|
|
@@ -1811,14 +1935,14 @@ exports.App = class App extends exports.Leafer {
|
|
|
1811
1935
|
this.renderer.update();
|
|
1812
1936
|
}
|
|
1813
1937
|
__render(canvas, _options) {
|
|
1814
|
-
this.children.forEach(leafer =>
|
|
1938
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
1815
1939
|
}
|
|
1816
1940
|
__onResize(event) {
|
|
1817
|
-
this.children.forEach(leafer =>
|
|
1941
|
+
this.children.forEach(leafer => leafer.resize(event));
|
|
1818
1942
|
super.__onResize(event);
|
|
1819
1943
|
}
|
|
1820
1944
|
__checkUpdateLayout() {
|
|
1821
|
-
this.children.forEach(leafer =>
|
|
1945
|
+
this.children.forEach(leafer => leafer.__layout.update());
|
|
1822
1946
|
}
|
|
1823
1947
|
__getChildConfig(userConfig) {
|
|
1824
1948
|
let config = Object.assign({}, this.config);
|
|
@@ -1844,16 +1968,32 @@ exports.App = __decorate([
|
|
|
1844
1968
|
], exports.App);
|
|
1845
1969
|
|
|
1846
1970
|
exports.Animate = Animate;
|
|
1971
|
+
exports.BoxData = BoxData;
|
|
1972
|
+
exports.CanvasData = CanvasData;
|
|
1847
1973
|
exports.ColorConvert = ColorConvert;
|
|
1848
1974
|
exports.Effect = Effect;
|
|
1975
|
+
exports.EllipseData = EllipseData;
|
|
1849
1976
|
exports.Export = Export;
|
|
1977
|
+
exports.FrameData = FrameData;
|
|
1978
|
+
exports.GroupData = GroupData;
|
|
1979
|
+
exports.ImageData = ImageData;
|
|
1980
|
+
exports.LeaferData = LeaferData;
|
|
1850
1981
|
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
1982
|
+
exports.LineData = LineData;
|
|
1851
1983
|
exports.Paint = Paint;
|
|
1984
|
+
exports.PathData = PathData;
|
|
1985
|
+
exports.PenData = PenData;
|
|
1986
|
+
exports.PolygonData = PolygonData;
|
|
1987
|
+
exports.RectData = RectData;
|
|
1852
1988
|
exports.RectRender = RectRender;
|
|
1989
|
+
exports.StarData = StarData;
|
|
1853
1990
|
exports.TextConvert = TextConvert;
|
|
1991
|
+
exports.TextData = TextData;
|
|
1854
1992
|
exports.UIBounds = UIBounds;
|
|
1993
|
+
exports.UIData = UIData;
|
|
1855
1994
|
exports.UIHit = UIHit;
|
|
1856
1995
|
exports.UIRender = UIRender;
|
|
1996
|
+
exports.UnitConvert = UnitConvert;
|
|
1857
1997
|
exports.effectType = effectType;
|
|
1858
1998
|
exports.resizeType = resizeType;
|
|
1859
1999
|
Object.keys(core).forEach(function (k) {
|