@leafer-ui/display 1.0.0-rc.3 → 1.0.0-rc.30
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 +65 -30
- package/src/Canvas.ts +19 -20
- package/src/Ellipse.ts +9 -6
- package/src/Frame.ts +8 -5
- package/src/Group.ts +28 -22
- package/src/Image.ts +7 -27
- package/src/Leafer.ts +447 -0
- package/src/Line.ts +19 -16
- package/src/Path.ts +4 -19
- package/src/Pen.ts +18 -8
- package/src/Polygon.ts +12 -24
- package/src/Rect.ts +3 -11
- package/src/Star.ts +3 -3
- package/src/Text.ts +69 -38
- package/src/UI.ts +313 -84
- package/src/index.ts +1 -0
- package/types/index.d.ts +266 -113
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/display",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.30",
|
|
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-rc.
|
|
26
|
-
"@leafer-ui/data": "1.0.0-rc.
|
|
27
|
-
"@leafer-ui/display-module": "1.0.0-rc.
|
|
28
|
-
"@leafer-ui/decorator": "1.0.0-rc.
|
|
29
|
-
"@leafer-ui/external": "1.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.30",
|
|
26
|
+
"@leafer-ui/data": "1.0.0-rc.30",
|
|
27
|
+
"@leafer-ui/display-module": "1.0.0-rc.30",
|
|
28
|
+
"@leafer-ui/decorator": "1.0.0-rc.30",
|
|
29
|
+
"@leafer-ui/external": "1.0.0-rc.30"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.0.0-rc.
|
|
33
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
32
|
+
"@leafer/interface": "1.0.0-rc.30",
|
|
33
|
+
"@leafer-ui/interface": "1.0.0-rc.30"
|
|
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,17 +18,21 @@ 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
|
|
27
31
|
|
|
28
|
-
public
|
|
32
|
+
public isOverflow: boolean
|
|
29
33
|
|
|
30
34
|
constructor(data?: IBoxInputData) {
|
|
31
35
|
super(data)
|
|
32
|
-
this.isBranchLeaf = true
|
|
33
36
|
this.__layout.renderChanged || this.__layout.renderChange()
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -40,29 +43,56 @@ export class Box extends Group implements IBox {
|
|
|
40
43
|
public __updateRectRenderSpread(): number { return 0 }
|
|
41
44
|
|
|
42
45
|
public __updateRenderSpread(): number {
|
|
43
|
-
|
|
44
|
-
this.__.__drawAfterFill = this.__.overflow === 'hide'
|
|
45
|
-
if (!width) width = this.__.__drawAfterFill ? 0 : 1
|
|
46
|
-
return width
|
|
46
|
+
return this.__updateRectRenderSpread() || -1
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
@rewrite(rect.__updateBoxBounds)
|
|
51
|
-
public
|
|
51
|
+
public __updateRectBoxBounds(): void { }
|
|
52
|
+
|
|
53
|
+
public __updateBoxBounds(): void {
|
|
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
|
+
|
|
71
|
+
} else {
|
|
72
|
+
this.__updateRectBoxBounds()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
52
75
|
|
|
53
76
|
@rewrite(rect.__updateStrokeBounds)
|
|
54
77
|
public __updateStrokeBounds(): void { }
|
|
55
78
|
|
|
56
79
|
public __updateRenderBounds(): void {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
let isOverflow: boolean
|
|
81
|
+
const { renderBounds } = this.__layout
|
|
82
|
+
|
|
83
|
+
if (this.children.length) {
|
|
61
84
|
super.__updateRenderBounds()
|
|
62
|
-
|
|
85
|
+
copy(childrenRenderBounds, renderBounds)
|
|
86
|
+
this.__updateRectRenderBounds()
|
|
87
|
+
|
|
88
|
+
isOverflow = !includes(renderBounds, childrenRenderBounds) || undefined
|
|
89
|
+
} else {
|
|
90
|
+
this.__updateRectRenderBounds()
|
|
63
91
|
}
|
|
64
|
-
}
|
|
65
92
|
|
|
93
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow)
|
|
94
|
+
if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide')) add(renderBounds, childrenRenderBounds)
|
|
95
|
+
}
|
|
66
96
|
|
|
67
97
|
@rewrite(rect.__updateRenderBounds)
|
|
68
98
|
public __updateRectRenderBounds(): void { }
|
|
@@ -76,10 +106,6 @@ export class Box extends Group implements IBox {
|
|
|
76
106
|
}
|
|
77
107
|
|
|
78
108
|
|
|
79
|
-
@rewrite(rect.__drawPathByData)
|
|
80
|
-
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
81
|
-
|
|
82
|
-
|
|
83
109
|
@rewrite(rect.__render)
|
|
84
110
|
public __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
|
|
85
111
|
|
|
@@ -92,16 +118,25 @@ export class Box extends Group implements IBox {
|
|
|
92
118
|
this.__renderRect(canvas, options)
|
|
93
119
|
} else {
|
|
94
120
|
this.__renderRect(canvas, options)
|
|
95
|
-
this.__renderGroup(canvas, options)
|
|
121
|
+
if (this.children.length) this.__renderGroup(canvas, options)
|
|
96
122
|
}
|
|
97
123
|
}
|
|
98
124
|
|
|
99
125
|
public __drawAfterFill(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
}
|
|
105
140
|
}
|
|
106
141
|
|
|
107
142
|
}
|
package/src/Canvas.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ILeaferCanvas, ILeaferCanvasConfig,
|
|
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,48 +13,47 @@ 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
|
-
ui.__layout.
|
|
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)
|
|
53
52
|
if (scale) typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y)
|
|
54
53
|
if (rotation) m.rotate(rotation)
|
|
55
|
-
matrix.
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
1
|
+
import { INumber } from '@leafer/interface'
|
|
2
|
+
import { PathCommandDataHelper, Platform, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
|
|
5
5
|
import { EllipseData } from '@leafer-ui/data'
|
|
@@ -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)
|
|
@@ -48,9 +48,12 @@ export class Ellipse extends UI implements IEllipse {
|
|
|
48
48
|
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius)
|
|
49
49
|
moveTo(path, width, ry)
|
|
50
50
|
}
|
|
51
|
-
ellipse(path, rx, ry, rx, ry, 0,
|
|
51
|
+
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// fix node
|
|
55
|
+
if (Platform.ellipseToCurve) this.__.path = this.getPath(true)
|
|
56
|
+
|
|
54
57
|
} else {
|
|
55
58
|
|
|
56
59
|
if (startAngle || endAngle) {
|
package/src/Frame.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dataProcessor, registerUI, affectRenderBoundsType } from '@leafer/core'
|
|
1
|
+
import { dataProcessor, registerUI, affectRenderBoundsType, surfaceType } from '@leafer/core'
|
|
3
2
|
|
|
4
|
-
import { IFrame, IFrameData, IFrameInputData, IOverflow } from '@leafer-ui/interface'
|
|
3
|
+
import { IFrame, IFrameData, IFrameInputData, IFill, IOverflow } from '@leafer-ui/interface'
|
|
5
4
|
import { FrameData } from '@leafer-ui/data'
|
|
6
5
|
|
|
7
6
|
import { Box } from './Box'
|
|
@@ -12,14 +11,18 @@ export class Frame extends Box implements IFrame {
|
|
|
12
11
|
|
|
13
12
|
public get __tag() { return 'Frame' }
|
|
14
13
|
|
|
14
|
+
public get isFrame(): boolean { return true }
|
|
15
|
+
|
|
15
16
|
@dataProcessor(FrameData)
|
|
16
17
|
declare public __: IFrameData
|
|
17
18
|
|
|
19
|
+
@surfaceType('#FFFFFF')
|
|
20
|
+
declare public fill?: IFill
|
|
21
|
+
|
|
18
22
|
@affectRenderBoundsType('hide')
|
|
19
|
-
declare public overflow
|
|
23
|
+
declare public overflow?: IOverflow
|
|
20
24
|
|
|
21
25
|
constructor(data?: IFrameInputData) {
|
|
22
26
|
super(data)
|
|
23
|
-
if (!this.__.fill) this.__.fill = '#FFFFFF'
|
|
24
27
|
}
|
|
25
28
|
}
|
package/src/Group.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IJSONOptions, IPickOptions, IPickResult, IPointData } from '@leafer/interface'
|
|
1
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'
|
|
@@ -8,38 +9,31 @@ import { UI } from './UI'
|
|
|
8
9
|
|
|
9
10
|
@useModule(Branch)
|
|
10
11
|
@registerUI()
|
|
11
|
-
export class Group extends UI implements IGroup {
|
|
12
|
+
export class Group extends UI implements IGroup { // tip: rewrited Box
|
|
12
13
|
|
|
13
14
|
public get __tag() { return 'Group' }
|
|
14
15
|
|
|
16
|
+
public get isBranch(): boolean { return true }
|
|
17
|
+
|
|
15
18
|
@dataProcessor(GroupData)
|
|
16
19
|
declare public __: IGroupData
|
|
17
20
|
|
|
18
21
|
declare public children: IUI[]
|
|
19
22
|
|
|
20
|
-
public get resizeable(): boolean { return false }
|
|
21
|
-
|
|
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 {
|
|
@@ -47,13 +41,17 @@ export class Group extends UI implements IGroup {
|
|
|
47
41
|
const { children } = data
|
|
48
42
|
delete data.children
|
|
49
43
|
|
|
50
|
-
if (!this.children)
|
|
44
|
+
if (!this.children) {
|
|
45
|
+
this.__setBranch()
|
|
46
|
+
} else {
|
|
47
|
+
this.clear()
|
|
48
|
+
}
|
|
51
49
|
|
|
52
50
|
super.set(data)
|
|
53
51
|
|
|
54
52
|
let child: IUI
|
|
55
53
|
children.forEach(childData => {
|
|
56
|
-
child = UICreator.get(childData.tag, childData) as IUI
|
|
54
|
+
child = (childData as IUI).__ ? childData as IUI : UICreator.get(childData.tag, childData) as IUI
|
|
57
55
|
this.add(child)
|
|
58
56
|
})
|
|
59
57
|
|
|
@@ -64,12 +62,18 @@ export class Group extends UI implements IGroup {
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
public toJSON():
|
|
68
|
-
const data = super.toJSON()
|
|
69
|
-
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))
|
|
70
68
|
return data
|
|
71
69
|
}
|
|
72
70
|
|
|
71
|
+
|
|
72
|
+
// hit rewrite
|
|
73
|
+
|
|
74
|
+
public pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult { return undefined }
|
|
75
|
+
|
|
76
|
+
|
|
73
77
|
// add
|
|
74
78
|
|
|
75
79
|
public addAt(child: IUI, index: number): void {
|
|
@@ -80,7 +84,7 @@ export class Group extends UI implements IGroup {
|
|
|
80
84
|
this.add(child, this.children.indexOf(after) + 1)
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
public addBefore(child:
|
|
87
|
+
public addBefore(child: IUI, before: IUI): void {
|
|
84
88
|
this.add(child, this.children.indexOf(before))
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -94,4 +98,6 @@ export class Group extends UI implements IGroup {
|
|
|
94
98
|
|
|
95
99
|
public removeAll(_destroy?: boolean): void { }
|
|
96
100
|
|
|
101
|
+
public clear(): void { }
|
|
102
|
+
|
|
97
103
|
}
|
package/src/Image.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ILeaferImage,
|
|
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'
|
|
@@ -16,37 +16,17 @@ export class Image extends Rect implements IImage {
|
|
|
16
16
|
declare public __: IImageData
|
|
17
17
|
|
|
18
18
|
@boundsType('')
|
|
19
|
-
public url:
|
|
19
|
+
public url: IString
|
|
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 {
|