From 80dd0fcc3ec66650c70a139d5d8937fc6be7f97b Mon Sep 17 00:00:00 2001 From: wanjining Date: Thu, 26 Sep 2024 15:42:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=91=E5=8D=955.0Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanjining --- .../pattern/text/text_model_ng.cpp | 7 ++++ .../pattern/text/text_model_ng.h | 1 + .../core/interfaces/arkoala/arkoala_api.h | 1 + .../native/node/node_text_modifier.cpp | 8 +++++ interfaces/native/native_node.h | 12 +++++++ interfaces/native/node/style_modifier.cpp | 36 ++++++++++++++++--- 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp index afa2f5fdeda..7acb53de31a 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp @@ -1106,4 +1106,11 @@ void TextModelNG::SetHalfLeading(FrameNode* frameNode, bool halfLeading) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextLayoutProperty, HalfLeading, halfLeading, frameNode); } + +bool TextModelNG::GetHalfLeading(FrameNode* frameNode) +{ + bool value = false; + ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(TextLayoutProperty, HalfLeading, value, frameNode, value); + return value; +} } // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.h b/frameworks/core/components_ng/pattern/text/text_model_ng.h index 63a1be3ca03..24e766891fa 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.h +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.h @@ -173,6 +173,7 @@ public: static void SetSelectionMenuOptions(FrameNode* frameNode, const NG::OnCreateMenuCallback&& onCreateMenuCallback, const NG::OnMenuItemClickCallback&& onMenuItemClick); static void SetHalfLeading(FrameNode* frameNode, bool halfLeading); + static bool GetHalfLeading(FrameNode* frameNode); }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 74110082dff..81105c45dd2 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -2055,6 +2055,7 @@ struct ArkUITextModifier { void (*resetTextMaxFontScale)(ArkUINodeHandle node); void (*setTextHalfLeading)(ArkUINodeHandle node, ArkUI_Bool value); void (*resetTextHalfLeading)(ArkUINodeHandle node); + ArkUI_Int32 (*getTextHalfLeading)(ArkUINodeHandle node); void (*setTextOnClick)(ArkUINodeHandle node, void* callback); void (*resetTextOnClick)(ArkUINodeHandle node); void (*setTextResponseRegion)( diff --git a/frameworks/core/interfaces/native/node/node_text_modifier.cpp b/frameworks/core/interfaces/native/node/node_text_modifier.cpp index 8347be2cd1a..0f32c3773c8 100644 --- a/frameworks/core/interfaces/native/node/node_text_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_text_modifier.cpp @@ -1159,6 +1159,13 @@ void ResetTextHalfLeading(ArkUINodeHandle node) CHECK_NULL_VOID(frameNode); TextModelNG::SetHalfLeading(frameNode, false); } + +ArkUI_Int32 GetTextHalfLeading(ArkUINodeHandle node) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_RETURN(frameNode, false); + return static_cast(TextModelNG::GetHalfLeading(frameNode)); +} } // namespace namespace NodeModifier { @@ -1188,6 +1195,7 @@ const ArkUITextModifier* GetTextModifier() ResetTextDataDetectorConfigWithEvent, SetTextOnCopy, ResetTextOnCopy, SetTextOnTextSelectionChange, ResetTextOnTextSelectionChange, SetTextSelectionMenuOptions, ResetTextSelectionMenuOptions, SetTextMinFontScale, ResetTextMinFontScale, SetTextMaxFontScale, ResetTextMaxFontScale, SetTextHalfLeading, ResetTextHalfLeading, + GetTextHalfLeading, SetOnClick, ResetOnClick, SetResponseRegion, ResetResponseRegion }; return &modifier; diff --git a/interfaces/native/native_node.h b/interfaces/native/native_node.h index 2624c2b1900..3ad1074fbb8 100644 --- a/interfaces/native/native_node.h +++ b/interfaces/native/native_node.h @@ -2024,6 +2024,18 @@ typedef enum { */ NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** + * @brief 设置文本居中显示。 + * + * 属性设置方法参数{@link ArkUI_AttributeItem}格式:\n + * .value[0].i32:文本是否居中,默认值false。\n + * \n + * 属性获取方法返回值{@link ArkUI_AttributeItem}格式:\n + * .value[0].i32:文本是否居中。\n + * + */ + NODE_TEXT_HALF_LEADING = 1029, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * diff --git a/interfaces/native/node/style_modifier.cpp b/interfaces/native/node/style_modifier.cpp index 43755c01cfc..8a919d3dc96 100644 --- a/interfaces/native/node/style_modifier.cpp +++ b/interfaces/native/node/style_modifier.cpp @@ -9433,6 +9433,33 @@ void ResetTextContentWithStyledString(ArkUI_NodeHandle node) fullImpl->getNodeModifiers()->getTextModifier()->resetTextContentWithStyledString(node->uiNodeHandle); } +int32_t SetHalfLeading(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM); + if (actualSize < 0 || !InRegion(NUM_0, NUM_1, item->value[NUM_0].i32)) { + return ERROR_CODE_PARAM_INVALID; + } + // already check in entry point. + auto* fullImpl = GetFullImpl(); + fullImpl->getNodeModifiers()->getTextModifier()->setTextHalfLeading( + node->uiNodeHandle, item->value[NUM_0].i32); + return ERROR_CODE_NO_ERROR; +} + +const ArkUI_AttributeItem* GetHalfLeading(ArkUI_NodeHandle node) +{ + auto fullImpl = GetFullImpl(); + g_numberValues[0].i32 = fullImpl->getNodeModifiers()->getTextModifier()->getTextHalfLeading(node->uiNodeHandle); + g_attributeItem.size = REQUIRED_ONE_PARAM; + return &g_attributeItem; +} + +void ResetHalfLeading(ArkUI_NodeHandle node) +{ + auto* fullImpl = GetFullImpl(); + fullImpl->getNodeModifiers()->getTextModifier()->resetTextHalfLeading(node->uiNodeHandle); +} + const ArkUI_AttributeItem* GetTextEllipsisMode(ArkUI_NodeHandle node) { auto fullImpl = GetFullImpl(); @@ -12847,7 +12874,7 @@ int32_t SetTextAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI_A SetTextCopyOption, SetBaseLineOffset, SetTextShadow, SetTextMinFontSize, SetTextMaxFontSize, SetTextFont, SetTextHeightAdaptivePolicy, SetTextIndent, SetTextWordBreak, SetTextEllipsisMode, SetLineSpacing, SetFontFeature, SetTextEnableDateDetector, SetTextDataDetectorConfig, SetTextSelectedBackgroundColor, - SetTextContentWithStyledString }; + SetTextContentWithStyledString, SetHalfLeading }; if (static_cast(subTypeId) >= sizeof(setters) / sizeof(Setter*)) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "text node attribute: %{public}d NOT IMPLEMENT", subTypeId); return ERROR_CODE_NATIVE_IMPL_TYPE_NOT_SUPPORTED; @@ -12861,8 +12888,9 @@ const ArkUI_AttributeItem* GetTextAttribute(ArkUI_NodeHandle node, int32_t subTy GetDecoration, GetTextCase, GetLetterSpacing, GetMaxLines, GetTextAlign, GetTextOverflow, GetTextFontFamily, GetTextCopyOption, GetBaseLineOffset, GetTextShadow, GetTextMinFontSize, GetTextMaxFontSize, GetTextFont, GetTextHeightAdaptivePolicy, GetTextIndent, GetTextWordBreak, GetTextEllipsisMode, GetLineSpacing, - GetFontFeature, GetTextEnableDateDetector, GetTextDataDetectorConfig, GetTextSelectedBackgroundColor }; - if (static_cast(subTypeId) >= sizeof(getters) / sizeof(Getter*)) { + GetFontFeature, GetTextEnableDateDetector, GetTextDataDetectorConfig, GetTextSelectedBackgroundColor, + nullptr, GetHalfLeading }; + if (static_cast(subTypeId) >= sizeof(getters) / sizeof(Getter*) || !getters[subTypeId]) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "text node attribute: %{public}d NOT IMPLEMENT", subTypeId); return nullptr; } @@ -12877,7 +12905,7 @@ void ResetTextAttribute(ArkUI_NodeHandle node, int32_t subTypeId) ResetTextOverflow, ResetTextFontFamily, ResetTextCopyOption, ResetBaselineOffset, ResetTextShadow, ResetTextMinFontSize, ResetTextMaxFontSize, ResetTextFont, ResetTextHeightAdaptivePolicy, ResetTextIndent, ResetTextWordBreak, ResetTextEllipsisMode, ResetLineSpacing, ResetFontFeature, ResetTextEnableDateDetector, - ResetTextDataDetectorConfig, ResetTextSelectedBackgroundColor, ResetTextContentWithStyledString }; + ResetTextDataDetectorConfig, ResetTextSelectedBackgroundColor, ResetTextContentWithStyledString, ResetHalfLeading }; if (static_cast(subTypeId) >= sizeof(resetters) / sizeof(Resetter*)) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "text node attribute: %{public}d NOT IMPLEMENT", subTypeId); return;