@leafer-ui/display 1.0.0-alpha.7 → 1.0.0-alpha.9
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 +7 -7
- package/src/Ellipse.ts +5 -3
- package/src/Frame.ts +3 -3
- package/src/Group.ts +5 -7
- package/src/Image.ts +3 -2
- package/src/Line.ts +6 -9
- package/src/Path.ts +2 -2
- package/src/Polygon.ts +1 -0
- package/src/Rect.ts +5 -7
- package/src/Star.ts +3 -2
- package/src/Text.ts +10 -14
- package/src/UI.ts +10 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/display",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "@leafer-ui/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-alpha.
|
|
23
|
-
"@leafer-ui/data": "1.0.0-alpha.
|
|
24
|
-
"@leafer-ui/display-module": "1.0.0-alpha.
|
|
25
|
-
"@leafer-ui/decorator": "1.0.0-alpha.
|
|
22
|
+
"@leafer/core": "1.0.0-alpha.9",
|
|
23
|
+
"@leafer-ui/data": "1.0.0-alpha.9",
|
|
24
|
+
"@leafer-ui/display-module": "1.0.0-alpha.9",
|
|
25
|
+
"@leafer-ui/decorator": "1.0.0-alpha.9"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
29
|
-
"@leafer-ui/interface": "1.0.0-alpha.
|
|
28
|
+
"@leafer/interface": "1.0.0-alpha.9",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0-alpha.9"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Ellipse.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __Number } from '@leafer/interface'
|
|
1
2
|
import { PathCreator, OneRadian, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
2
3
|
|
|
3
4
|
import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
|
|
@@ -6,6 +7,7 @@ import { EllipseData } from '@leafer-ui/data'
|
|
|
6
7
|
import { UI } from './UI'
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
const { PI } = Math
|
|
10
12
|
const { begin, moveTo, close, ellipse } = PathCreator
|
|
11
13
|
|
|
@@ -17,13 +19,13 @@ export class Ellipse extends UI implements IEllipse {
|
|
|
17
19
|
public __: IEllipseData
|
|
18
20
|
|
|
19
21
|
@pathType(0)
|
|
20
|
-
public innerRadius:
|
|
22
|
+
public innerRadius: __Number
|
|
21
23
|
|
|
22
24
|
@pathType(0)
|
|
23
|
-
public startAngle:
|
|
25
|
+
public startAngle: __Number
|
|
24
26
|
|
|
25
27
|
@pathType(0)
|
|
26
|
-
public endAngle:
|
|
28
|
+
public endAngle: __Number
|
|
27
29
|
|
|
28
30
|
constructor(data?: IEllipseInputData) {
|
|
29
31
|
super(data)
|
package/src/Frame.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions,
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions, IPathDrawer, IBoundsData, IPathCommandData, __Boolean } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, dataProcessor, boundsType, rewrite, useModule, rewriteAble, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IFrame, IFrameData, IFrameInputData } from '@leafer-ui/interface'
|
|
@@ -24,7 +24,7 @@ export class Frame extends Group implements IFrame {
|
|
|
24
24
|
public __: IFrameData
|
|
25
25
|
|
|
26
26
|
@boundsType(true)
|
|
27
|
-
public clip:
|
|
27
|
+
public clip: __Boolean
|
|
28
28
|
|
|
29
29
|
constructor(data?: IFrameInputData) {
|
|
30
30
|
super(data)
|
|
@@ -33,7 +33,7 @@ export class Frame extends Group implements IFrame {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
@rewrite(rect.__drawPathByData)
|
|
36
|
-
public __drawPathByData(_drawer:
|
|
36
|
+
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
37
37
|
|
|
38
38
|
public __updateBoxBounds(): void {
|
|
39
39
|
this.__updateRectBoxBounds()
|
package/src/Group.ts
CHANGED
|
@@ -21,12 +21,6 @@ export class Group extends UI implements IGroup {
|
|
|
21
21
|
this.children = []
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
public __updatePath(): void {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public add(_child: IUI, _index?: number): void { } // Branch rewrite
|
|
29
|
-
|
|
30
24
|
public addAt(child: IUI, index: number): void {
|
|
31
25
|
this.add(child, index)
|
|
32
26
|
}
|
|
@@ -39,6 +33,10 @@ export class Group extends UI implements IGroup {
|
|
|
39
33
|
this.add(child, this.children.indexOf(before))
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
|
|
36
|
+
// Branch rewrite
|
|
37
|
+
|
|
38
|
+
public add(_child: IUI, _index?: number): void { }
|
|
39
|
+
|
|
40
|
+
public remove(_child?: IUI): void { }
|
|
43
41
|
|
|
44
42
|
}
|
package/src/Image.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __String } from '@leafer/interface'
|
|
1
2
|
import { boundsType, dataProcessor, registerUI } from '@leafer/core'
|
|
2
3
|
|
|
3
4
|
import { IImage, IImageInputData, IImageData } from '@leafer-ui/interface'
|
|
@@ -13,10 +14,10 @@ export class Image extends Rect implements IImage {
|
|
|
13
14
|
public __: IImageData
|
|
14
15
|
|
|
15
16
|
@boundsType('')
|
|
16
|
-
public url:
|
|
17
|
+
public url: __String
|
|
17
18
|
|
|
18
19
|
@boundsType('')
|
|
19
|
-
public thumb:
|
|
20
|
+
public thumb: __String
|
|
20
21
|
|
|
21
22
|
constructor(data?: IImageInputData) {
|
|
22
23
|
super(data)
|
package/src/Line.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPointData, ITwoPointBoundsData, __Number } from '@leafer/interface'
|
|
2
2
|
import { PathCreator, PointHelper, TwoPointBoundsHelper, boundsType, dataProcessor, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ILine, ILineData, ILineInputData } from '@leafer-ui/interface'
|
|
@@ -23,20 +23,17 @@ export class Line extends UI implements ILine {
|
|
|
23
23
|
@boundsType()
|
|
24
24
|
public rotation: __Number
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
protected __to: IPointData
|
|
26
|
+
protected __toPoint: IPointData
|
|
28
27
|
|
|
29
28
|
public get toPoint(): IPointData {
|
|
30
|
-
if (this.
|
|
29
|
+
if (this.__toPoint && !this.__layout.boxBoundsChanged) return this.__toPoint
|
|
31
30
|
|
|
32
|
-
const { width,
|
|
31
|
+
const { width, rotation } = this.__
|
|
33
32
|
const to: IPointData = { x: 0, y: 0 }
|
|
34
33
|
|
|
35
34
|
if (width) to.x = width
|
|
36
|
-
if (height) to.y = height
|
|
37
|
-
|
|
38
35
|
if (rotation) rotate(to, rotation)
|
|
39
|
-
this.
|
|
36
|
+
this.__toPoint = to
|
|
40
37
|
|
|
41
38
|
return to
|
|
42
39
|
}
|
|
@@ -64,7 +61,7 @@ export class Line extends UI implements ILine {
|
|
|
64
61
|
|
|
65
62
|
public __updateBoxBounds(): void {
|
|
66
63
|
setPoint(pointBounds, 0, 0)
|
|
67
|
-
addPoint(pointBounds, this.
|
|
64
|
+
addPoint(pointBounds, this.__toPoint.x, this.__toPoint.y)
|
|
68
65
|
toBounds(pointBounds, this.__layout.boxBounds)
|
|
69
66
|
}
|
|
70
67
|
|
package/src/Path.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ITwoPointBoundsData, ILeaferCanvas, IPathCommandData } from '@leafer/interface'
|
|
1
|
+
import { ITwoPointBoundsData, ILeaferCanvas, IPathCommandData, IWindingRule } from '@leafer/interface'
|
|
2
2
|
import { PathHelper, TwoPointBoundsHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IPath, IPathData, IPathInputData,
|
|
4
|
+
import { IPath, IPathData, IPathInputData, IPathString } from '@leafer-ui/interface'
|
|
5
5
|
import { PathData } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { UI } from './UI'
|
package/src/Polygon.ts
CHANGED
package/src/Rect.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPathDrawer, IPathCommandData, __Number } from '@leafer/interface'
|
|
2
2
|
import { dataProcessor, registerUI, useModule } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IRect, IRectInputData, IRectData } from '@leafer-ui/interface'
|
|
@@ -19,12 +19,10 @@ export class Rect extends UI implements IRect {
|
|
|
19
19
|
super(data)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
public
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (borderRadius) {
|
|
27
|
-
drawer.roundRect(0, 0, width, height, borderRadius)
|
|
22
|
+
public __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void {
|
|
23
|
+
const { width, height, cornerRadius } = this.__
|
|
24
|
+
if (cornerRadius) {
|
|
25
|
+
drawer.roundRect(0, 0, width, height, cornerRadius)
|
|
28
26
|
} else {
|
|
29
27
|
drawer.rect(0, 0, width, height)
|
|
30
28
|
}
|
package/src/Star.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __Number } from '@leafer/interface'
|
|
1
2
|
import { PathCreator, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
2
3
|
|
|
3
4
|
import { IStar, IStarData, IStarInputData } from '@leafer-ui/interface'
|
|
@@ -17,10 +18,10 @@ export class Star extends UI implements IStar {
|
|
|
17
18
|
public __: IStarData
|
|
18
19
|
|
|
19
20
|
@pathType(5)
|
|
20
|
-
public points:
|
|
21
|
+
public points: __Number
|
|
21
22
|
|
|
22
23
|
@pathType(0.38)
|
|
23
|
-
public innerRadius:
|
|
24
|
+
public innerRadius: __Number
|
|
24
25
|
|
|
25
26
|
constructor(data?: IStarInputData) {
|
|
26
27
|
super(data)
|
package/src/Text.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPathDrawer, IPathCommandData, __Boolean, __Number, __String } from '@leafer/interface'
|
|
2
2
|
import { Platform, boundsType, dataProcessor, registerUI, useModule } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IText, IFontWeight, ITextCase, ITextDecoration, IPercent, ITextData, ITextInputData } from '@leafer-ui/interface'
|
|
@@ -16,19 +16,19 @@ export class Text extends UI implements IText {
|
|
|
16
16
|
public __: ITextData
|
|
17
17
|
|
|
18
18
|
@boundsType('')
|
|
19
|
-
public content:
|
|
19
|
+
public content: __String
|
|
20
20
|
|
|
21
21
|
@boundsType('arial')
|
|
22
|
-
public fontFamily:
|
|
22
|
+
public fontFamily: __String
|
|
23
23
|
|
|
24
24
|
@boundsType(12)
|
|
25
|
-
public fontSize:
|
|
25
|
+
public fontSize: __Number
|
|
26
26
|
|
|
27
27
|
@boundsType('normal')
|
|
28
28
|
public fontWeight: IFontWeight
|
|
29
29
|
|
|
30
30
|
@boundsType(false)
|
|
31
|
-
public italic:
|
|
31
|
+
public italic: __Boolean
|
|
32
32
|
|
|
33
33
|
@boundsType('normal')
|
|
34
34
|
public textCase: ITextCase
|
|
@@ -37,26 +37,22 @@ export class Text extends UI implements IText {
|
|
|
37
37
|
public textDecoration: ITextDecoration
|
|
38
38
|
|
|
39
39
|
@boundsType()
|
|
40
|
-
public letterSpacing:
|
|
40
|
+
public letterSpacing: __Number | IPercent
|
|
41
41
|
|
|
42
42
|
@boundsType()
|
|
43
|
-
public lineHeight:
|
|
43
|
+
public lineHeight: __Number | IPercent
|
|
44
44
|
|
|
45
45
|
@boundsType()
|
|
46
|
-
public paragraphIndent:
|
|
46
|
+
public paragraphIndent: __Number
|
|
47
47
|
|
|
48
48
|
@boundsType()
|
|
49
|
-
public paragraphSpacing:
|
|
49
|
+
public paragraphSpacing: __Number
|
|
50
50
|
|
|
51
51
|
constructor(data?: ITextInputData) {
|
|
52
52
|
super(data)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
public
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public __drawPathByData(drawer: ICanvasDrawPath, _data: IPathCommandData): void {
|
|
55
|
+
public __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void {
|
|
60
56
|
const { width, height } = this.__
|
|
61
57
|
drawer.rect(0, 0, width, height)
|
|
62
58
|
}
|
package/src/UI.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ILeaferCanvas,
|
|
1
|
+
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IMatrixData, IBoundsData, __Number, __Boolean, __String } from '@leafer/interface'
|
|
2
2
|
import { Leaf, PathHelper, affectEventBoundsType, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, dataProcessor, useModule, rewrite, rewriteAble } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup,
|
|
4
|
+
import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString } from '@leafer-ui/interface'
|
|
5
5
|
import { effectType } from '@leafer-ui/decorator'
|
|
6
6
|
|
|
7
7
|
import { UIData } from '@leafer-ui/data'
|
|
@@ -100,15 +100,6 @@ export class UI extends Leaf implements IUI {
|
|
|
100
100
|
@surfaceType()
|
|
101
101
|
public fill: IPaint | IPaint[] | IPaintString
|
|
102
102
|
|
|
103
|
-
// border
|
|
104
|
-
|
|
105
|
-
@pathType()
|
|
106
|
-
public borderRadius: __Number | __Number[] | IBorderRadiusString
|
|
107
|
-
|
|
108
|
-
@affectEventBoundsType(1)
|
|
109
|
-
public borderWidth: __Number | __Number[] | IBorderWidthString
|
|
110
|
-
|
|
111
|
-
|
|
112
103
|
// stroke
|
|
113
104
|
|
|
114
105
|
@affectEventBoundsType()
|
|
@@ -118,7 +109,7 @@ export class UI extends Leaf implements IUI {
|
|
|
118
109
|
public strokeAlign: IStrokeAlign
|
|
119
110
|
|
|
120
111
|
@affectEventBoundsType(1)
|
|
121
|
-
public strokeWidth:
|
|
112
|
+
public strokeWidth: number | number[] | IStrokeWidthString
|
|
122
113
|
|
|
123
114
|
@surfaceType('none')
|
|
124
115
|
public strokeCap: IStrokeCap
|
|
@@ -139,7 +130,7 @@ export class UI extends Leaf implements IUI {
|
|
|
139
130
|
// corner
|
|
140
131
|
|
|
141
132
|
@pathType()
|
|
142
|
-
public cornerRadius:
|
|
133
|
+
public cornerRadius: number | number[] | ICornerRadiusString
|
|
143
134
|
|
|
144
135
|
@pathType()
|
|
145
136
|
public cornerSmoothing: __Number
|
|
@@ -176,14 +167,15 @@ export class UI extends Leaf implements IUI {
|
|
|
176
167
|
|
|
177
168
|
|
|
178
169
|
public __updateRenderPath(): void {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
if (this.__.path) {
|
|
171
|
+
const { __: data } = this
|
|
172
|
+
data.__pathForRender = data.cornerRadius ? PathHelper.smoothCorner(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
|
|
173
|
+
}
|
|
182
174
|
}
|
|
183
175
|
|
|
184
176
|
public __drawRenderPath(canvas: ILeaferCanvas): void {
|
|
185
177
|
canvas.beginPath()
|
|
186
|
-
this.__drawPathByData(canvas, this.__.
|
|
178
|
+
this.__drawPathByData(canvas, this.__.__pathForRender)
|
|
187
179
|
}
|
|
188
180
|
|
|
189
181
|
public __drawPath(canvas: ILeaferCanvas): void {
|
|
@@ -192,6 +184,6 @@ export class UI extends Leaf implements IUI {
|
|
|
192
184
|
}
|
|
193
185
|
|
|
194
186
|
@rewrite(PathHelper.drawData)
|
|
195
|
-
public __drawPathByData(_drawer:
|
|
187
|
+
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
196
188
|
|
|
197
189
|
}
|