@leafer/display 1.0.0-beta.2 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/src/Branch.ts +4 -64
- package/src/Leaf.ts +28 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "@leafer/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/math": "1.0.0-beta.
|
|
23
|
-
"@leafer/data": "1.0.0-beta.
|
|
24
|
-
"@leafer/layout": "1.0.0-beta.
|
|
25
|
-
"@leafer/display-module": "1.0.0-beta.
|
|
26
|
-
"@leafer/event": "1.0.0-beta.
|
|
27
|
-
"@leafer/decorator": "1.0.0-beta.
|
|
28
|
-
"@leafer/helper": "1.0.0-beta.
|
|
22
|
+
"@leafer/math": "1.0.0-beta.5",
|
|
23
|
+
"@leafer/data": "1.0.0-beta.5",
|
|
24
|
+
"@leafer/layout": "1.0.0-beta.5",
|
|
25
|
+
"@leafer/display-module": "1.0.0-beta.5",
|
|
26
|
+
"@leafer/event": "1.0.0-beta.5",
|
|
27
|
+
"@leafer/decorator": "1.0.0-beta.5",
|
|
28
|
+
"@leafer/helper": "1.0.0-beta.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@leafer/interface": "1.0.0-beta.
|
|
31
|
+
"@leafer/interface": "1.0.0-beta.5"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Branch.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ILeaf
|
|
1
|
+
import { ILeaf } from '@leafer/interface'
|
|
2
2
|
import { ChildEvent } from '@leafer/event'
|
|
3
3
|
import { BoundsHelper } from '@leafer/math'
|
|
4
4
|
import { BranchHelper, LeafBoundsHelper, WaitHelper } from '@leafer/helper'
|
|
5
5
|
import { useModule } from '@leafer/decorator'
|
|
6
|
-
import { LeafMask } from '@leafer/display-module'
|
|
6
|
+
import { BranchRender, LeafMask } from '@leafer/display-module'
|
|
7
7
|
|
|
8
8
|
import { Leaf } from './Leaf'
|
|
9
9
|
|
|
@@ -12,6 +12,8 @@ const { setByListWithHandle } = BoundsHelper
|
|
|
12
12
|
const { sort } = BranchHelper
|
|
13
13
|
const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
@useModule(BranchRender)
|
|
15
17
|
@useModule(LeafMask)
|
|
16
18
|
export class Branch extends Leaf {
|
|
17
19
|
|
|
@@ -51,14 +53,6 @@ export class Branch extends Leaf {
|
|
|
51
53
|
setByListWithHandle(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds)
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
public __updateChange(): void {
|
|
55
|
-
const { __layout: layout } = this
|
|
56
|
-
if (layout.childrenSortChanged) {
|
|
57
|
-
this.__updateSortChildren()
|
|
58
|
-
layout.childrenSortChanged = false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
|
|
63
57
|
// own
|
|
64
58
|
|
|
@@ -72,60 +66,6 @@ export class Branch extends Leaf {
|
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
68
|
|
|
75
|
-
public __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
76
|
-
|
|
77
|
-
if (this.__worldOpacity) {
|
|
78
|
-
|
|
79
|
-
let child: ILeaf
|
|
80
|
-
const { children } = this
|
|
81
|
-
|
|
82
|
-
if (this.__hasMask && children.length > 1) {
|
|
83
|
-
|
|
84
|
-
let mask: boolean
|
|
85
|
-
let maskCanvas = canvas.getSameCanvas()
|
|
86
|
-
let contentCanvas = canvas.getSameCanvas()
|
|
87
|
-
|
|
88
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
89
|
-
child = children[i]
|
|
90
|
-
|
|
91
|
-
if (child.isMask) {
|
|
92
|
-
if (mask) {
|
|
93
|
-
this.__renderMask(canvas, contentCanvas, maskCanvas)
|
|
94
|
-
maskCanvas.clear()
|
|
95
|
-
contentCanvas.clear()
|
|
96
|
-
} else {
|
|
97
|
-
mask = true
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
child.__render(maskCanvas, options)
|
|
101
|
-
continue
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
child.__render(contentCanvas, options)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.__renderMask(canvas, contentCanvas, maskCanvas)
|
|
108
|
-
maskCanvas.recycle()
|
|
109
|
-
contentCanvas.recycle()
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
|
-
|
|
113
|
-
const { bounds, hideBounds } = options
|
|
114
|
-
|
|
115
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
116
|
-
child = children[i]
|
|
117
|
-
|
|
118
|
-
if (bounds && !bounds.hit(child.__world, options.matrix)) continue
|
|
119
|
-
if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue
|
|
120
|
-
|
|
121
|
-
child.__render(canvas, options)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
69
|
public add(child: ILeaf, index?: number): void {
|
|
130
70
|
|
|
131
71
|
if (child.parent) child.parent.remove(child)
|
package/src/Leaf.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LeafData } from '@leafer/data'
|
|
|
4
4
|
import { LeafLayout } from '@leafer/layout'
|
|
5
5
|
import { LeafDataProxy, LeafMatrix, LeafBounds, LeafHit, LeafEventer, LeafRender } from '@leafer/display-module'
|
|
6
6
|
import { useModule } from '@leafer/decorator'
|
|
7
|
-
import { WaitHelper } from '@leafer/helper'
|
|
7
|
+
import { LeafHelper, WaitHelper } from '@leafer/helper'
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const { LEAF, create } = IncrementId
|
|
@@ -18,6 +18,8 @@ const { LEAF, create } = IncrementId
|
|
|
18
18
|
export class Leaf implements ILeaf {
|
|
19
19
|
|
|
20
20
|
public get tag(): string { return this.__tag }
|
|
21
|
+
public set tag(_value: string) { }
|
|
22
|
+
|
|
21
23
|
public get __tag(): string { return 'Leaf' }
|
|
22
24
|
|
|
23
25
|
public readonly innerId: InnerId // 内部唯一标识
|
|
@@ -56,10 +58,11 @@ export class Leaf implements ILeaf {
|
|
|
56
58
|
public __tempNumber: number // temp sort
|
|
57
59
|
|
|
58
60
|
public __hasMask?: boolean
|
|
61
|
+
public __hasEraser?: boolean
|
|
59
62
|
public __hitCanvas?: IHitCanvas
|
|
60
63
|
|
|
61
64
|
public get __onlyHitMask(): boolean { return this.__hasMask && !this.__.hitChildren }
|
|
62
|
-
public get __ignoreHitWorld(): boolean { return this.__hasMask && this.__.hitChildren }
|
|
65
|
+
public get __ignoreHitWorld(): boolean { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren }
|
|
63
66
|
|
|
64
67
|
// event
|
|
65
68
|
public __captureMap?: IEventListenerMap
|
|
@@ -88,11 +91,11 @@ export class Leaf implements ILeaf {
|
|
|
88
91
|
|
|
89
92
|
|
|
90
93
|
public waitParent(item: IFunction): void {
|
|
91
|
-
this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]
|
|
94
|
+
this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item])
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
public waitLeafer(item: IFunction): void {
|
|
95
|
-
this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item]
|
|
98
|
+
this.leafer ? item() : (this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item])
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
|
|
@@ -172,7 +175,9 @@ export class Leaf implements ILeaf {
|
|
|
172
175
|
|
|
173
176
|
// LeafMask rewrite
|
|
174
177
|
|
|
175
|
-
public
|
|
178
|
+
public __updateEraser(_value?: boolean): void { }
|
|
179
|
+
|
|
180
|
+
public __updateMask(_value?: boolean): void { }
|
|
176
181
|
|
|
177
182
|
public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void { }
|
|
178
183
|
|
|
@@ -217,6 +222,24 @@ export class Leaf implements ILeaf {
|
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
|
|
225
|
+
// transform
|
|
226
|
+
|
|
227
|
+
public move(x: number, y?: number): void {
|
|
228
|
+
LeafHelper.moveLocal(this, x, y)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public scaleOf(origin: IPointData, x: number, y?: number): void {
|
|
232
|
+
this.__layout.checkUpdate()
|
|
233
|
+
if (y === undefined) y = x
|
|
234
|
+
LeafHelper.zoomOfLocal(this, PointHelper.tempToOuterOf(origin, this.__local), x, y)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public rotateOf(origin: IPointData, angle: number): void {
|
|
238
|
+
this.__layout.checkUpdate()
|
|
239
|
+
LeafHelper.rotateOfLocal(this, PointHelper.tempToOuterOf(origin, this.__local), angle)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
220
243
|
// LeafHit rewrite
|
|
221
244
|
|
|
222
245
|
public __hitWorld(_point: IRadiusPointData): boolean { return true }
|