@leafer-ui/data 1.7.0 → 1.8.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/data",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "@leafer-ui/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.7.0",
26
- "@leafer-ui/external": "1.7.0"
25
+ "@leafer/core": "1.8.0",
26
+ "@leafer-ui/external": "1.8.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.7.0",
30
- "@leafer-ui/interface": "1.7.0"
29
+ "@leafer/interface": "1.8.0",
30
+ "@leafer-ui/interface": "1.8.0"
31
31
  }
32
32
  }
package/src/BoxData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IBoxData } from '@leafer-ui/interface'
1
+ import { IBox, IBoxData } from '@leafer-ui/interface'
2
2
 
3
3
  import { GroupData } from "./GroupData"
4
4
 
@@ -7,9 +7,9 @@ export class BoxData extends GroupData implements IBoxData {
7
7
 
8
8
  public get __boxStroke(): boolean { return !(this as IBoxData).__pathInputed }
9
9
 
10
- // 路径与圆角直接当溢出处理
11
- public get __drawAfterFill(): boolean { const t = this as IBoxData; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length) as unknown as boolean }
10
+ // 当成整体处理
11
+ public get __drawAfterFill(): boolean { const t = this as IBoxData; return t.__single || t.__clipAfterFill }
12
12
 
13
- public get __clipAfterFill(): boolean { return this.__leaf.isOverflow || super.__clipAfterFill }
13
+ public get __clipAfterFill(): boolean { const t = this as IBoxData; return t.overflow === 'hide' && t.__leaf.children.length && ((t.__leaf as IBox).isOverflow || super.__clipAfterFill) as unknown as boolean }
14
14
 
15
15
  }
package/src/UIData.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { INumber, IValue, IBoolean, IPathCommandData, IPathString, IPointData, IPathCommandObject, IObject, IFilter } from '@leafer/interface'
2
2
  import { PathConvert, DataHelper, LeafData, Debug } from '@leafer/core'
3
3
 
4
- import { IUI, IUIData, ILeafPaint } from '@leafer-ui/interface'
4
+ import { IUI, IUIData, ILeafPaint, IStrokeComputedStyle } from '@leafer-ui/interface'
5
5
  import { Paint, PaintImage, ColorConvert } from '@leafer-ui/external'
6
6
 
7
7
 
@@ -20,20 +20,13 @@ export class UIData extends LeafData implements IUIData {
20
20
  public __isFills?: boolean
21
21
  public __isStrokes?: boolean
22
22
 
23
- public get __strokeWidth(): number {
24
- const { strokeWidth, strokeWidthFixed } = this as IUIData
25
- if (strokeWidthFixed) {
26
- const ui = this.__leaf
27
- let { scaleX } = ui.__nowWorld || ui.__world
28
- if (scaleX < 0) scaleX = -scaleX
29
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth
30
- } else return strokeWidth
31
- }
23
+ public get __strokeWidth(): number { return this.__getRealStrokeWidth() }
32
24
 
33
- public get __hasMultiPaint(): boolean { // fix: opacity
34
- const t = this as IUIData
35
- return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect
36
- }
25
+ public get __maxStrokeWidth(): number { const t = this as IUIData; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth }
26
+
27
+ public __hasMultiStrokeStyle?: number // 是否存在多个不同的描述样式(同时存储多个描边样式中的最大宽度用于运算)
28
+
29
+ public get __hasMultiPaint(): boolean { const t = this as IUIData; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect } // fix: opacity
37
30
 
38
31
  public __isAlphaPixelFill?: boolean // png / svg / webp
39
32
  public __isAlphaPixelStroke?: boolean
@@ -41,7 +34,7 @@ export class UIData extends LeafData implements IUIData {
41
34
  public __isTransparentFill?: boolean // 半透明的
42
35
  public __isTransparentStroke?: boolean
43
36
 
44
- public get __clipAfterFill(): boolean { const t = this as IUIData; return (t.cornerRadius || t.innerShadow || t.__pathInputed) as unknown as boolean } // 用于 __drawAfterFill()
37
+ public get __clipAfterFill(): boolean { const t = this as IUIData; return (t.cornerRadius || t.innerShadow || t.__pathInputed) as unknown as boolean } // 用于 (Box | Canvas | Robot) __drawAfterFill() 时裁剪内容
45
38
  public get __hasSurface(): boolean { const t = this as IUIData; return (t.fill || t.stroke) as unknown as boolean }
46
39
 
47
40
  public __needComputePaint: boolean
@@ -145,6 +138,20 @@ export class UIData extends LeafData implements IUIData {
145
138
  this.__needComputePaint = undefined
146
139
  }
147
140
 
141
+
142
+ public __getRealStrokeWidth(childStyle?: IStrokeComputedStyle): number {
143
+ let { strokeWidth, strokeWidthFixed } = this as IUIData
144
+ if (childStyle) {
145
+ if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth
146
+ if (childStyle.strokeWidthFixed !== undefined) strokeWidthFixed = childStyle.strokeWidthFixed
147
+ }
148
+ if (strokeWidthFixed) {
149
+ const scale = this.__leaf.getClampRenderScale()
150
+ return scale > 1 ? strokeWidth / scale : strokeWidth
151
+ } else return strokeWidth
152
+ }
153
+
154
+
148
155
  public __setPaint(attrName: 'fill' | 'stroke', value: IValue): void {
149
156
  this.__setInput(attrName, value)
150
157
  const layout = this.__leaf.__layout
@@ -165,6 +172,7 @@ export class UIData extends LeafData implements IUIData {
165
172
  this._fill = this.__isFills = undefined
166
173
  } else {
167
174
  stintSet(this, '__isAlphaPixelStroke', undefined)
175
+ stintSet(this, '__hasMultiStrokeStyle', undefined)
168
176
  this._stroke = this.__isStrokes = undefined
169
177
  }
170
178
  }
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { INumber, IPointData, IBoolean, IValue, IPathCommandData, IPathCommandObject, IPathString } from '@leafer/interface';
2
2
  import { LeafData } from '@leafer/core';
3
- import { IUIData, IUI, IGroupData, IBoxData, ILeaferData, IObject, IJSONOptions, IFrameData, ILineData, IRectData, IEllipseData, IPolygonData, IStarData, IPathData, IPenData, ITextData, IBackgroundBoxStyle, IFontWeight, IImageData, IImage, ICanvasData } from '@leafer-ui/interface';
3
+ import { IUIData, IUI, IStrokeComputedStyle, IGroupData, IBoxData, ILeaferData, IObject, IJSONOptions, IFrameData, ILineData, IRectData, IEllipseData, IPolygonData, IStarData, IPathData, IPenData, ITextData, IBackgroundBoxStyle, IFontWeight, IImageData, IImage, ICanvasData } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UIData extends LeafData implements IUIData {
6
6
  __leaf: IUI;
@@ -9,6 +9,8 @@ declare class UIData extends LeafData implements IUIData {
9
9
  __isFills?: boolean;
10
10
  __isStrokes?: boolean;
11
11
  get __strokeWidth(): number;
12
+ get __maxStrokeWidth(): number;
13
+ __hasMultiStrokeStyle?: number;
12
14
  get __hasMultiPaint(): boolean;
13
15
  __isAlphaPixelFill?: boolean;
14
16
  __isAlphaPixelStroke?: boolean;
@@ -39,6 +41,7 @@ declare class UIData extends LeafData implements IUIData {
39
41
  protected setInnerShadow(value: IValue): void;
40
42
  protected setFilter(value: IValue): void;
41
43
  __computePaint(): void;
44
+ __getRealStrokeWidth(childStyle?: IStrokeComputedStyle): number;
42
45
  __setPaint(attrName: 'fill' | 'stroke', value: IValue): void;
43
46
  __removePaint(attrName: 'fill' | 'stroke', removeInput?: boolean): void;
44
47
  }