From f4a94fcf886bf8abdead941ec32cc2d173b89428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E7=BA=A2=E6=9D=B0?= Date: Sat, 13 Sep 2025 16:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E7=BB=84=E4=BB=B6=E5=8F=8D?= =?UTF-8?q?=E8=89=B2C-API=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石红杰 Change-Id: Ie95b3cd8b9901f5f784d07e647d5f14092c131d2 --- .../core/interfaces/arkoala/arkoala_api.h | 7 +++ .../node/node_list_item_group_modifier.cpp | 33 +++++++++++ .../native/node/node_list_modifier.cpp | 55 +++++++++++++++++++ .../native/node/node_scroll_modifier.cpp | 19 +++++++ .../native/node/water_flow_modifier.cpp | 20 +++++++ interfaces/native/node/style_modifier.cpp | 16 +++--- 6 files changed, 141 insertions(+), 9 deletions(-) diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index ebf7a214d18..f5603860693 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -3424,6 +3424,7 @@ struct ArkUIListModifier { void (*resetListScrollBarWidth)(ArkUINodeHandle node); ArkUI_Uint32 (*getListScrollBarColor)(ArkUINodeHandle node); void (*setListScrollBarColor)(ArkUINodeHandle node, ArkUI_CharPtr value); + void (*setListScrollBarColorPtr)(ArkUINodeHandle node, ArkUI_Int32 color, void* colorRawPtr); void (*resetListScrollBarColor)(ArkUINodeHandle node); ArkUI_Int32 (*getAlignListItem)(ArkUINodeHandle node); void (*setAlignListItem)(ArkUINodeHandle node, ArkUI_Int32 listItemAlign); @@ -3439,6 +3440,8 @@ struct ArkUIListModifier { ArkUI_Float32 (*getContentEndOffset)(ArkUINodeHandle node); void (*listSetDivider)(ArkUINodeHandle node, const ArkUI_Uint32 color, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + void (*listSetDividerPtr)(ArkUINodeHandle node, const ArkUI_Uint32 color, const ArkUI_Float32* values, + const ArkUI_Int32* units, ArkUI_Int32 length, void* colorRawPtr); void (*listResetDivider)(ArkUINodeHandle node); void (*setChainAnimationOptions)( ArkUINodeHandle node, const struct ArkUIChainAnimationOptionsType* chainAnimationOptions); @@ -3523,6 +3526,8 @@ struct ArkUIListModifier { struct ArkUIListItemGroupModifier { void (*listItemGroupSetDivider)(ArkUINodeHandle node, ArkUI_Uint32 color, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + void (*listItemGroupSetDividerPtr)(ArkUINodeHandle node, ArkUI_Uint32 color, const ArkUI_Float32* values, + const ArkUI_Int32* units, ArkUI_Int32 length, void* colorRawPtr); void (*listItemGroupResetDivider)(ArkUINodeHandle node); void (*listItemGroupSetHeader)(ArkUINodeHandle node, ArkUINodeHandle header); void (*listItemGroupResetHeader)(ArkUINodeHandle node); @@ -4026,6 +4031,7 @@ struct ArkUIScrollModifier { void (*resetScrollScrollable)(ArkUINodeHandle node); ArkUI_Uint32 (*getScrollScrollBarColor)(ArkUINodeHandle node); void (*setScrollScrollBarColor)(ArkUINodeHandle node, ArkUI_Uint32 scrollBarColor); + void (*setScrollScrollBarColorPtr)(ArkUINodeHandle node, ArkUI_Uint32 scrollBarColor, void* colorRawPtr); void (*resetScrollScrollBarColor)(ArkUINodeHandle node); ArkUI_Float32 (*getScrollScrollBarWidth)(ArkUINodeHandle node); void (*setScrollScrollBarWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); @@ -5470,6 +5476,7 @@ struct ArkUIWaterFlowModifier { void (*resetWaterFlowScrollBarWidth)(ArkUINodeHandle node); ArkUI_Float32 (*getWaterFlowScrollBarWidth)(ArkUINodeHandle node); void (*setWaterFlowScrollBarColor)(ArkUINodeHandle node, ArkUI_CharPtr value); + void (*setWaterFlowScrollBarColorPtr)(ArkUINodeHandle node, ArkUI_Int32 color, void* colorRawPtr); void (*resetWaterFlowScrollBarColor)(ArkUINodeHandle node); ArkUI_Uint32 (*getWaterFlowScrollBarColor)(ArkUINodeHandle node); ArkUI_Int32 (*getEdgeEffect)(ArkUINodeHandle node, ArkUI_Int32 (*values)[3]); diff --git a/frameworks/core/interfaces/native/node/node_list_item_group_modifier.cpp b/frameworks/core/interfaces/native/node/node_list_item_group_modifier.cpp index b3ec2f2f84e..c7ee578b100 100755 --- a/frameworks/core/interfaces/native/node/node_list_item_group_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_list_item_group_modifier.cpp @@ -16,6 +16,7 @@ #include "interfaces/native/node/list_option.h" #include "bridge/common/utils/utils.h" +#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/pattern/list/list_item_group_model_ng.h" #include "core/interfaces/native/node/node_adapter_impl.h" @@ -44,6 +45,37 @@ void ListItemGroupSetDivider( ListItemGroupModelNG::SetDivider(frameNode, divider); } +void ListItemGroupSetDividerPtr(ArkUINodeHandle node, ArkUI_Uint32 color, const ArkUI_Float32* values, + const ArkUI_Int32* units, ArkUI_Int32 length, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + + if (length != DEFAULT_GROUP_DIVIDER_VALUES_COUNT) { + return; + } + + V2::ItemDivider divider; + + Color result = Color(color); + if (SystemProperties::ConfigChangePerform()) { + RefPtr resObj; + if (!colorRawPtr) { + ResourceParseUtils::CompleteResourceObjectFromColor(resObj, result, frameNode->GetTag()); + } else { + resObj = AceType::Claim(reinterpret_cast(colorRawPtr)); + } + ListItemGroupModelNG::ParseResObjDividerColor(frameNode, resObj); + } + divider.color = Color(color); + + divider.strokeWidth = Dimension(values[CALL_ARG_0], static_cast(units[CALL_ARG_0])); + divider.startMargin = Dimension(values[CALL_ARG_1], static_cast(units[CALL_ARG_1])); + divider.endMargin = Dimension(values[CALL_ARG_2], static_cast(units[CALL_ARG_2])); + + ListItemGroupModelNG::SetDivider(frameNode, divider); +} + void ListItemGroupResetDivider(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -220,6 +252,7 @@ const ArkUIListItemGroupModifier* GetListItemGroupModifier() CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line static const ArkUIListItemGroupModifier modifier = { .listItemGroupSetDivider = ListItemGroupSetDivider, + .listItemGroupSetDividerPtr = ListItemGroupSetDividerPtr, .listItemGroupResetDivider = ListItemGroupResetDivider, .listItemGroupSetHeader = ListItemGroupSetHeader, .listItemGroupResetHeader = ListItemGroupResetHeader, diff --git a/frameworks/core/interfaces/native/node/node_list_modifier.cpp b/frameworks/core/interfaces/native/node/node_list_modifier.cpp index 6e0c8dcfcbd..c711638417e 100644 --- a/frameworks/core/interfaces/native/node/node_list_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_list_modifier.cpp @@ -17,6 +17,7 @@ #include "interfaces/native/node/list_option.h" #include "interfaces/native/node/node_model.h" +#include "core/common/resource/resource_parse_utils.h" #include "core/components/list/list_theme.h" #include "core/components_ng/pattern/list/list_model_ng.h" #include "core/components_ng/pattern/scrollable/scrollable_model_ng.h" @@ -450,6 +451,24 @@ void SetListScrollBarColor(ArkUINodeHandle node, ArkUI_CharPtr value) ListModelNG::SetListScrollBarColor(frameNode, value); } +void SetListScrollBarColorPtr(ArkUINodeHandle node, ArkUI_Int32 color, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + Color result = Color(color); + auto value = Color(color).ColorToString(); + ListModelNG::SetListScrollBarColor(frameNode, value); + if (SystemProperties::ConfigChangePerform()) { + RefPtr resObj; + if (!colorRawPtr) { + ResourceParseUtils::CompleteResourceObjectFromColor(resObj, result, frameNode->GetTag()); + } else { + resObj = AceType::Claim(reinterpret_cast(colorRawPtr)); + } + ListModelNG::CreateWithResourceObjScrollBarColor(frameNode, resObj); + } +} + void ResetListScrollBarColor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -565,6 +584,40 @@ void ListSetDivider( ListModelNG::SetDivider(frameNode, divider); } +void ListSetDividerPtr(ArkUINodeHandle node, ArkUI_Uint32 color, const ArkUI_Float32 *values, const int32_t *units, + ArkUI_Int32 length, void *colorRawPtr) +{ + auto *frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + + if (length != DEFAULT_DIVIDER_VALUES_COUNT) { + return; + } + + V2::ItemDivider divider; + + Color result = Color(color); + if (SystemProperties::ConfigChangePerform()) { + RefPtr resObj; + if (!colorRawPtr) { + ResourceParseUtils::CompleteResourceObjectFromColor(resObj, result, frameNode->GetTag()); + } else { + resObj = AceType::Claim(reinterpret_cast(colorRawPtr)); + } + ListModelNG::ParseResObjDividerColor(frameNode, resObj); + } + divider.color = Color(color); + + divider.strokeWidth = + Dimension(values[CALL_STROKE_WIDTH], static_cast(units[CALL_STROKE_WIDTH])); + divider.startMargin = + Dimension(values[CALL_START_MARGIN], static_cast(units[CALL_START_MARGIN])); + divider.endMargin = + Dimension(values[CALL_END_MARGIN], static_cast(units[CALL_END_MARGIN])); + + ListModelNG::SetDivider(frameNode, divider); +} + void ListResetDivider(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -959,6 +1012,7 @@ const ArkUIListModifier* GetListModifier() .resetListScrollBarWidth = ResetListScrollBarWidth, .getListScrollBarColor = GetListScrollBarColor, .setListScrollBarColor = SetListScrollBarColor, + .setListScrollBarColorPtr = SetListScrollBarColorPtr, .resetListScrollBarColor = ResetListScrollBarColor, .getAlignListItem = GetAlignListItem, .setAlignListItem = SetAlignListItem, @@ -973,6 +1027,7 @@ const ArkUIListModifier* GetListModifier() .resetContentEndOffset = ResetContentEndOffset, .getContentEndOffset = GetContentEndOffset, .listSetDivider = ListSetDivider, + .listSetDividerPtr = ListSetDividerPtr, .listResetDivider = ListResetDivider, .setChainAnimationOptions = SetChainAnimationOptions, .resetChainAnimationOptions = ResetChainAnimationOptions, diff --git a/frameworks/core/interfaces/native/node/node_scroll_modifier.cpp b/frameworks/core/interfaces/native/node/node_scroll_modifier.cpp index 3787ebca0d6..261d0e206dd 100644 --- a/frameworks/core/interfaces/native/node/node_scroll_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_scroll_modifier.cpp @@ -15,6 +15,7 @@ #include "core/interfaces/native/node/node_scroll_modifier.h" #include "interfaces/native/node/node_model.h" +#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/pattern/list/list_model_ng.h" #include "core/components_ng/pattern/scroll/scroll_model_ng.h" #include "core/components_ng/pattern/scrollable/scrollable_model_ng.h" @@ -261,6 +262,23 @@ void SetScrollScrollBarColor(ArkUINodeHandle node, uint32_t scrollBarColor) ScrollModelNG::SetScrollBarColor(frameNode, Color(scrollBarColor)); } +void SetScrollScrollBarColorPtr(ArkUINodeHandle node, uint32_t scrollBarColor, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + Color result = Color(scrollBarColor); + if (SystemProperties::ConfigChangePerform()) { + RefPtr resObj; + if (!colorRawPtr) { + ResourceParseUtils::CompleteResourceObjectFromColor(resObj, result, frameNode->GetTag()); + } else { + resObj = AceType::Claim(reinterpret_cast(colorRawPtr)); + } + ScrollModelNG::CreateWithResourceObjScrollBarColor(frameNode, resObj); + } + ScrollModelNG::SetScrollBarColor(frameNode, Color(scrollBarColor)); +} + void ResetScrollScrollBarColor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -792,6 +810,7 @@ const ArkUIScrollModifier* GetScrollModifier() .resetScrollScrollable = ResetScrollScrollable, .getScrollScrollBarColor = GetScrollScrollBarColor, .setScrollScrollBarColor = SetScrollScrollBarColor, + .setScrollScrollBarColorPtr = SetScrollScrollBarColorPtr, .resetScrollScrollBarColor = ResetScrollScrollBarColor, .getScrollScrollBarWidth = GetScrollScrollBarWidth, .setScrollScrollBarWidth = SetScrollScrollBarWidth, diff --git a/frameworks/core/interfaces/native/node/water_flow_modifier.cpp b/frameworks/core/interfaces/native/node/water_flow_modifier.cpp index 8930f54a481..7575ec75889 100644 --- a/frameworks/core/interfaces/native/node/water_flow_modifier.cpp +++ b/frameworks/core/interfaces/native/node/water_flow_modifier.cpp @@ -17,6 +17,7 @@ #include "interfaces/native/node/node_model.h" #include "interfaces/native/node/waterflow_section_option.h" +#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/pattern/scrollable/scrollable_model_ng.h" #include "core/components_ng/pattern/waterflow/water_flow_model_ng.h" #include "core/interfaces/native/node/node_adapter_impl.h" @@ -452,6 +453,24 @@ void SetWaterFlowScrollBarColor(ArkUINodeHandle node, ArkUI_CharPtr value) WaterFlowModelNG::SetScrollBarColor(frameNode, value); } +void SetWaterFlowScrollBarColorPtr(ArkUINodeHandle node, ArkUI_Int32 color, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + Color result = Color(color); + if (SystemProperties::ConfigChangePerform()) { + RefPtr resObj; + if (!colorRawPtr) { + ResourceParseUtils::CompleteResourceObjectFromColor(resObj, result, frameNode->GetTag()); + } else { + resObj = AceType::Claim(reinterpret_cast(colorRawPtr)); + } + WaterFlowModelNG::ParseResObjScrollBarColor(frameNode, resObj); + } + auto value = Color(color).ColorToString(); + WaterFlowModelNG::SetScrollBarColor(frameNode, value); +} + void ResetWaterFlowScrollBarColor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -768,6 +787,7 @@ const ArkUIWaterFlowModifier* GetWaterFlowModifier() .resetWaterFlowScrollBarWidth = ResetWaterFlowBarWidth, .getWaterFlowScrollBarWidth = GetWaterFlowBarWidth, .setWaterFlowScrollBarColor = SetWaterFlowScrollBarColor, + .setWaterFlowScrollBarColorPtr = SetWaterFlowScrollBarColorPtr, .resetWaterFlowScrollBarColor = ResetWaterFlowScrollBarColor, .getWaterFlowScrollBarColor = GetWaterFlowScrollBarColor, .getEdgeEffect = GetEdgeEffect, diff --git a/interfaces/native/node/style_modifier.cpp b/interfaces/native/node/style_modifier.cpp index 7b7ac11b10b..db9694590f6 100644 --- a/interfaces/native/node/style_modifier.cpp +++ b/interfaces/native/node/style_modifier.cpp @@ -6144,14 +6144,12 @@ int32_t SetScrollScrollBarColor(ArkUI_NodeHandle node, const ArkUI_AttributeItem auto fullImpl = GetFullImpl(); auto color = item->value[NUM_0].u32; if (node->type == ARKUI_NODE_LIST) { - auto value = Color(color).ColorToString(); - fullImpl->getNodeModifiers()->getListModifier()->setListScrollBarColor(node->uiNodeHandle, value.c_str()); + fullImpl->getNodeModifiers()->getListModifier()->setListScrollBarColorPtr(node->uiNodeHandle, color, nullptr); } else if (node->type == ARKUI_NODE_SCROLL) { - fullImpl->getNodeModifiers()->getScrollModifier()->setScrollScrollBarColor(node->uiNodeHandle, color); + fullImpl->getNodeModifiers()->getScrollModifier()->setScrollScrollBarColorPtr(node->uiNodeHandle, color, nullptr); } else if (node->type == ARKUI_NODE_WATER_FLOW) { - auto value = Color(color).ColorToString(); - fullImpl->getNodeModifiers()->getWaterFlowModifier()->setWaterFlowScrollBarColor( - node->uiNodeHandle, value.c_str()); + fullImpl->getNodeModifiers()->getWaterFlowModifier()->setWaterFlowScrollBarColorPtr( + node->uiNodeHandle, color, nullptr); } else if (node->type == ARKUI_NODE_GRID) { fullImpl->getNodeModifiers()->getGridModifier()->setGridScrollBarColor(node->uiNodeHandle, color); } @@ -7158,7 +7156,7 @@ int32_t SetListDivider(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) ArkUI_Float32 values[NUM_3] = { item->value[NUM_1].f32, item->value[NUM_2].f32, item->value[NUM_3].f32 }; ArkUI_Int32 units[NUM_3] = { unit, unit, unit }; - fullImpl->getNodeModifiers()->getListModifier()->listSetDivider(node->uiNodeHandle, color, values, units, NUM_3); + fullImpl->getNodeModifiers()->getListModifier()->listSetDividerPtr(node->uiNodeHandle, color, values, units, NUM_3, nullptr); return ERROR_CODE_NO_ERROR; } @@ -9576,8 +9574,8 @@ int32_t SetListItemGroupDivider(ArkUI_NodeHandle node, const ArkUI_AttributeItem ArkUI_Float32 values[NUM_3] = { item->value[NUM_1].f32, item->value[NUM_2].f32, item->value[NUM_3].f32 }; ArkUI_Int32 units[NUM_3] = { unit, unit, unit }; - fullImpl->getNodeModifiers()->getListItemGroupModifier()->listItemGroupSetDivider( - node->uiNodeHandle, color, values, units, NUM_3); + fullImpl->getNodeModifiers()->getListItemGroupModifier()->listItemGroupSetDividerPtr( + node->uiNodeHandle, color, values, units, NUM_3, nullptr); return ERROR_CODE_NO_ERROR; } -- Gitee