@leafer-ui/draw 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/draw.cjs +1115 -1180
- package/lib/draw.esm.js +1075 -1177
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.esm.min.js.map +1 -1
- package/lib/draw.min.cjs +1 -1
- package/lib/draw.min.cjs.map +1 -1
- package/package.json +6 -6
package/lib/draw.cjs
CHANGED
|
@@ -1,48 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var core = require(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function __decorate(decorators, target, key, desc) {
|
|
23
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
30
|
-
var e = new Error(message);
|
|
31
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var core = require("@leafer/core");
|
|
4
|
+
|
|
5
|
+
function __decorate(decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
12
|
+
var e = new Error(message);
|
|
13
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
32
14
|
};
|
|
33
15
|
|
|
34
16
|
function effectType(defaultValue) {
|
|
35
|
-
return core.decorateLeafAttr(defaultValue,
|
|
17
|
+
return core.decorateLeafAttr(defaultValue, key => core.attr({
|
|
36
18
|
set(value) {
|
|
37
19
|
this.__setAttr(key, value);
|
|
38
|
-
if (value)
|
|
39
|
-
this.__.__useEffect = true;
|
|
20
|
+
if (value) this.__.__useEffect = true;
|
|
40
21
|
this.__layout.renderChanged || this.__layout.renderChange();
|
|
41
22
|
}
|
|
42
23
|
}));
|
|
43
24
|
}
|
|
25
|
+
|
|
44
26
|
function resizeType(defaultValue) {
|
|
45
|
-
return core.decorateLeafAttr(defaultValue,
|
|
27
|
+
return core.decorateLeafAttr(defaultValue, key => core.attr({
|
|
46
28
|
set(value) {
|
|
47
29
|
this.__setAttr(key, value);
|
|
48
30
|
this.__layout.boxChanged || this.__layout.boxChange();
|
|
@@ -50,221 +32,266 @@ function resizeType(defaultValue) {
|
|
|
50
32
|
}
|
|
51
33
|
}));
|
|
52
34
|
}
|
|
35
|
+
|
|
53
36
|
function zoomLayerType() {
|
|
54
37
|
return (target, key) => {
|
|
55
|
-
const privateKey =
|
|
38
|
+
const privateKey = "_" + key;
|
|
56
39
|
core.defineKey(target, key, {
|
|
57
|
-
set(value) {
|
|
58
|
-
this[privateKey] = value;
|
|
40
|
+
set(value) {
|
|
41
|
+
if (this.isLeafer) this[privateKey] = value;
|
|
42
|
+
},
|
|
59
43
|
get() {
|
|
60
|
-
return this.isApp
|
|
61
|
-
? this.tree.zoomLayer
|
|
62
|
-
: (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
|
|
44
|
+
return this.isApp ? this.tree.zoomLayer : this.isLeafer ? this[privateKey] || this : this.leafer && this.leafer.zoomLayer;
|
|
63
45
|
}
|
|
64
46
|
});
|
|
65
47
|
};
|
|
66
48
|
}
|
|
67
49
|
|
|
50
|
+
function createAttr(defaultValue) {
|
|
51
|
+
return (target, key) => {
|
|
52
|
+
core.defineKey(target, key, core.createDescriptor(key, defaultValue));
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
68
56
|
function hasTransparent$1(color) {
|
|
69
|
-
if (!color || color.length === 7 || color.length === 4)
|
|
70
|
-
|
|
71
|
-
if (color === 'transparent')
|
|
72
|
-
return true;
|
|
57
|
+
if (!color || color.length === 7 || color.length === 4) return false;
|
|
58
|
+
if (color === "transparent") return true;
|
|
73
59
|
const first = color[0];
|
|
74
|
-
if (first ===
|
|
60
|
+
if (first === "#") {
|
|
75
61
|
switch (color.length) {
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
case 5:
|
|
63
|
+
return color[4] !== "f" && color[4] !== "F";
|
|
64
|
+
|
|
65
|
+
case 9:
|
|
66
|
+
return color[7] !== "f" && color[7] !== "F" || color[8] !== "f" && color[8] !== "F";
|
|
78
67
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (i > -1)
|
|
84
|
-
return parseFloat(color.slice(i + 1)) < 1;
|
|
68
|
+
} else if (first === "r" || first === "h") {
|
|
69
|
+
if (color[3] === "a") {
|
|
70
|
+
const i = color.lastIndexOf(",");
|
|
71
|
+
if (i > -1) return parseFloat(color.slice(i + 1)) < 1;
|
|
85
72
|
}
|
|
86
73
|
}
|
|
87
74
|
return false;
|
|
88
75
|
}
|
|
89
76
|
|
|
90
77
|
const TextConvert = {};
|
|
78
|
+
|
|
91
79
|
const ColorConvert = {
|
|
92
80
|
hasTransparent: hasTransparent$1
|
|
93
81
|
};
|
|
82
|
+
|
|
94
83
|
const UnitConvert = {
|
|
95
84
|
number(value, percentRefer) {
|
|
96
|
-
return
|
|
85
|
+
return core.isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
|
|
97
86
|
}
|
|
98
87
|
};
|
|
88
|
+
|
|
99
89
|
const PathArrow = {};
|
|
90
|
+
|
|
100
91
|
const Paint = {};
|
|
92
|
+
|
|
101
93
|
const PaintImage = {};
|
|
94
|
+
|
|
102
95
|
const PaintGradient = {};
|
|
96
|
+
|
|
103
97
|
const Effect = {};
|
|
98
|
+
|
|
104
99
|
const Filter = {
|
|
105
|
-
apply() {
|
|
100
|
+
apply() {
|
|
101
|
+
core.Plugin.need("filter");
|
|
102
|
+
}
|
|
106
103
|
};
|
|
104
|
+
|
|
107
105
|
const Export = {};
|
|
106
|
+
|
|
108
107
|
const State = {
|
|
109
|
-
setStyleName() {
|
|
110
|
-
|
|
108
|
+
setStyleName() {
|
|
109
|
+
return core.Plugin.need("state");
|
|
110
|
+
},
|
|
111
|
+
set() {
|
|
112
|
+
return core.Plugin.need("state");
|
|
113
|
+
}
|
|
111
114
|
};
|
|
115
|
+
|
|
112
116
|
const Transition = {
|
|
113
117
|
list: {},
|
|
114
|
-
register(attrName, fn) {
|
|
115
|
-
|
|
118
|
+
register(attrName, fn) {
|
|
119
|
+
Transition.list[attrName] = fn;
|
|
120
|
+
},
|
|
121
|
+
get(attrName) {
|
|
122
|
+
return Transition.list[attrName];
|
|
123
|
+
}
|
|
116
124
|
};
|
|
117
125
|
|
|
118
|
-
const { parse, objectToCanvasData } = core.PathConvert;
|
|
119
|
-
|
|
126
|
+
const {parse: parse, objectToCanvasData: objectToCanvasData} = core.PathConvert;
|
|
127
|
+
|
|
128
|
+
const {stintSet: stintSet$1} = core.DataHelper, {hasTransparent: hasTransparent} = ColorConvert;
|
|
129
|
+
|
|
120
130
|
const emptyPaint = {};
|
|
121
|
-
|
|
131
|
+
|
|
132
|
+
const debug$1 = core.Debug.get("UIData");
|
|
133
|
+
|
|
122
134
|
class UIData extends core.LeafData {
|
|
123
|
-
get scale() {
|
|
135
|
+
get scale() {
|
|
136
|
+
const {scaleX: scaleX, scaleY: scaleY} = this;
|
|
137
|
+
return scaleX !== scaleY ? {
|
|
138
|
+
x: scaleX,
|
|
139
|
+
y: scaleY
|
|
140
|
+
} : scaleX;
|
|
141
|
+
}
|
|
124
142
|
get __strokeWidth() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
scaleX = -scaleX;
|
|
131
|
-
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
132
|
-
}
|
|
133
|
-
else
|
|
134
|
-
return strokeWidth;
|
|
143
|
+
return this.__getRealStrokeWidth();
|
|
144
|
+
}
|
|
145
|
+
get __maxStrokeWidth() {
|
|
146
|
+
const t = this;
|
|
147
|
+
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth;
|
|
135
148
|
}
|
|
136
149
|
get __hasMultiPaint() {
|
|
137
150
|
const t = this;
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
get __clipAfterFill() {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
get
|
|
145
|
-
|
|
151
|
+
return t.fill && this.__useStroke || t.__isFills && t.fill.length > 1 || t.__isStrokes && t.stroke.length > 1 || t.__useEffect;
|
|
152
|
+
}
|
|
153
|
+
get __clipAfterFill() {
|
|
154
|
+
const t = this;
|
|
155
|
+
return t.cornerRadius || t.innerShadow || t.__pathInputed;
|
|
156
|
+
}
|
|
157
|
+
get __hasSurface() {
|
|
158
|
+
const t = this;
|
|
159
|
+
return t.fill || t.stroke;
|
|
160
|
+
}
|
|
161
|
+
get __autoWidth() {
|
|
162
|
+
return !this._width;
|
|
163
|
+
}
|
|
164
|
+
get __autoHeight() {
|
|
165
|
+
return !this._height;
|
|
166
|
+
}
|
|
167
|
+
get __autoSide() {
|
|
168
|
+
return !this._width || !this._height;
|
|
169
|
+
}
|
|
170
|
+
get __autoSize() {
|
|
171
|
+
return !this._width && !this._height;
|
|
172
|
+
}
|
|
146
173
|
setVisible(value) {
|
|
147
174
|
this._visible = value;
|
|
148
|
-
const { leafer
|
|
149
|
-
if (leafer)
|
|
150
|
-
leafer.watcher.hasVisible = true;
|
|
175
|
+
const {leafer: leafer} = this.__leaf;
|
|
176
|
+
if (leafer) leafer.watcher.hasVisible = true;
|
|
151
177
|
}
|
|
152
178
|
setWidth(value) {
|
|
153
179
|
if (value < 0) {
|
|
154
180
|
this._width = -value;
|
|
155
181
|
this.__leaf.scaleX *= -1;
|
|
156
|
-
debug$1.warn(
|
|
157
|
-
}
|
|
158
|
-
else
|
|
159
|
-
this._width = value;
|
|
182
|
+
debug$1.warn("width < 0, instead -scaleX ", this);
|
|
183
|
+
} else this._width = value;
|
|
160
184
|
}
|
|
161
185
|
setHeight(value) {
|
|
162
186
|
if (value < 0) {
|
|
163
187
|
this._height = -value;
|
|
164
188
|
this.__leaf.scaleY *= -1;
|
|
165
|
-
debug$1.warn(
|
|
166
|
-
}
|
|
167
|
-
else
|
|
168
|
-
this._height = value;
|
|
189
|
+
debug$1.warn("height < 0, instead -scaleY", this);
|
|
190
|
+
} else this._height = value;
|
|
169
191
|
}
|
|
170
192
|
setFill(value) {
|
|
171
|
-
if (this.__naturalWidth)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.__isFills && this.__removePaint('fill', true);
|
|
193
|
+
if (this.__naturalWidth) this.__removeNaturalSize();
|
|
194
|
+
if (core.isString(value) || !value) {
|
|
195
|
+
stintSet$1(this, "__isTransparentFill", hasTransparent(value));
|
|
196
|
+
this.__isFills && this.__removePaint("fill", true);
|
|
176
197
|
this._fill = value;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
this.__setPaint('fill', value);
|
|
198
|
+
} else if (core.isObject(value)) {
|
|
199
|
+
this.__setPaint("fill", value);
|
|
180
200
|
}
|
|
181
201
|
}
|
|
182
202
|
setStroke(value) {
|
|
183
|
-
if (
|
|
184
|
-
stintSet$1(this,
|
|
185
|
-
this.__isStrokes && this.__removePaint(
|
|
203
|
+
if (core.isString(value) || !value) {
|
|
204
|
+
stintSet$1(this, "__isTransparentStroke", hasTransparent(value));
|
|
205
|
+
this.__isStrokes && this.__removePaint("stroke", true);
|
|
186
206
|
this._stroke = value;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
this.__setPaint('stroke', value);
|
|
207
|
+
} else if (core.isObject(value)) {
|
|
208
|
+
this.__setPaint("stroke", value);
|
|
190
209
|
}
|
|
191
210
|
}
|
|
192
211
|
setPath(value) {
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
this.__setInput(
|
|
196
|
-
this._path =
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (this.__input)
|
|
200
|
-
this.__removeInput('path');
|
|
212
|
+
const isStr = core.isString(value);
|
|
213
|
+
if (isStr || value && core.isObject(value[0])) {
|
|
214
|
+
this.__setInput("path", value);
|
|
215
|
+
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
216
|
+
} else {
|
|
217
|
+
if (this.__input) this.__removeInput("path");
|
|
201
218
|
this._path = value;
|
|
202
219
|
}
|
|
203
220
|
}
|
|
204
221
|
setShadow(value) {
|
|
205
|
-
setArray(this,
|
|
222
|
+
setArray(this, "shadow", value);
|
|
206
223
|
}
|
|
207
224
|
setInnerShadow(value) {
|
|
208
|
-
setArray(this,
|
|
225
|
+
setArray(this, "innerShadow", value);
|
|
209
226
|
}
|
|
210
227
|
setFilter(value) {
|
|
211
|
-
setArray(this,
|
|
228
|
+
setArray(this, "filter", value);
|
|
212
229
|
}
|
|
213
230
|
__computePaint() {
|
|
214
|
-
const { fill, stroke } = this.__input;
|
|
215
|
-
if (fill)
|
|
216
|
-
|
|
217
|
-
if (stroke)
|
|
218
|
-
Paint.compute('stroke', this.__leaf);
|
|
231
|
+
const {fill: fill, stroke: stroke} = this.__input;
|
|
232
|
+
if (fill) Paint.compute("fill", this.__leaf);
|
|
233
|
+
if (stroke) Paint.compute("stroke", this.__leaf);
|
|
219
234
|
this.__needComputePaint = undefined;
|
|
220
235
|
}
|
|
236
|
+
__getRealStrokeWidth(childStyle) {
|
|
237
|
+
let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
|
|
238
|
+
if (childStyle) {
|
|
239
|
+
if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
|
|
240
|
+
if (!core.isUndefined(childStyle.strokeWidthFixed)) strokeWidthFixed = childStyle.strokeWidthFixed;
|
|
241
|
+
}
|
|
242
|
+
if (strokeWidthFixed) {
|
|
243
|
+
const scale = this.__leaf.getClampRenderScale();
|
|
244
|
+
return scale > 1 ? strokeWidth / scale : strokeWidth;
|
|
245
|
+
} else return strokeWidth;
|
|
246
|
+
}
|
|
221
247
|
__setPaint(attrName, value) {
|
|
222
248
|
this.__setInput(attrName, value);
|
|
223
249
|
const layout = this.__leaf.__layout;
|
|
224
250
|
layout.boxChanged || layout.boxChange();
|
|
225
|
-
if (value
|
|
251
|
+
if (core.isArray(value) && !value.length) {
|
|
226
252
|
this.__removePaint(attrName);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.__isFills = true, this._fill || (this._fill = emptyPaint);
|
|
231
|
-
else
|
|
232
|
-
this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
|
|
253
|
+
} else {
|
|
254
|
+
if (attrName === "fill") this.__isFills = true, this._fill || (this._fill = emptyPaint); else this.__isStrokes = true,
|
|
255
|
+
this._stroke || (this._stroke = emptyPaint);
|
|
233
256
|
}
|
|
234
257
|
}
|
|
235
258
|
__removePaint(attrName, removeInput) {
|
|
236
|
-
if (removeInput)
|
|
237
|
-
this.__removeInput(attrName);
|
|
259
|
+
if (removeInput) this.__removeInput(attrName);
|
|
238
260
|
PaintImage.recycleImage(attrName, this);
|
|
239
|
-
if (attrName ===
|
|
240
|
-
stintSet$1(this,
|
|
261
|
+
if (attrName === "fill") {
|
|
262
|
+
stintSet$1(this, "__isAlphaPixelFill", undefined);
|
|
241
263
|
this._fill = this.__isFills = undefined;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
stintSet$1(this,
|
|
264
|
+
} else {
|
|
265
|
+
stintSet$1(this, "__isAlphaPixelStroke", undefined);
|
|
266
|
+
stintSet$1(this, "__hasMultiStrokeStyle", undefined);
|
|
245
267
|
this._stroke = this.__isStrokes = undefined;
|
|
246
268
|
}
|
|
247
269
|
}
|
|
248
270
|
}
|
|
271
|
+
|
|
249
272
|
function setArray(data, key, value) {
|
|
250
273
|
data.__setInput(key, value);
|
|
251
|
-
if (value
|
|
252
|
-
if (value.some(
|
|
253
|
-
value = value.filter((item) => item.visible !== false);
|
|
274
|
+
if (core.isArray(value)) {
|
|
275
|
+
if (value.some(item => item.visible === false)) value = value.filter(item => item.visible !== false);
|
|
254
276
|
value.length || (value = undefined);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
value = value && value.visible !== false ? [value] : undefined;
|
|
258
|
-
data['_' + key] = value;
|
|
277
|
+
} else value = value && value.visible !== false ? [ value ] : undefined;
|
|
278
|
+
data["_" + key] = value;
|
|
259
279
|
}
|
|
260
280
|
|
|
261
|
-
class GroupData extends UIData {
|
|
262
|
-
}
|
|
281
|
+
class GroupData extends UIData {}
|
|
263
282
|
|
|
264
283
|
class BoxData extends GroupData {
|
|
265
|
-
get __boxStroke() {
|
|
266
|
-
|
|
267
|
-
|
|
284
|
+
get __boxStroke() {
|
|
285
|
+
return !this.__pathInputed;
|
|
286
|
+
}
|
|
287
|
+
get __drawAfterFill() {
|
|
288
|
+
const t = this;
|
|
289
|
+
return t.__single || t.__clipAfterFill;
|
|
290
|
+
}
|
|
291
|
+
get __clipAfterFill() {
|
|
292
|
+
const t = this;
|
|
293
|
+
return t.overflow === "hide" && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill);
|
|
294
|
+
}
|
|
268
295
|
}
|
|
269
296
|
|
|
270
297
|
class LeaferData extends GroupData {
|
|
@@ -275,75 +302,69 @@ class LeaferData extends GroupData {
|
|
|
275
302
|
}
|
|
276
303
|
}
|
|
277
304
|
|
|
278
|
-
class FrameData extends BoxData {
|
|
279
|
-
}
|
|
305
|
+
class FrameData extends BoxData {}
|
|
280
306
|
|
|
281
|
-
class LineData extends UIData {
|
|
282
|
-
}
|
|
307
|
+
class LineData extends UIData {}
|
|
283
308
|
|
|
284
309
|
class RectData extends UIData {
|
|
285
|
-
get __boxStroke() {
|
|
310
|
+
get __boxStroke() {
|
|
311
|
+
return !this.__pathInputed;
|
|
312
|
+
}
|
|
286
313
|
}
|
|
287
314
|
|
|
288
315
|
class EllipseData extends UIData {
|
|
289
|
-
get __boxStroke() {
|
|
316
|
+
get __boxStroke() {
|
|
317
|
+
return !this.__pathInputed;
|
|
318
|
+
}
|
|
290
319
|
}
|
|
291
320
|
|
|
292
|
-
class PolygonData extends UIData {
|
|
293
|
-
}
|
|
321
|
+
class PolygonData extends UIData {}
|
|
294
322
|
|
|
295
|
-
class StarData extends UIData {
|
|
296
|
-
}
|
|
323
|
+
class StarData extends UIData {}
|
|
297
324
|
|
|
298
325
|
class PathData extends UIData {
|
|
299
|
-
get __pathInputed() {
|
|
326
|
+
get __pathInputed() {
|
|
327
|
+
return 2;
|
|
328
|
+
}
|
|
300
329
|
}
|
|
301
330
|
|
|
302
|
-
class PenData extends GroupData {
|
|
303
|
-
}
|
|
331
|
+
class PenData extends GroupData {}
|
|
304
332
|
|
|
305
333
|
const fontWeightMap = {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
334
|
+
thin: 100,
|
|
335
|
+
"extra-light": 200,
|
|
336
|
+
light: 300,
|
|
337
|
+
normal: 400,
|
|
338
|
+
medium: 500,
|
|
339
|
+
"semi-bold": 600,
|
|
340
|
+
bold: 700,
|
|
341
|
+
"extra-bold": 800,
|
|
342
|
+
black: 900
|
|
315
343
|
};
|
|
344
|
+
|
|
316
345
|
class TextData extends UIData {
|
|
317
|
-
get __useNaturalRatio() {
|
|
346
|
+
get __useNaturalRatio() {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
318
349
|
setFontWeight(value) {
|
|
319
|
-
if (
|
|
320
|
-
this.__setInput(
|
|
350
|
+
if (core.isString(value)) {
|
|
351
|
+
this.__setInput("fontWeight", value);
|
|
321
352
|
value = fontWeightMap[value] || 400;
|
|
322
|
-
}
|
|
323
|
-
else if (this.__input)
|
|
324
|
-
this.__removeInput('fontWeight');
|
|
353
|
+
} else if (this.__input) this.__removeInput("fontWeight");
|
|
325
354
|
this._fontWeight = value;
|
|
326
355
|
}
|
|
327
356
|
setBoxStyle(value) {
|
|
328
357
|
let t = this.__leaf, box = t.__box;
|
|
329
358
|
if (value) {
|
|
330
|
-
const { boxStyle
|
|
331
|
-
if (box)
|
|
332
|
-
for (let key in boxStyle)
|
|
333
|
-
box[key] = undefined;
|
|
334
|
-
else
|
|
335
|
-
box = t.__box = core.UICreator.get('Rect', 0);
|
|
359
|
+
const {boxStyle: boxStyle} = this;
|
|
360
|
+
if (box) for (let key in boxStyle) box[key] = undefined; else box = t.__box = core.UICreator.get("Rect", 0);
|
|
336
361
|
const layout = t.__layout, boxLayout = box.__layout;
|
|
337
|
-
if (!boxStyle)
|
|
338
|
-
box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
362
|
+
if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
339
363
|
box.set(value);
|
|
340
|
-
if (boxLayout.strokeChanged)
|
|
341
|
-
|
|
342
|
-
if (boxLayout.renderChanged)
|
|
343
|
-
layout.renderChange();
|
|
364
|
+
if (boxLayout.strokeChanged) layout.strokeChange();
|
|
365
|
+
if (boxLayout.renderChanged) layout.renderChange();
|
|
344
366
|
box.__updateChange();
|
|
345
|
-
}
|
|
346
|
-
else if (box) {
|
|
367
|
+
} else if (box) {
|
|
347
368
|
t.__box = box.parent = null;
|
|
348
369
|
box.destroy();
|
|
349
370
|
}
|
|
@@ -357,7 +378,11 @@ class ImageData extends RectData {
|
|
|
357
378
|
this._url = value;
|
|
358
379
|
}
|
|
359
380
|
__setImageFill(value) {
|
|
360
|
-
this.fill = value ? {
|
|
381
|
+
this.fill = value ? {
|
|
382
|
+
type: "image",
|
|
383
|
+
mode: "stretch",
|
|
384
|
+
url: value
|
|
385
|
+
} : undefined;
|
|
361
386
|
}
|
|
362
387
|
__getData() {
|
|
363
388
|
const data = super.__getData();
|
|
@@ -372,11 +397,15 @@ class ImageData extends RectData {
|
|
|
372
397
|
}
|
|
373
398
|
|
|
374
399
|
class CanvasData extends RectData {
|
|
375
|
-
get __isCanvas() {
|
|
376
|
-
|
|
400
|
+
get __isCanvas() {
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
get __drawAfterFill() {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
377
406
|
__getInputData(names, options) {
|
|
378
407
|
const data = super.__getInputData(names, options);
|
|
379
|
-
data.url = this.__leaf.canvas.toDataURL(
|
|
408
|
+
data.url = this.__leaf.canvas.toDataURL("image/png");
|
|
380
409
|
return data;
|
|
381
410
|
}
|
|
382
411
|
}
|
|
@@ -384,17 +413,16 @@ class CanvasData extends RectData {
|
|
|
384
413
|
const UIBounds = {
|
|
385
414
|
__updateStrokeSpread() {
|
|
386
415
|
let width = 0, boxWidth = 0;
|
|
387
|
-
const data = this.__, { strokeAlign, strokeWidth
|
|
388
|
-
if ((data.stroke || data.hitStroke ===
|
|
389
|
-
boxWidth = width = strokeAlign ===
|
|
416
|
+
const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
|
|
417
|
+
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
418
|
+
boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
390
419
|
if (!data.__boxStroke) {
|
|
391
420
|
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
|
|
392
|
-
const storkeCapAddWidth = data.strokeCap ===
|
|
421
|
+
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
393
422
|
width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
394
423
|
}
|
|
395
424
|
}
|
|
396
|
-
if (data.__useArrow)
|
|
397
|
-
width += strokeWidth * 5;
|
|
425
|
+
if (data.__useArrow) width += strokeWidth * 5;
|
|
398
426
|
if (box) {
|
|
399
427
|
width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
|
|
400
428
|
boxWidth = box.__layout.strokeBoxSpread;
|
|
@@ -404,40 +432,37 @@ const UIBounds = {
|
|
|
404
432
|
},
|
|
405
433
|
__updateRenderSpread() {
|
|
406
434
|
let width = 0;
|
|
407
|
-
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
408
|
-
if (shadow)
|
|
409
|
-
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
if (filter)
|
|
413
|
-
width += Filter.getSpread(filter);
|
|
435
|
+
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
|
|
436
|
+
if (shadow) shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
437
|
+
if (blur) width = Math.max(width, blur);
|
|
438
|
+
if (filter) width += Filter.getSpread(filter);
|
|
439
|
+
if (renderSpread) width += renderSpread;
|
|
414
440
|
let shapeWidth = width = Math.ceil(width);
|
|
415
|
-
if (innerShadow)
|
|
416
|
-
|
|
417
|
-
if (backgroundBlur)
|
|
418
|
-
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
441
|
+
if (innerShadow) innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
442
|
+
if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
419
443
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
420
444
|
width += this.__layout.strokeSpread || 0;
|
|
421
445
|
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
422
446
|
}
|
|
423
447
|
};
|
|
424
448
|
|
|
425
|
-
const { stintSet
|
|
449
|
+
const {stintSet: stintSet} = core.DataHelper;
|
|
450
|
+
|
|
426
451
|
const UIRender = {
|
|
427
452
|
__updateChange() {
|
|
428
453
|
const data = this.__;
|
|
429
454
|
if (data.__useStroke) {
|
|
430
455
|
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
431
|
-
stintSet(this.__world,
|
|
432
|
-
stintSet(data,
|
|
456
|
+
stintSet(this.__world, "half", useStroke && data.strokeAlign === "center" && data.strokeWidth % 2);
|
|
457
|
+
stintSet(data, "__fillAfterStroke", useStroke && data.strokeAlign === "outside" && data.fill && !data.__isTransparentFill);
|
|
433
458
|
}
|
|
434
459
|
if (data.__useEffect) {
|
|
435
|
-
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
436
|
-
stintSet(data,
|
|
460
|
+
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
461
|
+
stintSet(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(core.isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
|
|
437
462
|
data.__useEffect = !!(shadow || otherEffect);
|
|
438
463
|
}
|
|
439
464
|
data.__checkSingle();
|
|
440
|
-
stintSet(data,
|
|
465
|
+
stintSet(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
441
466
|
},
|
|
442
467
|
__drawFast(canvas, options) {
|
|
443
468
|
drawFast(this, canvas, options);
|
|
@@ -445,65 +470,43 @@ const UIRender = {
|
|
|
445
470
|
__draw(canvas, options, originCanvas) {
|
|
446
471
|
const data = this.__;
|
|
447
472
|
if (data.__complex) {
|
|
448
|
-
if (data.__needComputePaint)
|
|
449
|
-
|
|
450
|
-
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
|
|
473
|
+
if (data.__needComputePaint) data.__computePaint();
|
|
474
|
+
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke, __isFastShadow: __isFastShadow} = data;
|
|
451
475
|
this.__drawRenderPath(canvas);
|
|
452
476
|
if (data.__useEffect && !__isFastShadow) {
|
|
453
477
|
const shape = Paint.shape(this, canvas, options);
|
|
454
478
|
this.__nowWorld = this.__getNowWorld(options);
|
|
455
|
-
const { shadow, innerShadow, filter } = data;
|
|
456
|
-
if (shadow)
|
|
457
|
-
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
if (innerShadow)
|
|
465
|
-
Effect.innerShadow(this, canvas, shape);
|
|
466
|
-
if (stroke && !__fillAfterStroke)
|
|
467
|
-
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
468
|
-
if (filter)
|
|
469
|
-
Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
470
|
-
if (shape.worldCanvas)
|
|
471
|
-
shape.worldCanvas.recycle();
|
|
479
|
+
const {shadow: shadow, innerShadow: innerShadow, filter: filter} = data;
|
|
480
|
+
if (shadow) Effect.shadow(this, canvas, shape);
|
|
481
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
482
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
483
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
484
|
+
if (innerShadow) Effect.innerShadow(this, canvas, shape);
|
|
485
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
486
|
+
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
487
|
+
if (shape.worldCanvas) shape.worldCanvas.recycle();
|
|
472
488
|
shape.canvas.recycle();
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
if (__fillAfterStroke)
|
|
476
|
-
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
489
|
+
} else {
|
|
490
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
477
491
|
if (__isFastShadow) {
|
|
478
|
-
const shadow = data.shadow[0], { scaleX, scaleY } = this.
|
|
492
|
+
const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
|
|
479
493
|
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
480
494
|
}
|
|
481
|
-
if (fill)
|
|
482
|
-
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
if (__drawAfterFill)
|
|
486
|
-
this.__drawAfterFill(canvas, options);
|
|
487
|
-
if (stroke && !__fillAfterStroke)
|
|
488
|
-
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
495
|
+
if (fill) data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
496
|
+
if (__isFastShadow) canvas.restore();
|
|
497
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
498
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
489
499
|
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (data.__pathInputed)
|
|
493
|
-
drawFast(this, canvas, options);
|
|
494
|
-
else
|
|
495
|
-
this.__drawFast(canvas, options);
|
|
500
|
+
} else {
|
|
501
|
+
if (data.__pathInputed) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
496
502
|
}
|
|
497
503
|
},
|
|
498
504
|
__drawShape(canvas, options) {
|
|
499
505
|
this.__drawRenderPath(canvas);
|
|
500
|
-
const data = this.__, { fill, stroke } = data;
|
|
501
|
-
if (fill && !options.ignoreFill)
|
|
502
|
-
|
|
503
|
-
if (data.
|
|
504
|
-
this.__drawAfterFill(canvas, options);
|
|
505
|
-
if (stroke && !options.ignoreStroke)
|
|
506
|
-
data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
506
|
+
const data = this.__, {fill: fill, stroke: stroke} = data;
|
|
507
|
+
if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill("#000000", this, canvas);
|
|
508
|
+
if (data.__isCanvas) this.__drawAfterFill(canvas, options);
|
|
509
|
+
if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke("#000000", this, canvas);
|
|
507
510
|
},
|
|
508
511
|
__drawAfterFill(canvas, options) {
|
|
509
512
|
if (this.__.__clipAfterFill) {
|
|
@@ -511,108 +514,126 @@ const UIRender = {
|
|
|
511
514
|
canvas.clipUI(this);
|
|
512
515
|
this.__drawContent(canvas, options);
|
|
513
516
|
canvas.restore();
|
|
514
|
-
}
|
|
515
|
-
else
|
|
516
|
-
this.__drawContent(canvas, options);
|
|
517
|
+
} else this.__drawContent(canvas, options);
|
|
517
518
|
}
|
|
518
519
|
};
|
|
520
|
+
|
|
519
521
|
function drawFast(ui, canvas, options) {
|
|
520
|
-
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
|
|
522
|
+
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill, __fillAfterStroke: __fillAfterStroke} = ui.__;
|
|
521
523
|
ui.__drawRenderPath(canvas);
|
|
522
|
-
if (__fillAfterStroke)
|
|
523
|
-
|
|
524
|
-
if (
|
|
525
|
-
|
|
526
|
-
if (__drawAfterFill)
|
|
527
|
-
ui.__drawAfterFill(canvas, options);
|
|
528
|
-
if (stroke && !__fillAfterStroke)
|
|
529
|
-
Paint.stroke(stroke, ui, canvas);
|
|
524
|
+
if (__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
525
|
+
if (fill) Paint.fill(fill, ui, canvas);
|
|
526
|
+
if (__drawAfterFill) ui.__drawAfterFill(canvas, options);
|
|
527
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke, ui, canvas);
|
|
530
528
|
}
|
|
531
529
|
|
|
532
530
|
const RectRender = {
|
|
533
531
|
__drawFast(canvas, options) {
|
|
534
|
-
let { x, y, width, height } = this.__layout.boxBounds;
|
|
535
|
-
const { fill, stroke, __drawAfterFill } = this.__;
|
|
532
|
+
let {x: x, y: y, width: width, height: height} = this.__layout.boxBounds;
|
|
533
|
+
const {fill: fill, stroke: stroke, __drawAfterFill: __drawAfterFill} = this.__;
|
|
536
534
|
if (fill) {
|
|
537
535
|
canvas.fillStyle = fill;
|
|
538
536
|
canvas.fillRect(x, y, width, height);
|
|
539
537
|
}
|
|
540
|
-
if (__drawAfterFill)
|
|
541
|
-
this.__drawAfterFill(canvas, options);
|
|
538
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options);
|
|
542
539
|
if (stroke) {
|
|
543
|
-
const { strokeAlign, __strokeWidth } = this.__;
|
|
544
|
-
if (!
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const half = __strokeWidth / 2;
|
|
540
|
+
const {strokeAlign: strokeAlign, __strokeWidth: strokeWidth} = this.__;
|
|
541
|
+
if (!strokeWidth) return;
|
|
542
|
+
canvas.setStroke(stroke, strokeWidth, this.__);
|
|
543
|
+
const half = strokeWidth / 2;
|
|
548
544
|
switch (strokeAlign) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
545
|
+
case "center":
|
|
546
|
+
canvas.strokeRect(0, 0, width, height);
|
|
547
|
+
break;
|
|
548
|
+
|
|
549
|
+
case "inside":
|
|
550
|
+
width -= strokeWidth, height -= strokeWidth;
|
|
551
|
+
if (width < 0 || height < 0) {
|
|
552
|
+
canvas.save();
|
|
553
|
+
this.__clip(canvas, options);
|
|
554
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
555
|
+
canvas.restore();
|
|
556
|
+
} else canvas.strokeRect(x + half, y + half, width, height);
|
|
557
|
+
break;
|
|
558
|
+
|
|
559
|
+
case "outside":
|
|
560
|
+
canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
|
|
561
|
+
break;
|
|
566
562
|
}
|
|
567
563
|
}
|
|
568
564
|
}
|
|
569
565
|
};
|
|
570
566
|
|
|
571
567
|
var UI_1;
|
|
568
|
+
|
|
572
569
|
exports.UI = UI_1 = class UI extends core.Leaf {
|
|
573
|
-
get app() {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
get
|
|
570
|
+
get app() {
|
|
571
|
+
return this.leafer && this.leafer.app;
|
|
572
|
+
}
|
|
573
|
+
get isFrame() {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
set scale(value) {
|
|
577
|
+
core.MathHelper.assignScale(this, value);
|
|
578
|
+
}
|
|
579
|
+
get scale() {
|
|
580
|
+
return this.__.scale;
|
|
581
|
+
}
|
|
582
|
+
get isAutoWidth() {
|
|
583
|
+
const t = this.__;
|
|
584
|
+
return t.__autoWidth || t.autoWidth;
|
|
585
|
+
}
|
|
586
|
+
get isAutoHeight() {
|
|
587
|
+
const t = this.__;
|
|
588
|
+
return t.__autoHeight || t.autoHeight;
|
|
589
|
+
}
|
|
577
590
|
get pen() {
|
|
578
|
-
const { path
|
|
591
|
+
const {path: path} = this.__;
|
|
579
592
|
core.pen.set(this.path = path || []);
|
|
580
|
-
if (!path)
|
|
581
|
-
this.__drawPathByBox(core.pen);
|
|
593
|
+
if (!path) this.__drawPathByBox(core.pen);
|
|
582
594
|
return core.pen;
|
|
583
595
|
}
|
|
584
596
|
constructor(data) {
|
|
585
597
|
super(data);
|
|
586
598
|
}
|
|
587
|
-
reset(_data) {
|
|
599
|
+
reset(_data) {}
|
|
588
600
|
set(data, transition) {
|
|
589
601
|
if (data) {
|
|
590
602
|
if (transition) {
|
|
591
|
-
if (transition ===
|
|
603
|
+
if (transition === "temp") {
|
|
592
604
|
this.lockNormalStyle = true;
|
|
593
605
|
Object.assign(this, data);
|
|
594
606
|
this.lockNormalStyle = false;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
this.animate(data, transition);
|
|
598
|
-
}
|
|
599
|
-
else
|
|
600
|
-
Object.assign(this, data);
|
|
607
|
+
} else this.animate(data, transition);
|
|
608
|
+
} else Object.assign(this, data);
|
|
601
609
|
}
|
|
602
610
|
}
|
|
603
611
|
get(name) {
|
|
604
|
-
return
|
|
612
|
+
return core.isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
613
|
+
}
|
|
614
|
+
createProxyData() {
|
|
615
|
+
return undefined;
|
|
616
|
+
}
|
|
617
|
+
find(_condition, _options) {
|
|
618
|
+
return core.Plugin.need("find");
|
|
619
|
+
}
|
|
620
|
+
findTag(tag) {
|
|
621
|
+
return this.find({
|
|
622
|
+
tag: tag
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
findOne(_condition, _options) {
|
|
626
|
+
return core.Plugin.need("find");
|
|
627
|
+
}
|
|
628
|
+
findId(id) {
|
|
629
|
+
return this.findOne({
|
|
630
|
+
id: id
|
|
631
|
+
});
|
|
605
632
|
}
|
|
606
|
-
createProxyData() { return undefined; }
|
|
607
|
-
find(_condition, _options) { return core.Plugin.need('find'); }
|
|
608
|
-
findTag(tag) { return this.find({ tag }); }
|
|
609
|
-
findOne(_condition, _options) { return core.Plugin.need('find'); }
|
|
610
|
-
findId(id) { return this.findOne({ id }); }
|
|
611
633
|
getPath(curve, pathForRender) {
|
|
612
634
|
this.__layout.update();
|
|
613
635
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
614
|
-
if (!path)
|
|
615
|
-
core.pen.set(path = []), this.__drawPathByBox(core.pen);
|
|
636
|
+
if (!path) core.pen.set(path = []), this.__drawPathByBox(core.pen);
|
|
616
637
|
return curve ? core.PathConvert.toCanvasData(path, true) : path;
|
|
617
638
|
}
|
|
618
639
|
getPathString(curve, pathForRender, floatLength) {
|
|
@@ -624,18 +645,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
624
645
|
__onUpdateSize() {
|
|
625
646
|
if (this.__.__input) {
|
|
626
647
|
const data = this.__;
|
|
627
|
-
|
|
648
|
+
data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
|
|
628
649
|
}
|
|
629
650
|
}
|
|
630
651
|
__updateRenderPath() {
|
|
631
652
|
const data = this.__;
|
|
632
653
|
if (data.path) {
|
|
633
654
|
data.__pathForRender = data.cornerRadius ? core.PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
634
|
-
if (data.__useArrow)
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
else
|
|
638
|
-
data.__pathForRender && (data.__pathForRender = undefined);
|
|
655
|
+
if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
|
|
656
|
+
} else data.__pathForRender && (data.__pathForRender = undefined);
|
|
639
657
|
}
|
|
640
658
|
__drawRenderPath(canvas) {
|
|
641
659
|
canvas.beginPath();
|
|
@@ -649,31 +667,28 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
649
667
|
data ? core.PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
650
668
|
}
|
|
651
669
|
__drawPathByBox(drawer) {
|
|
652
|
-
const { x, y, width, height } = this.__layout.boxBounds;
|
|
670
|
+
const {x: x, y: y, width: width, height: height} = this.__layout.boxBounds;
|
|
653
671
|
if (this.__.cornerRadius) {
|
|
654
|
-
const { cornerRadius
|
|
655
|
-
drawer.roundRect(x, y, width, height,
|
|
656
|
-
}
|
|
657
|
-
else
|
|
658
|
-
drawer.rect(x, y, width, height);
|
|
672
|
+
const {cornerRadius: cornerRadius} = this.__;
|
|
673
|
+
drawer.roundRect(x, y, width, height, core.isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
674
|
+
} else drawer.rect(x, y, width, height);
|
|
659
675
|
}
|
|
660
676
|
drawImagePlaceholder(canvas, _image) {
|
|
661
677
|
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
662
678
|
}
|
|
663
679
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
664
|
-
return core.Plugin.need(
|
|
680
|
+
return core.Plugin.need("animate");
|
|
665
681
|
}
|
|
666
|
-
killAnimate(_type, _nextStyle) {
|
|
682
|
+
killAnimate(_type, _nextStyle) {}
|
|
667
683
|
export(_filename, _options) {
|
|
668
|
-
return core.Plugin.need(
|
|
684
|
+
return core.Plugin.need("export");
|
|
669
685
|
}
|
|
670
686
|
syncExport(_filename, _options) {
|
|
671
|
-
return core.Plugin.need(
|
|
687
|
+
return core.Plugin.need("export");
|
|
672
688
|
}
|
|
673
689
|
clone(data) {
|
|
674
690
|
const json = core.DataHelper.clone(this.toJSON());
|
|
675
|
-
if (data)
|
|
676
|
-
Object.assign(json, data);
|
|
691
|
+
if (data) Object.assign(json, data);
|
|
677
692
|
return UI_1.one(json);
|
|
678
693
|
}
|
|
679
694
|
static one(data, x, y, width, height) {
|
|
@@ -685,238 +700,169 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
685
700
|
static registerData(data) {
|
|
686
701
|
core.dataProcessor(data)(this.prototype);
|
|
687
702
|
}
|
|
688
|
-
static setEditConfig(_config) {
|
|
689
|
-
static setEditOuter(_toolName) {
|
|
690
|
-
static setEditInner(_editorName) {
|
|
703
|
+
static setEditConfig(_config) {}
|
|
704
|
+
static setEditOuter(_toolName) {}
|
|
705
|
+
static setEditInner(_editorName) {}
|
|
691
706
|
destroy() {
|
|
692
707
|
this.fill = this.stroke = null;
|
|
693
|
-
if (this.__animate)
|
|
694
|
-
this.killAnimate();
|
|
708
|
+
if (this.__animate) this.killAnimate();
|
|
695
709
|
super.destroy();
|
|
696
710
|
}
|
|
697
711
|
};
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
__decorate([
|
|
702
|
-
|
|
703
|
-
], exports.UI.prototype, "
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
__decorate([
|
|
708
|
-
|
|
709
|
-
], exports.UI.prototype, "
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
__decorate([
|
|
714
|
-
|
|
715
|
-
], exports.UI.prototype, "
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
__decorate([
|
|
720
|
-
|
|
721
|
-
], exports.UI.prototype, "
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
__decorate([
|
|
726
|
-
|
|
727
|
-
], exports.UI.prototype, "
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
__decorate([
|
|
732
|
-
|
|
733
|
-
], exports.UI.prototype, "
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
__decorate([
|
|
738
|
-
|
|
739
|
-
], exports.UI.prototype, "
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
__decorate([
|
|
744
|
-
|
|
745
|
-
], exports.UI.prototype, "
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
__decorate([
|
|
750
|
-
|
|
751
|
-
], exports.UI.prototype, "
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
__decorate([
|
|
756
|
-
|
|
757
|
-
], exports.UI.prototype, "
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
__decorate([
|
|
762
|
-
|
|
763
|
-
], exports.UI.prototype, "
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
__decorate([
|
|
768
|
-
|
|
769
|
-
], exports.UI.prototype, "
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
__decorate([
|
|
774
|
-
|
|
775
|
-
], exports.UI.prototype, "
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
__decorate([
|
|
780
|
-
|
|
781
|
-
], exports.UI.prototype, "
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
__decorate([
|
|
786
|
-
|
|
787
|
-
], exports.UI.prototype, "
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
__decorate([
|
|
792
|
-
|
|
793
|
-
], exports.UI.prototype, "
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
__decorate([
|
|
798
|
-
|
|
799
|
-
], exports.UI.prototype, "
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
__decorate([
|
|
804
|
-
|
|
805
|
-
], exports.UI.prototype, "
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
__decorate([
|
|
810
|
-
|
|
811
|
-
], exports.UI.prototype, "
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
__decorate([
|
|
816
|
-
|
|
817
|
-
], exports.UI.prototype, "
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
__decorate([
|
|
822
|
-
|
|
823
|
-
], exports.UI.prototype, "
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
__decorate([
|
|
828
|
-
|
|
829
|
-
], exports.UI.prototype, "
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
__decorate([
|
|
834
|
-
|
|
835
|
-
], exports.UI.prototype, "
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
__decorate([
|
|
840
|
-
|
|
841
|
-
], exports.UI.prototype, "
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
], exports.UI.prototype, "cursor", void 0);
|
|
845
|
-
__decorate([
|
|
846
|
-
core.surfaceType()
|
|
847
|
-
], exports.UI.prototype, "fill", void 0);
|
|
848
|
-
__decorate([
|
|
849
|
-
core.strokeType(undefined, true)
|
|
850
|
-
], exports.UI.prototype, "stroke", void 0);
|
|
851
|
-
__decorate([
|
|
852
|
-
core.strokeType('inside')
|
|
853
|
-
], exports.UI.prototype, "strokeAlign", void 0);
|
|
854
|
-
__decorate([
|
|
855
|
-
core.strokeType(1, true)
|
|
856
|
-
], exports.UI.prototype, "strokeWidth", void 0);
|
|
857
|
-
__decorate([
|
|
858
|
-
core.strokeType(false)
|
|
859
|
-
], exports.UI.prototype, "strokeWidthFixed", void 0);
|
|
860
|
-
__decorate([
|
|
861
|
-
core.strokeType('none')
|
|
862
|
-
], exports.UI.prototype, "strokeCap", void 0);
|
|
863
|
-
__decorate([
|
|
864
|
-
core.strokeType('miter')
|
|
865
|
-
], exports.UI.prototype, "strokeJoin", void 0);
|
|
866
|
-
__decorate([
|
|
867
|
-
core.strokeType()
|
|
868
|
-
], exports.UI.prototype, "dashPattern", void 0);
|
|
869
|
-
__decorate([
|
|
870
|
-
core.strokeType(0)
|
|
871
|
-
], exports.UI.prototype, "dashOffset", void 0);
|
|
872
|
-
__decorate([
|
|
873
|
-
core.strokeType(10)
|
|
874
|
-
], exports.UI.prototype, "miterLimit", void 0);
|
|
875
|
-
__decorate([
|
|
876
|
-
core.pathType(0)
|
|
877
|
-
], exports.UI.prototype, "cornerRadius", void 0);
|
|
878
|
-
__decorate([
|
|
879
|
-
core.pathType()
|
|
880
|
-
], exports.UI.prototype, "cornerSmoothing", void 0);
|
|
881
|
-
__decorate([
|
|
882
|
-
effectType()
|
|
883
|
-
], exports.UI.prototype, "shadow", void 0);
|
|
884
|
-
__decorate([
|
|
885
|
-
effectType()
|
|
886
|
-
], exports.UI.prototype, "innerShadow", void 0);
|
|
887
|
-
__decorate([
|
|
888
|
-
effectType()
|
|
889
|
-
], exports.UI.prototype, "blur", void 0);
|
|
890
|
-
__decorate([
|
|
891
|
-
effectType()
|
|
892
|
-
], exports.UI.prototype, "backgroundBlur", void 0);
|
|
893
|
-
__decorate([
|
|
894
|
-
effectType()
|
|
895
|
-
], exports.UI.prototype, "grayscale", void 0);
|
|
896
|
-
__decorate([
|
|
897
|
-
effectType()
|
|
898
|
-
], exports.UI.prototype, "filter", void 0);
|
|
899
|
-
__decorate([
|
|
900
|
-
core.surfaceType()
|
|
901
|
-
], exports.UI.prototype, "placeholderColor", void 0);
|
|
902
|
-
__decorate([
|
|
903
|
-
core.dataType(100)
|
|
904
|
-
], exports.UI.prototype, "placeholderDelay", void 0);
|
|
905
|
-
__decorate([
|
|
906
|
-
core.dataType({})
|
|
907
|
-
], exports.UI.prototype, "data", void 0);
|
|
908
|
-
__decorate([
|
|
909
|
-
core.rewrite(core.Leaf.prototype.reset)
|
|
910
|
-
], exports.UI.prototype, "reset", null);
|
|
911
|
-
exports.UI = UI_1 = __decorate([
|
|
912
|
-
core.useModule(UIBounds),
|
|
913
|
-
core.useModule(UIRender),
|
|
914
|
-
core.rewriteAble()
|
|
915
|
-
], exports.UI);
|
|
712
|
+
|
|
713
|
+
__decorate([ core.dataProcessor(UIData) ], exports.UI.prototype, "__", void 0);
|
|
714
|
+
|
|
715
|
+
__decorate([ zoomLayerType() ], exports.UI.prototype, "zoomLayer", void 0);
|
|
716
|
+
|
|
717
|
+
__decorate([ core.dataType("") ], exports.UI.prototype, "id", void 0);
|
|
718
|
+
|
|
719
|
+
__decorate([ core.dataType("") ], exports.UI.prototype, "name", void 0);
|
|
720
|
+
|
|
721
|
+
__decorate([ core.dataType("") ], exports.UI.prototype, "className", void 0);
|
|
722
|
+
|
|
723
|
+
__decorate([ core.surfaceType("pass-through") ], exports.UI.prototype, "blendMode", void 0);
|
|
724
|
+
|
|
725
|
+
__decorate([ core.opacityType(1) ], exports.UI.prototype, "opacity", void 0);
|
|
726
|
+
|
|
727
|
+
__decorate([ core.visibleType(true) ], exports.UI.prototype, "visible", void 0);
|
|
728
|
+
|
|
729
|
+
__decorate([ core.surfaceType(false) ], exports.UI.prototype, "locked", void 0);
|
|
730
|
+
|
|
731
|
+
__decorate([ core.surfaceType(false) ], exports.UI.prototype, "dim", void 0);
|
|
732
|
+
|
|
733
|
+
__decorate([ core.surfaceType(false) ], exports.UI.prototype, "dimskip", void 0);
|
|
734
|
+
|
|
735
|
+
__decorate([ core.sortType(0) ], exports.UI.prototype, "zIndex", void 0);
|
|
736
|
+
|
|
737
|
+
__decorate([ core.maskType(false) ], exports.UI.prototype, "mask", void 0);
|
|
738
|
+
|
|
739
|
+
__decorate([ core.eraserType(false) ], exports.UI.prototype, "eraser", void 0);
|
|
740
|
+
|
|
741
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "x", void 0);
|
|
742
|
+
|
|
743
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "y", void 0);
|
|
744
|
+
|
|
745
|
+
__decorate([ core.boundsType(100, true) ], exports.UI.prototype, "width", void 0);
|
|
746
|
+
|
|
747
|
+
__decorate([ core.boundsType(100, true) ], exports.UI.prototype, "height", void 0);
|
|
748
|
+
|
|
749
|
+
__decorate([ core.scaleType(1, true) ], exports.UI.prototype, "scaleX", void 0);
|
|
750
|
+
|
|
751
|
+
__decorate([ core.scaleType(1, true) ], exports.UI.prototype, "scaleY", void 0);
|
|
752
|
+
|
|
753
|
+
__decorate([ core.rotationType(0, true) ], exports.UI.prototype, "rotation", void 0);
|
|
754
|
+
|
|
755
|
+
__decorate([ core.rotationType(0, true) ], exports.UI.prototype, "skewX", void 0);
|
|
756
|
+
|
|
757
|
+
__decorate([ core.rotationType(0, true) ], exports.UI.prototype, "skewY", void 0);
|
|
758
|
+
|
|
759
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "offsetX", void 0);
|
|
760
|
+
|
|
761
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "offsetY", void 0);
|
|
762
|
+
|
|
763
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "scrollX", void 0);
|
|
764
|
+
|
|
765
|
+
__decorate([ core.positionType(0, true) ], exports.UI.prototype, "scrollY", void 0);
|
|
766
|
+
|
|
767
|
+
__decorate([ core.autoLayoutType() ], exports.UI.prototype, "origin", void 0);
|
|
768
|
+
|
|
769
|
+
__decorate([ core.autoLayoutType() ], exports.UI.prototype, "around", void 0);
|
|
770
|
+
|
|
771
|
+
__decorate([ core.dataType(false) ], exports.UI.prototype, "lazy", void 0);
|
|
772
|
+
|
|
773
|
+
__decorate([ core.naturalBoundsType(1) ], exports.UI.prototype, "pixelRatio", void 0);
|
|
774
|
+
|
|
775
|
+
__decorate([ core.affectRenderBoundsType(0) ], exports.UI.prototype, "renderSpread", void 0);
|
|
776
|
+
|
|
777
|
+
__decorate([ core.pathInputType() ], exports.UI.prototype, "path", void 0);
|
|
778
|
+
|
|
779
|
+
__decorate([ core.pathType() ], exports.UI.prototype, "windingRule", void 0);
|
|
780
|
+
|
|
781
|
+
__decorate([ core.pathType(true) ], exports.UI.prototype, "closed", void 0);
|
|
782
|
+
|
|
783
|
+
__decorate([ core.boundsType(0) ], exports.UI.prototype, "padding", void 0);
|
|
784
|
+
|
|
785
|
+
__decorate([ core.boundsType(false) ], exports.UI.prototype, "lockRatio", void 0);
|
|
786
|
+
|
|
787
|
+
__decorate([ core.boundsType() ], exports.UI.prototype, "widthRange", void 0);
|
|
788
|
+
|
|
789
|
+
__decorate([ core.boundsType() ], exports.UI.prototype, "heightRange", void 0);
|
|
790
|
+
|
|
791
|
+
__decorate([ core.dataType(false) ], exports.UI.prototype, "draggable", void 0);
|
|
792
|
+
|
|
793
|
+
__decorate([ core.dataType() ], exports.UI.prototype, "dragBounds", void 0);
|
|
794
|
+
|
|
795
|
+
__decorate([ core.dataType(false) ], exports.UI.prototype, "editable", void 0);
|
|
796
|
+
|
|
797
|
+
__decorate([ core.hitType(true) ], exports.UI.prototype, "hittable", void 0);
|
|
798
|
+
|
|
799
|
+
__decorate([ core.hitType("path") ], exports.UI.prototype, "hitFill", void 0);
|
|
800
|
+
|
|
801
|
+
__decorate([ core.strokeType("path") ], exports.UI.prototype, "hitStroke", void 0);
|
|
802
|
+
|
|
803
|
+
__decorate([ core.hitType(false) ], exports.UI.prototype, "hitBox", void 0);
|
|
804
|
+
|
|
805
|
+
__decorate([ core.hitType(true) ], exports.UI.prototype, "hitChildren", void 0);
|
|
806
|
+
|
|
807
|
+
__decorate([ core.hitType(true) ], exports.UI.prototype, "hitSelf", void 0);
|
|
808
|
+
|
|
809
|
+
__decorate([ core.hitType() ], exports.UI.prototype, "hitRadius", void 0);
|
|
810
|
+
|
|
811
|
+
__decorate([ core.cursorType("") ], exports.UI.prototype, "cursor", void 0);
|
|
812
|
+
|
|
813
|
+
__decorate([ core.surfaceType() ], exports.UI.prototype, "fill", void 0);
|
|
814
|
+
|
|
815
|
+
__decorate([ core.strokeType(undefined, true) ], exports.UI.prototype, "stroke", void 0);
|
|
816
|
+
|
|
817
|
+
__decorate([ core.strokeType("inside") ], exports.UI.prototype, "strokeAlign", void 0);
|
|
818
|
+
|
|
819
|
+
__decorate([ core.strokeType(1, true) ], exports.UI.prototype, "strokeWidth", void 0);
|
|
820
|
+
|
|
821
|
+
__decorate([ core.strokeType(false) ], exports.UI.prototype, "strokeWidthFixed", void 0);
|
|
822
|
+
|
|
823
|
+
__decorate([ core.strokeType("none") ], exports.UI.prototype, "strokeCap", void 0);
|
|
824
|
+
|
|
825
|
+
__decorate([ core.strokeType("miter") ], exports.UI.prototype, "strokeJoin", void 0);
|
|
826
|
+
|
|
827
|
+
__decorate([ core.strokeType() ], exports.UI.prototype, "dashPattern", void 0);
|
|
828
|
+
|
|
829
|
+
__decorate([ core.strokeType(0) ], exports.UI.prototype, "dashOffset", void 0);
|
|
830
|
+
|
|
831
|
+
__decorate([ core.strokeType(10) ], exports.UI.prototype, "miterLimit", void 0);
|
|
832
|
+
|
|
833
|
+
__decorate([ core.pathType(0) ], exports.UI.prototype, "cornerRadius", void 0);
|
|
834
|
+
|
|
835
|
+
__decorate([ core.pathType() ], exports.UI.prototype, "cornerSmoothing", void 0);
|
|
836
|
+
|
|
837
|
+
__decorate([ effectType() ], exports.UI.prototype, "shadow", void 0);
|
|
838
|
+
|
|
839
|
+
__decorate([ effectType() ], exports.UI.prototype, "innerShadow", void 0);
|
|
840
|
+
|
|
841
|
+
__decorate([ effectType() ], exports.UI.prototype, "blur", void 0);
|
|
842
|
+
|
|
843
|
+
__decorate([ effectType() ], exports.UI.prototype, "backgroundBlur", void 0);
|
|
844
|
+
|
|
845
|
+
__decorate([ effectType() ], exports.UI.prototype, "grayscale", void 0);
|
|
846
|
+
|
|
847
|
+
__decorate([ effectType() ], exports.UI.prototype, "filter", void 0);
|
|
848
|
+
|
|
849
|
+
__decorate([ core.surfaceType() ], exports.UI.prototype, "placeholderColor", void 0);
|
|
850
|
+
|
|
851
|
+
__decorate([ core.dataType(100) ], exports.UI.prototype, "placeholderDelay", void 0);
|
|
852
|
+
|
|
853
|
+
__decorate([ core.dataType({}) ], exports.UI.prototype, "data", void 0);
|
|
854
|
+
|
|
855
|
+
__decorate([ core.rewrite(core.Leaf.prototype.reset) ], exports.UI.prototype, "reset", null);
|
|
856
|
+
|
|
857
|
+
exports.UI = UI_1 = __decorate([ core.useModule(UIBounds), core.useModule(UIRender), core.rewriteAble() ], exports.UI);
|
|
916
858
|
|
|
917
859
|
exports.Group = class Group extends exports.UI {
|
|
918
|
-
get __tag() {
|
|
919
|
-
|
|
860
|
+
get __tag() {
|
|
861
|
+
return "Group";
|
|
862
|
+
}
|
|
863
|
+
get isBranch() {
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
920
866
|
constructor(data) {
|
|
921
867
|
super(data);
|
|
922
868
|
}
|
|
@@ -925,29 +871,28 @@ exports.Group = class Group extends exports.UI {
|
|
|
925
871
|
super.reset(data);
|
|
926
872
|
}
|
|
927
873
|
__setBranch() {
|
|
928
|
-
if (!this.children)
|
|
929
|
-
this.children = [];
|
|
874
|
+
if (!this.children) this.children = [];
|
|
930
875
|
}
|
|
931
876
|
set(data, transition) {
|
|
932
877
|
if (data) {
|
|
933
878
|
if (data.children) {
|
|
934
|
-
const { children
|
|
879
|
+
const {children: children} = data;
|
|
935
880
|
delete data.children;
|
|
936
881
|
this.children ? this.clear() : this.__setBranch();
|
|
937
882
|
super.set(data, transition);
|
|
938
883
|
children.forEach(child => this.add(child));
|
|
939
884
|
data.children = children;
|
|
940
|
-
}
|
|
941
|
-
else
|
|
942
|
-
super.set(data, transition);
|
|
885
|
+
} else super.set(data, transition);
|
|
943
886
|
}
|
|
944
887
|
}
|
|
945
888
|
toJSON(options) {
|
|
946
889
|
const data = super.toJSON(options);
|
|
947
|
-
data.children = this.children.map(child => child.toJSON(options));
|
|
890
|
+
if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
|
|
948
891
|
return data;
|
|
949
892
|
}
|
|
950
|
-
pick(_hitPoint, _options) {
|
|
893
|
+
pick(_hitPoint, _options) {
|
|
894
|
+
return undefined;
|
|
895
|
+
}
|
|
951
896
|
addAt(child, index) {
|
|
952
897
|
this.add(child, index);
|
|
953
898
|
}
|
|
@@ -957,45 +902,63 @@ exports.Group = class Group extends exports.UI {
|
|
|
957
902
|
addBefore(child, before) {
|
|
958
903
|
this.add(child, this.children.indexOf(before));
|
|
959
904
|
}
|
|
960
|
-
add(_child, _index) {
|
|
961
|
-
addMany(..._children) {
|
|
962
|
-
remove(_child, _destroy) {
|
|
963
|
-
removeAll(_destroy) {
|
|
964
|
-
clear() {
|
|
905
|
+
add(_child, _index) {}
|
|
906
|
+
addMany(..._children) {}
|
|
907
|
+
remove(_child, _destroy) {}
|
|
908
|
+
removeAll(_destroy) {}
|
|
909
|
+
clear() {}
|
|
965
910
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
__decorate([
|
|
970
|
-
|
|
971
|
-
], exports.Group.prototype, "
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
], exports.Group.prototype, "height", void 0);
|
|
975
|
-
exports.Group = __decorate([
|
|
976
|
-
core.useModule(core.Branch),
|
|
977
|
-
core.registerUI()
|
|
978
|
-
], exports.Group);
|
|
911
|
+
|
|
912
|
+
__decorate([ core.dataProcessor(GroupData) ], exports.Group.prototype, "__", void 0);
|
|
913
|
+
|
|
914
|
+
__decorate([ core.boundsType(0) ], exports.Group.prototype, "width", void 0);
|
|
915
|
+
|
|
916
|
+
__decorate([ core.boundsType(0) ], exports.Group.prototype, "height", void 0);
|
|
917
|
+
|
|
918
|
+
exports.Group = __decorate([ core.useModule(core.Branch), core.registerUI() ], exports.Group);
|
|
979
919
|
|
|
980
920
|
var Leafer_1;
|
|
981
|
-
|
|
921
|
+
|
|
922
|
+
const debug = core.Debug.get("Leafer");
|
|
923
|
+
|
|
982
924
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
983
|
-
get __tag() {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
get
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
get
|
|
990
|
-
|
|
991
|
-
|
|
925
|
+
get __tag() {
|
|
926
|
+
return "Leafer";
|
|
927
|
+
}
|
|
928
|
+
get isApp() {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
get app() {
|
|
932
|
+
return this.parent || this;
|
|
933
|
+
}
|
|
934
|
+
get isLeafer() {
|
|
935
|
+
return true;
|
|
936
|
+
}
|
|
937
|
+
get imageReady() {
|
|
938
|
+
return this.viewReady && core.Resource.isComplete;
|
|
939
|
+
}
|
|
940
|
+
get layoutLocked() {
|
|
941
|
+
return !this.layouter.running;
|
|
942
|
+
}
|
|
943
|
+
get FPS() {
|
|
944
|
+
return this.renderer ? this.renderer.FPS : 60;
|
|
945
|
+
}
|
|
946
|
+
get cursorPoint() {
|
|
947
|
+
return this.interaction && this.interaction.hoverData || {
|
|
948
|
+
x: this.width / 2,
|
|
949
|
+
y: this.height / 2
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
get clientBounds() {
|
|
953
|
+
return this.canvas && this.canvas.getClientBounds(true) || core.getBoundsData();
|
|
954
|
+
}
|
|
992
955
|
constructor(userConfig, data) {
|
|
993
956
|
super(data);
|
|
994
957
|
this.config = {
|
|
995
958
|
start: true,
|
|
996
959
|
hittable: true,
|
|
997
960
|
smooth: true,
|
|
998
|
-
lazySpeard: 100
|
|
961
|
+
lazySpeard: 100
|
|
999
962
|
};
|
|
1000
963
|
this.leafs = 0;
|
|
1001
964
|
this.__eventIds = [];
|
|
@@ -1005,15 +968,13 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1005
968
|
this.__viewCompletedWait = [];
|
|
1006
969
|
this.__nextRenderWait = [];
|
|
1007
970
|
this.userConfig = userConfig;
|
|
1008
|
-
if (userConfig && (userConfig.view || userConfig.width))
|
|
1009
|
-
this.init(userConfig);
|
|
971
|
+
if (userConfig && (userConfig.view || userConfig.width)) this.init(userConfig);
|
|
1010
972
|
Leafer_1.list.add(this);
|
|
1011
973
|
}
|
|
1012
974
|
init(userConfig, parentApp) {
|
|
1013
|
-
if (this.canvas)
|
|
1014
|
-
return;
|
|
975
|
+
if (this.canvas) return;
|
|
1015
976
|
let start;
|
|
1016
|
-
const { config
|
|
977
|
+
const {config: config} = this;
|
|
1017
978
|
this.__setLeafer(this);
|
|
1018
979
|
if (parentApp) {
|
|
1019
980
|
this.parentApp = parentApp;
|
|
@@ -1028,8 +989,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1028
989
|
}
|
|
1029
990
|
const canvas = this.canvas = core.Creator.canvas(config);
|
|
1030
991
|
this.__controllers.push(this.renderer = core.Creator.renderer(this, canvas, config), this.watcher = core.Creator.watcher(this, config), this.layouter = core.Creator.layouter(this, config));
|
|
1031
|
-
if (this.isApp)
|
|
1032
|
-
this.__setApp();
|
|
992
|
+
if (this.isApp) this.__setApp();
|
|
1033
993
|
this.__checkAutoLayout(config, parentApp);
|
|
1034
994
|
this.view = canvas.view;
|
|
1035
995
|
if (!parentApp) {
|
|
@@ -1039,22 +999,23 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1039
999
|
this.__controllers.unshift(this.interaction);
|
|
1040
1000
|
this.hitCanvasManager = core.Creator.hitCanvasManager();
|
|
1041
1001
|
}
|
|
1042
|
-
this.canvasManager = new core.CanvasManager
|
|
1002
|
+
this.canvasManager = new core.CanvasManager;
|
|
1043
1003
|
start = config.start;
|
|
1044
1004
|
}
|
|
1045
1005
|
this.hittable = config.hittable;
|
|
1046
1006
|
this.fill = config.fill;
|
|
1047
1007
|
this.canvasManager.add(canvas);
|
|
1048
1008
|
this.__listenEvents();
|
|
1049
|
-
if (start)
|
|
1050
|
-
this.__startTimer = setTimeout(this.start.bind(this));
|
|
1009
|
+
if (start) this.__startTimer = setTimeout(this.start.bind(this));
|
|
1051
1010
|
core.WaitHelper.run(this.__initWait);
|
|
1052
1011
|
this.onInit();
|
|
1053
1012
|
}
|
|
1054
|
-
onInit() {
|
|
1055
|
-
initType(_type) {
|
|
1013
|
+
onInit() {}
|
|
1014
|
+
initType(_type) {}
|
|
1056
1015
|
set(data, transition) {
|
|
1057
|
-
this.waitInit(() => {
|
|
1016
|
+
this.waitInit(() => {
|
|
1017
|
+
super.set(data, transition);
|
|
1018
|
+
});
|
|
1058
1019
|
}
|
|
1059
1020
|
start() {
|
|
1060
1021
|
clearTimeout(this.__startTimer);
|
|
@@ -1062,8 +1023,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1062
1023
|
this.running = true;
|
|
1063
1024
|
this.ready ? this.emitLeafer(core.LeaferEvent.RESTART) : this.emitLeafer(core.LeaferEvent.START);
|
|
1064
1025
|
this.__controllers.forEach(item => item.start());
|
|
1065
|
-
if (!this.isApp)
|
|
1066
|
-
this.renderer.render();
|
|
1026
|
+
if (!this.isApp) this.renderer.render();
|
|
1067
1027
|
}
|
|
1068
1028
|
}
|
|
1069
1029
|
stop() {
|
|
@@ -1087,29 +1047,25 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1087
1047
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
1088
1048
|
}
|
|
1089
1049
|
forceRender(bounds, sync) {
|
|
1090
|
-
const { renderer
|
|
1050
|
+
const {renderer: renderer} = this;
|
|
1091
1051
|
if (renderer) {
|
|
1092
1052
|
renderer.addBlock(bounds ? new core.Bounds(bounds) : this.canvas.bounds);
|
|
1093
|
-
if (this.viewReady)
|
|
1094
|
-
sync ? renderer.render() : renderer.update();
|
|
1053
|
+
if (this.viewReady) sync ? renderer.render() : renderer.update();
|
|
1095
1054
|
}
|
|
1096
1055
|
}
|
|
1097
1056
|
requestRender(change = false) {
|
|
1098
|
-
if (this.renderer)
|
|
1099
|
-
this.renderer.update(change);
|
|
1057
|
+
if (this.renderer) this.renderer.update(change);
|
|
1100
1058
|
}
|
|
1101
1059
|
updateCursor(cursor) {
|
|
1102
1060
|
const i = this.interaction;
|
|
1103
|
-
if (i)
|
|
1104
|
-
cursor ? i.setCursor(cursor) : i.updateCursor();
|
|
1061
|
+
if (i) cursor ? i.setCursor(cursor) : i.updateCursor();
|
|
1105
1062
|
}
|
|
1106
1063
|
updateLazyBounds() {
|
|
1107
1064
|
this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
|
|
1108
1065
|
}
|
|
1109
1066
|
__doResize(size) {
|
|
1110
|
-
const { canvas
|
|
1111
|
-
if (!canvas || canvas.isSameSize(size))
|
|
1112
|
-
return;
|
|
1067
|
+
const {canvas: canvas} = this;
|
|
1068
|
+
if (!canvas || canvas.isSameSize(size)) return;
|
|
1113
1069
|
const old = core.DataHelper.copyAttrs({}, this.canvas, core.canvasSizeAttrs);
|
|
1114
1070
|
canvas.resize(size);
|
|
1115
1071
|
this.updateLazyBounds();
|
|
@@ -1118,10 +1074,11 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1118
1074
|
__onResize(event) {
|
|
1119
1075
|
this.emitEvent(event);
|
|
1120
1076
|
core.DataHelper.copyAttrs(this.__, event, core.canvasSizeAttrs);
|
|
1121
|
-
setTimeout(() => {
|
|
1122
|
-
this.canvasManager.clearRecycled();
|
|
1077
|
+
setTimeout(() => {
|
|
1078
|
+
if (this.canvasManager) this.canvasManager.clearRecycled();
|
|
1079
|
+
}, 0);
|
|
1123
1080
|
}
|
|
1124
|
-
__setApp() {
|
|
1081
|
+
__setApp() {}
|
|
1125
1082
|
__bindApp(app) {
|
|
1126
1083
|
this.selector = app.selector;
|
|
1127
1084
|
this.interaction = app.interaction;
|
|
@@ -1134,8 +1091,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1134
1091
|
}
|
|
1135
1092
|
__checkAutoLayout(config, parentApp) {
|
|
1136
1093
|
if (!parentApp) {
|
|
1137
|
-
if (!config.width || !config.height)
|
|
1138
|
-
this.autoLayout = new core.AutoBounds(config);
|
|
1094
|
+
if (!config.width || !config.height) this.autoLayout = new core.AutoBounds(config);
|
|
1139
1095
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
1140
1096
|
}
|
|
1141
1097
|
}
|
|
@@ -1143,15 +1099,11 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1143
1099
|
if (this.canvas) {
|
|
1144
1100
|
if (core.canvasSizeAttrs.includes(attrName)) {
|
|
1145
1101
|
this.__changeCanvasSize(attrName, newValue);
|
|
1146
|
-
}
|
|
1147
|
-
else if (attrName === 'fill') {
|
|
1102
|
+
} else if (attrName === "fill") {
|
|
1148
1103
|
this.__changeFill(newValue);
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
this.canvas.hittable = newValue;
|
|
1153
|
-
}
|
|
1154
|
-
else if (attrName === 'zIndex') {
|
|
1104
|
+
} else if (attrName === "hittable") {
|
|
1105
|
+
if (!this.parent) this.canvas.hittable = newValue;
|
|
1106
|
+
} else if (attrName === "zIndex") {
|
|
1155
1107
|
this.canvas.zIndex = newValue;
|
|
1156
1108
|
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
1157
1109
|
}
|
|
@@ -1159,23 +1111,18 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1159
1111
|
return super.__setAttr(attrName, newValue);
|
|
1160
1112
|
}
|
|
1161
1113
|
__getAttr(attrName) {
|
|
1162
|
-
if (this.canvas && core.canvasSizeAttrs.includes(attrName))
|
|
1163
|
-
return this.canvas[attrName];
|
|
1114
|
+
if (this.canvas && core.canvasSizeAttrs.includes(attrName)) return this.canvas[attrName];
|
|
1164
1115
|
return super.__getAttr(attrName);
|
|
1165
1116
|
}
|
|
1166
1117
|
__changeCanvasSize(attrName, newValue) {
|
|
1167
1118
|
const data = core.DataHelper.copyAttrs({}, this.canvas, core.canvasSizeAttrs);
|
|
1168
1119
|
data[attrName] = this.config[attrName] = newValue;
|
|
1169
|
-
if (newValue)
|
|
1170
|
-
this.canvas.stopAutoLayout();
|
|
1120
|
+
if (newValue) this.canvas.stopAutoLayout();
|
|
1171
1121
|
this.__doResize(data);
|
|
1172
1122
|
}
|
|
1173
1123
|
__changeFill(newValue) {
|
|
1174
1124
|
this.config.fill = newValue;
|
|
1175
|
-
if (this.canvas.allowBackgroundColor)
|
|
1176
|
-
this.canvas.backgroundColor = newValue;
|
|
1177
|
-
else
|
|
1178
|
-
this.forceRender();
|
|
1125
|
+
if (this.canvas.allowBackgroundColor) this.canvas.backgroundColor = newValue; else this.forceRender();
|
|
1179
1126
|
}
|
|
1180
1127
|
__onCreated() {
|
|
1181
1128
|
this.created = true;
|
|
@@ -1188,45 +1135,41 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1188
1135
|
core.WaitHelper.run(this.__readyWait);
|
|
1189
1136
|
}
|
|
1190
1137
|
__onViewReady() {
|
|
1191
|
-
if (this.viewReady)
|
|
1192
|
-
return;
|
|
1138
|
+
if (this.viewReady) return;
|
|
1193
1139
|
this.viewReady = true;
|
|
1194
1140
|
this.emitLeafer(core.LeaferEvent.VIEW_READY);
|
|
1195
1141
|
core.WaitHelper.run(this.__viewReadyWait);
|
|
1196
1142
|
}
|
|
1197
1143
|
__onLayoutEnd() {
|
|
1198
|
-
const { grow, width: fixedWidth, height: fixedHeight
|
|
1144
|
+
const {grow: grow, width: fixedWidth, height: fixedHeight} = this.config;
|
|
1199
1145
|
if (grow) {
|
|
1200
|
-
let { width, height, pixelRatio } = this;
|
|
1201
|
-
const bounds = grow ===
|
|
1202
|
-
if (!fixedWidth)
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1146
|
+
let {width: width, height: height, pixelRatio: pixelRatio} = this;
|
|
1147
|
+
const bounds = grow === "box" ? this.worldBoxBounds : this.__world;
|
|
1148
|
+
if (!fixedWidth) width = Math.max(1, bounds.x + bounds.width);
|
|
1149
|
+
if (!fixedHeight) height = Math.max(1, bounds.y + bounds.height);
|
|
1150
|
+
this.__doResize({
|
|
1151
|
+
width: width,
|
|
1152
|
+
height: height,
|
|
1153
|
+
pixelRatio: pixelRatio
|
|
1154
|
+
});
|
|
1207
1155
|
}
|
|
1208
|
-
if (!this.ready)
|
|
1209
|
-
this.__onReady();
|
|
1156
|
+
if (!this.ready) this.__onReady();
|
|
1210
1157
|
}
|
|
1211
1158
|
__onNextRender() {
|
|
1212
1159
|
if (this.viewReady) {
|
|
1213
1160
|
core.WaitHelper.run(this.__nextRenderWait);
|
|
1214
|
-
const { imageReady
|
|
1215
|
-
if (imageReady && !this.viewCompleted)
|
|
1216
|
-
this.__checkViewCompleted();
|
|
1161
|
+
const {imageReady: imageReady} = this;
|
|
1162
|
+
if (imageReady && !this.viewCompleted) this.__checkViewCompleted();
|
|
1217
1163
|
if (!imageReady) {
|
|
1218
1164
|
this.viewCompleted = false;
|
|
1219
1165
|
this.requestRender();
|
|
1220
1166
|
}
|
|
1221
|
-
}
|
|
1222
|
-
else
|
|
1223
|
-
this.requestRender();
|
|
1167
|
+
} else this.requestRender();
|
|
1224
1168
|
}
|
|
1225
1169
|
__checkViewCompleted(emit = true) {
|
|
1226
1170
|
this.nextRender(() => {
|
|
1227
1171
|
if (this.imageReady) {
|
|
1228
|
-
if (emit)
|
|
1229
|
-
this.emitLeafer(core.LeaferEvent.VIEW_COMPLETED);
|
|
1172
|
+
if (emit) this.emitLeafer(core.LeaferEvent.VIEW_COMPLETED);
|
|
1230
1173
|
core.WaitHelper.run(this.__viewCompletedWait);
|
|
1231
1174
|
this.viewCompleted = true;
|
|
1232
1175
|
}
|
|
@@ -1238,34 +1181,25 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1238
1181
|
}
|
|
1239
1182
|
}
|
|
1240
1183
|
waitInit(item, bind) {
|
|
1241
|
-
if (bind)
|
|
1242
|
-
|
|
1243
|
-
if (!this.__initWait)
|
|
1244
|
-
this.__initWait = [];
|
|
1184
|
+
if (bind) item = item.bind(bind);
|
|
1185
|
+
if (!this.__initWait) this.__initWait = [];
|
|
1245
1186
|
this.canvas ? item() : this.__initWait.push(item);
|
|
1246
1187
|
}
|
|
1247
1188
|
waitReady(item, bind) {
|
|
1248
|
-
if (bind)
|
|
1249
|
-
item = item.bind(bind);
|
|
1189
|
+
if (bind) item = item.bind(bind);
|
|
1250
1190
|
this.ready ? item() : this.__readyWait.push(item);
|
|
1251
1191
|
}
|
|
1252
1192
|
waitViewReady(item, bind) {
|
|
1253
|
-
if (bind)
|
|
1254
|
-
item = item.bind(bind);
|
|
1193
|
+
if (bind) item = item.bind(bind);
|
|
1255
1194
|
this.viewReady ? item() : this.__viewReadyWait.push(item);
|
|
1256
1195
|
}
|
|
1257
1196
|
waitViewCompleted(item, bind) {
|
|
1258
|
-
if (bind)
|
|
1259
|
-
item = item.bind(bind);
|
|
1197
|
+
if (bind) item = item.bind(bind);
|
|
1260
1198
|
this.__viewCompletedWait.push(item);
|
|
1261
|
-
if (this.viewCompleted)
|
|
1262
|
-
this.__checkViewCompleted(false);
|
|
1263
|
-
else if (!this.running)
|
|
1264
|
-
this.start();
|
|
1199
|
+
if (this.viewCompleted) this.__checkViewCompleted(false); else if (!this.running) this.start();
|
|
1265
1200
|
}
|
|
1266
1201
|
nextRender(item, bind, off) {
|
|
1267
|
-
if (bind)
|
|
1268
|
-
item = item.bind(bind);
|
|
1202
|
+
if (bind) item = item.bind(bind);
|
|
1269
1203
|
const list = this.__nextRenderWait;
|
|
1270
1204
|
if (off) {
|
|
1271
1205
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -1274,16 +1208,21 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1274
1208
|
break;
|
|
1275
1209
|
}
|
|
1276
1210
|
}
|
|
1277
|
-
}
|
|
1278
|
-
else
|
|
1279
|
-
list.push(item);
|
|
1211
|
+
} else list.push(item);
|
|
1280
1212
|
this.requestRender();
|
|
1281
1213
|
}
|
|
1282
1214
|
zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
|
|
1283
|
-
return core.Plugin.need(
|
|
1215
|
+
return core.Plugin.need("view");
|
|
1216
|
+
}
|
|
1217
|
+
getValidMove(moveX, moveY) {
|
|
1218
|
+
return {
|
|
1219
|
+
x: moveX,
|
|
1220
|
+
y: moveY
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
getValidScale(changeScale) {
|
|
1224
|
+
return changeScale;
|
|
1284
1225
|
}
|
|
1285
|
-
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
1286
|
-
getValidScale(changeScale) { return changeScale; }
|
|
1287
1226
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
1288
1227
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
1289
1228
|
}
|
|
@@ -1291,29 +1230,23 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1291
1230
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
1292
1231
|
}
|
|
1293
1232
|
getClientPointByWorld(worldPoint) {
|
|
1294
|
-
const { x, y } = this.clientBounds;
|
|
1295
|
-
return {
|
|
1233
|
+
const {x: x, y: y} = this.clientBounds;
|
|
1234
|
+
return {
|
|
1235
|
+
x: x + worldPoint.x,
|
|
1236
|
+
y: y + worldPoint.y
|
|
1237
|
+
};
|
|
1296
1238
|
}
|
|
1297
1239
|
updateClientBounds() {
|
|
1298
1240
|
this.canvas && this.canvas.updateClientBounds();
|
|
1299
1241
|
}
|
|
1300
|
-
receiveEvent(_event) {
|
|
1242
|
+
receiveEvent(_event) {}
|
|
1301
1243
|
emitLeafer(type) {
|
|
1302
1244
|
this.emitEvent(new core.LeaferEvent(type, this));
|
|
1303
1245
|
}
|
|
1304
1246
|
__listenEvents() {
|
|
1305
|
-
const runId = core.Run.start(
|
|
1306
|
-
this.once([
|
|
1307
|
-
|
|
1308
|
-
[core.LayoutEvent.START, this.updateLazyBounds, this],
|
|
1309
|
-
[core.RenderEvent.START, this.__onCreated, this],
|
|
1310
|
-
[core.RenderEvent.END, this.__onViewReady, this]
|
|
1311
|
-
]);
|
|
1312
|
-
this.__eventIds.push(this.on_([
|
|
1313
|
-
[core.WatchEvent.DATA, this.__onWatchData, this],
|
|
1314
|
-
[core.LayoutEvent.END, this.__onLayoutEnd, this],
|
|
1315
|
-
[core.RenderEvent.NEXT, this.__onNextRender, this]
|
|
1316
|
-
]));
|
|
1247
|
+
const runId = core.Run.start("FirstCreate " + this.innerName);
|
|
1248
|
+
this.once([ [ core.LeaferEvent.START, () => core.Run.end(runId) ], [ core.LayoutEvent.START, this.updateLazyBounds, this ], [ core.RenderEvent.START, this.__onCreated, this ], [ core.RenderEvent.END, this.__onViewReady, this ] ]);
|
|
1249
|
+
this.__eventIds.push(this.on_([ [ core.WatchEvent.DATA, this.__onWatchData, this ], [ core.LayoutEvent.END, this.__onLayoutEnd, this ], [ core.RenderEvent.NEXT, this.__onNextRender, this ] ]));
|
|
1317
1250
|
}
|
|
1318
1251
|
__removeListenEvents() {
|
|
1319
1252
|
this.off_(this.__eventIds);
|
|
@@ -1329,20 +1262,18 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1329
1262
|
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
1330
1263
|
this.__controllers.length = 0;
|
|
1331
1264
|
if (!this.parent) {
|
|
1332
|
-
if (this.selector)
|
|
1333
|
-
|
|
1334
|
-
if (this.hitCanvasManager)
|
|
1335
|
-
this.hitCanvasManager.destroy();
|
|
1265
|
+
if (this.selector) this.selector.destroy();
|
|
1266
|
+
if (this.hitCanvasManager) this.hitCanvasManager.destroy();
|
|
1336
1267
|
this.canvasManager.destroy();
|
|
1337
1268
|
}
|
|
1338
1269
|
this.canvas.destroy();
|
|
1339
1270
|
this.config.view = this.view = this.parentApp = null;
|
|
1340
|
-
if (this.userConfig)
|
|
1341
|
-
this.userConfig.view = null;
|
|
1271
|
+
if (this.userConfig) this.userConfig.view = null;
|
|
1342
1272
|
super.destroy();
|
|
1343
|
-
setTimeout(() => {
|
|
1344
|
-
|
|
1345
|
-
|
|
1273
|
+
setTimeout(() => {
|
|
1274
|
+
core.ImageManager.clearRecycled();
|
|
1275
|
+
}, 100);
|
|
1276
|
+
} catch (e) {
|
|
1346
1277
|
debug.error(e);
|
|
1347
1278
|
}
|
|
1348
1279
|
}
|
|
@@ -1350,253 +1281,237 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1350
1281
|
sync ? doDestory() : setTimeout(doDestory);
|
|
1351
1282
|
}
|
|
1352
1283
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
], exports.Leafer.prototype, "__", void 0);
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
exports.Leafer = Leafer_1 = __decorate([
|
|
1361
|
-
core.registerUI()
|
|
1362
|
-
], exports.Leafer);
|
|
1284
|
+
|
|
1285
|
+
exports.Leafer.list = new core.LeafList;
|
|
1286
|
+
|
|
1287
|
+
__decorate([ core.dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
|
|
1288
|
+
|
|
1289
|
+
__decorate([ core.boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
|
|
1290
|
+
|
|
1291
|
+
exports.Leafer = Leafer_1 = __decorate([ core.registerUI() ], exports.Leafer);
|
|
1363
1292
|
|
|
1364
1293
|
exports.Rect = class Rect extends exports.UI {
|
|
1365
|
-
get __tag() {
|
|
1294
|
+
get __tag() {
|
|
1295
|
+
return "Rect";
|
|
1296
|
+
}
|
|
1366
1297
|
constructor(data) {
|
|
1367
1298
|
super(data);
|
|
1368
1299
|
}
|
|
1369
1300
|
};
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
exports.Rect = __decorate([
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
], exports.Rect);
|
|
1378
|
-
|
|
1379
|
-
const { copy, add, includes: includes$1 } = core.BoundsHelper;
|
|
1301
|
+
|
|
1302
|
+
__decorate([ core.dataProcessor(RectData) ], exports.Rect.prototype, "__", void 0);
|
|
1303
|
+
|
|
1304
|
+
exports.Rect = __decorate([ core.useModule(RectRender), core.rewriteAble(), core.registerUI() ], exports.Rect);
|
|
1305
|
+
|
|
1306
|
+
const {copy: copy, add: add, includes: includes$1} = core.BoundsHelper;
|
|
1307
|
+
|
|
1380
1308
|
const rect = exports.Rect.prototype, group = exports.Group.prototype;
|
|
1309
|
+
|
|
1381
1310
|
const childrenRenderBounds = {};
|
|
1311
|
+
|
|
1382
1312
|
exports.Box = class Box extends exports.Group {
|
|
1383
|
-
get __tag() {
|
|
1384
|
-
|
|
1313
|
+
get __tag() {
|
|
1314
|
+
return "Box";
|
|
1315
|
+
}
|
|
1316
|
+
get isBranchLeaf() {
|
|
1317
|
+
return true;
|
|
1318
|
+
}
|
|
1385
1319
|
constructor(data) {
|
|
1386
1320
|
super(data);
|
|
1387
1321
|
this.__layout.renderChanged || this.__layout.renderChange();
|
|
1388
1322
|
}
|
|
1389
|
-
__updateStrokeSpread() {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1323
|
+
__updateStrokeSpread() {
|
|
1324
|
+
return 0;
|
|
1325
|
+
}
|
|
1326
|
+
__updateRectRenderSpread() {
|
|
1327
|
+
return 0;
|
|
1328
|
+
}
|
|
1329
|
+
__updateRenderSpread() {
|
|
1330
|
+
return this.__updateRectRenderSpread() || -1;
|
|
1331
|
+
}
|
|
1332
|
+
__updateRectBoxBounds() {}
|
|
1393
1333
|
__updateBoxBounds(_secondLayout) {
|
|
1394
|
-
const data = this.__;
|
|
1395
1334
|
if (this.children.length && !this.pathInputed) {
|
|
1335
|
+
const data = this.__;
|
|
1396
1336
|
if (data.__autoSide) {
|
|
1397
|
-
if (data.__hasSurface)
|
|
1398
|
-
this.__extraUpdate();
|
|
1337
|
+
if (data.__hasSurface) this.__extraUpdate();
|
|
1399
1338
|
super.__updateBoxBounds();
|
|
1400
|
-
const { boxBounds
|
|
1339
|
+
const {boxBounds: boxBounds} = this.__layout;
|
|
1401
1340
|
if (!data.__autoSize) {
|
|
1402
1341
|
if (data.__autoWidth) {
|
|
1403
1342
|
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
1404
1343
|
boxBounds.height = data.height, boxBounds.y = 0;
|
|
1405
|
-
}
|
|
1406
|
-
else {
|
|
1344
|
+
} else {
|
|
1407
1345
|
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
1408
1346
|
boxBounds.width = data.width, boxBounds.x = 0;
|
|
1409
1347
|
}
|
|
1410
1348
|
}
|
|
1411
1349
|
this.__updateNaturalSize();
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
this.__updateRectBoxBounds();
|
|
1415
|
-
}
|
|
1416
|
-
else
|
|
1417
|
-
this.__updateRectBoxBounds();
|
|
1350
|
+
} else this.__updateRectBoxBounds();
|
|
1351
|
+
} else this.__updateRectBoxBounds();
|
|
1418
1352
|
}
|
|
1419
|
-
__updateStrokeBounds() {
|
|
1353
|
+
__updateStrokeBounds() {}
|
|
1420
1354
|
__updateRenderBounds() {
|
|
1421
1355
|
let isOverflow;
|
|
1422
|
-
const { renderBounds } = this.__layout;
|
|
1423
1356
|
if (this.children.length) {
|
|
1357
|
+
const data = this.__, {renderBounds: renderBounds, boxBounds: boxBounds} = this.__layout;
|
|
1424
1358
|
super.__updateRenderBounds();
|
|
1425
1359
|
copy(childrenRenderBounds, renderBounds);
|
|
1426
1360
|
this.__updateRectRenderBounds();
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1361
|
+
if (data.scrollY || data.scrollX) {
|
|
1362
|
+
childrenRenderBounds.x += data.scrollX;
|
|
1363
|
+
childrenRenderBounds.y += data.scrollY;
|
|
1364
|
+
}
|
|
1365
|
+
isOverflow = !includes$1(boxBounds, childrenRenderBounds);
|
|
1366
|
+
if (isOverflow && data.overflow !== "hide") add(renderBounds, childrenRenderBounds);
|
|
1367
|
+
} else this.__updateRectRenderBounds();
|
|
1368
|
+
core.DataHelper.stintSet(this, "isOverflow", isOverflow);
|
|
1369
|
+
this.__updateScrollBar();
|
|
1370
|
+
}
|
|
1371
|
+
__updateRectRenderBounds() {}
|
|
1372
|
+
__updateScrollBar() {}
|
|
1373
|
+
__updateRectChange() {}
|
|
1437
1374
|
__updateChange() {
|
|
1438
1375
|
super.__updateChange();
|
|
1439
1376
|
this.__updateRectChange();
|
|
1440
1377
|
}
|
|
1441
|
-
__renderRect(_canvas, _options) {
|
|
1442
|
-
__renderGroup(_canvas, _options) {
|
|
1378
|
+
__renderRect(_canvas, _options) {}
|
|
1379
|
+
__renderGroup(_canvas, _options) {}
|
|
1443
1380
|
__render(canvas, options) {
|
|
1444
1381
|
if (this.__.__drawAfterFill) {
|
|
1445
1382
|
this.__renderRect(canvas, options);
|
|
1446
|
-
}
|
|
1447
|
-
else {
|
|
1383
|
+
} else {
|
|
1448
1384
|
this.__renderRect(canvas, options);
|
|
1449
|
-
if (this.children.length)
|
|
1450
|
-
this.__renderGroup(canvas, options);
|
|
1385
|
+
if (this.children.length) this.__renderGroup(canvas, options);
|
|
1451
1386
|
}
|
|
1387
|
+
if (this.scrollBar) this.scrollBar.__render(canvas, options);
|
|
1452
1388
|
}
|
|
1453
1389
|
__drawContent(canvas, options) {
|
|
1454
1390
|
this.__renderGroup(canvas, options);
|
|
1455
|
-
if (this.__.__useStroke) {
|
|
1391
|
+
if (this.__.__useStroke || this.__.__useEffect) {
|
|
1456
1392
|
canvas.setWorld(this.__nowWorld);
|
|
1457
1393
|
this.__drawRenderPath(canvas);
|
|
1458
1394
|
}
|
|
1459
1395
|
}
|
|
1460
1396
|
};
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
__decorate([
|
|
1465
|
-
|
|
1466
|
-
], exports.Box.prototype, "
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
__decorate([
|
|
1471
|
-
|
|
1472
|
-
], exports.Box.prototype, "
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
__decorate([
|
|
1477
|
-
|
|
1478
|
-
], exports.Box.prototype, "
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
__decorate([
|
|
1483
|
-
|
|
1484
|
-
], exports.Box.prototype, "
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
__decorate([
|
|
1489
|
-
core.rewrite(rect.__updateRenderBounds)
|
|
1490
|
-
], exports.Box.prototype, "__updateRectRenderBounds", null);
|
|
1491
|
-
__decorate([
|
|
1492
|
-
core.rewrite(rect.__updateChange)
|
|
1493
|
-
], exports.Box.prototype, "__updateRectChange", null);
|
|
1494
|
-
__decorate([
|
|
1495
|
-
core.rewrite(rect.__render)
|
|
1496
|
-
], exports.Box.prototype, "__renderRect", null);
|
|
1497
|
-
__decorate([
|
|
1498
|
-
core.rewrite(group.__render)
|
|
1499
|
-
], exports.Box.prototype, "__renderGroup", null);
|
|
1500
|
-
exports.Box = __decorate([
|
|
1501
|
-
core.rewriteAble(),
|
|
1502
|
-
core.registerUI()
|
|
1503
|
-
], exports.Box);
|
|
1397
|
+
|
|
1398
|
+
__decorate([ core.dataProcessor(BoxData) ], exports.Box.prototype, "__", void 0);
|
|
1399
|
+
|
|
1400
|
+
__decorate([ core.boundsType(100) ], exports.Box.prototype, "width", void 0);
|
|
1401
|
+
|
|
1402
|
+
__decorate([ core.boundsType(100) ], exports.Box.prototype, "height", void 0);
|
|
1403
|
+
|
|
1404
|
+
__decorate([ core.dataType(false) ], exports.Box.prototype, "resizeChildren", void 0);
|
|
1405
|
+
|
|
1406
|
+
__decorate([ core.affectRenderBoundsType("show") ], exports.Box.prototype, "overflow", void 0);
|
|
1407
|
+
|
|
1408
|
+
__decorate([ core.rewrite(rect.__updateStrokeSpread) ], exports.Box.prototype, "__updateStrokeSpread", null);
|
|
1409
|
+
|
|
1410
|
+
__decorate([ core.rewrite(rect.__updateRenderSpread) ], exports.Box.prototype, "__updateRectRenderSpread", null);
|
|
1411
|
+
|
|
1412
|
+
__decorate([ core.rewrite(rect.__updateBoxBounds) ], exports.Box.prototype, "__updateRectBoxBounds", null);
|
|
1413
|
+
|
|
1414
|
+
__decorate([ core.rewrite(rect.__updateStrokeBounds) ], exports.Box.prototype, "__updateStrokeBounds", null);
|
|
1415
|
+
|
|
1416
|
+
__decorate([ core.rewrite(rect.__updateRenderBounds) ], exports.Box.prototype, "__updateRectRenderBounds", null);
|
|
1417
|
+
|
|
1418
|
+
__decorate([ core.rewrite(rect.__updateChange) ], exports.Box.prototype, "__updateRectChange", null);
|
|
1419
|
+
|
|
1420
|
+
__decorate([ core.rewrite(rect.__render) ], exports.Box.prototype, "__renderRect", null);
|
|
1421
|
+
|
|
1422
|
+
__decorate([ core.rewrite(group.__render) ], exports.Box.prototype, "__renderGroup", null);
|
|
1423
|
+
|
|
1424
|
+
exports.Box = __decorate([ core.rewriteAble(), core.registerUI() ], exports.Box);
|
|
1504
1425
|
|
|
1505
1426
|
exports.Frame = class Frame extends exports.Box {
|
|
1506
|
-
get __tag() {
|
|
1507
|
-
|
|
1427
|
+
get __tag() {
|
|
1428
|
+
return "Frame";
|
|
1429
|
+
}
|
|
1430
|
+
get isFrame() {
|
|
1431
|
+
return true;
|
|
1432
|
+
}
|
|
1508
1433
|
constructor(data) {
|
|
1509
1434
|
super(data);
|
|
1510
1435
|
}
|
|
1511
1436
|
};
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
__decorate([
|
|
1516
|
-
|
|
1517
|
-
], exports.Frame.prototype, "
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
], exports.Frame);
|
|
1524
|
-
|
|
1525
|
-
const { moveTo: moveTo$3, closePath: closePath$2, ellipse } = core.PathCommandDataHelper;
|
|
1437
|
+
|
|
1438
|
+
__decorate([ core.dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
|
|
1439
|
+
|
|
1440
|
+
__decorate([ core.surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
|
|
1441
|
+
|
|
1442
|
+
__decorate([ core.affectRenderBoundsType("hide") ], exports.Frame.prototype, "overflow", void 0);
|
|
1443
|
+
|
|
1444
|
+
exports.Frame = __decorate([ core.registerUI() ], exports.Frame);
|
|
1445
|
+
|
|
1446
|
+
const {moveTo: moveTo$3, closePath: closePath$2, ellipse: ellipse} = core.PathCommandDataHelper;
|
|
1447
|
+
|
|
1526
1448
|
exports.Ellipse = class Ellipse extends exports.UI {
|
|
1527
|
-
get __tag() {
|
|
1449
|
+
get __tag() {
|
|
1450
|
+
return "Ellipse";
|
|
1451
|
+
}
|
|
1528
1452
|
constructor(data) {
|
|
1529
1453
|
super(data);
|
|
1530
1454
|
}
|
|
1531
1455
|
__updatePath() {
|
|
1532
|
-
const { width, height, innerRadius, startAngle, endAngle } = this.__;
|
|
1456
|
+
const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
|
|
1533
1457
|
const rx = width / 2, ry = height / 2;
|
|
1534
1458
|
const path = this.__.path = [];
|
|
1535
1459
|
if (innerRadius) {
|
|
1536
1460
|
if (startAngle || endAngle) {
|
|
1537
|
-
if (innerRadius < 1)
|
|
1538
|
-
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
|
|
1461
|
+
if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
|
|
1539
1462
|
ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
|
|
1540
|
-
if (innerRadius < 1)
|
|
1541
|
-
|
|
1542
|
-
}
|
|
1543
|
-
else {
|
|
1463
|
+
if (innerRadius < 1) closePath$2(path);
|
|
1464
|
+
} else {
|
|
1544
1465
|
if (innerRadius < 1) {
|
|
1545
1466
|
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
|
|
1546
1467
|
moveTo$3(path, width, ry);
|
|
1547
1468
|
}
|
|
1548
1469
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
1549
1470
|
}
|
|
1550
|
-
if (core.Platform.ellipseToCurve)
|
|
1551
|
-
|
|
1552
|
-
}
|
|
1553
|
-
else {
|
|
1471
|
+
if (core.Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
1472
|
+
} else {
|
|
1554
1473
|
if (startAngle || endAngle) {
|
|
1555
1474
|
moveTo$3(path, rx, ry);
|
|
1556
1475
|
ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false);
|
|
1557
1476
|
closePath$2(path);
|
|
1558
|
-
}
|
|
1559
|
-
else {
|
|
1477
|
+
} else {
|
|
1560
1478
|
ellipse(path, rx, ry, rx, ry);
|
|
1561
1479
|
}
|
|
1562
1480
|
}
|
|
1563
1481
|
}
|
|
1564
1482
|
};
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
__decorate([
|
|
1569
|
-
|
|
1570
|
-
], exports.Ellipse.prototype, "
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
__decorate([
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
const { rotate, getAngle, getDistance, defaultPoint } = core.PointHelper;
|
|
1583
|
-
const { toBounds } = core.PathBounds;
|
|
1483
|
+
|
|
1484
|
+
__decorate([ core.dataProcessor(EllipseData) ], exports.Ellipse.prototype, "__", void 0);
|
|
1485
|
+
|
|
1486
|
+
__decorate([ core.pathType(0) ], exports.Ellipse.prototype, "innerRadius", void 0);
|
|
1487
|
+
|
|
1488
|
+
__decorate([ core.pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
|
|
1489
|
+
|
|
1490
|
+
__decorate([ core.pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
|
|
1491
|
+
|
|
1492
|
+
exports.Ellipse = __decorate([ core.registerUI() ], exports.Ellipse);
|
|
1493
|
+
|
|
1494
|
+
const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = core.PathCommandDataHelper;
|
|
1495
|
+
|
|
1496
|
+
const {rotate: rotate, getAngle: getAngle, getDistance: getDistance, defaultPoint: defaultPoint} = core.PointHelper;
|
|
1497
|
+
|
|
1498
|
+
const {toBounds: toBounds} = core.PathBounds;
|
|
1499
|
+
|
|
1584
1500
|
exports.Line = class Line extends exports.UI {
|
|
1585
|
-
get __tag() {
|
|
1501
|
+
get __tag() {
|
|
1502
|
+
return "Line";
|
|
1503
|
+
}
|
|
1586
1504
|
get toPoint() {
|
|
1587
|
-
const { width, rotation } = this.__;
|
|
1505
|
+
const {width: width, rotation: rotation} = this.__;
|
|
1588
1506
|
const to = core.getPointData();
|
|
1589
|
-
if (width)
|
|
1590
|
-
|
|
1591
|
-
if (rotation)
|
|
1592
|
-
rotate(to, rotation);
|
|
1507
|
+
if (width) to.x = width;
|
|
1508
|
+
if (rotation) rotate(to, rotation);
|
|
1593
1509
|
return to;
|
|
1594
1510
|
}
|
|
1595
1511
|
set toPoint(value) {
|
|
1596
1512
|
this.width = getDistance(defaultPoint, value);
|
|
1597
1513
|
this.rotation = getAngle(defaultPoint, value);
|
|
1598
|
-
if (this.height)
|
|
1599
|
-
this.height = 0;
|
|
1514
|
+
if (this.height) this.height = 0;
|
|
1600
1515
|
}
|
|
1601
1516
|
constructor(data) {
|
|
1602
1517
|
super(data);
|
|
@@ -1606,8 +1521,7 @@ exports.Line = class Line extends exports.UI {
|
|
|
1606
1521
|
const path = data.path = [];
|
|
1607
1522
|
if (data.points) {
|
|
1608
1523
|
drawPoints$1(path, data.points, false, data.closed);
|
|
1609
|
-
}
|
|
1610
|
-
else {
|
|
1524
|
+
} else {
|
|
1611
1525
|
moveTo$2(path, 0, 0);
|
|
1612
1526
|
lineTo$2(path, this.width, 0);
|
|
1613
1527
|
}
|
|
@@ -1616,47 +1530,40 @@ exports.Line = class Line extends exports.UI {
|
|
|
1616
1530
|
const data = this.__;
|
|
1617
1531
|
if (!this.pathInputed && data.points && data.curve) {
|
|
1618
1532
|
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
1619
|
-
if (data.__useArrow)
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
else
|
|
1623
|
-
super.__updateRenderPath();
|
|
1533
|
+
if (data.__useArrow) PathArrow.addArrows(this, false);
|
|
1534
|
+
} else super.__updateRenderPath();
|
|
1624
1535
|
}
|
|
1625
1536
|
__updateBoxBounds() {
|
|
1626
1537
|
if (this.points) {
|
|
1627
1538
|
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1628
|
-
}
|
|
1629
|
-
else
|
|
1630
|
-
super.__updateBoxBounds();
|
|
1539
|
+
} else super.__updateBoxBounds();
|
|
1631
1540
|
}
|
|
1632
1541
|
};
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
__decorate([
|
|
1637
|
-
|
|
1638
|
-
], exports.Line.prototype, "
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
__decorate([
|
|
1643
|
-
|
|
1644
|
-
], exports.Line.prototype, "
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
core.registerUI()
|
|
1653
|
-
], exports.Line);
|
|
1654
|
-
|
|
1655
|
-
const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
|
|
1656
|
-
const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = core.PathCommandDataHelper;
|
|
1542
|
+
|
|
1543
|
+
__decorate([ core.dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
|
|
1544
|
+
|
|
1545
|
+
__decorate([ core.affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
|
|
1546
|
+
|
|
1547
|
+
__decorate([ core.boundsType(0) ], exports.Line.prototype, "height", void 0);
|
|
1548
|
+
|
|
1549
|
+
__decorate([ core.pathType() ], exports.Line.prototype, "points", void 0);
|
|
1550
|
+
|
|
1551
|
+
__decorate([ core.pathType(0) ], exports.Line.prototype, "curve", void 0);
|
|
1552
|
+
|
|
1553
|
+
__decorate([ core.pathType(false) ], exports.Line.prototype, "closed", void 0);
|
|
1554
|
+
|
|
1555
|
+
exports.Line = __decorate([ core.registerUI() ], exports.Line);
|
|
1556
|
+
|
|
1557
|
+
const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
|
|
1558
|
+
|
|
1559
|
+
const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = core.PathCommandDataHelper;
|
|
1560
|
+
|
|
1657
1561
|
const line = exports.Line.prototype;
|
|
1562
|
+
|
|
1658
1563
|
exports.Polygon = class Polygon extends exports.UI {
|
|
1659
|
-
get __tag() {
|
|
1564
|
+
get __tag() {
|
|
1565
|
+
return "Polygon";
|
|
1566
|
+
}
|
|
1660
1567
|
constructor(data) {
|
|
1661
1568
|
super(data);
|
|
1662
1569
|
}
|
|
@@ -1664,138 +1571,142 @@ exports.Polygon = class Polygon extends exports.UI {
|
|
|
1664
1571
|
const path = this.__.path = [];
|
|
1665
1572
|
if (this.__.points) {
|
|
1666
1573
|
drawPoints(path, this.__.points, false, true);
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
const { width, height, sides } = this.__;
|
|
1574
|
+
} else {
|
|
1575
|
+
const {width: width, height: height, sides: sides} = this.__;
|
|
1670
1576
|
const rx = width / 2, ry = height / 2;
|
|
1671
1577
|
moveTo$1(path, rx, 0);
|
|
1672
1578
|
for (let i = 1; i < sides; i++) {
|
|
1673
|
-
lineTo$1(path, rx + rx * sin$1(
|
|
1579
|
+
lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
|
|
1674
1580
|
}
|
|
1675
1581
|
closePath$1(path);
|
|
1676
1582
|
}
|
|
1677
1583
|
}
|
|
1678
|
-
__updateRenderPath() {
|
|
1679
|
-
__updateBoxBounds() {
|
|
1584
|
+
__updateRenderPath() {}
|
|
1585
|
+
__updateBoxBounds() {}
|
|
1680
1586
|
};
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
__decorate([
|
|
1685
|
-
|
|
1686
|
-
], exports.Polygon.prototype, "
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
__decorate([
|
|
1691
|
-
|
|
1692
|
-
], exports.Polygon.prototype, "
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
core.rewriteAble(),
|
|
1701
|
-
core.registerUI()
|
|
1702
|
-
], exports.Polygon);
|
|
1703
|
-
|
|
1704
|
-
const { sin, cos, PI } = Math;
|
|
1705
|
-
const { moveTo, lineTo, closePath } = core.PathCommandDataHelper;
|
|
1587
|
+
|
|
1588
|
+
__decorate([ core.dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
|
|
1589
|
+
|
|
1590
|
+
__decorate([ core.pathType(3) ], exports.Polygon.prototype, "sides", void 0);
|
|
1591
|
+
|
|
1592
|
+
__decorate([ core.pathType() ], exports.Polygon.prototype, "points", void 0);
|
|
1593
|
+
|
|
1594
|
+
__decorate([ core.pathType(0) ], exports.Polygon.prototype, "curve", void 0);
|
|
1595
|
+
|
|
1596
|
+
__decorate([ core.rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
|
|
1597
|
+
|
|
1598
|
+
__decorate([ core.rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
|
|
1599
|
+
|
|
1600
|
+
exports.Polygon = __decorate([ core.rewriteAble(), core.registerUI() ], exports.Polygon);
|
|
1601
|
+
|
|
1602
|
+
const {sin: sin, cos: cos, PI: PI} = Math;
|
|
1603
|
+
|
|
1604
|
+
const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = core.PathCommandDataHelper;
|
|
1605
|
+
|
|
1706
1606
|
exports.Star = class Star extends exports.UI {
|
|
1707
|
-
get __tag() {
|
|
1607
|
+
get __tag() {
|
|
1608
|
+
return "Star";
|
|
1609
|
+
}
|
|
1708
1610
|
constructor(data) {
|
|
1709
1611
|
super(data);
|
|
1710
1612
|
}
|
|
1711
1613
|
__updatePath() {
|
|
1712
|
-
const { width, height, corners, innerRadius } = this.__;
|
|
1614
|
+
const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
|
|
1713
1615
|
const rx = width / 2, ry = height / 2;
|
|
1714
1616
|
const path = this.__.path = [];
|
|
1715
1617
|
moveTo(path, rx, 0);
|
|
1716
1618
|
for (let i = 1; i < corners * 2; i++) {
|
|
1717
|
-
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(
|
|
1619
|
+
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
|
|
1718
1620
|
}
|
|
1719
1621
|
closePath(path);
|
|
1720
1622
|
}
|
|
1721
1623
|
};
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
__decorate([
|
|
1726
|
-
|
|
1727
|
-
], exports.Star.prototype, "
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
], exports.Star.prototype, "innerRadius", void 0);
|
|
1731
|
-
exports.Star = __decorate([
|
|
1732
|
-
core.registerUI()
|
|
1733
|
-
], exports.Star);
|
|
1624
|
+
|
|
1625
|
+
__decorate([ core.dataProcessor(StarData) ], exports.Star.prototype, "__", void 0);
|
|
1626
|
+
|
|
1627
|
+
__decorate([ core.pathType(5) ], exports.Star.prototype, "corners", void 0);
|
|
1628
|
+
|
|
1629
|
+
__decorate([ core.pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
|
|
1630
|
+
|
|
1631
|
+
exports.Star = __decorate([ core.registerUI() ], exports.Star);
|
|
1734
1632
|
|
|
1735
1633
|
exports.Image = class Image extends exports.Rect {
|
|
1736
|
-
get __tag() {
|
|
1737
|
-
|
|
1738
|
-
|
|
1634
|
+
get __tag() {
|
|
1635
|
+
return "Image";
|
|
1636
|
+
}
|
|
1637
|
+
get ready() {
|
|
1638
|
+
const {image: image} = this;
|
|
1639
|
+
return image && image.ready;
|
|
1640
|
+
}
|
|
1641
|
+
get image() {
|
|
1642
|
+
const {fill: fill} = this.__;
|
|
1643
|
+
return core.isArray(fill) && fill[0].image;
|
|
1644
|
+
}
|
|
1739
1645
|
constructor(data) {
|
|
1740
1646
|
super(data);
|
|
1741
1647
|
}
|
|
1742
1648
|
};
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
__decorate([
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
core.registerUI()
|
|
1751
|
-
], exports.Image);
|
|
1649
|
+
|
|
1650
|
+
__decorate([ core.dataProcessor(ImageData) ], exports.Image.prototype, "__", void 0);
|
|
1651
|
+
|
|
1652
|
+
__decorate([ core.boundsType("") ], exports.Image.prototype, "url", void 0);
|
|
1653
|
+
|
|
1654
|
+
exports.Image = __decorate([ core.registerUI() ], exports.Image);
|
|
1655
|
+
|
|
1752
1656
|
const MyImage = exports.Image;
|
|
1753
1657
|
|
|
1754
1658
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
1755
|
-
get __tag() {
|
|
1756
|
-
|
|
1757
|
-
|
|
1659
|
+
get __tag() {
|
|
1660
|
+
return "Canvas";
|
|
1661
|
+
}
|
|
1662
|
+
get context() {
|
|
1663
|
+
return this.canvas.context;
|
|
1664
|
+
}
|
|
1665
|
+
get ready() {
|
|
1666
|
+
return !this.url;
|
|
1667
|
+
}
|
|
1758
1668
|
constructor(data) {
|
|
1759
1669
|
super(data);
|
|
1760
1670
|
this.canvas = core.Creator.canvas(this.__);
|
|
1761
|
-
if (data && data.url)
|
|
1762
|
-
this.drawImage(data.url);
|
|
1671
|
+
if (data && data.url) this.drawImage(data.url);
|
|
1763
1672
|
}
|
|
1764
1673
|
drawImage(url) {
|
|
1765
|
-
new core.LeaferImage({
|
|
1674
|
+
new core.LeaferImage({
|
|
1675
|
+
url: url
|
|
1676
|
+
}).load(image => {
|
|
1766
1677
|
this.context.drawImage(image.view, 0, 0);
|
|
1767
1678
|
this.url = undefined;
|
|
1768
1679
|
this.paint();
|
|
1769
|
-
this.emitEvent(new core.ImageEvent(core.ImageEvent.LOADED, {
|
|
1680
|
+
this.emitEvent(new core.ImageEvent(core.ImageEvent.LOADED, {
|
|
1681
|
+
image: image
|
|
1682
|
+
}));
|
|
1770
1683
|
});
|
|
1771
1684
|
}
|
|
1772
1685
|
draw(ui, offset, scale, rotation) {
|
|
1773
1686
|
const matrix = new core.Matrix(ui.worldTransform).invert();
|
|
1774
|
-
const m = new core.Matrix
|
|
1775
|
-
if (offset)
|
|
1776
|
-
|
|
1777
|
-
if (
|
|
1778
|
-
typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
|
|
1779
|
-
if (rotation)
|
|
1780
|
-
m.rotate(rotation);
|
|
1687
|
+
const m = new core.Matrix;
|
|
1688
|
+
if (offset) m.translate(offset.x, offset.y);
|
|
1689
|
+
if (scale) core.isNumber(scale) ? m.scale(scale) : m.scale(scale.x, scale.y);
|
|
1690
|
+
if (rotation) m.rotate(rotation);
|
|
1781
1691
|
matrix.multiplyParent(m);
|
|
1782
|
-
ui.__render(this.canvas, {
|
|
1692
|
+
ui.__render(this.canvas, {
|
|
1693
|
+
matrix: matrix.withScale()
|
|
1694
|
+
});
|
|
1783
1695
|
this.paint();
|
|
1784
1696
|
}
|
|
1785
1697
|
paint() {
|
|
1786
1698
|
this.forceRender();
|
|
1787
1699
|
}
|
|
1788
1700
|
__drawContent(canvas, _options) {
|
|
1789
|
-
const { width, height } = this.__, { view
|
|
1701
|
+
const {width: width, height: height} = this.__, {view: view} = this.canvas;
|
|
1790
1702
|
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
1791
1703
|
}
|
|
1792
1704
|
__updateSize() {
|
|
1793
|
-
const { canvas
|
|
1705
|
+
const {canvas: canvas} = this;
|
|
1794
1706
|
if (canvas) {
|
|
1795
|
-
const { smooth, safeResize } = this.__;
|
|
1707
|
+
const {smooth: smooth, safeResize: safeResize} = this.__;
|
|
1796
1708
|
canvas.resize(this.__, safeResize);
|
|
1797
|
-
if (canvas.smooth !== smooth)
|
|
1798
|
-
canvas.smooth = smooth;
|
|
1709
|
+
if (canvas.smooth !== smooth) canvas.smooth = smooth;
|
|
1799
1710
|
}
|
|
1800
1711
|
}
|
|
1801
1712
|
destroy() {
|
|
@@ -1806,59 +1717,56 @@ exports.Canvas = class Canvas extends exports.Rect {
|
|
|
1806
1717
|
super.destroy();
|
|
1807
1718
|
}
|
|
1808
1719
|
};
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
__decorate([
|
|
1813
|
-
|
|
1814
|
-
], exports.Canvas.prototype, "
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
__decorate([
|
|
1819
|
-
|
|
1820
|
-
], exports.Canvas.prototype, "
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
__decorate([
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
resizeType()
|
|
1829
|
-
], exports.Canvas.prototype, "contextSettings", void 0);
|
|
1830
|
-
exports.Canvas = __decorate([
|
|
1831
|
-
core.registerUI()
|
|
1832
|
-
], exports.Canvas);
|
|
1833
|
-
|
|
1834
|
-
const { copyAndSpread, includes, spread, setList } = core.BoundsHelper;
|
|
1720
|
+
|
|
1721
|
+
__decorate([ core.dataProcessor(CanvasData) ], exports.Canvas.prototype, "__", void 0);
|
|
1722
|
+
|
|
1723
|
+
__decorate([ resizeType(100) ], exports.Canvas.prototype, "width", void 0);
|
|
1724
|
+
|
|
1725
|
+
__decorate([ resizeType(100) ], exports.Canvas.prototype, "height", void 0);
|
|
1726
|
+
|
|
1727
|
+
__decorate([ resizeType(1) ], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
1728
|
+
|
|
1729
|
+
__decorate([ resizeType(true) ], exports.Canvas.prototype, "smooth", void 0);
|
|
1730
|
+
|
|
1731
|
+
__decorate([ core.dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
1732
|
+
|
|
1733
|
+
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
1734
|
+
|
|
1735
|
+
exports.Canvas = __decorate([ core.registerUI() ], exports.Canvas);
|
|
1736
|
+
|
|
1737
|
+
const {copyAndSpread: copyAndSpread, includes: includes, spread: spread, setList: setList} = core.BoundsHelper;
|
|
1738
|
+
|
|
1835
1739
|
exports.Text = class Text extends exports.UI {
|
|
1836
|
-
get __tag() {
|
|
1837
|
-
|
|
1740
|
+
get __tag() {
|
|
1741
|
+
return "Text";
|
|
1742
|
+
}
|
|
1743
|
+
get textDrawData() {
|
|
1744
|
+
this.updateLayout();
|
|
1745
|
+
return this.__.__textDrawData;
|
|
1746
|
+
}
|
|
1838
1747
|
constructor(data) {
|
|
1839
1748
|
super(data);
|
|
1840
1749
|
}
|
|
1841
1750
|
__updateTextDrawData() {
|
|
1842
1751
|
const data = this.__;
|
|
1843
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
1752
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
1844
1753
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
1845
1754
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
1846
1755
|
data.__padding = padding ? core.MathHelper.fourNumber(padding) : undefined;
|
|
1847
|
-
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize *
|
|
1848
|
-
data.__font = `${italic ?
|
|
1849
|
-
data.__clipText = textOverflow !==
|
|
1850
|
-
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text ===
|
|
1756
|
+
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
1757
|
+
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize}px ${fontFamily}`;
|
|
1758
|
+
data.__clipText = textOverflow !== "show" && !data.__autoSize;
|
|
1759
|
+
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
1851
1760
|
}
|
|
1852
1761
|
__updateBoxBounds() {
|
|
1853
1762
|
const data = this.__;
|
|
1854
1763
|
const layout = this.__layout;
|
|
1855
|
-
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight
|
|
1764
|
+
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
1856
1765
|
this.__updateTextDrawData();
|
|
1857
|
-
const {
|
|
1766
|
+
const {bounds: contentBounds} = data.__textDrawData;
|
|
1858
1767
|
const b = layout.boxBounds;
|
|
1859
1768
|
layout.contentBounds = contentBounds;
|
|
1860
|
-
if (data.__lineHeight < fontSize)
|
|
1861
|
-
spread(contentBounds, fontSize / 2);
|
|
1769
|
+
if (data.__lineHeight < fontSize) spread(contentBounds, fontSize / 2);
|
|
1862
1770
|
if (autoWidth || autoHeight) {
|
|
1863
1771
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
1864
1772
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -1866,165 +1774,126 @@ exports.Text = class Text extends exports.UI {
|
|
|
1866
1774
|
b.height = autoHeight ? contentBounds.height : data.height;
|
|
1867
1775
|
if (padding) {
|
|
1868
1776
|
const [top, right, bottom, left] = data.__padding;
|
|
1869
|
-
if (autoWidth)
|
|
1870
|
-
|
|
1871
|
-
if (autoHeight)
|
|
1872
|
-
b.y -= top, b.height += (bottom + top);
|
|
1777
|
+
if (autoWidth) b.x -= left, b.width += right + left;
|
|
1778
|
+
if (autoHeight) b.y -= top, b.height += bottom + top;
|
|
1873
1779
|
}
|
|
1874
1780
|
this.__updateNaturalSize();
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
if (
|
|
1879
|
-
b.width += fontSize * 0.16;
|
|
1880
|
-
core.DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
|
|
1881
|
-
if (this.isOverflow)
|
|
1882
|
-
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
1883
|
-
else
|
|
1884
|
-
data.__textBoxBounds = b;
|
|
1781
|
+
} else super.__updateBoxBounds();
|
|
1782
|
+
if (italic) b.width += fontSize * .16;
|
|
1783
|
+
core.DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
1784
|
+
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
1885
1785
|
}
|
|
1886
1786
|
__onUpdateSize() {
|
|
1887
|
-
if (this.__box)
|
|
1888
|
-
this.__box.__onUpdateSize();
|
|
1787
|
+
if (this.__box) this.__box.__onUpdateSize();
|
|
1889
1788
|
super.__onUpdateSize();
|
|
1890
1789
|
}
|
|
1891
1790
|
__updateRenderSpread() {
|
|
1892
1791
|
let width = super.__updateRenderSpread();
|
|
1893
|
-
if (!width)
|
|
1894
|
-
width = this.isOverflow ? 1 : 0;
|
|
1792
|
+
if (!width) width = this.isOverflow ? 1 : 0;
|
|
1895
1793
|
return width;
|
|
1896
1794
|
}
|
|
1897
1795
|
__updateRenderBounds() {
|
|
1898
|
-
const { renderBounds, renderSpread } = this.__layout;
|
|
1796
|
+
const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
|
|
1899
1797
|
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
1900
|
-
if (this.__box)
|
|
1901
|
-
this.__box.__layout.renderBounds = renderBounds;
|
|
1798
|
+
if (this.__box) this.__box.__layout.renderBounds = renderBounds;
|
|
1902
1799
|
}
|
|
1903
1800
|
__drawRenderPath(canvas) {
|
|
1904
1801
|
canvas.font = this.__.__font;
|
|
1905
1802
|
}
|
|
1906
1803
|
__draw(canvas, options, originCanvas) {
|
|
1907
1804
|
const box = this.__box;
|
|
1908
|
-
if (box)
|
|
1909
|
-
|
|
1910
|
-
if (this.textEditing && !options.exporting)
|
|
1911
|
-
return;
|
|
1805
|
+
if (box) box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
1806
|
+
if (this.textEditing && !options.exporting) return;
|
|
1912
1807
|
super.__draw(canvas, options, originCanvas);
|
|
1913
1808
|
}
|
|
1914
1809
|
__drawShape(canvas, options) {
|
|
1915
|
-
if (options.shape)
|
|
1916
|
-
this.__box && this.__box.__drawShape(canvas, options);
|
|
1810
|
+
if (options.shape) this.__box && this.__box.__drawShape(canvas, options);
|
|
1917
1811
|
super.__drawShape(canvas, options);
|
|
1918
1812
|
}
|
|
1919
1813
|
destroy() {
|
|
1920
|
-
if (this.boxStyle)
|
|
1921
|
-
this.boxStyle = null;
|
|
1814
|
+
if (this.boxStyle) this.boxStyle = null;
|
|
1922
1815
|
super.destroy();
|
|
1923
1816
|
}
|
|
1924
1817
|
};
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
__decorate([
|
|
1929
|
-
|
|
1930
|
-
], exports.Text.prototype, "
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
__decorate([
|
|
1935
|
-
|
|
1936
|
-
], exports.Text.prototype, "
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
__decorate([
|
|
1941
|
-
|
|
1942
|
-
], exports.Text.prototype, "
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
__decorate([
|
|
1947
|
-
|
|
1948
|
-
], exports.Text.prototype, "
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
__decorate([
|
|
1953
|
-
|
|
1954
|
-
], exports.Text.prototype, "
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
__decorate([
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
], exports.Text.prototype, "
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
__decorate([
|
|
1968
|
-
|
|
1969
|
-
], exports.Text.prototype, "
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
__decorate([
|
|
1974
|
-
|
|
1975
|
-
], exports.Text.prototype, "
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
__decorate([
|
|
1980
|
-
|
|
1981
|
-
], exports.Text.prototype, "
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
], exports.Text.prototype, "paraSpacing", void 0);
|
|
1985
|
-
__decorate([
|
|
1986
|
-
core.boundsType('x')
|
|
1987
|
-
], exports.Text.prototype, "writingMode", void 0);
|
|
1988
|
-
__decorate([
|
|
1989
|
-
core.boundsType('left')
|
|
1990
|
-
], exports.Text.prototype, "textAlign", void 0);
|
|
1991
|
-
__decorate([
|
|
1992
|
-
core.boundsType('top')
|
|
1993
|
-
], exports.Text.prototype, "verticalAlign", void 0);
|
|
1994
|
-
__decorate([
|
|
1995
|
-
core.boundsType(true)
|
|
1996
|
-
], exports.Text.prototype, "autoSizeAlign", void 0);
|
|
1997
|
-
__decorate([
|
|
1998
|
-
core.boundsType('normal')
|
|
1999
|
-
], exports.Text.prototype, "textWrap", void 0);
|
|
2000
|
-
__decorate([
|
|
2001
|
-
core.boundsType('show')
|
|
2002
|
-
], exports.Text.prototype, "textOverflow", void 0);
|
|
2003
|
-
__decorate([
|
|
2004
|
-
core.surfaceType(false)
|
|
2005
|
-
], exports.Text.prototype, "textEditing", void 0);
|
|
2006
|
-
exports.Text = __decorate([
|
|
2007
|
-
core.registerUI()
|
|
2008
|
-
], exports.Text);
|
|
1818
|
+
|
|
1819
|
+
__decorate([ core.dataProcessor(TextData) ], exports.Text.prototype, "__", void 0);
|
|
1820
|
+
|
|
1821
|
+
__decorate([ core.boundsType(0) ], exports.Text.prototype, "width", void 0);
|
|
1822
|
+
|
|
1823
|
+
__decorate([ core.boundsType(0) ], exports.Text.prototype, "height", void 0);
|
|
1824
|
+
|
|
1825
|
+
__decorate([ core.surfaceType() ], exports.Text.prototype, "boxStyle", void 0);
|
|
1826
|
+
|
|
1827
|
+
__decorate([ core.dataType(false) ], exports.Text.prototype, "resizeFontSize", void 0);
|
|
1828
|
+
|
|
1829
|
+
__decorate([ core.surfaceType("#000000") ], exports.Text.prototype, "fill", void 0);
|
|
1830
|
+
|
|
1831
|
+
__decorate([ core.affectStrokeBoundsType("outside") ], exports.Text.prototype, "strokeAlign", void 0);
|
|
1832
|
+
|
|
1833
|
+
__decorate([ core.hitType("all") ], exports.Text.prototype, "hitFill", void 0);
|
|
1834
|
+
|
|
1835
|
+
__decorate([ core.boundsType("") ], exports.Text.prototype, "text", void 0);
|
|
1836
|
+
|
|
1837
|
+
__decorate([ core.boundsType("") ], exports.Text.prototype, "placeholder", void 0);
|
|
1838
|
+
|
|
1839
|
+
__decorate([ core.boundsType("caption") ], exports.Text.prototype, "fontFamily", void 0);
|
|
1840
|
+
|
|
1841
|
+
__decorate([ core.boundsType(12) ], exports.Text.prototype, "fontSize", void 0);
|
|
1842
|
+
|
|
1843
|
+
__decorate([ core.boundsType("normal") ], exports.Text.prototype, "fontWeight", void 0);
|
|
1844
|
+
|
|
1845
|
+
__decorate([ core.boundsType(false) ], exports.Text.prototype, "italic", void 0);
|
|
1846
|
+
|
|
1847
|
+
__decorate([ core.boundsType("none") ], exports.Text.prototype, "textCase", void 0);
|
|
1848
|
+
|
|
1849
|
+
__decorate([ core.boundsType("none") ], exports.Text.prototype, "textDecoration", void 0);
|
|
1850
|
+
|
|
1851
|
+
__decorate([ core.boundsType(0) ], exports.Text.prototype, "letterSpacing", void 0);
|
|
1852
|
+
|
|
1853
|
+
__decorate([ core.boundsType({
|
|
1854
|
+
type: "percent",
|
|
1855
|
+
value: 1.5
|
|
1856
|
+
}) ], exports.Text.prototype, "lineHeight", void 0);
|
|
1857
|
+
|
|
1858
|
+
__decorate([ core.boundsType(0) ], exports.Text.prototype, "paraIndent", void 0);
|
|
1859
|
+
|
|
1860
|
+
__decorate([ core.boundsType(0) ], exports.Text.prototype, "paraSpacing", void 0);
|
|
1861
|
+
|
|
1862
|
+
__decorate([ core.boundsType("x") ], exports.Text.prototype, "writingMode", void 0);
|
|
1863
|
+
|
|
1864
|
+
__decorate([ core.boundsType("left") ], exports.Text.prototype, "textAlign", void 0);
|
|
1865
|
+
|
|
1866
|
+
__decorate([ core.boundsType("top") ], exports.Text.prototype, "verticalAlign", void 0);
|
|
1867
|
+
|
|
1868
|
+
__decorate([ core.boundsType(true) ], exports.Text.prototype, "autoSizeAlign", void 0);
|
|
1869
|
+
|
|
1870
|
+
__decorate([ core.boundsType("normal") ], exports.Text.prototype, "textWrap", void 0);
|
|
1871
|
+
|
|
1872
|
+
__decorate([ core.boundsType("show") ], exports.Text.prototype, "textOverflow", void 0);
|
|
1873
|
+
|
|
1874
|
+
__decorate([ core.surfaceType(false) ], exports.Text.prototype, "textEditing", void 0);
|
|
1875
|
+
|
|
1876
|
+
exports.Text = __decorate([ core.registerUI() ], exports.Text);
|
|
2009
1877
|
|
|
2010
1878
|
exports.Path = class Path extends exports.UI {
|
|
2011
|
-
get __tag() {
|
|
1879
|
+
get __tag() {
|
|
1880
|
+
return "Path";
|
|
1881
|
+
}
|
|
2012
1882
|
constructor(data) {
|
|
2013
1883
|
super(data);
|
|
2014
1884
|
}
|
|
2015
1885
|
};
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
__decorate([
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
exports.Path = __decorate([
|
|
2023
|
-
core.registerUI()
|
|
2024
|
-
], exports.Path);
|
|
1886
|
+
|
|
1887
|
+
__decorate([ core.dataProcessor(PathData) ], exports.Path.prototype, "__", void 0);
|
|
1888
|
+
|
|
1889
|
+
__decorate([ core.affectStrokeBoundsType("center") ], exports.Path.prototype, "strokeAlign", void 0);
|
|
1890
|
+
|
|
1891
|
+
exports.Path = __decorate([ core.registerUI() ], exports.Path);
|
|
2025
1892
|
|
|
2026
1893
|
exports.Pen = class Pen extends exports.Group {
|
|
2027
|
-
get __tag() {
|
|
1894
|
+
get __tag() {
|
|
1895
|
+
return "Pen";
|
|
1896
|
+
}
|
|
2028
1897
|
constructor(data) {
|
|
2029
1898
|
super(data);
|
|
2030
1899
|
}
|
|
@@ -2035,81 +1904,147 @@ exports.Pen = class Pen extends exports.Group {
|
|
|
2035
1904
|
this.add(path);
|
|
2036
1905
|
return this;
|
|
2037
1906
|
}
|
|
2038
|
-
beginPath() {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1907
|
+
beginPath() {
|
|
1908
|
+
return this;
|
|
1909
|
+
}
|
|
1910
|
+
moveTo(_x, _y) {
|
|
1911
|
+
return this;
|
|
1912
|
+
}
|
|
1913
|
+
lineTo(_x, _y) {
|
|
1914
|
+
return this;
|
|
1915
|
+
}
|
|
1916
|
+
bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) {
|
|
1917
|
+
return this;
|
|
1918
|
+
}
|
|
1919
|
+
quadraticCurveTo(_x1, _y1, _x, _y) {
|
|
1920
|
+
return this;
|
|
1921
|
+
}
|
|
1922
|
+
closePath() {
|
|
1923
|
+
return this;
|
|
1924
|
+
}
|
|
1925
|
+
rect(_x, _y, _width, _height) {
|
|
1926
|
+
return this;
|
|
1927
|
+
}
|
|
1928
|
+
roundRect(_x, _y, _width, _height, _cornerRadius) {
|
|
1929
|
+
return this;
|
|
1930
|
+
}
|
|
1931
|
+
ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
|
|
1932
|
+
return this;
|
|
1933
|
+
}
|
|
1934
|
+
arc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
|
|
1935
|
+
return this;
|
|
1936
|
+
}
|
|
1937
|
+
arcTo(_x1, _y1, _x2, _y2, _radius) {
|
|
1938
|
+
return this;
|
|
1939
|
+
}
|
|
1940
|
+
drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
|
|
1941
|
+
return this;
|
|
1942
|
+
}
|
|
1943
|
+
drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
|
|
1944
|
+
return this;
|
|
1945
|
+
}
|
|
1946
|
+
drawPoints(_points, _curve, _close) {
|
|
1947
|
+
return this;
|
|
1948
|
+
}
|
|
1949
|
+
clearPath() {
|
|
1950
|
+
return this;
|
|
1951
|
+
}
|
|
2053
1952
|
paint() {
|
|
2054
|
-
if (!this.pathElement.__layout.boxChanged)
|
|
2055
|
-
this.pathElement.forceUpdate('path');
|
|
1953
|
+
if (!this.pathElement.__layout.boxChanged) this.pathElement.forceUpdate("path");
|
|
2056
1954
|
}
|
|
2057
1955
|
};
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
__decorate([
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
core.useModule(core.PathCreator, ['set', 'path', 'paint']),
|
|
2066
|
-
core.registerUI()
|
|
2067
|
-
], exports.Pen);
|
|
1956
|
+
|
|
1957
|
+
__decorate([ core.dataProcessor(PenData) ], exports.Pen.prototype, "__", void 0);
|
|
1958
|
+
|
|
1959
|
+
__decorate([ penPathType() ], exports.Pen.prototype, "path", void 0);
|
|
1960
|
+
|
|
1961
|
+
exports.Pen = __decorate([ core.useModule(core.PathCreator, [ "set", "path", "paint" ]), core.registerUI() ], exports.Pen);
|
|
1962
|
+
|
|
2068
1963
|
function penPathType() {
|
|
2069
1964
|
return (target, key) => {
|
|
2070
1965
|
core.defineKey(target, key, {
|
|
2071
|
-
get() {
|
|
1966
|
+
get() {
|
|
1967
|
+
return this.__path;
|
|
1968
|
+
}
|
|
2072
1969
|
});
|
|
2073
1970
|
};
|
|
2074
1971
|
}
|
|
2075
1972
|
|
|
2076
1973
|
exports.BoxData = BoxData;
|
|
1974
|
+
|
|
2077
1975
|
exports.CanvasData = CanvasData;
|
|
1976
|
+
|
|
2078
1977
|
exports.ColorConvert = ColorConvert;
|
|
1978
|
+
|
|
2079
1979
|
exports.Effect = Effect;
|
|
1980
|
+
|
|
2080
1981
|
exports.EllipseData = EllipseData;
|
|
1982
|
+
|
|
2081
1983
|
exports.Export = Export;
|
|
1984
|
+
|
|
2082
1985
|
exports.Filter = Filter;
|
|
1986
|
+
|
|
2083
1987
|
exports.FrameData = FrameData;
|
|
1988
|
+
|
|
2084
1989
|
exports.GroupData = GroupData;
|
|
1990
|
+
|
|
2085
1991
|
exports.ImageData = ImageData;
|
|
1992
|
+
|
|
2086
1993
|
exports.LeaferData = LeaferData;
|
|
1994
|
+
|
|
2087
1995
|
exports.LineData = LineData;
|
|
1996
|
+
|
|
2088
1997
|
exports.MyImage = MyImage;
|
|
1998
|
+
|
|
2089
1999
|
exports.Paint = Paint;
|
|
2000
|
+
|
|
2090
2001
|
exports.PaintGradient = PaintGradient;
|
|
2002
|
+
|
|
2091
2003
|
exports.PaintImage = PaintImage;
|
|
2004
|
+
|
|
2092
2005
|
exports.PathArrow = PathArrow;
|
|
2006
|
+
|
|
2093
2007
|
exports.PathData = PathData;
|
|
2008
|
+
|
|
2094
2009
|
exports.PenData = PenData;
|
|
2010
|
+
|
|
2095
2011
|
exports.PolygonData = PolygonData;
|
|
2012
|
+
|
|
2096
2013
|
exports.RectData = RectData;
|
|
2014
|
+
|
|
2097
2015
|
exports.RectRender = RectRender;
|
|
2016
|
+
|
|
2098
2017
|
exports.StarData = StarData;
|
|
2018
|
+
|
|
2099
2019
|
exports.State = State;
|
|
2020
|
+
|
|
2100
2021
|
exports.TextConvert = TextConvert;
|
|
2022
|
+
|
|
2101
2023
|
exports.TextData = TextData;
|
|
2024
|
+
|
|
2102
2025
|
exports.Transition = Transition;
|
|
2026
|
+
|
|
2103
2027
|
exports.UIBounds = UIBounds;
|
|
2028
|
+
|
|
2104
2029
|
exports.UIData = UIData;
|
|
2030
|
+
|
|
2105
2031
|
exports.UIRender = UIRender;
|
|
2032
|
+
|
|
2106
2033
|
exports.UnitConvert = UnitConvert;
|
|
2034
|
+
|
|
2035
|
+
exports.createAttr = createAttr;
|
|
2036
|
+
|
|
2107
2037
|
exports.effectType = effectType;
|
|
2038
|
+
|
|
2108
2039
|
exports.resizeType = resizeType;
|
|
2040
|
+
|
|
2109
2041
|
exports.zoomLayerType = zoomLayerType;
|
|
2110
|
-
|
|
2111
|
-
|
|
2042
|
+
|
|
2043
|
+
Object.keys(core).forEach(function(k) {
|
|
2044
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2112
2045
|
enumerable: true,
|
|
2113
|
-
get: function
|
|
2046
|
+
get: function() {
|
|
2047
|
+
return core[k];
|
|
2048
|
+
}
|
|
2114
2049
|
});
|
|
2115
2050
|
});
|