@leafer-ui/display 1.0.0-rc.22 → 1.0.0-rc.24
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 +48 -23
- package/src/Leafer.ts +9 -7
- package/src/Line.ts +4 -3
- package/src/Text.ts +5 -8
- package/src/UI.ts +103 -45
- package/types/index.d.ts +37 -18
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.24",
|
|
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.24",
|
|
26
|
+
"@leafer-ui/data": "1.0.0-rc.24",
|
|
27
|
+
"@leafer-ui/display-module": "1.0.0-rc.24",
|
|
28
|
+
"@leafer-ui/decorator": "1.0.0-rc.24",
|
|
29
|
+
"@leafer-ui/external": "1.0.0-rc.24"
|
|
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.24",
|
|
33
|
+
"@leafer-ui/interface": "1.0.0-rc.24"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/Box.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { Rect } from './Rect'
|
|
|
9
9
|
|
|
10
10
|
const rect = Rect.prototype
|
|
11
11
|
const group = Group.prototype
|
|
12
|
-
const
|
|
13
|
-
const { copy, add } = BoundsHelper
|
|
12
|
+
const childrenRenderBounds = {} as IBoundsData
|
|
13
|
+
const { copy, add, includes } = BoundsHelper
|
|
14
14
|
|
|
15
15
|
@rewriteAble()
|
|
16
16
|
@registerUI()
|
|
@@ -26,6 +26,8 @@ export class Box extends Group implements IBox {
|
|
|
26
26
|
@affectRenderBoundsType('show')
|
|
27
27
|
declare public overflow: IOverflow
|
|
28
28
|
|
|
29
|
+
public isOverflow: boolean
|
|
30
|
+
|
|
29
31
|
constructor(data?: IBoxInputData) {
|
|
30
32
|
super(data)
|
|
31
33
|
this.__layout.renderChanged || this.__layout.renderChange()
|
|
@@ -38,9 +40,7 @@ export class Box extends Group implements IBox {
|
|
|
38
40
|
public __updateRectRenderSpread(): number { return 0 }
|
|
39
41
|
|
|
40
42
|
public __updateRenderSpread(): number {
|
|
41
|
-
|
|
42
|
-
const hide = this.__.__drawAfterFill = this.__.overflow === 'hide'
|
|
43
|
-
return (width || hide) ? width : -1
|
|
43
|
+
return this.__updateRectRenderSpread() || -1
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
@@ -49,14 +49,22 @@ export class Box extends Group implements IBox {
|
|
|
49
49
|
|
|
50
50
|
public __updateBoxBounds(): void {
|
|
51
51
|
const data = this.__
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!data.
|
|
58
|
-
|
|
52
|
+
|
|
53
|
+
if (this.children.length) {
|
|
54
|
+
if (data.__autoSide) {
|
|
55
|
+
if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this)
|
|
56
|
+
super.__updateBoxBounds()
|
|
57
|
+
if (!data.__autoSize) {
|
|
58
|
+
const b = this.__layout.boxBounds
|
|
59
|
+
if (!data.__autoWidth) b.x = 0, b.width = data.width
|
|
60
|
+
if (!data.__autoHeight) b.y = 0, b.height = data.height
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
this.__updateRectBoxBounds()
|
|
59
64
|
}
|
|
65
|
+
|
|
66
|
+
if (data.flow) this.__updateContentBounds()
|
|
67
|
+
|
|
60
68
|
} else {
|
|
61
69
|
this.__updateRectBoxBounds()
|
|
62
70
|
}
|
|
@@ -66,13 +74,21 @@ export class Box extends Group implements IBox {
|
|
|
66
74
|
public __updateStrokeBounds(): void { }
|
|
67
75
|
|
|
68
76
|
public __updateRenderBounds(): void {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
let isOverflow: boolean
|
|
78
|
+
const { renderBounds } = this.__layout
|
|
79
|
+
|
|
80
|
+
if (this.children.length) {
|
|
73
81
|
super.__updateRenderBounds()
|
|
74
|
-
|
|
82
|
+
copy(childrenRenderBounds, renderBounds)
|
|
83
|
+
this.__updateRectRenderBounds()
|
|
84
|
+
|
|
85
|
+
isOverflow = !includes(renderBounds, childrenRenderBounds) || undefined
|
|
86
|
+
} else {
|
|
87
|
+
this.__updateRectRenderBounds()
|
|
75
88
|
}
|
|
89
|
+
|
|
90
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow)
|
|
91
|
+
if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide')) add(renderBounds, childrenRenderBounds)
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
@rewrite(rect.__updateRenderBounds)
|
|
@@ -99,16 +115,25 @@ export class Box extends Group implements IBox {
|
|
|
99
115
|
this.__renderRect(canvas, options)
|
|
100
116
|
} else {
|
|
101
117
|
this.__renderRect(canvas, options)
|
|
102
|
-
this.__renderGroup(canvas, options)
|
|
118
|
+
if (this.children.length) this.__renderGroup(canvas, options)
|
|
103
119
|
}
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
public __drawAfterFill(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
const { length } = this.children
|
|
124
|
+
if (this.isOverflow) {
|
|
125
|
+
canvas.save()
|
|
126
|
+
canvas.clip()
|
|
127
|
+
if (length) this.__renderGroup(canvas, options)
|
|
128
|
+
canvas.restore()
|
|
129
|
+
} else {
|
|
130
|
+
if (length) this.__renderGroup(canvas, options)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (this.__.stroke && length) {
|
|
134
|
+
canvas.setWorld(this.__nowWorld)
|
|
135
|
+
this.__drawRenderPath(canvas)
|
|
136
|
+
}
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
}
|
package/src/Leafer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IFourNumber, IBounds } from '@leafer/interface'
|
|
1
|
+
import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IFourNumber, IBounds, IClientPointData } from '@leafer/interface'
|
|
2
2
|
import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IApp, IEditorBase } from '@leafer-ui/interface'
|
|
@@ -80,6 +80,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
80
80
|
|
|
81
81
|
public get FPS(): number { return this.renderer ? this.renderer.FPS : 60 }
|
|
82
82
|
public get cursorPoint(): IPointData { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 } }
|
|
83
|
+
public get clientBounds(): IBoundsData { return this.canvas && this.canvas.getClientBounds() }
|
|
83
84
|
public leafs = 0
|
|
84
85
|
|
|
85
86
|
public __eventIds: IEventListenerId[] = []
|
|
@@ -195,10 +196,6 @@ export class Leafer extends Group implements ILeafer {
|
|
|
195
196
|
Object.keys(data).forEach(key => (this as any)[key] = data[key])
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
public forceFullRender(): void {
|
|
199
|
-
this.forceRender()
|
|
200
|
-
}
|
|
201
|
-
|
|
202
199
|
public forceRender(bounds?: IBoundsData): void {
|
|
203
200
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds)
|
|
204
201
|
if (this.viewReady) this.renderer.update()
|
|
@@ -257,7 +254,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
257
254
|
} else if (attrName === 'fill') {
|
|
258
255
|
this.__changeFill(newValue as string)
|
|
259
256
|
} else if (attrName === 'hittable') {
|
|
260
|
-
this.canvas.hittable = newValue as boolean
|
|
257
|
+
if (!this.parent) this.canvas.hittable = newValue as boolean
|
|
261
258
|
}
|
|
262
259
|
}
|
|
263
260
|
return super.__setAttr(attrName, newValue)
|
|
@@ -280,7 +277,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
280
277
|
if (this.canvas.allowBackgroundColor) {
|
|
281
278
|
this.canvas.backgroundColor = newValue as string
|
|
282
279
|
} else {
|
|
283
|
-
this.
|
|
280
|
+
this.forceRender()
|
|
284
281
|
}
|
|
285
282
|
}
|
|
286
283
|
|
|
@@ -375,6 +372,11 @@ export class Leafer extends Group implements ILeafer {
|
|
|
375
372
|
public getValidMove(moveX: number, moveY: number): IPointData { return { x: moveX, y: moveY } }
|
|
376
373
|
public getValidScale(changeScale: number): number { return changeScale }
|
|
377
374
|
|
|
375
|
+
|
|
376
|
+
public getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData {
|
|
377
|
+
return this.interaction && this.interaction.getLocal(clientPoint, updateClient)
|
|
378
|
+
}
|
|
379
|
+
|
|
378
380
|
protected __checkUpdateLayout(): void {
|
|
379
381
|
this.__layout.update()
|
|
380
382
|
}
|
package/src/Line.ts
CHANGED
|
@@ -59,11 +59,12 @@ export class Line extends UI implements ILine { // tip: rewrited Polygon
|
|
|
59
59
|
|
|
60
60
|
public __updatePath(): void {
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const data = this.__
|
|
63
|
+
const path: number[] = data.path = []
|
|
63
64
|
|
|
64
|
-
if (
|
|
65
|
+
if (data.points) {
|
|
65
66
|
|
|
66
|
-
drawPoints(path,
|
|
67
|
+
drawPoints(path, data.points, false, data.closed)
|
|
67
68
|
|
|
68
69
|
} else {
|
|
69
70
|
|
package/src/Text.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData,
|
|
1
|
+
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData, IUnitData } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, hitType, MathHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow,
|
|
4
|
+
import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IStrokeAlign, IHitType, ITextWrap } from '@leafer-ui/interface'
|
|
5
5
|
import { TextData, UnitConvert } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { TextConvert } from '@leafer-ui/external'
|
|
@@ -9,7 +9,7 @@ import { TextConvert } from '@leafer-ui/external'
|
|
|
9
9
|
import { UI } from './UI'
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const { copyAndSpread, includes, spread, setList } = BoundsHelper
|
|
12
|
+
const { copyAndSpread, includes, isSame, spread, setList } = BoundsHelper
|
|
13
13
|
|
|
14
14
|
@registerUI()
|
|
15
15
|
export class Text extends UI implements IText {
|
|
@@ -26,9 +26,6 @@ export class Text extends UI implements IText {
|
|
|
26
26
|
@boundsType(0)
|
|
27
27
|
declare public height: INumber
|
|
28
28
|
|
|
29
|
-
@boundsType(0)
|
|
30
|
-
public padding: IFourNumber
|
|
31
|
-
|
|
32
29
|
@surfaceType('#000000')
|
|
33
30
|
declare public fill: IFill
|
|
34
31
|
|
|
@@ -62,7 +59,7 @@ export class Text extends UI implements IText {
|
|
|
62
59
|
@boundsType(0)
|
|
63
60
|
public letterSpacing: INumber | IUnitData
|
|
64
61
|
|
|
65
|
-
@boundsType({ type: 'percent', value:
|
|
62
|
+
@boundsType({ type: 'percent', value: 1.5 } as IUnitData)
|
|
66
63
|
public lineHeight: INumber | IUnitData
|
|
67
64
|
|
|
68
65
|
@boundsType(0)
|
|
@@ -172,7 +169,7 @@ export class Text extends UI implements IText {
|
|
|
172
169
|
if (italic) b.width += fontSize * 0.16
|
|
173
170
|
|
|
174
171
|
const contentBounds = includes(b, bounds) ? b : bounds
|
|
175
|
-
if (contentBounds
|
|
172
|
+
if (!isSame(contentBounds, layout.contentBounds)) {
|
|
176
173
|
layout.contentBounds = contentBounds
|
|
177
174
|
layout.renderChanged = true
|
|
178
175
|
setList(data.__textBoxBounds = {} as IBoundsData, [b, bounds])
|
package/src/UI.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType,
|
|
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, pen, naturalBoundsType, pathInputType } from '@leafer/core'
|
|
1
|
+
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData } from '@leafer/interface'
|
|
2
|
+
import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod,
|
|
4
|
+
import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction } from '@leafer-ui/interface'
|
|
5
5
|
import { arrowType, effectType, stateType, zoomLayerType } from '@leafer-ui/decorator'
|
|
6
6
|
|
|
7
7
|
import { UIData } from '@leafer-ui/data'
|
|
@@ -53,8 +53,8 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
53
53
|
@opacityType(1)
|
|
54
54
|
public opacity: INumber
|
|
55
55
|
|
|
56
|
-
@
|
|
57
|
-
public visible: IBoolean
|
|
56
|
+
@visibleType(true)
|
|
57
|
+
public visible: IBoolean | 0
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
@stateType(false)
|
|
@@ -72,13 +72,10 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
@maskType(false)
|
|
75
|
-
public mask: IBoolean
|
|
76
|
-
|
|
77
|
-
@surfaceType('pixel')
|
|
78
|
-
public maskType: IMaskType
|
|
75
|
+
public mask: IBoolean | IMaskType
|
|
79
76
|
|
|
80
77
|
@eraserType(false)
|
|
81
|
-
public eraser: IBoolean
|
|
78
|
+
public eraser: IBoolean | IEraserType
|
|
82
79
|
|
|
83
80
|
|
|
84
81
|
// position
|
|
@@ -114,12 +111,91 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
114
111
|
public skewY: INumber
|
|
115
112
|
|
|
116
113
|
|
|
114
|
+
// offset
|
|
115
|
+
@positionType(0, true)
|
|
116
|
+
public offsetX: INumber
|
|
117
|
+
|
|
118
|
+
@positionType(0, true)
|
|
119
|
+
public offsetY: INumber
|
|
120
|
+
|
|
121
|
+
// scroll
|
|
122
|
+
@positionType(0, true)
|
|
123
|
+
public scrollX: INumber
|
|
124
|
+
|
|
125
|
+
@positionType(0, true)
|
|
126
|
+
public scrollY: INumber
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// center
|
|
130
|
+
@autoLayoutType()
|
|
131
|
+
public origin: IAlign | IUnitPointData
|
|
132
|
+
|
|
117
133
|
@autoLayoutType()
|
|
118
|
-
public around:
|
|
134
|
+
public around: IAlign | IUnitPointData
|
|
119
135
|
|
|
120
136
|
|
|
137
|
+
// image
|
|
121
138
|
@dataType(false)
|
|
122
|
-
public
|
|
139
|
+
public lazy: IBoolean // load image / compute paint
|
|
140
|
+
|
|
141
|
+
@naturalBoundsType(1)
|
|
142
|
+
public pixelRatio: INumber
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
// path
|
|
146
|
+
@pathInputType()
|
|
147
|
+
public path: IPathCommandData | IPathString
|
|
148
|
+
|
|
149
|
+
@pathType()
|
|
150
|
+
public windingRule: IWindingRule
|
|
151
|
+
|
|
152
|
+
@pathType(true)
|
|
153
|
+
public closed: boolean
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// auto layout
|
|
157
|
+
@autoLayoutType(false)
|
|
158
|
+
public flow: IFlowType
|
|
159
|
+
|
|
160
|
+
@boundsType(0)
|
|
161
|
+
public padding: IFourNumber
|
|
162
|
+
|
|
163
|
+
@boundsType(0)
|
|
164
|
+
public gap: IGap | IPointGap
|
|
165
|
+
|
|
166
|
+
@boundsType('top-left')
|
|
167
|
+
public align: IFlowAlign | IFlowAxisAlign
|
|
168
|
+
|
|
169
|
+
@boundsType(false)
|
|
170
|
+
public wrap: IWrap
|
|
171
|
+
|
|
172
|
+
@boundsType('box')
|
|
173
|
+
public itemBox: IFlowBoxType
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@boundsType(true)
|
|
177
|
+
public inFlow: IBoolean
|
|
178
|
+
|
|
179
|
+
@boundsType() // rewrite in flow
|
|
180
|
+
public autoWidth: IAutoSize
|
|
181
|
+
|
|
182
|
+
@boundsType() // rewrite in flow
|
|
183
|
+
public autoHeight: IAutoSize
|
|
184
|
+
|
|
185
|
+
@boundsType()
|
|
186
|
+
public autoBox: IAutoBoxData | IConstraint
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@boundsType()
|
|
190
|
+
public widthRange: IRangeSize
|
|
191
|
+
|
|
192
|
+
@boundsType()
|
|
193
|
+
public heightRange: IRangeSize
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
// drag
|
|
197
|
+
@dataType(false)
|
|
198
|
+
public draggable: IBoolean | IAxis
|
|
123
199
|
|
|
124
200
|
@dataType()
|
|
125
201
|
public dragBounds?: IBoundsData | 'parent'
|
|
@@ -128,9 +204,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
128
204
|
@dataType(false)
|
|
129
205
|
public editable: IBoolean
|
|
130
206
|
|
|
131
|
-
@dataType('size')
|
|
132
|
-
public editSize?: IEditSize
|
|
133
|
-
|
|
134
207
|
|
|
135
208
|
// hit
|
|
136
209
|
@hitType(true)
|
|
@@ -194,25 +267,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
194
267
|
@strokeType(10)
|
|
195
268
|
public miterLimit: INumber
|
|
196
269
|
|
|
197
|
-
// image
|
|
198
|
-
|
|
199
|
-
@dataType(false)
|
|
200
|
-
public lazy: IBoolean // load image / compute paint
|
|
201
|
-
|
|
202
|
-
@naturalBoundsType(1)
|
|
203
|
-
public pixelRatio: INumber
|
|
204
|
-
|
|
205
|
-
// path
|
|
206
|
-
|
|
207
|
-
@pathInputType()
|
|
208
|
-
public path: IPathCommandData | IPathString
|
|
209
|
-
|
|
210
|
-
@pathType()
|
|
211
|
-
public windingRule: IWindingRule
|
|
212
|
-
|
|
213
|
-
@pathType(true)
|
|
214
|
-
public closed: boolean
|
|
215
|
-
|
|
216
270
|
|
|
217
271
|
// arrow
|
|
218
272
|
|
|
@@ -284,7 +338,9 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
284
338
|
}
|
|
285
339
|
|
|
286
340
|
public get pen(): IPathCreator {
|
|
287
|
-
|
|
341
|
+
const { path } = this.__
|
|
342
|
+
pen.set(this.path = path || [])
|
|
343
|
+
if (!path) this.__drawPathByBox(pen)
|
|
288
344
|
return pen
|
|
289
345
|
}
|
|
290
346
|
|
|
@@ -293,7 +349,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
293
349
|
|
|
294
350
|
public get editConfig(): IEditorConfig { return undefined }
|
|
295
351
|
|
|
296
|
-
public get editOuter(): string { return 'EditTool' }
|
|
352
|
+
public get editOuter(): string { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool' }
|
|
297
353
|
|
|
298
354
|
public get editInner(): string { return 'PathEditor' }
|
|
299
355
|
|
|
@@ -322,9 +378,13 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
322
378
|
|
|
323
379
|
// hit rewrite
|
|
324
380
|
|
|
325
|
-
public find(_condition: number | string | IFindUIMethod, _options?: any): IUI[] { return undefined }
|
|
381
|
+
public find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[] { return undefined }
|
|
382
|
+
|
|
383
|
+
public findTag(tag: string | string[]): IUI[] { return this.find({ tag }) }
|
|
326
384
|
|
|
327
|
-
public findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI { return undefined }
|
|
385
|
+
public findOne(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI { return undefined }
|
|
386
|
+
|
|
387
|
+
public findId(id: number | string): IUI { return this.findOne({ id }) }
|
|
328
388
|
|
|
329
389
|
|
|
330
390
|
// path
|
|
@@ -332,13 +392,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
332
392
|
public getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData {
|
|
333
393
|
this.__layout.update()
|
|
334
394
|
let path = pathForRender ? this.__.__pathForRender : this.__.path
|
|
335
|
-
if (!path)
|
|
336
|
-
const { width, height } = this.boxBounds
|
|
337
|
-
if (width || height) {
|
|
338
|
-
pen.set(path = [])
|
|
339
|
-
this.__drawPathByBox(pen)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
395
|
+
if (!path) pen.set(path = []), this.__drawPathByBox(pen)
|
|
342
396
|
return curve ? PathConvert.toCanvasData(path, true) : path
|
|
343
397
|
}
|
|
344
398
|
|
|
@@ -347,6 +401,10 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
347
401
|
}
|
|
348
402
|
|
|
349
403
|
|
|
404
|
+
public load(): void {
|
|
405
|
+
this.__.__computePaint() // 手动加载图片
|
|
406
|
+
}
|
|
407
|
+
|
|
350
408
|
public __onUpdateSize(): void {
|
|
351
409
|
if (this.__.__input) {
|
|
352
410
|
const data = this.__;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IString, INumber, IBoolean, IMaskType,
|
|
1
|
+
import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, IExportFileType, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IObject, IZoomType, IClientPointData, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D, IUnitData } from '@leafer/interface';
|
|
2
2
|
import { Leaf, LeafList } from '@leafer/core';
|
|
3
|
-
import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode,
|
|
3
|
+
import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IEditorConfig, IFindUIMethod, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, 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, 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;
|
|
@@ -17,14 +17,13 @@ declare class UI extends Leaf implements IUI {
|
|
|
17
17
|
className: IString;
|
|
18
18
|
blendMode: IBlendMode;
|
|
19
19
|
opacity: INumber;
|
|
20
|
-
visible: IBoolean;
|
|
20
|
+
visible: IBoolean | 0;
|
|
21
21
|
selected: IBoolean;
|
|
22
22
|
disabled: IBoolean;
|
|
23
23
|
locked: IBoolean;
|
|
24
24
|
zIndex: INumber;
|
|
25
|
-
mask: IBoolean;
|
|
26
|
-
|
|
27
|
-
eraser: IBoolean;
|
|
25
|
+
mask: IBoolean | IMaskType;
|
|
26
|
+
eraser: IBoolean | IEraserType;
|
|
28
27
|
x: INumber;
|
|
29
28
|
y: INumber;
|
|
30
29
|
width: INumber;
|
|
@@ -34,11 +33,32 @@ declare class UI extends Leaf implements IUI {
|
|
|
34
33
|
rotation: INumber;
|
|
35
34
|
skewX: INumber;
|
|
36
35
|
skewY: INumber;
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
offsetX: INumber;
|
|
37
|
+
offsetY: INumber;
|
|
38
|
+
scrollX: INumber;
|
|
39
|
+
scrollY: INumber;
|
|
40
|
+
origin: IAlign | IUnitPointData;
|
|
41
|
+
around: IAlign | IUnitPointData;
|
|
42
|
+
lazy: IBoolean;
|
|
43
|
+
pixelRatio: INumber;
|
|
44
|
+
path: IPathCommandData | IPathString;
|
|
45
|
+
windingRule: IWindingRule;
|
|
46
|
+
closed: boolean;
|
|
47
|
+
flow: IFlowType;
|
|
48
|
+
padding: IFourNumber;
|
|
49
|
+
gap: IGap | IPointGap;
|
|
50
|
+
align: IFlowAlign | IFlowAxisAlign;
|
|
51
|
+
wrap: IWrap;
|
|
52
|
+
itemBox: IFlowBoxType;
|
|
53
|
+
inFlow: IBoolean;
|
|
54
|
+
autoWidth: IAutoSize;
|
|
55
|
+
autoHeight: IAutoSize;
|
|
56
|
+
autoBox: IAutoBoxData | IConstraint;
|
|
57
|
+
widthRange: IRangeSize;
|
|
58
|
+
heightRange: IRangeSize;
|
|
59
|
+
draggable: IBoolean | IAxis;
|
|
39
60
|
dragBounds?: IBoundsData | 'parent';
|
|
40
61
|
editable: IBoolean;
|
|
41
|
-
editSize?: IEditSize;
|
|
42
62
|
hittable: IBoolean;
|
|
43
63
|
hitFill: IHitType;
|
|
44
64
|
hitStroke: IHitType;
|
|
@@ -57,11 +77,6 @@ declare class UI extends Leaf implements IUI {
|
|
|
57
77
|
dashPattern: INumber[] | IDashPatternString;
|
|
58
78
|
dashOffset: INumber;
|
|
59
79
|
miterLimit: INumber;
|
|
60
|
-
lazy: IBoolean;
|
|
61
|
-
pixelRatio: INumber;
|
|
62
|
-
path: IPathCommandData | IPathString;
|
|
63
|
-
windingRule: IWindingRule;
|
|
64
|
-
closed: boolean;
|
|
65
80
|
startArrow: IArrowType;
|
|
66
81
|
endArrow: IArrowType;
|
|
67
82
|
cornerRadius: IFourNumber | ICornerRadiusString;
|
|
@@ -88,10 +103,13 @@ declare class UI extends Leaf implements IUI {
|
|
|
88
103
|
set(data: IUIInputData): void;
|
|
89
104
|
get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
|
|
90
105
|
createProxyData(): IUIInputData;
|
|
91
|
-
find(_condition: number | string | IFindUIMethod, _options?: any): IUI[];
|
|
92
|
-
|
|
106
|
+
find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[];
|
|
107
|
+
findTag(tag: string | string[]): IUI[];
|
|
108
|
+
findOne(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI;
|
|
109
|
+
findId(id: number | string): IUI;
|
|
93
110
|
getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
|
|
94
111
|
getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
|
|
112
|
+
load(): void;
|
|
95
113
|
__onUpdateSize(): void;
|
|
96
114
|
__updateRenderPath(): void;
|
|
97
115
|
__drawRenderPath(canvas: ILeaferCanvas): void;
|
|
@@ -163,6 +181,7 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
163
181
|
lazyBounds: IBounds;
|
|
164
182
|
get FPS(): number;
|
|
165
183
|
get cursorPoint(): IPointData;
|
|
184
|
+
get clientBounds(): IBoundsData;
|
|
166
185
|
leafs: number;
|
|
167
186
|
__eventIds: IEventListenerId[];
|
|
168
187
|
protected __startTimer: ITimer;
|
|
@@ -182,7 +201,6 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
182
201
|
unlockLayout(): void;
|
|
183
202
|
lockLayout(): void;
|
|
184
203
|
resize(size: IScreenSizeData): void;
|
|
185
|
-
forceFullRender(): void;
|
|
186
204
|
forceRender(bounds?: IBoundsData): void;
|
|
187
205
|
updateCursor(cursor?: ICursorType): void;
|
|
188
206
|
updateLazyBounds(): void;
|
|
@@ -210,6 +228,7 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
210
228
|
zoom(_zoomType: IZoomType, _padding?: IFourNumber, _fixedScale?: boolean): IBoundsData;
|
|
211
229
|
getValidMove(moveX: number, moveY: number): IPointData;
|
|
212
230
|
getValidScale(changeScale: number): number;
|
|
231
|
+
getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
|
|
213
232
|
protected __checkUpdateLayout(): void;
|
|
214
233
|
protected emitLeafer(type: string): void;
|
|
215
234
|
protected __listenEvents(): void;
|
|
@@ -222,6 +241,7 @@ declare class Box extends Group implements IBox {
|
|
|
222
241
|
get isBranchLeaf(): boolean;
|
|
223
242
|
__: IBoxData;
|
|
224
243
|
overflow: IOverflow;
|
|
244
|
+
isOverflow: boolean;
|
|
225
245
|
constructor(data?: IBoxInputData);
|
|
226
246
|
__updateStrokeSpread(): number;
|
|
227
247
|
__updateRectRenderSpread(): number;
|
|
@@ -335,7 +355,6 @@ declare class Text extends UI implements IText {
|
|
|
335
355
|
__: ITextData;
|
|
336
356
|
width: INumber;
|
|
337
357
|
height: INumber;
|
|
338
|
-
padding: IFourNumber;
|
|
339
358
|
fill: IFill;
|
|
340
359
|
strokeAlign: IStrokeAlign;
|
|
341
360
|
hitFill: IHitType$1;
|