-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration of outline and shadow to label #16106
Conversation
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -2468,33 +2468,19 @@
*
* @zh
* 描边效果组件,用于字体描边,只能用于系统字体。
*
- * @example
- * ```ts
- * import { Node, Label, LabelOutline } from 'cc';
- * // Create a new node and add label components.
- * const node = new Node("New Label");
- * const label = node.addComponent(Label);
- * const outline = node.addComponent(LabelOutline);
- * node.parent = this.node;
- * ```
+ * @deprecated since v3.8.2, please use [[Label.enableOutline]] instead.
*/
export class LabelOutline extends Component {
- protected _color: math.Color;
- protected _width: number;
/**
* @en
* Outline color.
*
* @zh
* 改变描边的颜色。
*
- * @example
- * ```ts
- * import { Color } from 'cc';
- * outline.color = new Color(0.5, 0.3, 0.7, 1.0);
- * ```
+ * @deprecated since v3.8.2, please use [[Label.outlineColor]] instead.
*/
get color(): Readonly<math.Color>;
set color(value: Readonly<math.Color>);
/**
@@ -2503,18 +2489,20 @@
*
* @zh
* 改变描边的宽度。
*
- * @example
- * ```ts
- * outline.width = 3;
- * ```
+ * @deprecated since v3.8.2, please use [[Label.outlineWidth]] instead.
*/
get width(): number;
set width(value: number);
+ /**
+ * @deprecated since v3.8.2, please use [[Label.enableOutline]] instead.
+ */
onEnable(): void;
+ /**
+ * @deprecated since v3.8.2, please use [[Label.enableOutline]] instead.
+ */
onDisable(): void;
- protected _updateRenderData(): void;
}
/**
* @en
* Graphics component.
@@ -2869,32 +2857,20 @@
}
/**
* @en Shadow effect for Label component, only for system fonts or TTF fonts.
* @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。
- * @example
- * import { Node, Label, LabelShadow } from 'cc';
- * // Create a new node and add label components.
- * const node = new Node("New Label");
- * const label = node.addComponent(Label);
- * const shadow = node.addComponent(LabelShadow);
- * node.parent = this.node;
+ *
+ * @deprecated since v3.8.2, please use [[Label.enableShadow]] instead.
*/
export class LabelShadow extends Component {
- protected _color: math.Color;
- protected _offset: math.Vec2;
- protected _blur: number;
/**
* @en
* Shadow color.
*
* @zh
* 阴影的颜色。
*
- * @example
- * ```ts
- * import { Color } from 'cc';
- * labelShadow.color = new Color(0.5, 0.3, 0.7, 1.0);
- * ```
+ * @deprecated since v3.8.2, please use [[Label.shadowColor]] instead.
*/
get color(): Readonly<math.Color>;
set color(value: Readonly<math.Color>);
/**
@@ -2903,13 +2879,9 @@
*
* @zh
* 字体与阴影的偏移。
*
- * @example
- * ```ts
- * import { Vec2 } from 'cc';
- * labelShadow.offset = new Vec2(2, 2);
- * ```
+ * @deprecated since v3.8.2, please use [[Label.shadowOffset]] instead.
*/
get offset(): math.Vec2;
set offset(value: math.Vec2);
/**
@@ -2918,18 +2890,20 @@
*
* @zh
* 阴影的模糊程度。
*
- * @example
- * ```ts
- * labelShadow.blur = 2;
- * ```
+ * @deprecated since v3.8.2, please use [[Label.shadowBlur]] instead.
*/
get blur(): number;
set blur(value: number);
+ /**
+ * @deprecated since v3.8.2, please use [[Label.enableShadow]] instead.
+ */
onEnable(): void;
+ /**
+ * @deprecated since v3.8.2, please use [[Label.enableShadow]] instead.
+ */
onDisable(): void;
- protected _updateRenderData(): void;
}
/**
* @en
* Set the UI transparency component.
@@ -3250,8 +3224,68 @@
*/
get underlineHeight(): number;
set underlineHeight(value: number);
/**
+ ** @en
+ ** Outline effect used to change the display, only for system fonts or TTF fonts.
+ **
+ ** @zh
+ ** 描边效果组件,用于字体描边,只能用于系统字体或 ttf 字体。
+ **/
+ get enableOutline(): boolean;
+ set enableOutline(value: boolean);
+ /**
+ * @en
+ * Outline color.
+ *
+ * @zh
+ * 改变描边的颜色。
+ */
+ get outlineColor(): math.Color;
+ set outlineColor(value: math.Color);
+ /**
+ * @en
+ * Change the outline width.
+ *
+ * @zh
+ * 改变描边的宽度。
+ */
+ get outlineWidth(): number;
+ set outlineWidth(value: number);
+ /**
+ * @en Shadow effect for Label component, only for system fonts or TTF fonts. Disabled when cache mode is char.
+ * @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。在缓存模式为 char 时不可用。
+ */
+ get enableShadow(): boolean;
+ set enableShadow(value: boolean);
+ /**
+ * @en
+ * Shadow color.
+ *
+ * @zh
+ * 阴影的颜色。
+ */
+ get shadowColor(): math.Color;
+ set shadowColor(value: math.Color);
+ /**
+ * @en
+ * Offset between font and shadow.
+ *
+ * @zh
+ * 字体与阴影的偏移。
+ */
+ get shadowOffset(): math.Vec2;
+ set shadowOffset(value: math.Vec2);
+ /**
+ * @en
+ * A non-negative float specifying the level of shadow blur.
+ *
+ * @zh
+ * 阴影的模糊程度。
+ */
+ get shadowBlur(): number;
+ set shadowBlur(value: number);
+ /**
* @deprecated since v3.7.0, this is an engine private interface that will be removed in the future.
*/
get spriteFrame(): SpriteFrame | __private._cocos_2d_assembler_label_font_utils__LetterRenderTexture | null;
/**
@@ -3287,8 +3321,15 @@
protected _isBold: boolean;
protected _isUnderline: boolean;
protected _underlineHeight: number;
protected _cacheMode: CacheMode;
+ protected _enableOutline: boolean;
+ protected _outlineColor: math.Color;
+ protected _outlineWidth: number;
+ protected _enableShadow: boolean;
+ protected _shadowColor: math.Color;
+ protected _shadowOffset: math.Vec2;
+ protected _shadowBlur: number;
protected _N$file: Font | null;
protected _texture: SpriteFrame | __private._cocos_2d_assembler_label_font_utils__LetterRenderTexture | null;
protected _ttfSpriteFrame: SpriteFrame | null;
protected _userDefinedFont: Font | null;
|
cocos/2d/components/label-shadow.ts
Outdated
@@ -77,7 +68,10 @@ export class LabelShadow extends Component { | |||
} | |||
|
|||
this._color.set(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs to cache color anymore, just set label's property directly
cocos/2d/components/label-shadow.ts
Outdated
@@ -100,7 +90,10 @@ export class LabelShadow extends Component { | |||
|
|||
set offset (value) { | |||
this._offset = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs to cache color anymore, just set label's property directly
cocos/2d/components/label-outline.ts
Outdated
@@ -82,7 +70,10 @@ export class LabelOutline extends Component { | |||
} | |||
|
|||
this._color.set(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs to cache color anymore, just set label's property directly
cocos/2d/components/label.ts
Outdated
@editable | ||
@displayOrder(19) | ||
@tooltip('i18n:label.outline_used') | ||
get outlineUsed (): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the names in other software
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UE: Outlined enableShadow
Godot: outline_size shadow_outline_size
UGUI:皆为单独组件
@cocos-robot run test cases |
@cocos-robot run test cases |
cocos/2d/assembler/label/ttfUtils.ts
Outdated
let shadowComp = LabelShadow && comp.getComponent(LabelShadow); | ||
shadowComp = (shadowComp && shadowComp.enabled) ? shadowComp : null; | ||
if (shadowComp) { | ||
const isShadow = comp.enableShadow && (comp.shadowBlur > 0 || comp.shadowOffset.x !== 0 || comp.shadowOffset.y !== 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use approx
instead!
cocos/2d/components/label-outline.ts
Outdated
/** | ||
* @deprecated since v3.8.2, please use [[Label.enableOutline]] instead. | ||
*/ | ||
public onLoad (): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems not needs onLoad anymore.
cocos/2d/components/label.ts
Outdated
** Outline effect used to change the display, only for system fonts or TTF fonts. | ||
** | ||
** @zh | ||
** 描边效果组件,用于字体描边,只能用于系统字体。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description is not correct. And should hide it when font is BMFont?
fix: gulp-build-h5-source
Revert "fix: gulp-build-h5-source"
Re: https://github.com/cocos/3d-tasks/issues/10661
depend: https://github.com/cocos/engine-extensions/pull/345
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: