@visactor/vrender-core 0.17.19 → 0.17.20-alpha.2
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/cjs/core/stage.d.ts +2 -1
- package/cjs/core/stage.js +8 -4
- package/cjs/core/stage.js.map +1 -1
- package/cjs/graphic/graphic.js +3 -3
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/node-tree.js +4 -1
- package/cjs/graphic/node-tree.js.map +1 -1
- package/cjs/graphic/richtext/frame.d.ts +2 -2
- package/cjs/graphic/richtext/frame.js +1 -12
- package/cjs/graphic/richtext/frame.js.map +1 -1
- package/cjs/graphic/richtext/line.js +1 -12
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +2 -2
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext.js +2 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +1 -1
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic.d.ts +2 -2
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/picker.d.ts +1 -0
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/interface/render.d.ts +1 -0
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +3 -1
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/picker/picker-service.js +8 -3
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +126 -65
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +11 -8
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +4 -2
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.js +18 -10
- package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/index.d.ts +1 -0
- package/cjs/render/contributions/render/index.js +2 -1
- package/cjs/render/contributions/render/index.js.map +1 -1
- package/cjs/resource-loader/loader.d.ts +5 -0
- package/cjs/resource-loader/loader.js +56 -15
- package/cjs/resource-loader/loader.js.map +1 -1
- package/es/core/stage.d.ts +2 -1
- package/es/core/stage.js +8 -4
- package/es/core/stage.js.map +1 -1
- package/es/graphic/graphic.js +4 -4
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/node-tree.js +4 -1
- package/es/graphic/node-tree.js.map +1 -1
- package/es/graphic/richtext/frame.d.ts +2 -2
- package/es/graphic/richtext/frame.js +1 -12
- package/es/graphic/richtext/frame.js.map +1 -1
- package/es/graphic/richtext/line.js +1 -12
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +2 -2
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext.js +2 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +1 -1
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic.d.ts +2 -2
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/picker.d.ts +1 -0
- package/es/interface/picker.js.map +1 -1
- package/es/interface/render.d.ts +1 -0
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +3 -1
- package/es/interface/stage.js.map +1 -1
- package/es/picker/picker-service.js +8 -3
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +126 -69
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +11 -8
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/image-render.js +6 -2
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/incremental-draw-contribution.js +18 -10
- package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/es/render/contributions/render/index.d.ts +1 -0
- package/es/render/contributions/render/index.js +2 -0
- package/es/render/contributions/render/index.js.map +1 -1
- package/es/resource-loader/loader.d.ts +5 -0
- package/es/resource-loader/loader.js +56 -14
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,11 +2,7 @@ import { getTheme } from "../../graphic";
|
|
|
2
2
|
|
|
3
3
|
import { Generator } from "../../common/generator";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { parsePadding } from "../../common/utils";
|
|
8
|
-
|
|
9
|
-
import { AABBBounds, isArray } from "@visactor/vutils";
|
|
5
|
+
import { AABBBounds } from "@visactor/vutils";
|
|
10
6
|
|
|
11
7
|
import { application } from "../../application";
|
|
12
8
|
|
|
@@ -17,25 +13,33 @@ export class FlexLayoutPlugin {
|
|
|
17
13
|
this.name = "FlexLayoutPlugin", this.activeEvent = "onRegister", this.id = Generator.GenAutoIncrementId(),
|
|
18
14
|
this.key = this.name + this.id, this.tempBounds = new AABBBounds;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
pauseLayout(p) {
|
|
17
|
+
this.pause = p;
|
|
18
|
+
}
|
|
19
|
+
tryLayoutChildren(graphic) {
|
|
20
|
+
graphic.firstChild && this.tryLayout(graphic.firstChild);
|
|
21
|
+
}
|
|
22
|
+
tryLayout(graphic, force = !0) {
|
|
23
|
+
if (this.pause) return;
|
|
23
24
|
const p = graphic.parent;
|
|
24
|
-
if (!
|
|
25
|
+
if (!(force || p && graphic.needUpdateLayout())) return;
|
|
25
26
|
const theme = getTheme(p).group, {display: display = theme.display} = p.attribute;
|
|
26
27
|
if ("flex" !== display) return;
|
|
27
|
-
const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap,
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap, alignItems: alignItems = theme.alignItems, clip: clip = theme.clip} = p.attribute, {alignContent: alignContent = (null != alignItems ? alignItems : theme.alignContent)} = p.attribute;
|
|
29
|
+
let {width: width, height: height, justifyContent: justifyContent = theme.justifyContent} = p.attribute;
|
|
30
|
+
const children = p.getChildren();
|
|
31
|
+
if (null == width || null == height) {
|
|
32
|
+
let childrenWidth = 0, childrenHeight = 0, boundsLegal = 0;
|
|
33
|
+
if (children.forEach((child => {
|
|
34
|
+
const bounds = this.getAABBBounds(child);
|
|
35
|
+
bounds.empty() || ("column" === flexDirection || "column-reverse" === flexDirection ? (childrenHeight += bounds.height(),
|
|
36
|
+
childrenWidth = Math.max(childrenWidth, bounds.width())) : (childrenWidth += bounds.width(),
|
|
37
|
+
childrenHeight = Math.max(childrenHeight, bounds.height())), boundsLegal += bounds.x1,
|
|
38
|
+
boundsLegal += bounds.y1, boundsLegal += bounds.x2, boundsLegal += bounds.y2);
|
|
39
|
+
})), !isFinite(boundsLegal)) return;
|
|
40
|
+
width = childrenWidth, height = childrenHeight;
|
|
41
|
+
}
|
|
42
|
+
p.attribute.width = width, p.attribute.height = height, this.tempBounds.copy(p._AABBBounds);
|
|
39
43
|
const result = {
|
|
40
44
|
main: {
|
|
41
45
|
len: width,
|
|
@@ -44,16 +48,16 @@ export class FlexLayoutPlugin {
|
|
|
44
48
|
cross: {
|
|
45
49
|
len: height,
|
|
46
50
|
field: "y"
|
|
47
|
-
}
|
|
48
|
-
dir: 1
|
|
51
|
+
}
|
|
49
52
|
}, main = result.main, cross = result.cross;
|
|
50
|
-
"
|
|
51
|
-
cross.len = width, main.field = "y", cross.field = "x")
|
|
52
|
-
cross.len = width, main.field = "y", cross.field = "x", result.dir = -1);
|
|
53
|
+
"column" !== flexDirection && "column-reverse" !== flexDirection || (main.len = height,
|
|
54
|
+
cross.len = width, main.field = "y", cross.field = "x"), "row-reverse" !== flexDirection && "column-reverse" !== flexDirection || ("flex-start" === justifyContent ? justifyContent = "flex-end" : "flex-end" === justifyContent ? justifyContent = "flex-start" : children.reverse());
|
|
53
55
|
let mainLen = 0, crossLen = 0;
|
|
54
56
|
const mianLenArray = [];
|
|
55
|
-
|
|
56
|
-
const b =
|
|
57
|
+
children.forEach((c => {
|
|
58
|
+
const b = this.getAABBBounds(c);
|
|
59
|
+
if (b.empty()) return;
|
|
60
|
+
const ml = "x" === main.field ? b.width() : b.height(), cl = "x" === cross.field ? b.width() : b.height();
|
|
57
61
|
mianLenArray.push({
|
|
58
62
|
mainLen: ml,
|
|
59
63
|
crossLen: cl
|
|
@@ -82,30 +86,38 @@ export class FlexLayoutPlugin {
|
|
|
82
86
|
mainLen: mainLen,
|
|
83
87
|
crossLen: crossLen
|
|
84
88
|
});
|
|
85
|
-
const children = p.getChildren();
|
|
86
89
|
let lastIdx = 0;
|
|
87
90
|
if (mainList.forEach((s => {
|
|
88
91
|
this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s), lastIdx = s.idx + 1;
|
|
89
|
-
})), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length)
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})); else if ("flex-start" === alignContent) {
|
|
92
|
+
})), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length) {
|
|
93
|
+
const anchorPosMap = {
|
|
94
|
+
"flex-start": 0,
|
|
95
|
+
"flex-end": cross.len,
|
|
96
|
+
center: cross.len / 2
|
|
97
|
+
};
|
|
98
|
+
this.layoutCross(children, alignItems, cross, anchorPosMap, mianLenArray, mainList[0], 0);
|
|
99
|
+
} else if ("flex-start" === alignContent) {
|
|
98
100
|
lastIdx = 0;
|
|
99
101
|
let anchorPos = 0;
|
|
100
102
|
mainList.forEach(((s, i) => {
|
|
101
|
-
|
|
103
|
+
const anchorPosMap = {
|
|
104
|
+
"flex-start": anchorPos,
|
|
105
|
+
"flex-end": anchorPos + s.crossLen,
|
|
106
|
+
center: anchorPos + s.crossLen / 2
|
|
107
|
+
};
|
|
108
|
+
this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
|
|
102
109
|
lastIdx = s.idx + 1, anchorPos += s.crossLen;
|
|
103
110
|
}));
|
|
104
111
|
} else if ("center" === alignContent) {
|
|
105
112
|
lastIdx = 0;
|
|
106
113
|
let anchorPos = Math.max(0, (cross.len - crossLen) / 2);
|
|
107
114
|
mainList.forEach(((s, i) => {
|
|
108
|
-
|
|
115
|
+
const anchorPosMap = {
|
|
116
|
+
"flex-start": anchorPos,
|
|
117
|
+
"flex-end": anchorPos + s.crossLen,
|
|
118
|
+
center: anchorPos + s.crossLen / 2
|
|
119
|
+
};
|
|
120
|
+
this.layoutCross(children, "center", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
|
|
109
121
|
lastIdx = s.idx + 1, anchorPos += s.crossLen;
|
|
110
122
|
}));
|
|
111
123
|
} else if ("space-around" === alignContent) {
|
|
@@ -113,7 +125,12 @@ export class FlexLayoutPlugin {
|
|
|
113
125
|
const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);
|
|
114
126
|
let anchorPos = padding;
|
|
115
127
|
mainList.forEach(((s, i) => {
|
|
116
|
-
|
|
128
|
+
const anchorPosMap = {
|
|
129
|
+
"flex-start": anchorPos,
|
|
130
|
+
"flex-end": anchorPos + s.crossLen,
|
|
131
|
+
center: anchorPos + s.crossLen / 2
|
|
132
|
+
};
|
|
133
|
+
this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
|
|
117
134
|
lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
|
|
118
135
|
}));
|
|
119
136
|
} else if ("space-between" === alignContent) {
|
|
@@ -121,73 +138,113 @@ export class FlexLayoutPlugin {
|
|
|
121
138
|
const padding = Math.max(0, (cross.len - crossLen) / (2 * mainList.length - 2));
|
|
122
139
|
let anchorPos = 0;
|
|
123
140
|
mainList.forEach(((s, i) => {
|
|
124
|
-
|
|
141
|
+
const anchorPosMap = {
|
|
142
|
+
"flex-start": anchorPos,
|
|
143
|
+
"flex-end": anchorPos + s.crossLen,
|
|
144
|
+
center: anchorPos + s.crossLen / 2
|
|
145
|
+
};
|
|
146
|
+
this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
|
|
125
147
|
lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
|
|
126
148
|
}));
|
|
127
149
|
}
|
|
128
150
|
children.forEach(((child, idx) => {
|
|
129
151
|
child.addUpdateBoundTag(), child.addUpdatePositionTag(), child.clearUpdateLayoutTag();
|
|
130
|
-
})), p.addUpdateLayoutTag()
|
|
131
|
-
|
|
152
|
+
})), p.addUpdateLayoutTag();
|
|
153
|
+
const b = this.getAABBBounds(p);
|
|
154
|
+
clip || this.tempBounds.equals(b) || this.tryLayout(p, !1);
|
|
155
|
+
}
|
|
156
|
+
getAABBBounds(graphic) {
|
|
157
|
+
this.skipBoundsTrigger = !0;
|
|
158
|
+
const b = graphic.AABBBounds;
|
|
159
|
+
return this.skipBoundsTrigger = !1, b;
|
|
160
|
+
}
|
|
161
|
+
updateChildPos(posBaseLeftTop, lastP, lastBP) {
|
|
162
|
+
return posBaseLeftTop + (null != lastP ? lastP : 0) - lastBP;
|
|
132
163
|
}
|
|
133
164
|
layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, currSeg) {
|
|
134
165
|
if ("flex-start" === justifyContent) {
|
|
135
166
|
let pos = 0;
|
|
136
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
137
|
-
|
|
167
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
168
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
169
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
170
|
+
pos += mianLenArray[i].mainLen;
|
|
171
|
+
}
|
|
138
172
|
} else if ("flex-end" === justifyContent) {
|
|
139
173
|
let pos = main.len;
|
|
140
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
174
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
175
|
+
pos -= mianLenArray[i].mainLen;
|
|
176
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
177
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`]));
|
|
178
|
+
}
|
|
141
179
|
} else if ("space-around" === justifyContent) if (currSeg.mainLen >= main.len) {
|
|
142
180
|
let pos = 0;
|
|
143
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
144
|
-
|
|
181
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
182
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
183
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
184
|
+
pos += mianLenArray[i].mainLen;
|
|
185
|
+
}
|
|
145
186
|
} else {
|
|
146
187
|
const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / size / 2;
|
|
147
188
|
let pos = padding;
|
|
148
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
149
|
-
|
|
189
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
190
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
191
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
192
|
+
pos += mianLenArray[i].mainLen + 2 * padding;
|
|
193
|
+
}
|
|
150
194
|
} else if ("space-between" === justifyContent) if (currSeg.mainLen >= main.len) {
|
|
151
195
|
let pos = 0;
|
|
152
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
153
|
-
|
|
196
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
197
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
198
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
199
|
+
pos += mianLenArray[i].mainLen;
|
|
200
|
+
}
|
|
154
201
|
} else {
|
|
155
202
|
const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / (2 * size - 2);
|
|
156
203
|
let pos = 0;
|
|
157
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
158
|
-
|
|
204
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
205
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
206
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
207
|
+
pos += mianLenArray[i].mainLen + 2 * padding;
|
|
208
|
+
}
|
|
159
209
|
} else if ("center" === justifyContent) {
|
|
160
210
|
let pos = (main.len - currSeg.mainLen) / 2;
|
|
161
|
-
for (let i = lastIdx; i <= currSeg.idx; i++)
|
|
162
|
-
|
|
211
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
212
|
+
const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
|
|
213
|
+
!b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
|
|
214
|
+
pos += mianLenArray[i].mainLen;
|
|
215
|
+
}
|
|
163
216
|
}
|
|
164
217
|
}
|
|
165
|
-
layoutCross(children, alignItem, cross,
|
|
166
|
-
|
|
218
|
+
layoutCross(children, alignItem, cross, anchorPosMap, lenArray, currSeg, lastIdx) {
|
|
219
|
+
var _a;
|
|
220
|
+
for (let i = lastIdx; i <= currSeg.idx; i++) {
|
|
221
|
+
const child = children[i];
|
|
222
|
+
let {alignSelf: alignSelf} = child.attribute;
|
|
223
|
+
alignSelf && "auto" !== alignSelf || (alignSelf = alignItem);
|
|
224
|
+
const b = this.getAABBBounds(child), anchorPos = null !== (_a = anchorPosMap[alignSelf]) && void 0 !== _a ? _a : anchorPosMap["flex-start"];
|
|
225
|
+
"flex-end" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : "center" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen / 2 + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`]));
|
|
226
|
+
}
|
|
167
227
|
}
|
|
168
228
|
activate(context) {
|
|
169
229
|
this.pluginService = context, application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
|
|
170
|
-
graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic
|
|
230
|
+
graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage && graphic.stage === this.pluginService.stage && this.tryLayout(graphic, !1);
|
|
171
231
|
})), application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
|
|
172
|
-
graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && _tempBounds.copy(bounds);
|
|
232
|
+
graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && _tempBounds.copy(bounds);
|
|
173
233
|
})), application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
174
|
-
stage && stage === this.pluginService.stage && graphic.isContainer && (_tempBounds.equals(bounds) ||
|
|
175
|
-
this.layouting = !1));
|
|
234
|
+
stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && (_tempBounds.equals(bounds) || this.tryLayout(graphic, !1));
|
|
176
235
|
})), application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
|
|
177
|
-
graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic
|
|
236
|
+
graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1);
|
|
178
237
|
}));
|
|
179
238
|
}
|
|
180
239
|
deactivate(context) {
|
|
181
240
|
application.graphicService.hooks.onAttributeUpdate.taps = application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
|
|
241
|
+
application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
242
|
+
application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
182
243
|
application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
|
|
183
244
|
}
|
|
184
245
|
}
|
|
185
246
|
|
|
186
247
|
function getPadding(graphic, field) {
|
|
187
|
-
|
|
188
|
-
if (isNumber(graphic.attribute.boundsPadding)) return graphic.attribute.boundsPadding;
|
|
189
|
-
if (isArray(graphic.attribute.boundsPadding) && 1 === graphic.attribute.boundsPadding.length) return graphic.attribute.boundsPadding[0];
|
|
190
|
-
const paddingArray = parsePadding(graphic.attribute.boundsPadding);
|
|
191
|
-
return "x" === field ? paddingArray[3] : "y" === field ? paddingArray[0] : 0;
|
|
248
|
+
return 0;
|
|
192
249
|
}
|
|
193
250
|
//# sourceMappingURL=flex-layout-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/flex-layout-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,GAAG,IAAI,UAAU,EAAE,CAAC;AAErC,MAAM,OAAO,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,OAAE,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC5C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,eAAU,GAAe,IAAI,UAAU,EAAE,CAAC;IAgW5C,CAAC;IA7VC,SAAS,CAAC,OAAiB;QACzB,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO;SACR;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE;YACrC,OAAO;SACR;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAChC,MAAM,EAAE,OAAO,GAAG,KAAK,CA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KACxB;SAAM,IAAI,KAAK,KAAK,GAAG,EAAE;QACxB,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,OAAO,CAAC,CAAC;AACX,CAAC","file":"flex-layout-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IGroupAttribute, IStage } from '../../interface';\nimport { getTheme } from '../../graphic';\nimport type { IPlugin, IPluginService } from '../../interface';\nimport { Generator } from '../../common/generator';\nimport { isNumber } from '../../canvas/util';\nimport { parsePadding } from '../../common/utils';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isArray } from '@visactor/vutils';\nimport { application } from '../../application';\n\nconst _tempBounds = new AABBBounds();\n\nexport class FlexLayoutPlugin implements IPlugin {\n name: 'FlexLayoutPlugin' = 'FlexLayoutPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n id: number = Generator.GenAutoIncrementId();\n key: string = this.name + this.id;\n tempBounds: AABBBounds = new AABBBounds();\n layouting: boolean;\n\n tryLayout(graphic: IGraphic) {\n if (this.layouting) {\n return;\n }\n this.layouting = true;\n const p = graphic.parent;\n if (!p || !graphic.needUpdateLayout()) {\n return;\n }\n const theme = getTheme(p).group;\n const { display = theme.display } = p.attribute;\n if (display !== 'flex') {\n return;\n }\n const {\n // width,\n // height,\n flexDirection = theme.flexDirection,\n flexWrap = theme.flexWrap,\n justifyContent = theme.justifyContent,\n alignItems = theme.alignItems,\n alignContent = theme.alignContent,\n clip = theme.clip\n } = p.attribute;\n // if (!(width && height)) {\n // return;\n // }\n\n let childrenWidth = 0;\n let childrenHeight = 0;\n let boundsLegal = 0;\n p.forEachChildren((child: IGraphic) => {\n const bounds = child.AABBBounds;\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n childrenHeight += bounds.height();\n childrenWidth = Math.max(childrenWidth, bounds.width());\n } else {\n childrenWidth += bounds.width();\n childrenHeight = Math.max(childrenHeight, bounds.height());\n }\n boundsLegal += bounds.x1;\n boundsLegal += bounds.y1;\n boundsLegal += bounds.x2;\n boundsLegal += bounds.y2;\n });\n // judgement children bounds legal\n if (!isFinite(boundsLegal)) {\n return;\n }\n const width = p.attribute.width || childrenWidth;\n const height = p.attribute.height || childrenHeight;\n if (!p.attribute.width) {\n p.attribute.width = 0;\n }\n if (!p.attribute.height) {\n p.attribute.height = 0;\n }\n\n // 这里使用p._AABBBounds可能会将非布局造成的bounds更新也会触发重新布局\n // TODO: 增加layout前预处理,在非递归布局前将子节点及其全部父节点_AABBBounds更新\n this.tempBounds.copy(p._AABBBounds);\n const result = {\n main: { len: width, field: 'x' },\n cross: { len: height, field: 'y' },\n dir: 1\n };\n const main = result.main;\n const cross = result.cross;\n if (flexDirection === 'row-reverse') {\n result.dir = -1;\n } else if (flexDirection === 'column') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n } else if (flexDirection === 'column-reverse') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n result.dir = -1;\n }\n\n // 计算宽度\n let mainLen = 0;\n let crossLen = 0;\n const mianLenArray: { mainLen: number; crossLen: number }[] = [];\n p.forEachChildren((c: IGraphic) => {\n const b = c.AABBBounds;\n const ml = main.field === 'x' ? b.width() : b.height();\n const cl = cross.field === 'x' ? b.width() : b.height();\n mianLenArray.push({ mainLen: ml, crossLen: cl });\n mainLen += ml;\n crossLen = Math.max(crossLen, cl);\n });\n // 解析main\n const mainList: { idx: number; mainLen: number; crossLen: number }[] = [];\n if (mainLen > main.len && flexWrap === 'wrap') {\n let tempMainL = 0;\n let tempCrossL = 0;\n mianLenArray.forEach(({ mainLen, crossLen }, i) => {\n if (tempMainL + mainLen > main.len) {\n if (tempMainL === 0) {\n mainList.push({ idx: i, mainLen: tempMainL + mainLen, crossLen });\n tempMainL = 0;\n tempCrossL = 0;\n } else {\n mainList.push({ idx: i - 1, mainLen: tempMainL, crossLen });\n tempMainL = mainLen;\n tempCrossL = crossLen;\n }\n } else {\n tempMainL += mainLen;\n tempCrossL = Math.max(tempCrossL, crossLen);\n }\n });\n mainList.push({ idx: mianLenArray.length - 1, mainLen: tempMainL, crossLen: tempCrossL });\n } else {\n mainList.push({ idx: mianLenArray.length - 1, mainLen: mainLen, crossLen });\n }\n\n const children = p.getChildren() as IGraphic[];\n\n // 布局main\n let lastIdx: number = 0;\n mainList.forEach(s => {\n this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s);\n lastIdx = s.idx + 1;\n });\n\n crossLen = mainList.reduce((a, b) => a + b.crossLen, 0);\n\n // 布局cross\n if (mainList.length === 1) {\n if (alignItems === 'flex-end') {\n const anchorPos = cross.len;\n this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);\n } else if (alignItems === 'center') {\n const anchorPos = cross.len / 2;\n this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);\n } else {\n children.forEach(child => {\n child.attribute[cross.field] = getPadding(child, cross.field);\n });\n }\n } else {\n if (alignContent === 'flex-start') {\n lastIdx = 0;\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'center') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'center', cross, anchorPos + s.crossLen / 2, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'space-around') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n } else if (alignContent === 'space-between') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / (mainList.length * 2 - 2));\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n }\n }\n\n // update children\n children.forEach((child, idx) => {\n child.addUpdateBoundTag();\n child.addUpdatePositionTag();\n child.clearUpdateLayoutTag();\n });\n\n p.addUpdateLayoutTag();\n // 更新父级元素的layout,直到存在clip\n if (!clip && !this.tempBounds.equals(p.AABBBounds)) {\n // 判断父元素包围盒是否发生变化\n this.tryLayout(p);\n this.layouting = false;\n }\n }\n\n layoutMain(\n p: IGroup,\n children: IGraphic[],\n justifyContent: IGroupAttribute['justifyContent'],\n main: { len: number; field: string },\n mianLenArray: { mainLen: number; crossLen: number }[],\n lastIdx: number,\n currSeg: { idx: number; mainLen: number; crossLen: number }\n ) {\n if (justifyContent === 'flex-start') {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else if (justifyContent === 'flex-end') {\n let pos = main.len;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n pos -= mianLenArray[i].mainLen;\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n }\n } else if (justifyContent === 'space-around') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / size / 2;\n let pos = padding;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'space-between') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / (size * 2 - 2);\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'center') {\n let pos = (main.len - currSeg.mainLen) / 2;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n }\n }\n\n layoutCross(\n children: IGraphic[],\n alignItem: IGroupAttribute['alignItems'],\n cross: { len: number; field: string },\n anchorPos: number,\n lenArray: { mainLen: number; crossLen: number }[],\n currSeg: { idx: number; mainLen: number; crossLen: number },\n lastIdx: number\n ) {\n if (alignItem === 'flex-end') {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field);\n }\n } else if (alignItem === 'center') {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] =\n anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field);\n }\n } else {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] = anchorPos + getPadding(children[i], cross.field);\n }\n }\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic);\n this.layouting = false;\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer) {\n return;\n }\n _tempBounds.copy(bounds);\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer) {\n return;\n }\n if (!_tempBounds.equals(bounds)) {\n this.tryLayout(graphic);\n this.layouting = false;\n }\n }\n );\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic);\n this.layouting = false;\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n\nfunction getPadding(graphic: IGraphic, field: string): number {\n if (!graphic.attribute.boundsPadding) {\n return 0;\n } else if (isNumber(graphic.attribute.boundsPadding)) {\n return graphic.attribute.boundsPadding as number;\n } else if (isArray(graphic.attribute.boundsPadding) && graphic.attribute.boundsPadding.length === 1) {\n return graphic.attribute.boundsPadding[0];\n }\n const paddingArray = parsePadding(graphic.attribute.boundsPadding);\n if (field === 'x') {\n return paddingArray[3];\n } else if (field === 'y') {\n return paddingArray[0];\n }\n return 0;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/flex-layout-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,EAAE,UAAU,EAAW,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,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M,CAAC,IAAI,CAAC,EAAE;gBACpE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI;YAC1D,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACzE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI;YACzD,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACxE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAChH,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,UAAU,CAAC,OAAiB,EAAE,KAAa;IAclD,OAAO,CAAC,CAAC;AACX,CAAC","file":"flex-layout-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IGroupAttribute, IStage } from '../../interface';\nimport { getTheme } from '../../graphic';\nimport type { IPlugin, IPluginService } from '../../interface';\nimport { Generator } from '../../common/generator';\nimport { isNumber } from '../../canvas/util';\nimport { parsePadding } from '../../common/utils';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isArray } from '@visactor/vutils';\nimport { application } from '../../application';\n\nconst _tempBounds = new AABBBounds();\n\ntype IAnchorPosMap = {\n 'flex-start': number;\n 'flex-end': number;\n center: number;\n};\n\nexport class FlexLayoutPlugin implements IPlugin {\n name: 'FlexLayoutPlugin' = 'FlexLayoutPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n id: number = Generator.GenAutoIncrementId();\n key: string = this.name + this.id;\n tempBounds: AABBBounds = new AABBBounds();\n pause: boolean;\n skipBoundsTrigger: boolean;\n\n pauseLayout(p: boolean) {\n this.pause = p;\n }\n\n tryLayoutChildren(graphic: IGraphic) {\n if (graphic.firstChild) {\n this.tryLayout(graphic.firstChild as IGraphic);\n }\n }\n\n tryLayout(graphic: IGraphic, force: boolean = true) {\n if (this.pause) {\n return;\n }\n const p = graphic.parent;\n if (!(force || (p && graphic.needUpdateLayout()))) {\n return;\n }\n const theme = getTheme(p).group;\n const { display = theme.display } = p.attribute;\n if (display !== 'flex') {\n return;\n }\n const {\n // width,\n // height,\n flexDirection = theme.flexDirection,\n flexWrap = theme.flexWrap,\n alignItems = theme.alignItems,\n clip = theme.clip\n } = p.attribute;\n const { alignContent = alignItems ?? theme.alignContent } = p.attribute;\n // if (!(width && height)) {\n // return;\n // }\n\n let { width, height, justifyContent = theme.justifyContent } = p.attribute;\n const children = p.getChildren() as IGraphic[];\n if (width == null || height == null) {\n // 计算子节点flex排列后的宽高\n let childrenWidth = 0;\n let childrenHeight = 0;\n let boundsLegal = 0;\n children.forEach((child: IGraphic) => {\n const bounds = this.getAABBBounds(child);\n if (bounds.empty()) {\n return;\n }\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n childrenHeight += bounds.height();\n childrenWidth = Math.max(childrenWidth, bounds.width());\n } else {\n childrenWidth += bounds.width();\n childrenHeight = Math.max(childrenHeight, bounds.height());\n }\n boundsLegal += bounds.x1;\n boundsLegal += bounds.y1;\n boundsLegal += bounds.x2;\n boundsLegal += bounds.y2;\n });\n // judgement children bounds legal\n if (!isFinite(boundsLegal)) {\n return;\n }\n width = childrenWidth;\n height = childrenHeight;\n }\n\n p.attribute.width = width;\n p.attribute.height = height;\n\n // 这里使用p._AABBBounds可能会将非布局造成的bounds更新也会触发重新布局\n // TODO: 增加layout前预处理,在非递归布局前将子节点及其全部父节点_AABBBounds更新\n this.tempBounds.copy(p._AABBBounds);\n const result = {\n main: { len: width, field: 'x' },\n cross: { len: height, field: 'y' }\n };\n const main = result.main;\n const cross = result.cross;\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n }\n if (flexDirection === 'row-reverse' || flexDirection === 'column-reverse') {\n if (justifyContent === 'flex-start') {\n justifyContent = 'flex-end';\n } else if (justifyContent === 'flex-end') {\n justifyContent = 'flex-start';\n } else {\n children.reverse();\n }\n }\n\n // 计算宽度\n let mainLen = 0;\n let crossLen = 0;\n const mianLenArray: { mainLen: number; crossLen: number }[] = [];\n children.forEach((c: IGraphic) => {\n const b = this.getAABBBounds(c);\n if (b.empty()) {\n return;\n }\n const ml = main.field === 'x' ? b.width() : b.height();\n const cl = cross.field === 'x' ? b.width() : b.height();\n mianLenArray.push({ mainLen: ml, crossLen: cl });\n mainLen += ml;\n crossLen = Math.max(crossLen, cl);\n });\n // 解析main\n const mainList: { idx: number; mainLen: number; crossLen: number }[] = [];\n if (mainLen > main.len && flexWrap === 'wrap') {\n let tempMainL = 0;\n let tempCrossL = 0;\n mianLenArray.forEach(({ mainLen, crossLen }, i) => {\n if (tempMainL + mainLen > main.len) {\n if (tempMainL === 0) {\n mainList.push({ idx: i, mainLen: tempMainL + mainLen, crossLen });\n tempMainL = 0;\n tempCrossL = 0;\n } else {\n mainList.push({ idx: i - 1, mainLen: tempMainL, crossLen });\n tempMainL = mainLen;\n tempCrossL = crossLen;\n }\n } else {\n tempMainL += mainLen;\n tempCrossL = Math.max(tempCrossL, crossLen);\n }\n });\n mainList.push({ idx: mianLenArray.length - 1, mainLen: tempMainL, crossLen: tempCrossL });\n } else {\n mainList.push({ idx: mianLenArray.length - 1, mainLen: mainLen, crossLen });\n }\n\n // 布局main\n let lastIdx: number = 0;\n mainList.forEach(s => {\n this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s);\n lastIdx = s.idx + 1;\n });\n\n crossLen = mainList.reduce((a, b) => a + b.crossLen, 0);\n\n // 布局cross\n\n if (mainList.length === 1) {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': 0,\n 'flex-end': cross.len,\n center: cross.len / 2\n };\n this.layoutCross(children, alignItems, cross, anchorPosMap, mianLenArray, mainList[0], 0);\n } else {\n if (alignContent === 'flex-start') {\n lastIdx = 0;\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'center') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'center', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'space-around') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n } else if (alignContent === 'space-between') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / (mainList.length * 2 - 2));\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n }\n }\n\n // update children\n children.forEach((child, idx) => {\n child.addUpdateBoundTag();\n child.addUpdatePositionTag();\n child.clearUpdateLayoutTag();\n });\n\n p.addUpdateLayoutTag();\n // 更新父级元素的layout,直到存在clip\n const b = this.getAABBBounds(p);\n if (!clip && !this.tempBounds.equals(b)) {\n // 判断父元素包围盒是否发生变化\n this.tryLayout(p, false);\n }\n }\n\n // 避免获取bounds的时候递归进行布局\n getAABBBounds(graphic: IGraphic) {\n this.skipBoundsTrigger = true;\n const b = graphic.AABBBounds;\n this.skipBoundsTrigger = false;\n return b;\n }\n\n // 锚点并不一定总在左上角,根据位置和bounds的偏移进行定位\n private updateChildPos(posBaseLeftTop: number, lastP: number | undefined, lastBP: number): number {\n return posBaseLeftTop + (lastP ?? 0) - lastBP;\n }\n\n layoutMain(\n p: IGroup,\n children: IGraphic[],\n justifyContent: IGroupAttribute['justifyContent'],\n main: { len: number; field: string },\n mianLenArray: { mainLen: number; crossLen: number }[],\n lastIdx: number,\n currSeg: { idx: number; mainLen: number; crossLen: number }\n ) {\n if (justifyContent === 'flex-start') {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else if (justifyContent === 'flex-end') {\n let pos = main.len;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n pos -= mianLenArray[i].mainLen;\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n }\n } else if (justifyContent === 'space-around') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / size / 2;\n let pos = padding;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'space-between') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / (size * 2 - 2);\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'center') {\n let pos = (main.len - currSeg.mainLen) / 2;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n }\n }\n\n layoutCross(\n children: IGraphic[],\n alignItem: IGroupAttribute['alignItems'],\n cross: { len: number; field: string },\n anchorPosMap: IAnchorPosMap,\n lenArray: { mainLen: number; crossLen: number }[],\n currSeg: { idx: number; mainLen: number; crossLen: number },\n lastIdx: number\n ) {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const child = children[i];\n let { alignSelf } = child.attribute;\n if (!alignSelf || alignSelf === 'auto') {\n alignSelf = alignItem;\n }\n const b = this.getAABBBounds(child);\n const anchorPos = anchorPosMap[alignSelf] ?? anchorPosMap['flex-start'];\n if (alignSelf === 'flex-end') {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos - lenArray[i].crossLen + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n } else if (alignSelf === 'center') {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos - lenArray[i].crossLen / 2 + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n } else {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n }\n }\n // if (alignItem === 'flex-end') {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // } else if (alignItem === 'center') {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // } else {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // }\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n // 属性更新\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(graphic.stage && graphic.stage === this.pluginService.stage)) {\n return;\n }\n this.tryLayout(graphic, false);\n });\n // 包围盒更新(如果包围盒发生变化,就重新布局\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer || this.skipBoundsTrigger) {\n return;\n }\n _tempBounds.copy(bounds);\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer || this.skipBoundsTrigger) {\n return;\n }\n if (!_tempBounds.equals(bounds)) {\n this.tryLayout(graphic, false);\n }\n }\n );\n // 添加到场景树\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic, false);\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n\nfunction getPadding(graphic: IGraphic, field: string): number {\n // if (!graphic.attribute.boundsPadding) {\n // return 0;\n // } else if (isNumber(graphic.attribute.boundsPadding)) {\n // return graphic.attribute.boundsPadding as number;\n // } else if (isArray(graphic.attribute.boundsPadding) && graphic.attribute.boundsPadding.length === 1) {\n // return graphic.attribute.boundsPadding[0];\n // }\n // const paddingArray = parsePadding(graphic.attribute.boundsPadding);\n // if (field === 'x') {\n // return paddingArray[3];\n // } else if (field === 'y') {\n // return paddingArray[0];\n // }\n return 0;\n}\n"]}
|
|
@@ -58,6 +58,12 @@ let DefaultDrawContribution = class {
|
|
|
58
58
|
this.currentRenderService = renderService;
|
|
59
59
|
const {context: context, stage: stage, x: x = 0, y: y = 0, width: width, height: height} = drawContext;
|
|
60
60
|
if (!context) return;
|
|
61
|
+
if (drawContext.keepMatrix) {
|
|
62
|
+
if (context.nativeContext && context.nativeContext.getTransform) {
|
|
63
|
+
const t = context.nativeContext.getTransform();
|
|
64
|
+
context.setTransformFromMatrix(t, !0, 1);
|
|
65
|
+
}
|
|
66
|
+
} else context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
|
|
61
67
|
const dirtyBounds = this.dirtyBounds.setValue(0, 0, width, height);
|
|
62
68
|
if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {
|
|
63
69
|
const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, !1);
|
|
@@ -67,19 +73,17 @@ let DefaultDrawContribution = class {
|
|
|
67
73
|
const d = context.dpr % 1;
|
|
68
74
|
(d || .5 !== d) && (dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr,
|
|
69
75
|
dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr, dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr,
|
|
70
|
-
dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds)
|
|
71
|
-
context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
|
|
76
|
+
dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds);
|
|
72
77
|
const drawInArea = dirtyBounds.width() * context.dpr < context.canvas.width || dirtyBounds.height() * context.dpr < context.canvas.height;
|
|
73
78
|
context.save(), context.translate(x, y, !0), drawInArea && (context.beginPath(),
|
|
74
79
|
context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()),
|
|
75
|
-
context.clip()), stage.camera && (this.dirtyBounds.
|
|
76
|
-
this.
|
|
77
|
-
context.save(), renderService.renderTreeRoots.sort(((a, b) => {
|
|
80
|
+
context.clip()), stage.camera && (this.dirtyBounds.clear(), this.backupDirtyBounds.clear()),
|
|
81
|
+
this.clearScreen(renderService, context, drawContext), context.save(), renderService.renderTreeRoots.sort(((a, b) => {
|
|
78
82
|
var _a, _b;
|
|
79
83
|
return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
|
|
80
84
|
})).forEach((group => {
|
|
81
85
|
group.isContainer ? this.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : this.renderItem(group, drawContext);
|
|
82
|
-
})), context.restore(), context.restore(), context.draw(), context.inuse = !1;
|
|
86
|
+
})), context.restore(), context.restore(), context.draw(), drawContext.keepMatrix || (context.inuse = !1);
|
|
83
87
|
}
|
|
84
88
|
doRegister() {
|
|
85
89
|
throw new Error("暂不支持");
|
|
@@ -126,8 +130,7 @@ let DefaultDrawContribution = class {
|
|
|
126
130
|
group: group
|
|
127
131
|
}, subLayers.set(group._uid, incrementalLayer));
|
|
128
132
|
const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext(), idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);
|
|
129
|
-
idc.dirtyBounds.
|
|
130
|
-
idc.draw(this.currentRenderService, Object.assign(Object.assign({}, drawContext), {
|
|
133
|
+
idc.dirtyBounds.clear(), idc.backupDirtyBounds.clear(), idc.draw(this.currentRenderService, Object.assign(Object.assign({}, drawContext), {
|
|
131
134
|
drawContribution: idc,
|
|
132
135
|
clear: "transparent",
|
|
133
136
|
layer: incrementalLayer.layer,
|