@leafer-ui/display 1.0.0-rc.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/Box.ts +59 -39
- package/src/Canvas.ts +17 -18
- package/src/Ellipse.ts +3 -3
- package/src/Frame.ts +8 -5
- package/src/Group.ts +24 -31
- package/src/Image.ts +5 -25
- package/src/Leafer.ts +447 -0
- package/src/Line.ts +19 -30
- package/src/Path.ts +4 -21
- package/src/Pen.ts +18 -8
- package/src/Polygon.ts +3 -6
- package/src/Rect.ts +2 -6
- package/src/Star.ts +2 -2
- package/src/Text.ts +34 -29
- package/src/UI.ts +266 -92
- package/src/index.ts +1 -0
- package/types/index.d.ts +254 -119
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/display",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@leafer-ui/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.0
|
|
26
|
-
"@leafer-ui/data": "1.0.0
|
|
27
|
-
"@leafer-ui/display-module": "1.0.0
|
|
28
|
-
"@leafer-ui/decorator": "1.0.0
|
|
29
|
-
"@leafer-ui/external": "1.0.0
|
|
25
|
+
"@leafer/core": "1.0.0",
|
|
26
|
+
"@leafer-ui/data": "1.0.0",
|
|
27
|
+
"@leafer-ui/display-module": "1.0.0",
|
|
28
|
+
"@leafer-ui/decorator": "1.0.0",
|
|
29
|
+
"@leafer-ui/external": "1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.0.0
|
|
33
|
-
"@leafer-ui/interface": "1.0.0
|
|
32
|
+
"@leafer/interface": "1.0.0",
|
|
33
|
+
"@leafer-ui/interface": "1.0.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/Box.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions,
|
|
2
|
-
import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType } from '@leafer/core'
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions, IBoundsData, IBoolean } from '@leafer/interface'
|
|
2
|
+
import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType, dataType } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IBox, IBoxData, IBoxInputData, IOverflow } from '@leafer-ui/interface'
|
|
5
|
+
import { BoxData } from '@leafer-ui/data'
|
|
5
6
|
|
|
6
7
|
import { Group } from './Group'
|
|
7
8
|
import { Rect } from './Rect'
|
|
8
|
-
import { BoxData } from '@leafer-ui/data'
|
|
9
|
-
|
|
10
9
|
|
|
11
10
|
const rect = Rect.prototype
|
|
12
11
|
const group = Group.prototype
|
|
13
|
-
const
|
|
14
|
-
const { copy, add } = BoundsHelper
|
|
12
|
+
const childrenRenderBounds = {} as IBoundsData
|
|
13
|
+
const { copy, add, includes } = BoundsHelper
|
|
15
14
|
|
|
16
15
|
@rewriteAble()
|
|
17
16
|
@registerUI()
|
|
@@ -19,27 +18,24 @@ export class Box extends Group implements IBox {
|
|
|
19
18
|
|
|
20
19
|
public get __tag() { return 'Box' }
|
|
21
20
|
|
|
21
|
+
public get isBranchLeaf(): boolean { return true }
|
|
22
|
+
|
|
22
23
|
@dataProcessor(BoxData)
|
|
23
24
|
declare public __: IBoxData
|
|
24
25
|
|
|
26
|
+
@dataType(false)
|
|
27
|
+
public resizeChildren?: IBoolean
|
|
28
|
+
|
|
25
29
|
@affectRenderBoundsType('show')
|
|
26
|
-
declare public overflow
|
|
30
|
+
declare public overflow?: IOverflow
|
|
31
|
+
|
|
32
|
+
public isOverflow: boolean
|
|
27
33
|
|
|
28
34
|
constructor(data?: IBoxInputData) {
|
|
29
35
|
super(data)
|
|
30
|
-
this.isBranchLeaf = true
|
|
31
36
|
this.__layout.renderChanged || this.__layout.renderChange()
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
public __scaleResize(scaleX: number, scaleY: number): void {
|
|
35
|
-
if (this.__.__autoBounds && this.children.length) {
|
|
36
|
-
super.__scaleResize(scaleX, scaleY)
|
|
37
|
-
} else {
|
|
38
|
-
this.width *= scaleX
|
|
39
|
-
this.height *= scaleY
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
@rewrite(rect.__updateStrokeSpread)
|
|
44
40
|
public __updateStrokeSpread(): number { return 0 }
|
|
45
41
|
|
|
@@ -47,10 +43,7 @@ export class Box extends Group implements IBox {
|
|
|
47
43
|
public __updateRectRenderSpread(): number { return 0 }
|
|
48
44
|
|
|
49
45
|
public __updateRenderSpread(): number {
|
|
50
|
-
|
|
51
|
-
this.__.__drawAfterFill = this.__.overflow === 'hide'
|
|
52
|
-
if (!width) width = this.__.__drawAfterFill ? 0 : 1
|
|
53
|
-
return width
|
|
46
|
+
return this.__updateRectRenderSpread() || -1
|
|
54
47
|
}
|
|
55
48
|
|
|
56
49
|
|
|
@@ -58,8 +51,23 @@ export class Box extends Group implements IBox {
|
|
|
58
51
|
public __updateRectBoxBounds(): void { }
|
|
59
52
|
|
|
60
53
|
public __updateBoxBounds(): void {
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
const data = this.__
|
|
55
|
+
|
|
56
|
+
if (this.children.length) {
|
|
57
|
+
if (data.__autoSide) {
|
|
58
|
+
if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this)
|
|
59
|
+
super.__updateBoxBounds()
|
|
60
|
+
if (!data.__autoSize) {
|
|
61
|
+
const b = this.__layout.boxBounds
|
|
62
|
+
if (!data.__autoWidth) b.height += b.y, b.width = data.width, b.x = b.y = 0
|
|
63
|
+
if (!data.__autoHeight) b.width += b.x, b.height = data.height, b.y = b.x = 0
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
this.__updateRectBoxBounds()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (data.flow) this.__updateContentBounds()
|
|
70
|
+
|
|
63
71
|
} else {
|
|
64
72
|
this.__updateRectBoxBounds()
|
|
65
73
|
}
|
|
@@ -69,15 +77,22 @@ export class Box extends Group implements IBox {
|
|
|
69
77
|
public __updateStrokeBounds(): void { }
|
|
70
78
|
|
|
71
79
|
public __updateRenderBounds(): void {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
let isOverflow: boolean
|
|
81
|
+
const { renderBounds } = this.__layout
|
|
82
|
+
|
|
83
|
+
if (this.children.length) {
|
|
76
84
|
super.__updateRenderBounds()
|
|
77
|
-
|
|
85
|
+
copy(childrenRenderBounds, renderBounds)
|
|
86
|
+
this.__updateRectRenderBounds()
|
|
87
|
+
|
|
88
|
+
isOverflow = !includes(renderBounds, childrenRenderBounds) || undefined
|
|
89
|
+
} else {
|
|
90
|
+
this.__updateRectRenderBounds()
|
|
78
91
|
}
|
|
79
|
-
}
|
|
80
92
|
|
|
93
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow)
|
|
94
|
+
if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide')) add(renderBounds, childrenRenderBounds)
|
|
95
|
+
}
|
|
81
96
|
|
|
82
97
|
@rewrite(rect.__updateRenderBounds)
|
|
83
98
|
public __updateRectRenderBounds(): void { }
|
|
@@ -91,10 +106,6 @@ export class Box extends Group implements IBox {
|
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
|
|
94
|
-
@rewrite(rect.__drawPathByData)
|
|
95
|
-
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
96
|
-
|
|
97
|
-
|
|
98
109
|
@rewrite(rect.__render)
|
|
99
110
|
public __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
|
|
100
111
|
|
|
@@ -107,16 +118,25 @@ export class Box extends Group implements IBox {
|
|
|
107
118
|
this.__renderRect(canvas, options)
|
|
108
119
|
} else {
|
|
109
120
|
this.__renderRect(canvas, options)
|
|
110
|
-
this.__renderGroup(canvas, options)
|
|
121
|
+
if (this.children.length) this.__renderGroup(canvas, options)
|
|
111
122
|
}
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
public __drawAfterFill(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
const { length } = this.children
|
|
127
|
+
if (this.isOverflow) {
|
|
128
|
+
canvas.save()
|
|
129
|
+
canvas.clip()
|
|
130
|
+
if (length) this.__renderGroup(canvas, options)
|
|
131
|
+
canvas.restore()
|
|
132
|
+
} else {
|
|
133
|
+
if (length) this.__renderGroup(canvas, options)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (this.__.stroke && length) {
|
|
137
|
+
canvas.setWorld(this.__nowWorld)
|
|
138
|
+
this.__drawRenderPath(canvas)
|
|
139
|
+
}
|
|
120
140
|
}
|
|
121
141
|
|
|
122
142
|
}
|
package/src/Canvas.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData, ICanvasContext2D, IScreenSizeData, ISizeData
|
|
2
|
-
import { Creator, Matrix, Platform, dataProcessor, registerUI
|
|
1
|
+
import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData, ICanvasContext2D, ICanvasContext2DSettings, IScreenSizeData, ISizeData } from '@leafer/interface'
|
|
2
|
+
import { Creator, Matrix, Platform, dataProcessor, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ICanvas, ICanvasData, ICanvasInputData, IUI } from '@leafer-ui/interface'
|
|
5
|
-
import {
|
|
5
|
+
import { CanvasData } from '@leafer-ui/data'
|
|
6
|
+
import { resizeType } from '@leafer-ui/decorator'
|
|
6
7
|
|
|
7
8
|
import { Rect } from './Rect'
|
|
8
|
-
import { resizeType } from '@leafer-ui/decorator'
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@registerUI()
|
|
@@ -13,40 +13,39 @@ export class Canvas extends Rect implements ICanvas {
|
|
|
13
13
|
|
|
14
14
|
public get __tag() { return 'Canvas' }
|
|
15
15
|
|
|
16
|
-
@dataProcessor(
|
|
16
|
+
@dataProcessor(CanvasData)
|
|
17
17
|
declare public __: ICanvasData
|
|
18
18
|
|
|
19
19
|
@resizeType(100)
|
|
20
|
-
declare public width
|
|
20
|
+
declare public width?: INumber
|
|
21
21
|
|
|
22
22
|
@resizeType(100)
|
|
23
|
-
declare public height
|
|
23
|
+
declare public height?: INumber
|
|
24
24
|
|
|
25
25
|
@resizeType(Platform.devicePixelRatio)
|
|
26
|
-
public pixelRatio
|
|
26
|
+
declare public pixelRatio?: INumber
|
|
27
27
|
|
|
28
28
|
@resizeType(true)
|
|
29
|
-
public smooth
|
|
29
|
+
public smooth?: boolean
|
|
30
30
|
|
|
31
|
-
@
|
|
32
|
-
|
|
31
|
+
@resizeType()
|
|
32
|
+
public contextSettings?: ICanvasContext2DSettings
|
|
33
33
|
|
|
34
|
-
public canvas
|
|
34
|
+
public canvas?: ILeaferCanvas
|
|
35
35
|
|
|
36
|
-
public context
|
|
36
|
+
public context?: ICanvasContext2D
|
|
37
37
|
|
|
38
38
|
constructor(data?: ICanvasInputData) {
|
|
39
39
|
super(data)
|
|
40
40
|
this.canvas = Creator.canvas(this.__ as ILeaferCanvasConfig)
|
|
41
41
|
this.context = this.canvas.context
|
|
42
|
-
this.__.__drawAfterFill = true
|
|
42
|
+
this.__.__isCanvas = this.__.__drawAfterFill = true
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public draw(ui: IUI, offset?: IPointData, scale?: number | IPointData, rotation?: number): void {
|
|
46
46
|
ui.__layout.update()
|
|
47
47
|
|
|
48
|
-
const matrix = new Matrix(ui.__world)
|
|
49
|
-
matrix.invert()
|
|
48
|
+
const matrix = new Matrix(ui.__world).invert()
|
|
50
49
|
|
|
51
50
|
const m = new Matrix()
|
|
52
51
|
if (offset) m.translate(offset.x, offset.y)
|
|
@@ -54,7 +53,7 @@ export class Canvas extends Rect implements ICanvas {
|
|
|
54
53
|
if (rotation) m.rotate(rotation)
|
|
55
54
|
matrix.multiplyParent(m)
|
|
56
55
|
|
|
57
|
-
ui.__render(this.canvas, { matrix })
|
|
56
|
+
ui.__render(this.canvas, { matrix: matrix.withScale() })
|
|
58
57
|
this.paint()
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -65,7 +64,7 @@ export class Canvas extends Rect implements ICanvas {
|
|
|
65
64
|
public __drawAfterFill(canvas: ILeaferCanvas, _options: IRenderOptions): void {
|
|
66
65
|
const origin = this.canvas.view as ISizeData
|
|
67
66
|
const { width, height } = this
|
|
68
|
-
if (this.__.cornerRadius) {
|
|
67
|
+
if (this.__.cornerRadius || this.pathInputed) {
|
|
69
68
|
canvas.save()
|
|
70
69
|
canvas.clip()
|
|
71
70
|
canvas.drawImage(this.canvas.view as any, 0, 0, origin.width, origin.height, 0, 0, width, height)
|
package/src/Ellipse.ts
CHANGED
|
@@ -18,13 +18,13 @@ export class Ellipse extends UI implements IEllipse {
|
|
|
18
18
|
declare public __: IEllipseData
|
|
19
19
|
|
|
20
20
|
@pathType(0)
|
|
21
|
-
public innerRadius
|
|
21
|
+
public innerRadius?: INumber
|
|
22
22
|
|
|
23
23
|
@pathType(0)
|
|
24
|
-
public startAngle
|
|
24
|
+
public startAngle?: INumber
|
|
25
25
|
|
|
26
26
|
@pathType(0)
|
|
27
|
-
public endAngle
|
|
27
|
+
public endAngle?: INumber
|
|
28
28
|
|
|
29
29
|
constructor(data?: IEllipseInputData) {
|
|
30
30
|
super(data)
|
package/src/Frame.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dataProcessor, registerUI, affectRenderBoundsType } from '@leafer/core'
|
|
1
|
+
import { dataProcessor, registerUI, affectRenderBoundsType, surfaceType } from '@leafer/core'
|
|
2
2
|
|
|
3
|
-
import { IFrame, IFrameData, IFrameInputData, IOverflow } from '@leafer-ui/interface'
|
|
3
|
+
import { IFrame, IFrameData, IFrameInputData, IFill, IOverflow } from '@leafer-ui/interface'
|
|
4
4
|
import { FrameData } from '@leafer-ui/data'
|
|
5
5
|
|
|
6
6
|
import { Box } from './Box'
|
|
@@ -11,15 +11,18 @@ export class Frame extends Box implements IFrame {
|
|
|
11
11
|
|
|
12
12
|
public get __tag() { return 'Frame' }
|
|
13
13
|
|
|
14
|
+
public get isFrame(): boolean { return true }
|
|
15
|
+
|
|
14
16
|
@dataProcessor(FrameData)
|
|
15
17
|
declare public __: IFrameData
|
|
16
18
|
|
|
19
|
+
@surfaceType('#FFFFFF')
|
|
20
|
+
declare public fill?: IFill
|
|
21
|
+
|
|
17
22
|
@affectRenderBoundsType('hide')
|
|
18
|
-
declare public overflow
|
|
23
|
+
declare public overflow?: IOverflow
|
|
19
24
|
|
|
20
25
|
constructor(data?: IFrameInputData) {
|
|
21
26
|
super(data)
|
|
22
|
-
this.isFrame = true
|
|
23
|
-
if (!this.__.fill) this.__.fill = '#FFFFFF'
|
|
24
27
|
}
|
|
25
28
|
}
|
package/src/Group.ts
CHANGED
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IJSONOptions, IPickOptions, IPickResult, IPointData } from '@leafer/interface'
|
|
2
|
+
import { Branch, useModule, dataProcessor, registerUI, UICreator } from '@leafer/core'
|
|
2
3
|
|
|
3
|
-
import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData } from '@leafer-ui/interface'
|
|
4
|
+
import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData, IUIJSONData } from '@leafer-ui/interface'
|
|
4
5
|
import { GroupData } from '@leafer-ui/data'
|
|
5
6
|
|
|
6
7
|
import { UI } from './UI'
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
const matrix = MatrixHelper.get()
|
|
10
|
-
|
|
11
10
|
@useModule(Branch)
|
|
12
11
|
@registerUI()
|
|
13
|
-
export class Group extends UI implements IGroup {
|
|
12
|
+
export class Group extends UI implements IGroup { // tip: rewrited Box
|
|
14
13
|
|
|
15
14
|
public get __tag() { return 'Group' }
|
|
16
15
|
|
|
16
|
+
public get isBranch(): boolean { return true }
|
|
17
|
+
|
|
17
18
|
@dataProcessor(GroupData)
|
|
18
19
|
declare public __: IGroupData
|
|
19
20
|
|
|
20
21
|
declare public children: IUI[]
|
|
21
22
|
|
|
22
|
-
public set mask(child: IUI) {
|
|
23
|
-
if (this.__hasMask) this.__removeMask()
|
|
24
|
-
if (child) {
|
|
25
|
-
child.isMask = true
|
|
26
|
-
this.addAt(child, 0)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
public get mask(): IUI {
|
|
30
|
-
return this.children.find(item => item.isMask)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
23
|
constructor(data?: IGroupInputData) {
|
|
34
24
|
super(data)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public reset(data?: IGroupInputData): void {
|
|
35
28
|
this.__setBranch()
|
|
29
|
+
super.reset(data)
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
public __setBranch(): void {
|
|
39
|
-
this.isBranch = true
|
|
40
33
|
if (!this.children) this.children = []
|
|
41
34
|
}
|
|
42
35
|
|
|
36
|
+
|
|
43
37
|
// data
|
|
44
38
|
|
|
45
39
|
public set(data: IUIInputData): void {
|
|
@@ -50,14 +44,14 @@ export class Group extends UI implements IGroup {
|
|
|
50
44
|
if (!this.children) {
|
|
51
45
|
this.__setBranch()
|
|
52
46
|
} else {
|
|
53
|
-
this.
|
|
47
|
+
this.clear()
|
|
54
48
|
}
|
|
55
49
|
|
|
56
50
|
super.set(data)
|
|
57
51
|
|
|
58
52
|
let child: IUI
|
|
59
53
|
children.forEach(childData => {
|
|
60
|
-
child = UICreator.get(childData.tag, childData) as IUI
|
|
54
|
+
child = (childData as IUI).__ ? childData as IUI : UICreator.get(childData.tag, childData) as IUI
|
|
61
55
|
this.add(child)
|
|
62
56
|
})
|
|
63
57
|
|
|
@@ -68,20 +62,17 @@ export class Group extends UI implements IGroup {
|
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
public toJSON():
|
|
72
|
-
const data = super.toJSON()
|
|
73
|
-
data.children = this.children.map(child => child.toJSON())
|
|
65
|
+
public toJSON(options?: IJSONOptions): IUIJSONData {
|
|
66
|
+
const data = super.toJSON(options)
|
|
67
|
+
data.children = this.children.map(child => child.toJSON(options))
|
|
74
68
|
return data
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
children[i].transform(matrix, true)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
71
|
+
|
|
72
|
+
// hit rewrite
|
|
73
|
+
|
|
74
|
+
public pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult { return undefined }
|
|
75
|
+
|
|
85
76
|
|
|
86
77
|
// add
|
|
87
78
|
|
|
@@ -93,7 +84,7 @@ export class Group extends UI implements IGroup {
|
|
|
93
84
|
this.add(child, this.children.indexOf(after) + 1)
|
|
94
85
|
}
|
|
95
86
|
|
|
96
|
-
public addBefore(child:
|
|
87
|
+
public addBefore(child: IUI, before: IUI): void {
|
|
97
88
|
this.add(child, this.children.indexOf(before))
|
|
98
89
|
}
|
|
99
90
|
|
|
@@ -107,4 +98,6 @@ export class Group extends UI implements IGroup {
|
|
|
107
98
|
|
|
108
99
|
public removeAll(_destroy?: boolean): void { }
|
|
109
100
|
|
|
101
|
+
public clear(): void { }
|
|
102
|
+
|
|
110
103
|
}
|
package/src/Image.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILeaferImage, IString } from '@leafer/interface'
|
|
2
2
|
import { ImageEvent, boundsType, dataProcessor, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IImage, IImageInputData, IImageData
|
|
4
|
+
import { IImage, IImageInputData, IImageData } from '@leafer-ui/interface'
|
|
5
5
|
import { ImageData } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { Rect } from './Rect'
|
|
@@ -20,33 +20,13 @@ export class Image extends Rect implements IImage {
|
|
|
20
20
|
|
|
21
21
|
public get ready(): boolean { return this.image ? this.image.ready : false }
|
|
22
22
|
|
|
23
|
-
public image
|
|
23
|
+
public image?: ILeaferImage
|
|
24
24
|
|
|
25
25
|
constructor(data?: IImageInputData) {
|
|
26
26
|
super(data)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let update: boolean
|
|
32
|
-
|
|
33
|
-
const { url } = this
|
|
34
|
-
const fill = this.fill as IImagePaint
|
|
35
|
-
|
|
36
|
-
if (fill) {
|
|
37
|
-
if (fill.url !== url) update = true
|
|
38
|
-
} else {
|
|
39
|
-
if (url) update = true
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (update) {
|
|
43
|
-
if (this.image) this.image = null
|
|
44
|
-
this.fill = url ? { type: 'image', mode: 'strench', url } : undefined
|
|
45
|
-
this.once(ImageEvent.LOADED, (e) => this.image = e.image)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
super.__updateBoxBounds()
|
|
49
|
-
|
|
27
|
+
this.on(ImageEvent.LOADED, (e: ImageEvent) => {
|
|
28
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url) this.image = e.image
|
|
29
|
+
})
|
|
50
30
|
}
|
|
51
31
|
|
|
52
32
|
public destroy(): void {
|