@leafer-ui/display 1.0.0-rc.2 → 1.0.0-rc.21

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/src/Rect.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { IPathDrawer, IPathCommandData, __Number } from '@leafer/interface'
2
- import { dataProcessor, registerUI, 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'
@@ -9,8 +8,9 @@ import { UI } from './UI'
9
8
 
10
9
 
11
10
  @useModule(RectRender)
11
+ @rewriteAble()
12
12
  @registerUI()
13
- export class Rect extends UI implements IRect {
13
+ export class Rect extends UI implements IRect { // tip: rewrited Box
14
14
 
15
15
  public get __tag() { return 'Rect' }
16
16
 
@@ -21,12 +21,4 @@ export class Rect extends UI implements IRect {
21
21
  super(data)
22
22
  }
23
23
 
24
- public __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void {
25
- const { width, height, cornerRadius } = this.__
26
- if (cornerRadius) {
27
- drawer.roundRect(0, 0, width, height, cornerRadius)
28
- } else {
29
- drawer.rect(0, 0, width, height)
30
- }
31
- }
32
24
  }
package/src/Star.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { __Number } from '@leafer/interface'
1
+ import { INumber } from '@leafer/interface'
2
2
  import { PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IStar, IStarData, IStarInputData } from '@leafer-ui/interface'
@@ -20,10 +20,10 @@ export class Star extends UI implements IStar {
20
20
  declare public __: IStarData
21
21
 
22
22
  @pathType(5)
23
- public corners: __Number
23
+ public corners: INumber
24
24
 
25
25
  @pathType(0.382)
26
- public innerRadius: __Number
26
+ public innerRadius: INumber
27
27
 
28
28
  constructor(data?: IStarInputData) {
29
29
  super(data)
package/src/Text.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, __Boolean, __Number, __String } from '@leafer/interface'
2
- import { BoundsHelper, boundsType, dataProcessor, registerUI, affectStrokeBoundsType } from '@leafer/core'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData } from '@leafer/interface'
2
+ import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, hitType, MathHelper } from '@leafer/core'
3
3
 
4
- import { IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IUnitData, IStrokeAlign } from '@leafer-ui/interface'
4
+ import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IUnitData, 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 } = BoundsHelper
12
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper
13
13
 
14
14
  @registerUI()
15
15
  export class Text extends UI implements IText {
@@ -21,31 +21,37 @@ export class Text extends UI implements IText {
21
21
 
22
22
  // size
23
23
  @boundsType(0)
24
- declare public width: __Number
24
+ declare public width: INumber
25
25
 
26
26
  @boundsType(0)
27
- declare public height: __Number
27
+ declare public height: INumber
28
28
 
29
29
  @boundsType(0)
30
30
  public padding: number | number[]
31
31
 
32
+ @surfaceType('#000000')
33
+ declare public fill: IFill
34
+
32
35
  @affectStrokeBoundsType('outside')
33
36
  declare public strokeAlign: IStrokeAlign
34
37
 
38
+ @hitType('all')
39
+ declare public hitFill: IHitType
40
+
35
41
  @boundsType('')
36
- public text: __String
42
+ public text: IString
37
43
 
38
44
  @boundsType('L')
39
- public fontFamily: __String
45
+ public fontFamily: IString
40
46
 
41
47
  @boundsType(12)
42
- public fontSize: __Number
48
+ public fontSize: INumber
43
49
 
44
50
  @boundsType('normal')
45
51
  public fontWeight: IFontWeight
46
52
 
47
53
  @boundsType(false)
48
- public italic: __Boolean
54
+ public italic: IBoolean
49
55
 
50
56
  @boundsType('none')
51
57
  public textCase: ITextCase
@@ -54,16 +60,16 @@ export class Text extends UI implements IText {
54
60
  public textDecoration: ITextDecoration
55
61
 
56
62
  @boundsType(0)
57
- public letterSpacing: __Number | IUnitData
63
+ public letterSpacing: INumber | IUnitData
58
64
 
59
65
  @boundsType({ type: 'percent', value: 150 } as IUnitData)
60
- public lineHeight: __Number | IUnitData
66
+ public lineHeight: INumber | IUnitData
61
67
 
62
68
  @boundsType(0)
63
- public paraIndent: __Number
69
+ public paraIndent: INumber
64
70
 
65
71
  @boundsType(0)
66
- public paraSpacing: __Number
72
+ public paraSpacing: INumber
67
73
 
68
74
  @boundsType('left')
69
75
  public textAlign: ITextAlign
@@ -71,11 +77,14 @@ export class Text extends UI implements IText {
71
77
  @boundsType('top')
72
78
  public verticalAlign: IVerticalAlign
73
79
 
80
+ @boundsType('normal')
81
+ public textWrap: ITextWrap
82
+
74
83
  @boundsType('show')
75
84
  public textOverflow: IOverflow | string
76
85
 
77
86
  public get textDrawData(): ITextDrawData {
78
- this.__layout.checkUpdate()
87
+ this.__layout.update()
79
88
  return this.__.__textDrawData
80
89
  }
81
90
 
@@ -114,14 +123,19 @@ export class Text extends UI implements IText {
114
123
 
115
124
  const data = this.__
116
125
  const layout = this.__layout
117
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data
126
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data
127
+
128
+ const autoWidth = data.__autoWidth
129
+ const autoHeight = data.__autoHeight
118
130
 
119
131
  // compute
120
132
 
121
133
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize)
122
134
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize)
135
+ data.__padding = padding ? MathHelper.fourNumber(padding) : undefined
123
136
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2
124
137
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
138
+ data.__clipText = textOverflow !== 'show' && !data.__autoSize
125
139
 
126
140
  this.__updateTextDrawData()
127
141
 
@@ -130,23 +144,37 @@ export class Text extends UI implements IText {
130
144
 
131
145
  if (data.__lineHeight < fontSize) spread(bounds, fontSize / 2)
132
146
 
133
- const width = data.__getInput('width')
134
- const height = data.__getInput('height')
135
-
136
- if (width && height) {
137
- super.__updateBoxBounds()
138
- } else {
139
- b.x = width ? 0 : bounds.x
140
- b.y = height ? 0 : bounds.y
141
- b.width = width ? width : bounds.width
142
- b.height = height ? height : bounds.height
147
+ if (autoWidth || autoHeight) {
148
+ b.x = autoWidth ? bounds.x : 0
149
+ b.y = autoHeight ? bounds.y : 0
150
+ b.width = autoWidth ? bounds.width : data.width
151
+ b.height = autoHeight ? bounds.height : data.height
152
+
153
+ if (padding) {
154
+ const [top, right, bottom, left] = data.__padding
155
+ if (autoWidth) {
156
+ b.x -= left
157
+ b.width += (right + left)
158
+ }
159
+ if (autoHeight) {
160
+ b.y -= top
161
+ b.height += (bottom + top)
162
+ }
163
+ }
143
164
  this.__updateNaturalSize()
165
+ } else {
166
+ super.__updateBoxBounds()
144
167
  }
145
168
 
169
+ if (italic) b.width += fontSize * 0.16
170
+
146
171
  const contentBounds = includes(b, bounds) ? b : bounds
147
172
  if (contentBounds !== layout.contentBounds) {
148
173
  layout.contentBounds = contentBounds
149
174
  layout.renderChanged = true
175
+ setList(data.__textBoxBounds = {} as IBoundsData, [b, bounds])
176
+ } else {
177
+ data.__textBoxBounds = contentBounds
150
178
  }
151
179
 
152
180
  }
@@ -158,7 +186,7 @@ export class Text extends UI implements IText {
158
186
  }
159
187
 
160
188
  public __updateRenderBounds(): void {
161
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread)
189
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread)
162
190
  }
163
191
 
164
192
  }
package/src/UI.ts CHANGED
@@ -1,37 +1,49 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, __Number, __Boolean, __String, IPathString, IExportFileType, IPointData, ICursorType, 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 } from '@leafer/core'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IAround, IValue, IWindingRule, IPathCreator } 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, pen, naturalBoundsType, pathInputType } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IUIBaseInputData, IExportOptions, IExportResult } from '@leafer-ui/interface'
5
- import { effectType } from '@leafer-ui/decorator'
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, IEditorConfig } from '@leafer-ui/interface'
5
+ import { arrowType, effectType, stateType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
8
- import { UIBounds, UIHit, UIRender } from '@leafer-ui/display-module'
8
+ import { UIBounds, UIRender } from '@leafer-ui/display-module'
9
9
 
10
- import { Export, Paint } from '@leafer-ui/external'
10
+ import { Export, PathArrow } from '@leafer-ui/external'
11
11
 
12
12
 
13
13
  @useModule(UIBounds)
14
- @useModule(UIHit)
15
14
  @useModule(UIRender)
16
15
  @rewriteAble()
17
- export class UI extends Leaf implements IUI {
16
+ export class UI extends Leaf implements IUI { // tip: rewrited Box
18
17
 
19
18
  @dataProcessor(UIData)
20
19
  declare public __: IUIData
21
20
 
21
+ declare public proxyData: IUIInputData // need rewrite getter
22
+ declare public __proxyData?: IUIInputData
23
+
24
+ public get app(): ILeafer { return this.leafer && this.leafer.app }
25
+
26
+ declare public leafer?: ILeafer
22
27
  declare public parent?: IGroup
23
28
 
29
+ @zoomLayerType()
30
+ public zoomLayer: IGroup
31
+
32
+ public get isFrame(): boolean { return false }
33
+
34
+ declare public children?: IUI[]
35
+
24
36
  // ---
25
37
 
26
38
  // id
27
39
  @dataType('')
28
- public id: __String
40
+ public id: IString
29
41
 
30
42
  @dataType('')
31
- public name: __String
43
+ public name: IString
32
44
 
33
45
  @dataType('')
34
- public className: __String
46
+ public className: IString
35
47
 
36
48
 
37
49
  // layer
@@ -39,67 +51,90 @@ export class UI extends Leaf implements IUI {
39
51
  public blendMode: IBlendMode
40
52
 
41
53
  @opacityType(1)
42
- public opacity: __Number
54
+ public opacity: INumber
43
55
 
44
56
  @opacityType(true)
45
- public visible: __Boolean
57
+ public visible: IBoolean
46
58
 
47
- @maskType(false)
48
- public isMask: __Boolean
49
59
 
50
- @eraserType(false)
51
- public isEraser?: __Boolean
60
+ @stateType(false)
61
+ public selected: IBoolean
62
+
63
+ @stateType(false)
64
+ public disabled: IBoolean
65
+
66
+ @dataType(false)
67
+ public locked: IBoolean
68
+
52
69
 
53
70
  @sortType(0)
54
- public zIndex: __Number
71
+ public zIndex: INumber
55
72
 
56
- @dataType()
57
- public locked: __Boolean
73
+
74
+ @maskType(false)
75
+ public mask: IBoolean
76
+
77
+ @surfaceType('pixel')
78
+ public maskType: IMaskType
79
+
80
+ @eraserType(false)
81
+ public eraser: IBoolean
58
82
 
59
83
 
60
84
  // position
61
- @positionType(0)
62
- public x: __Number
85
+ @positionType(0, true)
86
+ public x: INumber
63
87
 
64
- @positionType(0)
65
- public y: __Number
88
+ @positionType(0, true)
89
+ public y: INumber
66
90
 
67
91
  // size
68
- @boundsType(100)
69
- public width: __Number
92
+ @boundsType(100, true)
93
+ public width: INumber
70
94
 
71
- @boundsType(100)
72
- public height: __Number
95
+ @boundsType(100, true)
96
+ public height: INumber
73
97
 
74
98
  // scale
75
- @scaleType(1)
76
- public scaleX: __Number
99
+ @scaleType(1, true)
100
+ public scaleX: INumber
77
101
 
78
- @scaleType(1)
79
- public scaleY: __Number
102
+ @scaleType(1, true)
103
+ public scaleY: INumber
80
104
 
81
105
  // rotate
82
- @rotationType(0)
83
- public rotation: __Number
106
+ @rotationType(0, true)
107
+ public rotation: INumber
84
108
 
85
109
  // skew
86
- @rotationType(0)
87
- public skewX: __Number
110
+ @rotationType(0, true)
111
+ public skewX: INumber
88
112
 
89
- @rotationType(0)
90
- public skewY: __Number
113
+ @rotationType(0, true)
114
+ public skewY: INumber
91
115
 
92
116
 
93
- @positionType()
117
+ @autoLayoutType()
94
118
  public around: IAround
95
119
 
96
120
 
97
121
  @dataType(false)
98
- public draggable: __Boolean
122
+ public draggable: IBoolean
123
+
124
+
125
+ @dataType(false)
126
+ public editable: IBoolean
127
+
128
+ @dataType('size')
129
+ public editSize?: IEditSize
130
+
131
+ @dataType()
132
+ public editorStyle: IEditorConfig
133
+
99
134
 
100
135
  // hit
101
136
  @hitType(true)
102
- public hittable: __Boolean
137
+ public hittable: IBoolean
103
138
 
104
139
  @hitType('path')
105
140
  public hitFill: IHitType
@@ -107,16 +142,19 @@ export class UI extends Leaf implements IUI {
107
142
  @strokeType('path')
108
143
  public hitStroke: IHitType
109
144
 
145
+ @hitType(false)
146
+ public hitBox: IBoolean
147
+
110
148
  @hitType(true)
111
- public hitChildren: __Boolean
149
+ public hitChildren: IBoolean
112
150
 
113
151
  @hitType(true)
114
- public hitSelf: __Boolean
152
+ public hitSelf: IBoolean
115
153
 
116
154
  @hitType()
117
- public hitRadius: __Number
155
+ public hitRadius: INumber
118
156
 
119
- @cursorType('default')
157
+ @cursorType('')
120
158
  public cursor: ICursorType | ICursorType[]
121
159
 
122
160
  // ---
@@ -125,18 +163,21 @@ export class UI extends Leaf implements IUI {
125
163
  // fill
126
164
 
127
165
  @surfaceType()
128
- public fill: IPaint | IPaint[] | IPaintString
166
+ public fill: IFill
129
167
 
130
168
  // stroke
131
169
 
132
170
  @strokeType()
133
- public stroke: IPaint | IPaint[] | IPaintString
171
+ public stroke: IStroke
134
172
 
135
173
  @strokeType('inside')
136
174
  public strokeAlign: IStrokeAlign
137
175
 
138
176
  @strokeType(1)
139
- public strokeWidth: number | number[] | IStrokeWidthString
177
+ public strokeWidth: INumber | INumber[] | IStrokeWidthString
178
+
179
+ @strokeType(false)
180
+ public strokeWidthFixed: IBoolean
140
181
 
141
182
  @strokeType('none')
142
183
  public strokeCap: IStrokeCap
@@ -145,22 +186,49 @@ export class UI extends Leaf implements IUI {
145
186
  public strokeJoin: IStrokeJoin
146
187
 
147
188
  @strokeType()
148
- public dashPattern: __Number[] | IDashPatternString
189
+ public dashPattern: INumber[] | IDashPatternString
149
190
 
150
191
  @strokeType()
151
- public dashOffset: __Number
192
+ public dashOffset: INumber
152
193
 
153
194
  @strokeType(10)
154
- public miterLimit: __Number
195
+ public miterLimit: INumber
155
196
 
197
+ // image
156
198
 
157
- // corner
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
158
209
 
159
210
  @pathType()
211
+ public windingRule: IWindingRule
212
+
213
+ @pathType(true)
214
+ public closed: boolean
215
+
216
+
217
+ // arrow
218
+
219
+ @arrowType('none')
220
+ public startArrow: IArrowType
221
+
222
+ @arrowType('none')
223
+ public endArrow: IArrowType
224
+
225
+ // corner
226
+
227
+ @pathType(0)
160
228
  public cornerRadius: number | number[] | ICornerRadiusString
161
229
 
162
230
  @pathType()
163
- public cornerSmoothing: __Number
231
+ public cornerSmoothing: INumber
164
232
 
165
233
  // effect
166
234
 
@@ -171,16 +239,37 @@ export class UI extends Leaf implements IUI {
171
239
  public innerShadow: IShadowEffect | IShadowEffect[] | IShadowString
172
240
 
173
241
  @effectType()
174
- public blur: __Number | IBlurEffect
242
+ public blur: INumber | IBlurEffect
175
243
 
176
244
  @effectType()
177
- public backgroundBlur: __Number | IBlurEffect
245
+ public backgroundBlur: INumber | IBlurEffect
178
246
 
179
247
  @effectType()
180
- public grayscale: __Number | IGrayscaleEffect
248
+ public grayscale: INumber | IGrayscaleEffect
249
+
181
250
 
251
+ // states
182
252
 
183
- public set scale(value: __Number | IPointData) {
253
+ @dataType()
254
+ public normalStyle: IUIInputData // auto restore hover / press / focus / selected / disabled style
255
+
256
+ @dataType()
257
+ public hoverStyle: IUIInputData
258
+
259
+ @dataType()
260
+ public pressStyle: IUIInputData
261
+
262
+ @dataType()
263
+ public focusStyle: IUIInputData
264
+
265
+ @dataType()
266
+ public selectedStyle: IUIInputData
267
+
268
+ @dataType()
269
+ public disabledStyle: IUIInputData
270
+
271
+
272
+ public set scale(value: INumber | IPointData) {
184
273
  if (typeof value === 'number') {
185
274
  this.scaleX = this.scaleY = value
186
275
  } else {
@@ -189,49 +278,79 @@ export class UI extends Leaf implements IUI {
189
278
  }
190
279
  }
191
280
 
192
- public get scale(): __Number | IPointData {
281
+ public get scale(): INumber | IPointData {
193
282
  const { scaleX, scaleY } = this
194
283
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX
195
284
  }
196
285
 
197
286
 
198
- constructor(data?: IUIBaseInputData) {
287
+ public get pen(): IPathCreator {
288
+ pen.set(this.path = this.__.path || [])
289
+ return pen
290
+ }
291
+
292
+
293
+ constructor(data?: IUIInputData) {
199
294
  super(data)
200
295
  }
201
296
 
202
297
 
298
+ // data
299
+
300
+ @rewrite(Leaf.prototype.reset)
301
+ public reset(_data?: IUIInputData): void { }
302
+
303
+
203
304
  public set(data: IUIInputData): void {
204
305
  Object.assign(this, data)
205
306
  }
206
307
 
207
- public get(): IUIInputData {
208
- return this.__.__getInputData()
308
+ public get(name?: string | string[] | IUIInputData): IUIInputData | IValue {
309
+ return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name)
209
310
  }
210
311
 
312
+ public createProxyData(): IUIInputData { return undefined }
313
+
211
314
 
212
- public getPath(curve?: boolean): IPathCommandData {
213
- const path = this.__.path
214
- if (!path) return []
315
+ // hit rewrite
316
+
317
+ public find(_condition: number | string | IFindUIMethod, _options?: any): IUI[] { return undefined }
318
+
319
+ public findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI { return undefined }
320
+
321
+
322
+ // path
323
+
324
+ public getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData {
325
+ this.__layout.update()
326
+ let path = pathForRender ? this.__.__pathForRender : this.__.path
327
+ if (!path) {
328
+ const { width, height } = this.boxBounds
329
+ if (width || height) {
330
+ pen.set(path = [])
331
+ this.__drawPathByBox(pen)
332
+ }
333
+ }
215
334
  return curve ? PathConvert.toCanvasData(path, true) : path
216
335
  }
217
336
 
218
- public getPathString(curve?: boolean): IPathString {
219
- return PathConvert.stringify(this.getPath(curve))
337
+ public getPathString(curve?: boolean, pathForRender?: boolean): IPathString {
338
+ return PathConvert.stringify(this.getPath(curve, pathForRender))
220
339
  }
221
340
 
222
341
 
223
342
  public __onUpdateSize(): void {
224
343
  if (this.__.__input) {
225
- const { fill, stroke } = this.__.__input
226
- if (fill) Paint.compute(this, 'fill')
227
- if (stroke) Paint.compute(this, 'stroke')
344
+ const data = this.__;
345
+ (data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint()
228
346
  }
229
347
  }
230
348
 
231
349
  public __updateRenderPath(): void {
232
350
  if (this.__.path) {
233
- const { __: data } = this
351
+ const data = this.__
234
352
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
353
+ if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius)
235
354
  }
236
355
  }
237
356
 
@@ -245,8 +364,25 @@ export class UI extends Leaf implements IUI {
245
364
  this.__drawPathByData(canvas, this.__.path)
246
365
  }
247
366
 
248
- @rewrite(PathDrawer.drawPathByData)
249
- public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
367
+ public __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void {
368
+ if (data) {
369
+ PathDrawer.drawPathByData(drawer, data)
370
+ } else {
371
+ this.__drawPathByBox(drawer)
372
+ }
373
+ }
374
+
375
+ public __drawPathByBox(drawer: IPathDrawer): void {
376
+ const { x, y, width, height } = this.__layout.boxBounds
377
+ if (this.__.cornerRadius) {
378
+ drawer.roundRect(x, y, width, height, this.__.cornerRadius)
379
+ } else {
380
+ drawer.rect(x, y, width, height)
381
+ }
382
+ }
383
+
384
+
385
+ // create
250
386
 
251
387
  public export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult> {
252
388
  return Export.export(this, filename, options)
@@ -260,6 +396,14 @@ export class UI extends Leaf implements IUI {
260
396
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
261
397
  }
262
398
 
399
+ static registerUI(): void {
400
+ registerUI()(this)
401
+ }
402
+
403
+ static registerData(data: IUIData): void {
404
+ dataProcessor(data)(this.prototype)
405
+ }
406
+
263
407
  public destroy(): void {
264
408
  this.fill = this.stroke = null
265
409
  super.destroy()