@leafer/display 1.0.0-rc.1 → 1.0.0-rc.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,16 +22,16 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.0-rc.1",
26
- "@leafer/data": "1.0.0-rc.1",
27
- "@leafer/layout": "1.0.0-rc.1",
28
- "@leafer/display-module": "1.0.0-rc.1",
29
- "@leafer/event": "1.0.0-rc.1",
30
- "@leafer/decorator": "1.0.0-rc.1",
31
- "@leafer/helper": "1.0.0-rc.1",
32
- "@leafer/platform": "1.0.0-rc.1"
25
+ "@leafer/math": "1.0.0-rc.11",
26
+ "@leafer/data": "1.0.0-rc.11",
27
+ "@leafer/layout": "1.0.0-rc.11",
28
+ "@leafer/display-module": "1.0.0-rc.11",
29
+ "@leafer/event": "1.0.0-rc.11",
30
+ "@leafer/decorator": "1.0.0-rc.11",
31
+ "@leafer/helper": "1.0.0-rc.11",
32
+ "@leafer/platform": "1.0.0-rc.11"
33
33
  },
34
34
  "devDependencies": {
35
- "@leafer/interface": "1.0.0-rc.1"
35
+ "@leafer/interface": "1.0.0-rc.11"
36
36
  }
37
37
  }
package/src/Branch.ts CHANGED
@@ -3,18 +3,17 @@ 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 { BranchRender, LeafMask } from '@leafer/display-module'
6
+ import { BranchRender } from '@leafer/display-module'
7
7
 
8
8
  import { Leaf } from './Leaf'
9
9
 
10
10
 
11
- const { setByListWithHandle } = BoundsHelper
11
+ const { setListWithFn } = BoundsHelper
12
12
  const { sort } = BranchHelper
13
- const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper
13
+ const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper
14
14
 
15
15
 
16
16
  @useModule(BranchRender)
17
- @useModule(LeafMask)
18
17
  export class Branch extends Leaf {
19
18
 
20
19
  constructor() {
@@ -42,15 +41,15 @@ export class Branch extends Leaf {
42
41
  }
43
42
 
44
43
  public __updateBoxBounds(): void {
45
- setByListWithHandle(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds)
44
+ setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds)
46
45
  }
47
46
 
48
47
  public __updateStrokeBounds(): void {
49
- setByListWithHandle(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalEventBounds : localEventBounds)
48
+ setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds)
50
49
  }
51
50
 
52
51
  public __updateRenderBounds(): void {
53
- setByListWithHandle(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds)
52
+ setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds)
54
53
  }
55
54
 
56
55
 
@@ -75,7 +74,7 @@ export class Branch extends Leaf {
75
74
 
76
75
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child)
77
76
  if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1
78
- child.__layout.boundsChanged || child.__layout.positionChange() // layouted(removed), need update
77
+ child.__layout.boundsChanged || child.__layout.matrixChange() // layouted(removed), need update
79
78
 
80
79
  if (child.__parentWait) WaitHelper.run(child.__parentWait)
81
80
 
@@ -119,6 +118,10 @@ export class Branch extends Leaf {
119
118
  }
120
119
  }
121
120
 
121
+ public clear(): void {
122
+ this.removeAll(true)
123
+ }
124
+
122
125
  protected __preRemove(): void {
123
126
  if (this.__hasMask) this.__updateMask()
124
127
  if (this.__hasEraser) this.__updateEraser()
package/src/Leaf.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, __Value, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String, IPointData, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IBoundsData, IBranch, IMatrixWithLayoutData } from '@leafer/interface'
2
- import { IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
1
+ import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, ILayoutAttr, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData } from '@leafer/interface'
2
+ import { BoundsHelper, IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
3
3
  import { LeafData } from '@leafer/data'
4
4
  import { LeafLayout } from '@leafer/layout'
5
- import { LeafDataProxy, LeafMatrix, LeafBounds, LeafHit, LeafEventer, LeafRender } from '@leafer/display-module'
6
- import { useModule } from '@leafer/decorator'
5
+ import { LeafDataProxy, LeafMatrix, LeafBounds, LeafEventer, LeafRender } from '@leafer/display-module'
6
+ import { boundsType, useModule, defineDataProcessor } from '@leafer/decorator'
7
7
  import { LeafHelper, WaitHelper } from '@leafer/helper'
8
8
 
9
9
 
10
10
  const { LEAF, create } = IncrementId
11
- const { toInnerPoint, toOuterPoint } = MatrixHelper
11
+ const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper
12
+ const { toOuterOf } = BoundsHelper
12
13
  const { tempToOuterOf, copy } = PointHelper
13
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal } = LeafHelper
14
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, transform, setTransform, drop } = LeafHelper
14
15
 
15
16
  @useModule(LeafDataProxy)
16
17
  @useModule(LeafMatrix)
17
18
  @useModule(LeafBounds)
18
- @useModule(LeafHit)
19
19
  @useModule(LeafEventer)
20
20
  @useModule(LeafRender)
21
21
  export class Leaf implements ILeaf {
@@ -31,7 +31,7 @@ export class Leaf implements ILeaf {
31
31
  public get __DataProcessor() { return LeafData }
32
32
  public get __LayoutProcessor() { return LeafLayout }
33
33
 
34
- public leafer?: ILeafer
34
+ public leafer?: ILeaferBase
35
35
  public parent?: ILeaf
36
36
 
37
37
  public isLeafer: boolean
@@ -41,31 +41,37 @@ export class Leaf implements ILeaf {
41
41
  public __: ILeafData
42
42
  public __layout: ILeafLayout
43
43
 
44
- public __world: IMatrixWithLayoutData
45
- public __local: IMatrixWithBoundsData
44
+ public __world: IMatrixWithBoundsScaleData
45
+ public __local?: IMatrixWithBoundsData // and localStrokeBounds? localRenderBounds?
46
+
47
+ public __nowWorld?: IMatrixWithBoundsScaleData // use __world or __cameraWorld render
48
+ public __cameraWorld?: IMatrixWithBoundsScaleData // use camera matrix render
49
+
50
+ public get __localMatrix(): IMatrixData { return this.__local || this.__layout }
51
+ public get __localBoxBounds(): IBoundsData { return this.__local || this.__layout }
46
52
 
47
53
  public __worldOpacity: number
48
54
 
49
55
  // now transform
50
- public get worldTransform(): IMatrixWithLayoutData { return this.__layout.getTransform('world') as IMatrixWithLayoutData }
51
- public get localTransform(): IMatrixWithBoundsData { return this.__layout.getTransform('local') as IMatrixWithBoundsData }
56
+ public get worldTransform(): IMatrixData { return this.__layout.getTransform('world') }
57
+ public get localTransform(): IMatrixData { return this.__layout.getTransform('local') }
52
58
 
53
59
  // now bounds
54
60
  public get boxBounds(): IBoundsData { return this.getBounds('box', 'inner') }
61
+ public get renderBounds(): IBoundsData { return this.getBounds('render', 'inner') }
55
62
  public get worldBoxBounds(): IBoundsData { return this.getBounds('box') }
56
63
  public get worldStrokeBounds(): IBoundsData { return this.getBounds('stroke') }
57
64
  public get worldRenderBounds(): IBoundsData { return this.getBounds('render') }
58
65
 
59
66
  // now opacity
60
- public get worldOpacity(): number { this.__layout.checkUpdate(); return this.__worldOpacity }
67
+ public get worldOpacity(): number { this.__layout.update(); return this.__worldOpacity }
61
68
 
62
69
  public __level: number // layer level 0 -> branch -> branch -> deep
63
70
  public __tempNumber: number // temp sort
64
71
 
65
- public get resizeable(): boolean { return true }
66
-
67
- public get __hasMirror(): boolean { return this.__world.scaleX < 0 || this.__world.scaleY < 0 }
72
+ public get __worldFlipped(): boolean { return this.__world.scaleX < 0 || this.__world.scaleY < 0 }
68
73
 
74
+ public __hasAutoLayout?: boolean
69
75
  public __hasMask?: boolean
70
76
  public __hasEraser?: boolean
71
77
  public __hitCanvas?: IHitCanvas
@@ -83,29 +89,35 @@ export class Leaf implements ILeaf {
83
89
  // branch
84
90
  public children?: ILeaf[]
85
91
 
92
+ // other
93
+ public noBounds?: boolean
86
94
 
87
95
  public destroyed: boolean
88
96
 
89
97
 
90
98
  constructor(data?: ILeafInputData) {
91
-
92
99
  this.innerId = create(LEAF)
100
+ this.reset(data)
101
+ }
102
+
93
103
 
94
- this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 }
95
- this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
104
+ public reset(data?: ILeafInputData): void {
105
+
106
+ this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 }
107
+ if (data !== null) this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
96
108
 
97
109
  this.__worldOpacity = 1
98
110
 
99
111
  this.__ = new this.__DataProcessor(this)
100
112
  this.__layout = new this.__LayoutProcessor(this)
101
113
 
102
- if (data) {
103
- if (data.children) {
104
- this.set(data)
105
- } else {
106
- Object.assign(this, data)
107
- }
108
- }
114
+ if (this.__level) this.resetCustom()
115
+ if (data) data.children ? this.set(data) : Object.assign(this, data)
116
+ }
117
+
118
+ public resetCustom(): void {
119
+ this.__hasMask = this.__hasEraser = null
120
+ this.forceUpdate()
109
121
  }
110
122
 
111
123
 
@@ -117,18 +129,21 @@ export class Leaf implements ILeaf {
117
129
  this.leafer ? item() : (this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item])
118
130
  }
119
131
 
120
- public nextRender(item: IFunction): void {
121
- this.leafer ? this.leafer.nextRender(item) : this.waitLeafer(() => this.leafer.nextRender(item))
132
+ public nextRender(item: IFunction, off?: 'off'): void {
133
+ this.leafer ? this.leafer.nextRender(item, off) : this.waitLeafer(() => this.leafer.nextRender(item, off))
122
134
  }
123
135
 
124
- public __bindLeafer(leafer: ILeafer | null): void {
136
+ public __bindLeafer(leafer: ILeaferBase | null): void {
125
137
  if (this.isLeafer) {
126
- if (leafer !== null) leafer = this as unknown as ILeafer
138
+ if (leafer !== null) leafer = this as unknown as ILeaferBase
127
139
  }
128
140
 
141
+ if (this.leafer && !leafer) this.leafer.leafs--
142
+
129
143
  this.leafer = leafer
130
144
 
131
145
  if (leafer) {
146
+ leafer.leafs++
132
147
  this.__level = this.parent ? this.parent.__level + 1 : 1
133
148
  if (this.__leaferWait) WaitHelper.run(this.__leaferWait)
134
149
  }
@@ -144,6 +159,7 @@ export class Leaf implements ILeaf {
144
159
  // data
145
160
 
146
161
  public set(_data: IObject): void { }
162
+ public get(): ILeafInputData { return undefined }
147
163
 
148
164
  public toJSON(): IObject {
149
165
  return this.__.__getInputData()
@@ -155,20 +171,37 @@ export class Leaf implements ILeaf {
155
171
 
156
172
  // LeafDataProxy rewrite
157
173
 
158
- public __setAttr(_attrName: string, _newValue: __Value): void { }
174
+ public __setAttr(_attrName: string, _newValue: IValue): void { }
159
175
 
160
- public __getAttr(_attrName: string): __Value { return undefined }
176
+ public __getAttr(_attrName: string): IValue { return undefined }
177
+
178
+ public setProxyAttr(_attrName: string, _newValue: IValue): void { }
179
+
180
+ public getProxyAttr(_attrName: string): IValue { return undefined }
181
+
182
+ // ---
183
+
184
+
185
+ // find
186
+
187
+ public find(_condition: number | string | IFindMethod, _options?: any): ILeaf[] { return undefined }
188
+
189
+ public findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf { return undefined }
161
190
 
162
191
  // ---
163
192
 
164
193
  public forceUpdate(attrName?: string): void {
165
- if (attrName === undefined) attrName = 'scaleX'
194
+ if (attrName === undefined) attrName = 'width'
166
195
  else if (attrName === 'surface') attrName = 'blendMode'
167
- const value = this.__.__getInput(attrName)
168
- this.__[attrName] = value === undefined ? null : undefined;
196
+ const value = this.__.__getInput(attrName);
197
+ (this.__ as any)[attrName] = value === undefined ? null : undefined;
169
198
  (this as any)[attrName] = value
170
199
  }
171
200
 
201
+ public updateLayout(): void {
202
+ this.__layout.update()
203
+ }
204
+
172
205
 
173
206
  // LeafMatrix rewrite
174
207
 
@@ -182,6 +215,8 @@ export class Leaf implements ILeaf {
182
215
 
183
216
  public __updateWorldBounds(): void { }
184
217
 
218
+ public __updateLocalBounds(): void { }
219
+
185
220
 
186
221
  public __updateLocalBoxBounds(): void { }
187
222
 
@@ -198,6 +233,7 @@ export class Leaf implements ILeaf {
198
233
  public __updateRenderBounds(): void { }
199
234
 
200
235
 
236
+ public __updateAutoLayout(): void { }
201
237
  public __updateNaturalSize(): void { }
202
238
 
203
239
 
@@ -212,28 +248,52 @@ export class Leaf implements ILeaf {
212
248
 
213
249
  // LeafMask rewrite
214
250
 
215
- public __updateEraser(_value?: boolean): void { }
251
+ public __updateEraser(value?: boolean): void {
252
+ this.__hasEraser = value ? true : this.children.some(item => item.__.eraser)
253
+ }
216
254
 
217
- public __updateMask(_value?: boolean): void { }
255
+ public __updateMask(value?: boolean): void {
256
+ this.__hasMask = value ? true : this.children.some(item => item.__.mask)
257
+ }
218
258
 
219
- public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void { }
259
+ public __renderMask(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
220
260
 
221
- public __removeMask(_child?: ILeaf): void { }
222
261
 
223
262
  // ---
224
263
 
225
264
 
226
265
  // convert
227
266
 
228
- public getWorld(attrName: IMatrixDecompositionAttr): number {
229
- this.__layout.checkUpdate()
267
+ public __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData {
268
+ if (options.matrix) {
269
+ if (!this.__cameraWorld) this.__cameraWorld = {} as IMatrixWithBoundsScaleData
270
+ const cameraWorld = this.__cameraWorld
271
+ multiplyParent(this.__world, options.matrix, cameraWorld, undefined, this.__world)
272
+ toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld)
273
+ return cameraWorld
274
+ } else {
275
+ return this.__world
276
+ }
277
+ }
278
+
279
+
280
+ public getWorld(attrName: ILayoutAttr): number {
281
+ this.__layout.update()
230
282
  if (attrName === 'x') return this.__world.e
231
283
  if (attrName === 'y') return this.__world.f
232
- return this.__world[attrName]
284
+ return this.getLayoutBounds()[attrName]
285
+ }
286
+
287
+ public getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData {
288
+ return this.__layout.getBounds(type, relative)
289
+ }
290
+
291
+ public getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData {
292
+ return this.__layout.getLayoutBounds(type, relative, unscale)
233
293
  }
234
294
 
235
- public getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType = 'world'): IBoundsData {
236
- return this.__layout.getBounds(type, locationType)
295
+ public getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[] {
296
+ return this.__layout.getLayoutPoints(type, relative)
237
297
  }
238
298
 
239
299
 
@@ -300,25 +360,51 @@ export class Leaf implements ILeaf {
300
360
  return point
301
361
  }
302
362
 
363
+ public getPagePoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
364
+ const layer = this.leafer ? this.leafer.zoomLayer : this
365
+ return layer.getInnerPoint(world, relative, distance, change)
366
+ }
367
+
368
+ public getWorldPointByPage(page: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
369
+ const layer = this.leafer ? this.leafer.zoomLayer : this
370
+ return layer.getWorldPoint(page, relative, distance, change)
371
+ }
372
+
303
373
 
304
374
  // transform
305
375
 
376
+ public setTransform(matrix: IMatrixData, resize?: boolean): void {
377
+ setTransform(this, matrix, resize)
378
+ }
379
+
380
+ public transform(matrix: IMatrixData, resize?: boolean): void {
381
+ transform(this, matrix, resize)
382
+ }
383
+
306
384
  public move(x: number, y?: number): void {
307
385
  moveLocal(this, x, y)
308
386
  }
309
387
 
310
- public scaleOf(origin: IPointData, x: number, y?: number): void {
311
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y)
388
+ public scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void {
389
+ zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize)
312
390
  }
313
391
 
314
- public rotateOf(origin: IPointData, angle: number): void {
315
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), angle)
392
+ public rotateOf(origin: IPointData, rotation: number): void {
393
+ rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation)
316
394
  }
317
395
 
318
- public skewOf(origin: IPointData, x: number, y: number): void {
319
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y)
396
+ public skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void {
397
+ skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize)
320
398
  }
321
399
 
400
+ // @leafer-ui/scale rewrite
401
+
402
+ public scaleResize(scaleX: number, scaleY = scaleX, _noResize?: boolean): void {
403
+ (this as ILeaf).scaleX *= scaleX;
404
+ (this as ILeaf).scaleY *= scaleY
405
+ }
406
+
407
+ public __scaleResize(_scaleX: number, _scaleY: number): void { }
322
408
 
323
409
  // LeafHit rewrite
324
410
 
@@ -326,7 +412,17 @@ export class Leaf implements ILeaf {
326
412
 
327
413
  public __hit(_local: IRadiusPointData): boolean { return true }
328
414
 
329
- public __drawHitPath(_canvas: ILeaferCanvas): void { }
415
+ public __hitFill(inner: IRadiusPointData, windingRule?: string): boolean {
416
+ return this.__hitCanvas?.hitFill(inner, windingRule)
417
+ }
418
+
419
+ public __hitStroke(inner: IRadiusPointData, strokeWidth: number): boolean {
420
+ return this.__hitCanvas?.hitStroke(inner, strokeWidth)
421
+ }
422
+
423
+ public __drawHitPath(canvas: ILeaferCanvas): void {
424
+ if (canvas) this.__drawRenderPath(canvas)
425
+ }
330
426
 
331
427
  public __updateHitCanvas(): void { }
332
428
 
@@ -341,6 +437,9 @@ export class Leaf implements ILeaf {
341
437
 
342
438
  public __draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
343
439
 
440
+
441
+ public __clip(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
442
+
344
443
  public __renderShape(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
345
444
 
346
445
 
@@ -372,6 +471,10 @@ export class Leaf implements ILeaf {
372
471
  if (this.parent) this.parent.remove(this, destroy)
373
472
  }
374
473
 
474
+ public dropTo(parent: ILeaf, index?: number, resize?: boolean): void {
475
+ drop(this, parent, index, resize)
476
+ }
477
+
375
478
  // ---
376
479
 
377
480
 
@@ -395,6 +498,15 @@ export class Leaf implements ILeaf {
395
498
 
396
499
  // ---
397
500
 
501
+ static changeAttr(attrName: string, defaultValue: IValue): void {
502
+ defineDataProcessor(this.prototype, attrName, defaultValue)
503
+ }
504
+
505
+ static addAttr(attrName: string, defaultValue: IValue, fn?: IAttrDecorator): void {
506
+ if (!fn) fn = boundsType
507
+ fn(defaultValue)(this.prototype, attrName)
508
+ }
509
+
398
510
 
399
511
  public destroy(): void {
400
512
  if (!this.destroyed) {
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, InnerId, ILeafer, ILeafData, ILeafLayout, IMatrixWithLayoutData, IMatrixWithBoundsData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, __Value, ILeaferCanvas, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IPointData, IRadiusPointData, IRenderOptions, IEventListener, IEventListenerOptions, IEventListenerId, IEvent } from '@leafer/interface';
1
+ import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, IValue, IFindMethod, ILeaferCanvas, IRenderOptions, ILayoutAttr, IBoundsType, ILocationType, ILayoutBoundsData, IPointData, IRadiusPointData, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IAttrDecorator } from '@leafer/interface';
2
2
  import { LeafData } from '@leafer/data';
3
3
  import { LeafLayout } from '@leafer/layout';
4
4
 
@@ -10,27 +10,32 @@ declare class Leaf implements ILeaf {
10
10
  get innerName(): string;
11
11
  get __DataProcessor(): typeof LeafData;
12
12
  get __LayoutProcessor(): typeof LeafLayout;
13
- leafer?: ILeafer;
13
+ leafer?: ILeaferBase;
14
14
  parent?: ILeaf;
15
15
  isLeafer: boolean;
16
16
  isBranch: boolean;
17
17
  isBranchLeaf: boolean;
18
18
  __: ILeafData;
19
19
  __layout: ILeafLayout;
20
- __world: IMatrixWithLayoutData;
21
- __local: IMatrixWithBoundsData;
20
+ __world: IMatrixWithBoundsScaleData;
21
+ __local?: IMatrixWithBoundsData;
22
+ __nowWorld?: IMatrixWithBoundsScaleData;
23
+ __cameraWorld?: IMatrixWithBoundsScaleData;
24
+ get __localMatrix(): IMatrixData;
25
+ get __localBoxBounds(): IBoundsData;
22
26
  __worldOpacity: number;
23
- get worldTransform(): IMatrixWithLayoutData;
24
- get localTransform(): IMatrixWithBoundsData;
27
+ get worldTransform(): IMatrixData;
28
+ get localTransform(): IMatrixData;
25
29
  get boxBounds(): IBoundsData;
30
+ get renderBounds(): IBoundsData;
26
31
  get worldBoxBounds(): IBoundsData;
27
32
  get worldStrokeBounds(): IBoundsData;
28
33
  get worldRenderBounds(): IBoundsData;
29
34
  get worldOpacity(): number;
30
35
  __level: number;
31
36
  __tempNumber: number;
32
- get resizeable(): boolean;
33
- get __hasMirror(): boolean;
37
+ get __worldFlipped(): boolean;
38
+ __hasAutoLayout?: boolean;
34
39
  __hasMask?: boolean;
35
40
  __hasEraser?: boolean;
36
41
  __hitCanvas?: IHitCanvas;
@@ -41,37 +46,50 @@ declare class Leaf implements ILeaf {
41
46
  __parentWait?: IFunction[];
42
47
  __leaferWait?: IFunction[];
43
48
  children?: ILeaf[];
49
+ noBounds?: boolean;
44
50
  destroyed: boolean;
45
51
  constructor(data?: ILeafInputData);
52
+ reset(data?: ILeafInputData): void;
53
+ resetCustom(): void;
46
54
  waitParent(item: IFunction): void;
47
55
  waitLeafer(item: IFunction): void;
48
- nextRender(item: IFunction): void;
49
- __bindLeafer(leafer: ILeafer | null): void;
56
+ nextRender(item: IFunction, off?: 'off'): void;
57
+ __bindLeafer(leafer: ILeaferBase | null): void;
50
58
  set(_data: IObject): void;
59
+ get(): ILeafInputData;
51
60
  toJSON(): IObject;
52
61
  toString(): string;
53
- __setAttr(_attrName: string, _newValue: __Value): void;
54
- __getAttr(_attrName: string): __Value;
62
+ __setAttr(_attrName: string, _newValue: IValue): void;
63
+ __getAttr(_attrName: string): IValue;
64
+ setProxyAttr(_attrName: string, _newValue: IValue): void;
65
+ getProxyAttr(_attrName: string): IValue;
66
+ find(_condition: number | string | IFindMethod, _options?: any): ILeaf[];
67
+ findOne(_condition: number | string | IFindMethod, _options?: any): ILeaf;
55
68
  forceUpdate(attrName?: string): void;
69
+ updateLayout(): void;
56
70
  __updateWorldMatrix(): void;
57
71
  __updateLocalMatrix(): void;
58
72
  __updateWorldBounds(): void;
73
+ __updateLocalBounds(): void;
59
74
  __updateLocalBoxBounds(): void;
60
75
  __updateLocalStrokeBounds(): void;
61
76
  __updateLocalRenderBounds(): void;
62
77
  __updateBoxBounds(): void;
63
78
  __updateStrokeBounds(): void;
64
79
  __updateRenderBounds(): void;
80
+ __updateAutoLayout(): void;
65
81
  __updateNaturalSize(): void;
66
82
  __updateStrokeSpread(): number;
67
83
  __updateRenderSpread(): number;
68
84
  __onUpdateSize(): void;
69
- __updateEraser(_value?: boolean): void;
70
- __updateMask(_value?: boolean): void;
71
- __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void;
72
- __removeMask(_child?: ILeaf): void;
73
- getWorld(attrName: IMatrixDecompositionAttr): number;
74
- getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData;
85
+ __updateEraser(value?: boolean): void;
86
+ __updateMask(value?: boolean): void;
87
+ __renderMask(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
88
+ __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData;
89
+ getWorld(attrName: ILayoutAttr): number;
90
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
91
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
92
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
75
93
  worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
76
94
  localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
77
95
  worldToInner(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
@@ -82,17 +100,26 @@ declare class Leaf implements ILeaf {
82
100
  getLocalPointByInner(inner: IPointData, _relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
83
101
  getWorldPoint(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
84
102
  getWorldPointByLocal(local: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
103
+ getPagePoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
104
+ getWorldPointByPage(page: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
105
+ setTransform(matrix: IMatrixData, resize?: boolean): void;
106
+ transform(matrix: IMatrixData, resize?: boolean): void;
85
107
  move(x: number, y?: number): void;
86
- scaleOf(origin: IPointData, x: number, y?: number): void;
87
- rotateOf(origin: IPointData, angle: number): void;
88
- skewOf(origin: IPointData, x: number, y: number): void;
108
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
109
+ rotateOf(origin: IPointData, rotation: number): void;
110
+ skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
111
+ scaleResize(scaleX: number, scaleY?: number, _noResize?: boolean): void;
112
+ __scaleResize(_scaleX: number, _scaleY: number): void;
89
113
  __hitWorld(_point: IRadiusPointData): boolean;
90
114
  __hit(_local: IRadiusPointData): boolean;
91
- __drawHitPath(_canvas: ILeaferCanvas): void;
115
+ __hitFill(inner: IRadiusPointData, windingRule?: string): boolean;
116
+ __hitStroke(inner: IRadiusPointData, strokeWidth: number): boolean;
117
+ __drawHitPath(canvas: ILeaferCanvas): void;
92
118
  __updateHitCanvas(): void;
93
119
  __render(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
94
120
  __drawFast(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
95
121
  __draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
122
+ __clip(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
96
123
  __renderShape(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
97
124
  __updateWorldOpacity(): void;
98
125
  __updateChange(): void;
@@ -103,6 +130,7 @@ declare class Leaf implements ILeaf {
103
130
  __updateSortChildren(): void;
104
131
  add(_child: ILeaf, _index?: number): void;
105
132
  remove(_child?: ILeaf, destroy?: boolean): void;
133
+ dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
106
134
  on(_type: string | string[], _listener: IEventListener, _options?: IEventListenerOptions | boolean): void;
107
135
  off(_type: string | string[], _listener: IEventListener, _options?: IEventListenerOptions | boolean): void;
108
136
  on_(_type: string | string[], _listener: IEventListener, _bind?: IObject, _options?: IEventListenerOptions | boolean): IEventListenerId;
@@ -111,6 +139,8 @@ declare class Leaf implements ILeaf {
111
139
  emit(_type: string, _event?: IEvent | IObject, _capture?: boolean): void;
112
140
  emitEvent(_event?: IEvent, _capture?: boolean): void;
113
141
  hasEvent(_type: string, _capture?: boolean): boolean;
142
+ static changeAttr(attrName: string, defaultValue: IValue): void;
143
+ static addAttr(attrName: string, defaultValue: IValue, fn?: IAttrDecorator): void;
114
144
  destroy(): void;
115
145
  }
116
146
 
@@ -126,6 +156,7 @@ declare class Branch extends Leaf {
126
156
  addMany(...children: ILeaf[]): void;
127
157
  remove(child?: Leaf, destroy?: boolean): void;
128
158
  removeAll(destroy?: boolean): void;
159
+ clear(): void;
129
160
  protected __preRemove(): void;
130
161
  protected __realRemoveChild(child: ILeaf): void;
131
162
  protected __emitChildEvent(type: string, child: ILeaf): void;