@leafer-ui/display 1.0.0-rc.12 → 1.0.0-rc.17
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 +11 -8
- package/src/Canvas.ts +4 -4
- package/src/Frame.ts +2 -1
- package/src/Group.ts +8 -2
- package/src/Leafer.ts +5 -4
- package/src/Line.ts +5 -2
- package/src/Path.ts +3 -15
- package/src/Pen.ts +17 -5
- package/src/Polygon.ts +1 -0
- package/src/Rect.ts +1 -5
- package/src/Text.ts +1 -1
- package/src/UI.ts +37 -12
- package/types/index.d.ts +17 -11
- package/src/Arrow.ts +0 -27
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.17",
|
|
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.17",
|
|
26
|
+
"@leafer-ui/data": "1.0.0-rc.17",
|
|
27
|
+
"@leafer-ui/display-module": "1.0.0-rc.17",
|
|
28
|
+
"@leafer-ui/decorator": "1.0.0-rc.17",
|
|
29
|
+
"@leafer-ui/external": "1.0.0-rc.17"
|
|
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.17",
|
|
33
|
+
"@leafer-ui/interface": "1.0.0-rc.17"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/Box.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions,
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions, IBoundsData } from '@leafer/interface'
|
|
2
2
|
import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IBox, IBoxData, IBoxInputData, IOverflow } from '@leafer-ui/interface'
|
|
@@ -18,6 +18,8 @@ export class Box extends Group implements IBox {
|
|
|
18
18
|
|
|
19
19
|
public get __tag() { return 'Box' }
|
|
20
20
|
|
|
21
|
+
public get isBranchLeaf(): boolean { return true }
|
|
22
|
+
|
|
21
23
|
@dataProcessor(BoxData)
|
|
22
24
|
declare public __: IBoxData
|
|
23
25
|
|
|
@@ -26,7 +28,6 @@ export class Box extends Group implements IBox {
|
|
|
26
28
|
|
|
27
29
|
constructor(data?: IBoxInputData) {
|
|
28
30
|
super(data)
|
|
29
|
-
this.isBranchLeaf = true
|
|
30
31
|
this.__layout.renderChanged || this.__layout.renderChange()
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -48,8 +49,15 @@ export class Box extends Group implements IBox {
|
|
|
48
49
|
public __updateRectBoxBounds(): void { }
|
|
49
50
|
|
|
50
51
|
public __updateBoxBounds(): void {
|
|
51
|
-
|
|
52
|
+
const data = this.__
|
|
53
|
+
if (data.__autoSide && this.children.length) {
|
|
54
|
+
if (this.leafer) this.leafer.layouter.addExtra(this)
|
|
52
55
|
super.__updateBoxBounds()
|
|
56
|
+
if (!data.__autoSize) {
|
|
57
|
+
const b = this.__layout.boxBounds
|
|
58
|
+
if (!data.__autoWidth) b.x = 0, b.width = data.width
|
|
59
|
+
if (!data.__autoHeight) b.y = 0, b.height = data.height
|
|
60
|
+
}
|
|
53
61
|
} else {
|
|
54
62
|
this.__updateRectBoxBounds()
|
|
55
63
|
}
|
|
@@ -68,7 +76,6 @@ export class Box extends Group implements IBox {
|
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
|
|
72
79
|
@rewrite(rect.__updateRenderBounds)
|
|
73
80
|
public __updateRectRenderBounds(): void { }
|
|
74
81
|
|
|
@@ -81,10 +88,6 @@ export class Box extends Group implements IBox {
|
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
|
|
84
|
-
@rewrite(rect.__drawPathByData)
|
|
85
|
-
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
86
|
-
|
|
87
|
-
|
|
88
91
|
@rewrite(rect.__render)
|
|
89
92
|
public __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
|
|
90
93
|
|
package/src/Canvas.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData
|
|
|
2
2
|
import { Creator, Matrix, Platform, dataProcessor, registerUI, hitType } 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,7 +13,7 @@ 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)
|
|
@@ -23,7 +23,7 @@ export class Canvas extends Rect implements ICanvas {
|
|
|
23
23
|
declare public height: INumber
|
|
24
24
|
|
|
25
25
|
@resizeType(Platform.devicePixelRatio)
|
|
26
|
-
public pixelRatio: INumber
|
|
26
|
+
declare public pixelRatio: INumber
|
|
27
27
|
|
|
28
28
|
@resizeType(true)
|
|
29
29
|
public smooth: boolean
|
package/src/Frame.ts
CHANGED
|
@@ -11,6 +11,8 @@ 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
|
|
|
@@ -22,6 +24,5 @@ export class Frame extends Box implements IFrame {
|
|
|
22
24
|
|
|
23
25
|
constructor(data?: IFrameInputData) {
|
|
24
26
|
super(data)
|
|
25
|
-
this.isFrame = true
|
|
26
27
|
}
|
|
27
28
|
}
|
package/src/Group.ts
CHANGED
|
@@ -13,6 +13,8 @@ export class Group extends UI implements IGroup {
|
|
|
13
13
|
|
|
14
14
|
public get __tag() { return 'Group' }
|
|
15
15
|
|
|
16
|
+
public get isBranch(): boolean { return true }
|
|
17
|
+
|
|
16
18
|
@dataProcessor(GroupData)
|
|
17
19
|
declare public __: IGroupData
|
|
18
20
|
|
|
@@ -20,14 +22,18 @@ export class Group extends UI implements IGroup {
|
|
|
20
22
|
|
|
21
23
|
constructor(data?: IGroupInputData) {
|
|
22
24
|
super(data)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public reset(data?: IGroupInputData): void {
|
|
23
28
|
this.__setBranch()
|
|
29
|
+
super.reset(data)
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
public __setBranch(): void {
|
|
27
|
-
this.isBranch = true
|
|
28
33
|
if (!this.children) this.children = []
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
|
|
31
37
|
// data
|
|
32
38
|
|
|
33
39
|
public set(data: IUIInputData): void {
|
|
@@ -38,7 +44,7 @@ export class Group extends UI implements IGroup {
|
|
|
38
44
|
if (!this.children) {
|
|
39
45
|
this.__setBranch()
|
|
40
46
|
} else {
|
|
41
|
-
this.
|
|
47
|
+
this.clear()
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
super.set(data)
|
package/src/Leafer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, ILeaf, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData } from '@leafer/interface'
|
|
1
|
+
import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, ILeaf, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber } from '@leafer/interface'
|
|
2
2
|
import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IGroup, IApp, IEditorBase } from '@leafer-ui/interface'
|
|
@@ -17,11 +17,13 @@ export class Leafer extends Group implements ILeafer {
|
|
|
17
17
|
declare public __: ILeaferData
|
|
18
18
|
|
|
19
19
|
@boundsType()
|
|
20
|
-
public pixelRatio:
|
|
20
|
+
declare public pixelRatio: INumber
|
|
21
21
|
|
|
22
22
|
public get isApp(): boolean { return false }
|
|
23
23
|
public get app(): ILeafer { return this.parent || this }
|
|
24
24
|
|
|
25
|
+
public get isLeafer(): boolean { return true }
|
|
26
|
+
|
|
25
27
|
declare public parent?: IApp
|
|
26
28
|
|
|
27
29
|
public running: boolean
|
|
@@ -197,7 +199,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
public forceRender(bounds?: IBoundsData): void {
|
|
200
|
-
this.renderer.addBlock(new Bounds(bounds)
|
|
202
|
+
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds)
|
|
201
203
|
if (this.viewReady) this.renderer.update()
|
|
202
204
|
}
|
|
203
205
|
|
|
@@ -231,7 +233,6 @@ export class Leafer extends Group implements ILeafer {
|
|
|
231
233
|
|
|
232
234
|
public __setLeafer(leafer: ILeafer): void {
|
|
233
235
|
this.leafer = leafer
|
|
234
|
-
this.isLeafer = !!leafer
|
|
235
236
|
this.__level = 1
|
|
236
237
|
}
|
|
237
238
|
|
package/src/Line.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ILine, ILineData, ILineInputData, IStrokeAlign } from '@leafer-ui/inter
|
|
|
5
5
|
import { LineData } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { UI } from './UI'
|
|
8
|
+
import { PathArrow } from '@leafer-ui/external'
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
const { moveTo, lineTo, drawPoints } = PathCommandDataHelper
|
|
@@ -70,8 +71,10 @@ export class Line extends UI implements ILine {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
public __updateRenderPath(): void {
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
const data = this.__
|
|
75
|
+
if (!this.pathInputed && data.points && data.curve) {
|
|
76
|
+
drawPoints(data.__pathForRender = [], data.points, data.curve, this.pathClosed)
|
|
77
|
+
if (data.__useArrow) PathArrow.addArrows(this, false)
|
|
75
78
|
} else {
|
|
76
79
|
super.__updateRenderPath()
|
|
77
80
|
}
|
package/src/Path.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PathBounds, dataProcessor, pathType, affectStrokeBoundsType, registerUI } from '@leafer/core'
|
|
1
|
+
import { dataProcessor, affectStrokeBoundsType, registerUI } from '@leafer/core'
|
|
3
2
|
|
|
4
|
-
import { IPath, IPathData, IPathInputData,
|
|
3
|
+
import { IPath, IPathData, IPathInputData, IStrokeAlign } from '@leafer-ui/interface'
|
|
5
4
|
import { PathData } from '@leafer-ui/data'
|
|
6
5
|
|
|
7
6
|
import { UI } from './UI'
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
const { toBounds } = PathBounds
|
|
11
|
-
|
|
12
9
|
@registerUI()
|
|
13
10
|
export class Path extends UI implements IPath {
|
|
14
11
|
|
|
@@ -17,21 +14,12 @@ export class Path extends UI implements IPath {
|
|
|
17
14
|
@dataProcessor(PathData)
|
|
18
15
|
declare public __: IPathData
|
|
19
16
|
|
|
20
|
-
@pathType()
|
|
21
|
-
public path: IPathCommandData | IPathString
|
|
22
|
-
|
|
23
|
-
@pathType()
|
|
24
|
-
public windingRule: IWindingRule
|
|
25
|
-
|
|
26
17
|
@affectStrokeBoundsType('center')
|
|
27
18
|
declare public strokeAlign: IStrokeAlign
|
|
28
19
|
|
|
29
20
|
constructor(data?: IPathInputData) {
|
|
30
21
|
super(data)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
public __updateBoxBounds(): void {
|
|
34
|
-
toBounds(this.__.path, this.__layout.boxBounds)
|
|
22
|
+
this.__.__pathInputed = 2
|
|
35
23
|
}
|
|
36
24
|
|
|
37
25
|
}
|
package/src/Pen.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PathCreator, dataProcessor, registerUI, useModule } from '@leafer/core'
|
|
1
|
+
import { PathCreator, dataProcessor, defineKey, registerUI, useModule } from '@leafer/core'
|
|
2
2
|
|
|
3
3
|
import { IPenData, IPenInputData, IPathInputData, IPathCommandData, IPath, IPen } from '@leafer-ui/interface'
|
|
4
4
|
import { PenData } from '@leafer-ui/data'
|
|
@@ -7,7 +7,7 @@ import { Group } from './Group'
|
|
|
7
7
|
import { Path } from './Path'
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@useModule(PathCreator, ['beginPath'])
|
|
10
|
+
@useModule(PathCreator, ['beginPath', 'path'])
|
|
11
11
|
@registerUI()
|
|
12
12
|
export class Pen extends Group implements IPen {
|
|
13
13
|
|
|
@@ -18,7 +18,11 @@ export class Pen extends Group implements IPen {
|
|
|
18
18
|
|
|
19
19
|
public pathElement: IPath
|
|
20
20
|
public pathStyle: IPathInputData
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
@penPathType()
|
|
23
|
+
declare public path: IPathCommandData // use __path, readonly
|
|
24
|
+
|
|
25
|
+
public __path: IPathCommandData
|
|
22
26
|
|
|
23
27
|
constructor(data?: IPenInputData) {
|
|
24
28
|
super(data)
|
|
@@ -27,13 +31,13 @@ export class Pen extends Group implements IPen {
|
|
|
27
31
|
public setStyle(data: IPathInputData): Pen {
|
|
28
32
|
const path = this.pathElement = new Path(data)
|
|
29
33
|
this.pathStyle = data
|
|
30
|
-
this.
|
|
34
|
+
this.__path = path.path as IPathCommandData || (path.path = [])
|
|
31
35
|
this.add(path)
|
|
32
36
|
return this
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
public beginPath(): Pen {
|
|
36
|
-
this.
|
|
40
|
+
this.__path.length = 0
|
|
37
41
|
this.paint()
|
|
38
42
|
return this
|
|
39
43
|
}
|
|
@@ -77,4 +81,12 @@ export class Pen extends Group implements IPen {
|
|
|
77
81
|
this.pathElement.forceUpdate('path')
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function penPathType() {
|
|
87
|
+
return (target: IPen, key: string) => {
|
|
88
|
+
defineKey(target, key, {
|
|
89
|
+
get() { return this.__path }
|
|
90
|
+
})
|
|
91
|
+
}
|
|
80
92
|
}
|
package/src/Polygon.ts
CHANGED
package/src/Rect.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dataProcessor, registerUI, rewrite, rewriteAble, useModule } from '@leafer/core'
|
|
1
|
+
import { dataProcessor, registerUI, rewriteAble, useModule } from '@leafer/core'
|
|
3
2
|
|
|
4
3
|
import { IRect, IRectInputData, IRectData } from '@leafer-ui/interface'
|
|
5
4
|
import { RectData } from '@leafer-ui/data'
|
|
@@ -22,7 +21,4 @@ export class Rect extends UI implements IRect {
|
|
|
22
21
|
super(data)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
@rewrite(UI.prototype.__drawPathByBox)
|
|
26
|
-
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
27
|
-
|
|
28
24
|
}
|
package/src/Text.ts
CHANGED
|
@@ -135,7 +135,7 @@ export class Text extends UI implements IText {
|
|
|
135
135
|
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined
|
|
136
136
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2
|
|
137
137
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
|
|
138
|
-
data.__clipText = textOverflow !== 'show' && !data.
|
|
138
|
+
data.__clipText = textOverflow !== 'show' && !data.__autoSize
|
|
139
139
|
|
|
140
140
|
this.__updateTextDrawData()
|
|
141
141
|
|
package/src/UI.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IAround } from '@leafer/interface'
|
|
2
|
-
import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, PathCreator } from '@leafer/core'
|
|
1
|
+
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IAround, IValue, IWindingRule } from '@leafer/interface'
|
|
2
|
+
import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, PathCreator, naturalBoundsType, pathInputType } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, IEditSize, ILeafer } from '@leafer-ui/interface'
|
|
5
|
-
import { effectType } from '@leafer-ui/decorator'
|
|
5
|
+
import { arrowType, effectType } from '@leafer-ui/decorator'
|
|
6
6
|
|
|
7
7
|
import { UIData } from '@leafer-ui/data'
|
|
8
8
|
import { UIBounds, UIRender } from '@leafer-ui/display-module'
|
|
9
9
|
|
|
10
|
-
import { Export } from '@leafer-ui/external'
|
|
10
|
+
import { Export, PathArrow } from '@leafer-ui/external'
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
@useModule(UIBounds)
|
|
@@ -26,7 +26,7 @@ export class UI extends Leaf implements IUI {
|
|
|
26
26
|
declare public leafer?: ILeafer
|
|
27
27
|
declare public parent?: IGroup
|
|
28
28
|
|
|
29
|
-
public isFrame
|
|
29
|
+
public get isFrame(): boolean { return false }
|
|
30
30
|
|
|
31
31
|
declare public children?: IUI[]
|
|
32
32
|
|
|
@@ -180,17 +180,29 @@ export class UI extends Leaf implements IUI {
|
|
|
180
180
|
@strokeType(10)
|
|
181
181
|
public miterLimit: INumber
|
|
182
182
|
|
|
183
|
-
//
|
|
183
|
+
// image
|
|
184
184
|
|
|
185
185
|
@dataType(false)
|
|
186
186
|
public lazy: IBoolean // load image / compute paint
|
|
187
187
|
|
|
188
|
+
@naturalBoundsType(1)
|
|
189
|
+
public pixelRatio: INumber
|
|
190
|
+
|
|
191
|
+
// path
|
|
192
|
+
|
|
193
|
+
@pathInputType()
|
|
194
|
+
public path: IPathCommandData | IPathString
|
|
195
|
+
|
|
196
|
+
@pathType()
|
|
197
|
+
public windingRule: IWindingRule
|
|
198
|
+
|
|
199
|
+
|
|
188
200
|
// arrow
|
|
189
201
|
|
|
190
|
-
@
|
|
202
|
+
@arrowType('none')
|
|
191
203
|
public startArrow: IArrowType
|
|
192
204
|
|
|
193
|
-
@
|
|
205
|
+
@arrowType('none')
|
|
194
206
|
public endArrow: IArrowType
|
|
195
207
|
|
|
196
208
|
// corner
|
|
@@ -249,8 +261,8 @@ export class UI extends Leaf implements IUI {
|
|
|
249
261
|
Object.assign(this, data)
|
|
250
262
|
}
|
|
251
263
|
|
|
252
|
-
public get(): IUIInputData {
|
|
253
|
-
return this.__.__getInputData()
|
|
264
|
+
public get(name?: string): IUIInputData | IValue {
|
|
265
|
+
return name ? this.__.__getInput(name) : this.__.__getInputData()
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
public createProxyData(): IUIInputData { return undefined }
|
|
@@ -294,6 +306,7 @@ export class UI extends Leaf implements IUI {
|
|
|
294
306
|
if (this.__.path) {
|
|
295
307
|
const data = this.__
|
|
296
308
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
|
|
309
|
+
if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius)
|
|
297
310
|
}
|
|
298
311
|
}
|
|
299
312
|
|
|
@@ -307,8 +320,13 @@ export class UI extends Leaf implements IUI {
|
|
|
307
320
|
this.__drawPathByData(canvas, this.__.path)
|
|
308
321
|
}
|
|
309
322
|
|
|
310
|
-
|
|
311
|
-
|
|
323
|
+
public __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void {
|
|
324
|
+
if (data) {
|
|
325
|
+
PathDrawer.drawPathByData(drawer, data)
|
|
326
|
+
} else {
|
|
327
|
+
this.__drawPathByBox(drawer)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
312
330
|
|
|
313
331
|
public __drawPathByBox(drawer: IPathDrawer): void {
|
|
314
332
|
const { x, y, width, height } = this.__layout.boxBounds
|
|
@@ -334,6 +352,13 @@ export class UI extends Leaf implements IUI {
|
|
|
334
352
|
return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
|
|
335
353
|
}
|
|
336
354
|
|
|
355
|
+
static registerUI(): void {
|
|
356
|
+
registerUI()(this)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
static registerData(data: IUIData): void {
|
|
360
|
+
dataProcessor(data)(this.prototype)
|
|
361
|
+
}
|
|
337
362
|
|
|
338
363
|
public destroy(): void {
|
|
339
364
|
this.fill = this.stroke = null
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IString, INumber, IBoolean, IMaskType, IAround, IHitType, ICursorType,
|
|
1
|
+
import { IString, INumber, IBoolean, IMaskType, IAround, IHitType, ICursorType, IPathCommandData, IPathString, IWindingRule, IPointData, IValue, ILeaferCanvas, IPathDrawer, IExportFileType, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IBoundsData, IResizeEvent, ILeaf, IRenderOptions, ILeaferImage, ICanvasContext2D } from '@leafer/interface';
|
|
2
2
|
import { Leaf } from '@leafer/core';
|
|
3
|
-
import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IEditSize, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IFindUIMethod, IExportOptions, IExportResult, IGroupData, IGroupInputData, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData,
|
|
3
|
+
import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IEditSize, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IFindUIMethod, IExportOptions, IExportResult, IGroupData, IGroupInputData, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
|
|
4
4
|
|
|
5
5
|
declare class UI extends Leaf implements IUI {
|
|
6
6
|
__: IUIData;
|
|
@@ -9,7 +9,7 @@ declare class UI extends Leaf implements IUI {
|
|
|
9
9
|
get app(): ILeafer;
|
|
10
10
|
leafer?: ILeafer;
|
|
11
11
|
parent?: IGroup;
|
|
12
|
-
isFrame
|
|
12
|
+
get isFrame(): boolean;
|
|
13
13
|
children?: IUI[];
|
|
14
14
|
id: IString;
|
|
15
15
|
name: IString;
|
|
@@ -54,6 +54,9 @@ declare class UI extends Leaf implements IUI {
|
|
|
54
54
|
dashOffset: INumber;
|
|
55
55
|
miterLimit: INumber;
|
|
56
56
|
lazy: IBoolean;
|
|
57
|
+
pixelRatio: INumber;
|
|
58
|
+
path: IPathCommandData | IPathString;
|
|
59
|
+
windingRule: IWindingRule;
|
|
57
60
|
startArrow: IArrowType;
|
|
58
61
|
endArrow: IArrowType;
|
|
59
62
|
cornerRadius: number | number[] | ICornerRadiusString;
|
|
@@ -68,7 +71,7 @@ declare class UI extends Leaf implements IUI {
|
|
|
68
71
|
constructor(data?: IUIInputData);
|
|
69
72
|
reset(_data?: IUIInputData): void;
|
|
70
73
|
set(data: IUIInputData): void;
|
|
71
|
-
get(): IUIInputData;
|
|
74
|
+
get(name?: string): IUIInputData | IValue;
|
|
72
75
|
createProxyData(): IUIInputData;
|
|
73
76
|
find(_condition: number | string | IFindUIMethod, _options?: any): IUI[];
|
|
74
77
|
findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI;
|
|
@@ -78,19 +81,23 @@ declare class UI extends Leaf implements IUI {
|
|
|
78
81
|
__updateRenderPath(): void;
|
|
79
82
|
__drawRenderPath(canvas: ILeaferCanvas): void;
|
|
80
83
|
__drawPath(canvas: ILeaferCanvas): void;
|
|
81
|
-
__drawPathByData(
|
|
84
|
+
__drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
|
|
82
85
|
__drawPathByBox(drawer: IPathDrawer): void;
|
|
83
86
|
export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
|
|
84
87
|
clone(): IUI;
|
|
85
88
|
static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
|
|
89
|
+
static registerUI(): void;
|
|
90
|
+
static registerData(data: IUIData): void;
|
|
86
91
|
destroy(): void;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
declare class Group extends UI implements IGroup {
|
|
90
95
|
get __tag(): string;
|
|
96
|
+
get isBranch(): boolean;
|
|
91
97
|
__: IGroupData;
|
|
92
98
|
children: IUI[];
|
|
93
99
|
constructor(data?: IGroupInputData);
|
|
100
|
+
reset(data?: IGroupInputData): void;
|
|
94
101
|
__setBranch(): void;
|
|
95
102
|
set(data: IUIInputData): void;
|
|
96
103
|
toJSON(): IUIInputData;
|
|
@@ -108,9 +115,10 @@ declare class Group extends UI implements IGroup {
|
|
|
108
115
|
declare class Leafer extends Group implements ILeafer {
|
|
109
116
|
get __tag(): string;
|
|
110
117
|
__: ILeaferData;
|
|
111
|
-
pixelRatio:
|
|
118
|
+
pixelRatio: INumber;
|
|
112
119
|
get isApp(): boolean;
|
|
113
120
|
get app(): ILeafer;
|
|
121
|
+
get isLeafer(): boolean;
|
|
114
122
|
parent?: IApp;
|
|
115
123
|
running: boolean;
|
|
116
124
|
created: boolean;
|
|
@@ -186,6 +194,7 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
186
194
|
|
|
187
195
|
declare class Box extends Group implements IBox {
|
|
188
196
|
get __tag(): string;
|
|
197
|
+
get isBranchLeaf(): boolean;
|
|
189
198
|
__: IBoxData;
|
|
190
199
|
overflow: IOverflow;
|
|
191
200
|
constructor(data?: IBoxInputData);
|
|
@@ -199,7 +208,6 @@ declare class Box extends Group implements IBox {
|
|
|
199
208
|
__updateRectRenderBounds(): void;
|
|
200
209
|
__updateRectChange(): void;
|
|
201
210
|
__updateChange(): void;
|
|
202
|
-
__drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void;
|
|
203
211
|
__renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
204
212
|
__renderGroup(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
205
213
|
__render(canvas: ILeaferCanvas, options: IRenderOptions): void;
|
|
@@ -208,6 +216,7 @@ declare class Box extends Group implements IBox {
|
|
|
208
216
|
|
|
209
217
|
declare class Frame extends Box implements IFrame {
|
|
210
218
|
get __tag(): string;
|
|
219
|
+
get isFrame(): boolean;
|
|
211
220
|
__: IFrameData;
|
|
212
221
|
fill: IFill;
|
|
213
222
|
overflow: IOverflow;
|
|
@@ -218,7 +227,6 @@ declare class Rect extends UI implements IRect {
|
|
|
218
227
|
get __tag(): string;
|
|
219
228
|
__: IRectData;
|
|
220
229
|
constructor(data?: IRectInputData);
|
|
221
|
-
__drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void;
|
|
222
230
|
}
|
|
223
231
|
|
|
224
232
|
declare class Ellipse extends UI implements IEllipse {
|
|
@@ -333,11 +341,8 @@ declare class Text extends UI implements IText {
|
|
|
333
341
|
declare class Path extends UI implements IPath {
|
|
334
342
|
get __tag(): string;
|
|
335
343
|
__: IPathData;
|
|
336
|
-
path: IPathCommandData | IPathString$1;
|
|
337
|
-
windingRule: IWindingRule;
|
|
338
344
|
strokeAlign: IStrokeAlign;
|
|
339
345
|
constructor(data?: IPathInputData);
|
|
340
|
-
__updateBoxBounds(): void;
|
|
341
346
|
}
|
|
342
347
|
|
|
343
348
|
declare class Pen extends Group implements IPen {
|
|
@@ -346,6 +351,7 @@ declare class Pen extends Group implements IPen {
|
|
|
346
351
|
pathElement: IPath;
|
|
347
352
|
pathStyle: IPathInputData;
|
|
348
353
|
path: IPathCommandData$1;
|
|
354
|
+
__path: IPathCommandData$1;
|
|
349
355
|
constructor(data?: IPenInputData);
|
|
350
356
|
setStyle(data: IPathInputData): Pen;
|
|
351
357
|
beginPath(): Pen;
|
package/src/Arrow.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { registerUI, strokeType, dataProcessor } from '@leafer/core'
|
|
2
|
-
|
|
3
|
-
import { IArrow, IArrowData, IArrowInputData, IArrowType } from '@leafer-ui/interface'
|
|
4
|
-
import { ArrowData } from '@leafer-ui/data'
|
|
5
|
-
|
|
6
|
-
import { Line } from './Line'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@registerUI()
|
|
10
|
-
export class Arrow extends Line implements IArrow {
|
|
11
|
-
|
|
12
|
-
public get __tag() { return 'Arrow' }
|
|
13
|
-
|
|
14
|
-
@dataProcessor(ArrowData)
|
|
15
|
-
declare public __: IArrowData
|
|
16
|
-
|
|
17
|
-
@strokeType('none')
|
|
18
|
-
declare public startArrow: IArrowType
|
|
19
|
-
|
|
20
|
-
@strokeType('lines')
|
|
21
|
-
declare public endArrow: IArrowType
|
|
22
|
-
|
|
23
|
-
constructor(data?: IArrowInputData) {
|
|
24
|
-
super(data)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|