diff --git a/frameworks/base/geometry/dimension.h b/frameworks/base/geometry/dimension.h index af9344444c42fd9133e2c77edb851b78efe5ef04..51c8e291e61a63498a3a5301976c3324ab6390b2 100644 --- a/frameworks/base/geometry/dimension.h +++ b/frameworks/base/geometry/dimension.h @@ -148,7 +148,7 @@ public: double GetNativeValue(DimensionUnit unit) const { - if (unit_ == unit) { + if (unit_ == unit || unit == DimensionUnit::PERCENT) { return value_; } else if (unit == DimensionUnit::PX) { return ConvertToPx(); diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 8bf7222c65ff08b66a9231e1c5a76e3f7e7ee15f..5787f04a05ab1441279d93c803ddc9d2221af5f2 100755 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -4233,4 +4233,14 @@ bool ViewAbstract::GetRenderGroup(FrameNode* frameNode) CHECK_NULL_RETURN(target, false); return target->GetRenderGroupValue(false); } + +void ViewAbstract::SetOnVisibleChange(FrameNode* frameNode, std::function &&onVisibleChange, + const std::vector &ratioList) +{ + auto pipeline = PipelineContext::GetCurrentContextSafely(); + CHECK_NULL_VOID(pipeline); + CHECK_NULL_VOID(frameNode); + frameNode->CleanVisibleAreaUserCallback(); + pipeline->AddVisibleAreaChangeNode(AceType::Claim(frameNode), ratioList, onVisibleChange); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/base/view_abstract.h b/frameworks/core/components_ng/base/view_abstract.h index a52b7021b816a10cfa8d653ee78ca5f10072fe94..007040c5fc6d7fbbeb7c81b9679b1e742a2ec3f1 100644 --- a/frameworks/core/components_ng/base/view_abstract.h +++ b/frameworks/core/components_ng/base/view_abstract.h @@ -654,6 +654,8 @@ public: static RenderFit GetRenderFit(FrameNode* frameNode); static BorderColorProperty GetOuterBorderColor(FrameNode* frameNode); static bool GetRenderGroup(FrameNode* frameNode); + static void SetOnVisibleChange(FrameNode* frameNode, std::function &&onVisibleChange, + const std::vector &ratioList); private: static void AddDragFrameNodeToManager(); diff --git a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.cpp b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.cpp index 3bf318fd1f5690d31d42ceb84c21c2228df0a113..84017671ba81aa4e1b17f0fb1dcd476e902a731d 100644 --- a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.cpp @@ -603,4 +603,11 @@ void WaterFlowModelNG::SetScrollToIndex(FrameNode* frameNode, int32_t index, int pattern->ScrollToIndex(index, animation, static_cast(alignment)); } +void WaterFlowModelNG::SetWaterflowFooter(FrameNode* frameNode, FrameNode* footerNode) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->AddFooter(AceType::Claim(footerNode)); +} + } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.h b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.h index 66077a90a6f72b3f2feda50ef6a6a31df19f2e94..9722f82c9f8bbccb4c1aa50f3e313a2d7d087ee5 100644 --- a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.h +++ b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_ng.h @@ -106,6 +106,7 @@ public: static void SetOnScrollFrameBegin(FrameNode* frameNode, OnScrollFrameBeginEvent&& ScrollFrameBegin); static void SetOnScrollIndex(FrameNode* frameNode, ScrollIndexFunc&& onScrollIndex); static void SetScrollToIndex(FrameNode* frameNode, int32_t index, int32_t animation, int32_t alignment); + static void SetWaterflowFooter(FrameNode* frameNode, FrameNode* footerNode); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WATERFLOW_WATER_FLOW_MODEL_NG_H \ No newline at end of file diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index d46751184eda4d09027a2fcc521bdca7b5e424bd..c0791ff105181c5f4e433147a501ee70c94511b1 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -180,6 +180,14 @@ struct ArkUITouchEvent { ArkUI_Int32 interceptResult; }; +struct ArkUIMouseEvent { + ArkUI_Int32 action; + ArkUI_Int32 button; + ArkUI_Int64 timeStamp; + ArkUITouchPoint actionTouchPoint; + ArkUI_Int32 subKind; +}; + struct ArkUIStringAndFloat { ArkUI_Float32 value; ArkUI_CharPtr valueStr; @@ -571,6 +579,7 @@ enum ArkUIEventCategory { GESTURE_ASYNC_EVENT = 6, TOUCH_EVENT = 7, TEXT_ARRAY = 8, + MOUSE_INPUT_EVENT = 9, }; #define ARKUI_MAX_EVENT_NUM 1000 @@ -842,6 +851,7 @@ struct ArkUINodeEvent { ArkUIAPIEventGestureAsyncEvent gestureAsyncEvent; ArkUITouchEvent touchEvent; ArkUIAPIEventTextArray textArrayEvent; + ArkUIMouseEvent mouseEvent; }; }; @@ -1304,6 +1314,8 @@ struct ArkUICommonModifier { void (*getOutlineColor)(ArkUINodeHandle node, ArkUI_Uint32* values); void (*getSize)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit); ArkUI_Bool (*getRenderGroup)(ArkUINodeHandle node); + void (*setOnVisibleAreaChange)( + ArkUINodeHandle node, ArkUI_Int64 extraParam, ArkUI_Float32* values, ArkUI_Int32 size); }; struct ArkUICommonShapeModifier { @@ -2595,6 +2607,8 @@ struct ArkUIWaterFlowModifier { ArkUI_Int32 (*getWaterFlowEnableScrollInteraction)(ArkUINodeHandle node); ArkUI_Float32 (*getWaterFlowFriction)(ArkUINodeHandle node); void (*setScrollToIndex)(ArkUINodeHandle node, ArkUI_Int32 index, ArkUI_Int32 animation, ArkUI_Int32 alignment); + void (*setWaterflowFooter)(ArkUINodeHandle node, ArkUINodeHandle footer); + void (*resetWaterflowFooter)(ArkUINodeHandle node); }; struct ArkUIMenuItemModifier { diff --git a/frameworks/core/interfaces/native/node/node_api.cpp b/frameworks/core/interfaces/native/node/node_api.cpp index c1aaf67ae6beb7f0b75471d7073c6f87e2aea47b..1f521a5749b5528233385f35d8d35faf69097b55 100644 --- a/frameworks/core/interfaces/native/node/node_api.cpp +++ b/frameworks/core/interfaces/native/node/node_api.cpp @@ -254,10 +254,10 @@ const ComponentAsyncEventHandler commonNodeAsyncEventHandlers[] = { NodeModifier::SetOnDisappear, NodeModifier::SetOnTouch, NodeModifier::SetOnClick, - nullptr, + NodeModifier::SetOnHover, NodeModifier::SetOnBlur, nullptr, - nullptr, + NodeModifier::SetOnMouse, NodeModifier::SetOnAreaChange, nullptr, nullptr, diff --git a/frameworks/core/interfaces/native/node/node_common_modifier.cpp b/frameworks/core/interfaces/native/node/node_common_modifier.cpp index deccf92b5147bc06bb897b1b8f9bd4b402fab0a4..7a5888119399c8e90cd8d30c7dba19909c211b1a 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_common_modifier.cpp @@ -5114,6 +5114,25 @@ void SetBackgroundImageSizeWithUnit( ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize); } +void SetOnVisibleAreaChange(ArkUINodeHandle node, ArkUI_Int64 extraParam, ArkUI_Float32* values, ArkUI_Int32 size) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + int32_t nodeId = frameNode->GetId(); + std::vector ratioList(values, values + size); + auto onEvent = [nodeId, extraParam](bool visible, double ratio) { + ArkUINodeEvent event; + event.kind = COMPONENT_ASYNC_EVENT; + event.nodeId = nodeId; + event.extraParam = static_cast(extraParam); + event.componentAsyncEvent.subKind = ON_VISIBLE_AREA_CHANGE; + event.componentAsyncEvent.data[0].i32 = visible; + event.componentAsyncEvent.data[1].f32 = static_cast(ratio); + SendArkUIAsyncEvent(&event); + }; + ViewAbstract::SetOnVisibleChange(frameNode, onEvent, ratioList); +} + } // namespace namespace NodeModifier { @@ -5178,7 +5197,8 @@ const ArkUICommonModifier* GetCommonModifier() GetHeight, GetBackgroundColor, GetBackgroundImage, GetPadding, GetPaddingDimension, GetConfigSize, GetKey, GetEnabled, GetMargin, GetMarginDimension, GetTranslate, SetMoveTransition, GetMoveTransition, ResetMask, GetAspectRatio, SetBackgroundImageResizable, ResetBackgroundImageResizable, - SetBackgroundImageSizeWithUnit, GetRenderFit, GetOutlineColor, GetSize, GetRenderGroup }; + SetBackgroundImageSizeWithUnit, GetRenderFit, GetOutlineColor, GetSize, GetRenderGroup, + SetOnVisibleAreaChange }; return &modifier; } @@ -5521,5 +5541,51 @@ void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam) }; ViewAbstract::SetOnTouchIntercept(frameNode, std::move(onTouchIntercept)); } + +void SetOnHover(ArkUINodeHandle node, void* extraParam) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + int32_t nodeId = frameNode->GetId(); + auto onEvent = [nodeId, extraParam](bool isHover, HoverInfo& info) { + ArkUINodeEvent event; + event.kind = COMPONENT_ASYNC_EVENT; + event.nodeId = nodeId; + event.extraParam = reinterpret_cast(extraParam); + event.componentAsyncEvent.subKind = ON_HOVER; + event.componentAsyncEvent.data[0].i32 = isHover; + SendArkUIAsyncEvent(&event); + }; + ViewAbstract::SetOnHover(frameNode, onEvent); +} + +void SetOnMouse(ArkUINodeHandle node, void* extraParam) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + int32_t nodeId = frameNode->GetId(); + auto onEvent = [nodeId, extraParam](MouseInfo& info) { + ArkUINodeEvent event; + event.kind = MOUSE_INPUT_EVENT; + event.nodeId = nodeId; + event.extraParam = reinterpret_cast(extraParam); + event.mouseEvent.subKind = ON_MOUSE; + event.mouseEvent.actionTouchPoint.nodeX = PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetX()); + event.mouseEvent.actionTouchPoint.nodeY = PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetY()); + event.mouseEvent.button = static_cast(info.GetButton()); + event.mouseEvent.action = static_cast(info.GetAction()); + event.mouseEvent.timeStamp = static_cast(info.GetTimeStamp().time_since_epoch().count()); + event.mouseEvent.actionTouchPoint.windowX = PipelineBase::Px2VpWithCurrentDensity( + info.GetGlobalLocation().GetX()); + event.mouseEvent.actionTouchPoint.windowY = PipelineBase::Px2VpWithCurrentDensity( + info.GetGlobalLocation().GetY()); + event.mouseEvent.actionTouchPoint.screenX = PipelineBase::Px2VpWithCurrentDensity( + info.GetScreenLocation().GetX()); + event.mouseEvent.actionTouchPoint.screenY = PipelineBase::Px2VpWithCurrentDensity( + info.GetScreenLocation().GetY()); + SendArkUIAsyncEvent(&event); + }; + ViewAbstract::SetOnMouse(frameNode, onEvent); +} } // namespace NodeModifier } // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/frameworks/core/interfaces/native/node/node_common_modifier.h b/frameworks/core/interfaces/native/node/node_common_modifier.h index c10738bc06a6ccc1bfe19de717d13a86cbf0a29e..4e6b5e49aea93e65fb03306f8d49ad249215689d 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.h +++ b/frameworks/core/interfaces/native/node/node_common_modifier.h @@ -28,4 +28,6 @@ void SetOnAreaChange(ArkUINodeHandle node, void* extraParam); void SetOnClick(ArkUINodeHandle node, void* extraParam); void SetOnTouch(ArkUINodeHandle node, void* extraParam); void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam); +void SetOnHover(ArkUINodeHandle node, void* extraParam); +void SetOnMouse(ArkUINodeHandle node, void* extraParam); } // namespace OHOS::Ace::NG::NodeModifier diff --git a/frameworks/core/interfaces/native/node/water_flow_modifier.cpp b/frameworks/core/interfaces/native/node/water_flow_modifier.cpp index 9e96d6a0829a104c2cc66073f44b541e9239f17c..a66429679c21291d987088de64e0fdd59a5a01fa 100644 --- a/frameworks/core/interfaces/native/node/water_flow_modifier.cpp +++ b/frameworks/core/interfaces/native/node/water_flow_modifier.cpp @@ -526,6 +526,22 @@ void SetScrollToIndex(ArkUINodeHandle node, ArkUI_Int32 index, ArkUI_Int32 anima WaterFlowModelNG::SetScrollToIndex(frameNode, index, animation, alignment); } +void SetWaterflowFooter(ArkUINodeHandle node, ArkUINodeHandle footer) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + auto* footerNode = reinterpret_cast(footer); + CHECK_NULL_VOID(footerNode); + WaterFlowModelNG::SetWaterflowFooter(frameNode, footerNode); +} + +void ResetWaterflowFooter(ArkUINodeHandle node) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + WaterFlowModelNG::SetWaterflowFooter(frameNode, nullptr); +} + } // namespace namespace NodeModifier { const ArkUIWaterFlowModifier* GetWaterFlowModifier() @@ -542,7 +558,7 @@ const ArkUIWaterFlowModifier* GetWaterFlowModifier() GetWaterFlowBarWidth, SetWaterFlowScrollBarColor, ResetWaterFlowScrollBarColor, GetWaterFlowScrollBarColor, GetEdgeEffect, SetWaterFlowSectionOptions, ResetWaterFlowSectionOptions, GetWaterFlowSectionOptions, GetItemMinWidth, GetItemMaxWidth, GetItemMinHeight, GetItemMaxHeight, GetWaterFlowEnableScrollInteraction, - GetWaterFlowFriction, SetScrollToIndex }; + GetWaterFlowFriction, SetScrollToIndex, SetWaterflowFooter, ResetWaterflowFooter, }; return &modifier; } diff --git a/interfaces/native/event/ui_input_event.cpp b/interfaces/native/event/ui_input_event.cpp index 758f6337992f3e8704b7b99858fc443246b17b73..0629fe78656a5fbd33e5be88a3c86734e59f1abc 100644 --- a/interfaces/native/event/ui_input_event.cpp +++ b/interfaces/native/event/ui_input_event.cpp @@ -147,6 +147,13 @@ int64_t OH_ArkUI_UIInputEvent_GetEventTime(const ArkUI_UIInputEvent* event) } return uiEvent->time.time_since_epoch().count(); } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->timeStamp; + } default: break; } @@ -218,6 +225,13 @@ float OH_ArkUI_PointerEvent_GetX(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.nodeX; + } default: break; } @@ -270,6 +284,13 @@ float OH_ArkUI_PointerEvent_GetY(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.nodeY; + } default: break; } @@ -323,6 +344,13 @@ float OH_ArkUI_PointerEvent_GetWindowX(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.windowX; + } default: break; } @@ -376,6 +404,13 @@ float OH_ArkUI_PointerEvent_GetWindowY(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.windowY; + } default: break; } @@ -429,6 +464,13 @@ float OH_ArkUI_PointerEvent_GetDisplayX(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.screenX; + } default: break; } @@ -482,6 +524,13 @@ float OH_ArkUI_PointerEvent_GetDisplayY(const ArkUI_UIInputEvent* event) } break; } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.screenY; + } default: break; } @@ -974,6 +1023,44 @@ int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* return OHOS::Ace::ERROR_CODE_NO_ERROR; } +int32_t OH_ArkUI_MouseEvent_GetMouseButton(const ArkUI_UIInputEvent* event) +{ + if (!event) { + return -1; + } + switch (event->eventTypeId) { + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return -1; + } + return OHOS::Ace::NodeModel::ConvertToCMouseEventButtonType(mouseEvent->button); + } + default: + break; + } + return -1; +} + +int32_t OH_ArkUI_MouseEvent_GetMouseAction(const ArkUI_UIInputEvent* event) +{ + if (!event) { + return -1; + } + switch (event->eventTypeId) { + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return -1; + } + return OHOS::Ace::NodeModel::ConvertToCMouseActionType(mouseEvent->action); + } + default: + break; + } + return -1; +} + #ifdef __cplusplus }; #endif diff --git a/interfaces/native/event/ui_input_event_impl.h b/interfaces/native/event/ui_input_event_impl.h index 2c10674c0ac892e4eac5cab15bc9afdd01acdb3f..4db68fbe68007bd26e0cc79c7e2def466ca3b352 100644 --- a/interfaces/native/event/ui_input_event_impl.h +++ b/interfaces/native/event/ui_input_event_impl.h @@ -26,6 +26,7 @@ typedef enum { AXIS_EVENT_ID = 0, // defined in ace_engine/frameworks/core/event/axis_event.h TOUCH_EVENT_ID = 1, // defined in ace_engine/frameworks/core/event/touch_event.h C_TOUCH_EVENT_ID = 2, // defined in ace_engine/frameworks/core/interfaces/arkoala/arkoala_api.h + C_MOUSE_EVENT_ID = 3, // defined in ace_engine/frameworks/core/interfaces/arkoala/arkoala_api.h } ArkUIEventTypeId; struct ArkUI_UIInputEvent { diff --git a/interfaces/native/libace.ndk.json b/interfaces/native/libace.ndk.json index 37255e9ffdb34e5411114e21cd44c52d3904d2d5..f3b7477a85adb33717550924bbe86f3fe311f0a0 100644 --- a/interfaces/native/libace.ndk.json +++ b/interfaces/native/libace.ndk.json @@ -667,6 +667,14 @@ "first_introduced": "12", "name": "OH_ArkUI_GetNodeContentFromNapiValue" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_MouseEvent_GetMouseButton" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_MouseEvent_GetMouseAction" + }, { "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_Create" diff --git a/interfaces/native/native_node.h b/interfaces/native/native_node.h index 76975e5344b3e98dccd56f310e58b36dd33aa84a..765f2305fc89876e47d46c4b62c755403b886edf 100644 --- a/interfaces/native/native_node.h +++ b/interfaces/native/native_node.h @@ -1388,6 +1388,68 @@ typedef enum { NODE_LAYOUT_WEIGHT, NODE_DISPLAY_PRIORITY, NODE_OUTLINE_WIDTH, + /** + * @brief 宽度属性,支持属性设置,属性重置和属性获取接口。 + * + * 属性设置方法参数{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:宽度数值,单位为百分比;\n + * \n + * 属性获取方法返回值{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:宽度数值,单位为百分比;\n + * + */ + NODE_WIDTH_PERCENT, + /** + * @brief 高度属性,支持属性设置,属性重置和属性获取接口。 + * + * 属性设置方法参数{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:高度数值,单位为百分比;\n + * \n + * 属性获取方法返回值{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:高度数值,单位为百分比;\n + * + */ + NODE_HEIGHT_PERCENT, + /** + * @brief 内间距属性,支持属性设置,属性重置和属性获取接口。 + * + * 属性设置方法参数{@link ArkUI_AttributeItem}格式有两种:\n + * 1:上下左右四个位置的内间距值相等。\n + * .value[0].f32:内间距数值,单位为百分比;\n + * 2:分别指定上下左右四个位置的内间距值。\n + * .value[0].f32:上内间距数值,单位为百分比;\n + * .value[1].f32:右内间距数值,单位为百分比;\n + * .value[2].f32:下内间距数值,单位为百分比;\n + * .value[3].f32:左内间距数值,单位为百分比;\n + * \n + * 属性获取方法返回值{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:上内间距数值,单位为百分比;\n + * .value[1].f32:右内间距数值,单位为百分比;\n + * .value[2].f32:下内间距数值,单位为百分比;\n + * .value[3].f32:左内间距数值,单位为百分比;\n + * + */ + NODE_PADDING_PERCENT, + /** + * @brief 外间距属性,支持属性设置,属性重置和属性获取接口。 + * + * 属性设置方法参数{@link ArkUI_AttributeItem}格式有两种:\n + * 1:上下左右四个位置的外间距值相等。\n + * .value[0].f32:外间距数值,单位为百分比;\n + * 2:分别指定上下左右四个位置的外间距值。\n + * .value[0].f32:上外间距数值,单位为百分比;\n + * .value[1].f32:右外间距数值,单位为百分比;\n + * .value[2].f32:下外间距数值,单位为百分比;\n + * .value[3].f32:左外间距数值,单位为百分比;\n + * \n + * 属性获取方法返回值{@link ArkUI_AttributeItem}格式:\n + * .value[0].f32:上外间距数值,单位为百分比;\n + * .value[1].f32:右外间距数值,单位为百分比;\n + * .value[2].f32:下外间距数值,单位为百分比;\n + * .value[3].f32:左外间距数值,单位为百分比;\n + * + */ + NODE_MARGIN_PERCENT, NODE_RENDER_FIT, @@ -4298,6 +4360,14 @@ typedef enum { * .value[0].i32: number of cached items in the water flowadapter. \n */ NODE_WATER_FLOW_CACHED_COUNT, + /** + * @brief 设置瀑布流组件末尾的自定义显示组件。 + * + * 属性设置方法{@link ArkUI_AttributeItem}参数格式: \n + * .object:参数类型{@Link ArkUI_NodeHandle}。 + * + */ + NODE_WATER_FLOW_FOOTER, /** * @brief 设置当前瀑布流子组件的约束尺寸属性,组件布局时,进行尺寸范围限制,支持属性设置,属性重置和属性获取接口。 * @@ -4470,6 +4540,34 @@ typedef enum { * {@link ArkUI_UIInputEvent}. \n */ NODE_ON_TOUCH_INTERCEPT, + /** + * @brief 组件可见区域变化事件。 + * + * 触发该事件的条件:组件可见面积与自身面积的比值接近设置的阈值时触发回调。\n + * 传入参数{@link ArkUI_AttributeItem}格式: \n + * .value[0...].f32: 阈值数组,阈值表示组件可见面积与组件自身面积的比值。每个阈值的取值范围均为[0.0, 1.0]\n + * 事件回调发生时,事件参数{@link ArkUI_NodeEvent}对象中的联合体类型为{@link ArkUI_NodeComponentEvent}。\n + * {@link ArkUI_NodeComponentEvent}中包含2个参数:\n + * ArkUI_NodeComponentEvent.data[0].i32:组件可见面积与自身面积的比值与上次变化相比的情况,变大为1,变小为0。\n + * ArkUI_NodeComponentEvent.data[1].f32:触发回调时组件可见面积与自身面积的比值。\n + */ + NODE_EVENT_ON_VISIBLE_AREA_CHANGE, + /** + * @brief 鼠标进入或退出组件事件。 + * + * 触发该事件的条件:鼠标进入或退出组件时触发回调。\n + * 事件回调发生时,事件参数{@link ArkUI_NodeEvent}对象中的联合体类型为{@link ArkUI_NodeComponentEvent}。\n + * {@link ArkUI_NodeComponentEvent}中包含1个参数:\n + * ArkUI_NodeComponentEvent.data[0].i32:鼠标是否悬浮在组件上,鼠标进入时为1,退出时为0。\n + */ + NODE_ON_HOVER, + /** + * @brief 组件点击事件。 + * + * 触发该事件的条件:组件被鼠标按键点击或者鼠标在组件上悬浮移动时触发该回调。\n + * 事件回调发生时,事件参数{@link ArkUI_NodeEvent}对象中的联合体类型为{@link ArkUI_UIInputEvent}。\n + */ + NODE_ON_MOUSE, /** * @brief 文本设置TextDataDetectorConfig且识别成功时,触发onDetectResultUpdate回调。 * diff --git a/interfaces/native/node/event_converter.cpp b/interfaces/native/node/event_converter.cpp index d55b038a16142f774b3ea95a035e2e69df7e9097..78d681f850cc070a484ebc8d8ceccc1f4d797305 100644 --- a/interfaces/native/node/event_converter.cpp +++ b/interfaces/native/node/event_converter.cpp @@ -36,6 +36,14 @@ constexpr int32_t ORIGIN_INPUT_EVENT_TOOL_TYPE_FINGER = 1; constexpr int32_t ORIGIN_INPUT_EVENT_TOOL_TYPE_PEN = 2; constexpr int32_t ORIGIN_INPUT_EVENT_TOOL_TYPE_MOUSE = 7; constexpr int32_t ORIGIN_INPUT_EVENT_TOOL_TYPE_TOUCHPAD = 9; +constexpr int32_t ORIGIN_MOUSE_ACTION_PRESS = 1; +constexpr int32_t ORIGIN_MOUSE_ACTION_RELEASE = 2; +constexpr int32_t ORIGIN_MOUSE_ACTION_MOVE = 3; +constexpr int32_t ORIGIN_MOUSE_BUTTON_LEFT = 1; +constexpr int32_t ORIGIN_MOUSE_BUTTON_RIGHT = 2; +constexpr int32_t ORIGIN_MOUSE_BUTTON_MIDDLE = 4; +constexpr int32_t ORIGIN_MOUSE_BUTTON_BACK = 8; +constexpr int32_t ORIGIN_MOUSE_BUTTON_FORWARD = 16; void ConvertToTouchEvent(const ArkUITouchEvent& origin, ArkUI_NodeTouchEvent& event) { @@ -232,6 +240,12 @@ ArkUI_Int32 ConvertOriginEventType(ArkUI_NodeEventType type, int32_t nodeType) return ON_WATER_FLOW_WILL_SCROLL; case NODE_ON_TOUCH_INTERCEPT: return ON_TOUCH_INTERCEPT; + case NODE_EVENT_ON_VISIBLE_AREA_CHANGE: + return ON_VISIBLE_AREA_CHANGE; + case NODE_ON_HOVER: + return ON_HOVER; + case NODE_ON_MOUSE: + return ON_MOUSE; case NODE_SCROLL_EVENT_ON_REACH_START: if (arkUINodeType == ARKUI_NODE_LIST) { return ON_LIST_REACH_START; @@ -370,6 +384,12 @@ ArkUI_Int32 ConvertToNodeEventType(ArkUIEventSubKind type) return NODE_WATER_FLOW_ON_WILL_SCROLL; case ON_TOUCH_INTERCEPT: return NODE_ON_TOUCH_INTERCEPT; + case ON_VISIBLE_AREA_CHANGE: + return NODE_EVENT_ON_VISIBLE_AREA_CHANGE; + case ON_HOVER: + return NODE_ON_HOVER; + case ON_MOUSE: + return NODE_ON_MOUSE; case ON_LIST_REACH_END: return NODE_SCROLL_EVENT_ON_REACH_END; case ON_WATER_FLOW_REACH_END: @@ -452,6 +472,12 @@ bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_NodeEvent* event) event->kind = ConvertToNodeEventType(subKind); return true; } + case MOUSE_INPUT_EVENT: { + event->category = static_cast(NODE_EVENT_CATEGORY_INPUT_EVENT); + ArkUIEventSubKind subKind = static_cast(origin->mouseEvent.subKind); + event->kind = ConvertToNodeEventType(subKind); + return true; + } default: TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "failed to convert origin event data"); break; @@ -508,6 +534,40 @@ int32_t ConvertToCInputEventToolType(int32_t originSourceToolType) return static_cast(UI_INPUT_EVENT_TOOL_TYPE_UNKNOWN); } +int32_t ConvertToCMouseActionType(int32_t originActionType) +{ + switch (originActionType) { + case ORIGIN_MOUSE_ACTION_PRESS: + return static_cast(UI_MOUSE_EVENT_ACTION_PRESS); + case ORIGIN_MOUSE_ACTION_RELEASE: + return static_cast(UI_MOUSE_EVENT_ACTION_RELEASE); + case ORIGIN_MOUSE_ACTION_MOVE: + return static_cast(UI_MOUSE_EVENT_ACTION_MOVE); + default: + break; + } + return static_cast(UI_MOUSE_EVENT_ACTION_UNKNOWN); +} + +int32_t ConvertToCMouseEventButtonType(int32_t originButtonType) +{ + switch (originButtonType) { + case ORIGIN_MOUSE_BUTTON_LEFT: + return static_cast(UI_MOUSE_EVENT_BUTTON_LEFT); + case ORIGIN_MOUSE_BUTTON_RIGHT: + return static_cast(UI_MOUSE_EVENT_BUTTON_RIGHT); + case ORIGIN_MOUSE_BUTTON_MIDDLE: + return static_cast(UI_MOUSE_EVENT_BUTTON_MIDDLE); + case ORIGIN_MOUSE_BUTTON_BACK: + return static_cast(UI_MOUSE_EVENT_BUTTON_BACK); + case ORIGIN_MOUSE_BUTTON_FORWARD: + return static_cast(UI_MOUSE_EVENT_BUTTON_FORWARD); + default: + break; + } + return static_cast(UI_MOUSE_EVENT_BUTTON_NONE); +} + bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_CompatibleNodeEvent* event) { ArkUIEventCategory eventCategory = static_cast(origin->kind); diff --git a/interfaces/native/node/event_converter.h b/interfaces/native/node/event_converter.h index 6470e669f14398d35302a7725e6bfa9997c5ede0..2ff1e034f3110d07ae6049f881a14c5b9c9f1b64 100644 --- a/interfaces/native/node/event_converter.h +++ b/interfaces/native/node/event_converter.h @@ -54,4 +54,7 @@ int32_t ConvertToCInputEventToolType(int32_t originSourceType); bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_CompatibleNodeEvent* event); bool ConvertEventResult(ArkUI_CompatibleNodeEvent* event, ArkUINodeEvent* origin); +int32_t ConvertToCMouseActionType(int32_t originActionType); +int32_t ConvertToCMouseEventButtonType(int32_t originButtonType); + }; // namespace OHOS::Ace::NodeModel diff --git a/interfaces/native/node/node_model.cpp b/interfaces/native/node/node_model.cpp index a39c0615d7960f0e171d54267de4081e1bb17f08..42b2a90d8197b7a290d9547964e80d71ed5c7942 100644 --- a/interfaces/native/node/node_model.cpp +++ b/interfaces/native/node/node_model.cpp @@ -300,8 +300,25 @@ int32_t RegisterNodeEvent(ArkUI_NodeHandle nodePtr, ArkUI_NodeEventType eventTyp auto* extraData = reinterpret_cast(nodePtr->extraData); extraData->eventMap[eventType] = extraParam; } - impl->getBasicAPI()->registerNodeAsyncEvent( - nodePtr->uiNodeHandle, static_cast(originEventType), reinterpret_cast(nodePtr)); + if (eventType == NODE_EVENT_ON_VISIBLE_AREA_CHANGE) { + auto radio = static_cast(userData); + ArkUI_Int32 radioLength = radio->size; + if (radioLength <= 0) { + return ERROR_CODE_PARAM_INVALID; + } + ArkUI_Float32 radioList[radioLength]; + for (int i = 0; i < radioLength; ++i) { + if (LessNotEqual(radio->value[i].f32, 0.0f) || GreatNotEqual(radio->value[i].f32, 1.0f)) { + return ERROR_CODE_PARAM_INVALID; + } + radioList[i] = radio->value[i].f32; + } + impl->getNodeModifiers()->getCommonModifier()->setOnVisibleAreaChange( + nodePtr->uiNodeHandle, reinterpret_cast(nodePtr), radioList, radioLength); + } else { + impl->getBasicAPI()->registerNodeAsyncEvent( + nodePtr->uiNodeHandle, static_cast(originEventType), reinterpret_cast(nodePtr)); + } return ERROR_CODE_NO_ERROR; } @@ -380,6 +397,11 @@ void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent) uiEvent.eventTypeId = C_TOUCH_EVENT_ID; uiEvent.inputEvent = &(innerEvent->touchEvent); event.origin = &uiEvent; + } else if (eventType == NODE_ON_MOUSE) { + uiEvent.inputType = ARKUI_UIINPUTEVENT_TYPE_MOUSE; + uiEvent.eventTypeId = C_MOUSE_EVENT_ID; + uiEvent.inputEvent = &(innerEvent->mouseEvent); + event.origin = &uiEvent; } else { event.origin = innerEvent; } @@ -418,6 +440,9 @@ int32_t GetNativeNodeEventType(ArkUINodeEvent* innerEvent) case TOUCH_EVENT: subKind = static_cast(innerEvent->touchEvent.subKind); break; + case MOUSE_INPUT_EVENT: + subKind = static_cast(innerEvent->mouseEvent.subKind); + break; default: break; /* Empty */ } diff --git a/interfaces/native/node/style_modifier.cpp b/interfaces/native/node/style_modifier.cpp index 599bff5a079479f9e4645188b36ea3212cd96652..319752c7886f955401131039ee573ff5156f445f 100644 --- a/interfaces/native/node/style_modifier.cpp +++ b/interfaces/native/node/style_modifier.cpp @@ -44,6 +44,7 @@ const std::regex SIZE_TYPE_MAGIC("([0-9]+)([a-z]+)"); constexpr char PARAMS_SEPARATOR_LEVEL1 = ';'; constexpr int UNIT_VP = 1; constexpr int UNIT_FP = 2; +constexpr int UNIT_PERCENT = 3; constexpr int NUM_0 = 0; constexpr int NUM_1 = 1; constexpr int NUM_2 = 2; @@ -2823,6 +2824,132 @@ const ArkUI_AttributeItem* GetOutlineWidth(ArkUI_NodeHandle node) return &g_attributeItem; } +int32_t SetWidthPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM); + if (actualSize < 0 || LessNotEqual(item->value[NUM_0].f32, 0.0f)) { + return ERROR_CODE_PARAM_INVALID; + } + auto* fullImpl = GetFullImpl(); + fullImpl->getNodeModifiers()->getCommonModifier()->setWidth( + node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr); + return ERROR_CODE_NO_ERROR; +} + +void ResetWidthPercent(ArkUI_NodeHandle node) +{ + ResetWidth(node); +} + +const ArkUI_AttributeItem* GetWidthPercent(ArkUI_NodeHandle node) +{ + auto modifier = GetFullImpl()->getNodeModifiers()->getCommonModifier(); + g_numberValues[0].f32 = modifier->getWidth(node->uiNodeHandle, UNIT_PERCENT); + if (LessNotEqual(g_numberValues[0].f32, 0.0f)) { + return nullptr; + } + return &g_attributeItem; +} + +int32_t SetHeightPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM); + if (actualSize < 0 || LessNotEqual(item->value[NUM_0].f32, 0.0f)) { + return ERROR_CODE_PARAM_INVALID; + } + auto* fullImpl = GetFullImpl(); + fullImpl->getNodeModifiers()->getCommonModifier()->setHeight( + node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr); + return ERROR_CODE_NO_ERROR; +} + +void ResetHeightPercent(ArkUI_NodeHandle node) +{ + ResetHeight(node); +} + +const ArkUI_AttributeItem* GetHeightPercent(ArkUI_NodeHandle node) +{ + auto modifier = GetFullImpl()->getNodeModifiers()->getCommonModifier(); + g_numberValues[0].f32 = modifier->getHeight(node->uiNodeHandle, UNIT_PERCENT); + if (LessNotEqual(g_numberValues[0].f32, 0.0f)) { + return nullptr; + } + return &g_attributeItem; +} + +int32_t SetPaddingPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + if (item->size != NUM_1 && item->size != NUM_4) { + return ERROR_CODE_PARAM_INVALID; + } + auto* fullImpl = GetFullImpl(); + int topIndex = NUM_0; + int rightIndex = item->size == NUM_1 ? NUM_0 : NUM_1; + int bottomIndex = item->size == NUM_1 ? NUM_0 : NUM_2; + int leftIndex = item->size == NUM_1 ? NUM_0 : NUM_3; + struct ArkUISizeType top = { item->value[topIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType right = { item->value[rightIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType bottom = { item->value[bottomIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType left = { item->value[leftIndex].f32, UNIT_PERCENT }; + fullImpl->getNodeModifiers()->getCommonModifier()->setPadding(node->uiNodeHandle, &top, &right, &bottom, &left); + return ERROR_CODE_NO_ERROR; +} + +void ResetPaddingPercent(ArkUI_NodeHandle node) +{ + ResetPadding(node); +} + +const ArkUI_AttributeItem* GetPaddingPercent(ArkUI_NodeHandle node) +{ + auto* fullImpl = GetFullImpl(); + ArkUI_Float32 paddings[NUM_4]; + ArkUI_Int32 length = 0; + fullImpl->getNodeModifiers()->getCommonModifier()->getPadding(node->uiNodeHandle, paddings, length, UNIT_PERCENT); + g_numberValues[NUM_0].f32 = paddings[NUM_0]; + g_numberValues[NUM_1].f32 = paddings[NUM_1]; + g_numberValues[NUM_2].f32 = paddings[NUM_2]; + g_numberValues[NUM_3].f32 = paddings[NUM_3]; + return &g_attributeItem; +} + +int32_t SetMarginPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + if (!item || (item->size != NUM_4 && item->size != NUM_1)) { + return ERROR_CODE_PARAM_INVALID; + } + auto* fullImpl = GetFullImpl(); + int topIndex = NUM_0; + int rightIndex = item->size == NUM_1 ? NUM_0 : NUM_1; + int bottomIndex = item->size == NUM_1 ? NUM_0 : NUM_2; + int leftIndex = item->size == NUM_1 ? NUM_0 : NUM_3; + struct ArkUISizeType top = { item->value[topIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType right = { item->value[rightIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType bottom = { item->value[bottomIndex].f32, UNIT_PERCENT }; + struct ArkUISizeType left = { item->value[leftIndex].f32, UNIT_PERCENT }; + fullImpl->getNodeModifiers()->getCommonModifier()->setMargin(node->uiNodeHandle, &top, &right, &bottom, &left); + return ERROR_CODE_NO_ERROR; +} + +void ResetMarginPercent(ArkUI_NodeHandle node) +{ + ResetMargin(node); +} + +const ArkUI_AttributeItem* GetMarginPercent(ArkUI_NodeHandle node) +{ + auto* fullImpl = GetFullImpl(); + ArkUI_Float32 margins[NUM_4]; + ArkUI_Int32 length = 0; + fullImpl->getNodeModifiers()->getCommonModifier()->getMargin(node->uiNodeHandle, margins, length, UNIT_PERCENT); + g_numberValues[NUM_0].f32 = margins[NUM_0]; + g_numberValues[NUM_1].f32 = margins[NUM_1]; + g_numberValues[NUM_2].f32 = margins[NUM_2]; + g_numberValues[NUM_3].f32 = margins[NUM_3]; + return &g_attributeItem; +} + int32_t SetRenderFit(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) { auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM); @@ -9847,6 +9974,25 @@ const ArkUI_AttributeItem* GetWaterFlowCachedCount(ArkUI_NodeHandle node) return &g_attributeItem; } +int32_t SetWaterFlowFooter(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) +{ + if (!item->object) { + return ERROR_CODE_PARAM_INVALID; + } + auto fullImpl = GetFullImpl(); + auto footerNodeHandle = reinterpret_cast(item->object); + fullImpl->getNodeModifiers()->getWaterFlowModifier()->setWaterflowFooter( + node->uiNodeHandle, footerNodeHandle->uiNodeHandle); + return ERROR_CODE_NO_ERROR; +} + +void ResetWaterFlowFooter(ArkUI_NodeHandle node) +{ + // already check in entry point. + auto* fullImpl = GetFullImpl(); + fullImpl->getNodeModifiers()->getWaterFlowModifier()->resetWaterflowFooter(node->uiNodeHandle); +} + int32_t SetWaterFlowSectionOption(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) { CHECK_NULL_RETURN(item, ERROR_CODE_PARAM_INVALID); @@ -10054,6 +10200,10 @@ int32_t SetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI SetLayoutWeight, SetDisplayPriority, SetOutlineWidth, + SetWidthPercent, + SetHeightPercent, + SetPaddingPercent, + SetMarginPercent, SetRenderFit, SetOutlineColor, SetSize, @@ -10140,6 +10290,10 @@ const ArkUI_AttributeItem* GetCommonAttribute(ArkUI_NodeHandle node, int32_t sub GetLayoutWeight, GetDisplayPriority, GetOutlineWidth, + GetWidthPercent, + GetHeightPercent, + GetPaddingPercent, + GetMarginPercent, GetRenderFit, GetOutlineColor, GetSize, @@ -10230,6 +10384,10 @@ void ResetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId) ResetLayoutWeight, ResetDisplayPriority, ResetOutlineWidth, + ResetWidthPercent, + ResetHeightPercent, + ResetPaddingPercent, + ResetMarginPercent, ResetRenderFit, ResetOutlineColor, ResetSize, @@ -11177,7 +11335,7 @@ int32_t SetWaterFlowAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const Ar { static Setter* setters[] = { SetLayoutDirection, SetColumnsTemplate, SetRowsTemplate, SetWaterFlowColumnsGap, SetWaterFlowRowsGap, SetWaterFlowSectionOption, SetWaterFlowNodeAdapter, SetWaterFlowCachedCount, - SetItemConstraintSize, SetWaterFlowScrollToIndex }; + SetWaterFlowFooter, SetItemConstraintSize, SetWaterFlowScrollToIndex }; if (subTypeId >= sizeof(setters) / sizeof(Setter*)) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "waterFlow node attribute: %{public}d NOT IMPLEMENT", subTypeId); return ERROR_CODE_NATIVE_IMPL_TYPE_NOT_SUPPORTED; @@ -11189,7 +11347,7 @@ void ResetWaterFlowAttribute(ArkUI_NodeHandle node, int32_t subTypeId) { static Resetter* resetters[] = { ResetLayoutDirection, ResetColumnsTemplate, ResetRowsTemplate, ResetWaterFlowColumnsGap, ResetWaterFlowRowsGap, ResetWaterFlowSectionOption, ResetWaterFlowNodeAdapter, - ResetWaterFlowCachedCount, ResetItemConstraintSize, nullptr }; + ResetWaterFlowCachedCount, ResetWaterFlowFooter, ResetItemConstraintSize, nullptr }; if (subTypeId >= sizeof(resetters) / sizeof(Resetter*)) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "waterFlow node attribute: %{public}d NOT IMPLEMENT", subTypeId); return; @@ -11201,7 +11359,7 @@ const ArkUI_AttributeItem* GetWaterFlowAttribute(ArkUI_NodeHandle node, int32_t { static Getter* getters[] = { GetLayoutDirection, GetColumnsTemplate, GetRowsTemplate, GetWaterFlowColumnsGap, GetWaterFlowRowsGap, GetWaterFlowSectionOption, GetWaterFlowNodeAdapter, GetWaterFlowCachedCount, - GetItemConstraintSize, nullptr }; + nullptr, GetItemConstraintSize, nullptr }; if (subTypeId >= sizeof(getters) / sizeof(Getter*)) { TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "waterFlow node attribute: %{public}d NOT IMPLEMENT", subTypeId); return nullptr; diff --git a/interfaces/native/ui_input_event.h b/interfaces/native/ui_input_event.h index 2be245513ff14d568e161f9ce3567b39745c35c3..d380670278887b3702272de2d0011327c9eae125 100644 --- a/interfaces/native/ui_input_event.h +++ b/interfaces/native/ui_input_event.h @@ -57,6 +57,7 @@ typedef enum { ARKUI_UIINPUTEVENT_TYPE_UNKNOWN = 0, ARKUI_UIINPUTEVENT_TYPE_TOUCH = 1, ARKUI_UIINPUTEVENT_TYPE_AXIS = 2, + ARKUI_UIINPUTEVENT_TYPE_MOUSE = 3, } ArkUI_UIInputEvent_Type; /** @@ -141,6 +142,42 @@ typedef enum { HTM_NONE, } HitTestMode; +/** + * @brief 定义鼠标事件的Action Code。 + * + * @since 12 + */ +enum { + /** 无效行为 */ + UI_MOUSE_EVENT_ACTION_UNKNOWN = 0, + /** 鼠标按键按下。 */ + UI_MOUSE_EVENT_ACTION_PRESS = 1, + /** 鼠标按键松开。 */ + UI_MOUSE_EVENT_ACTION_RELEASE = 2, + /** 鼠标移动。 */ + UI_MOUSE_EVENT_ACTION_MOVE = 3, +}; + +/** + * @brief 定义鼠标事件的按键类型。 + * + * @since 12 + */ +enum { + /** 无按键。 */ + UI_MOUSE_EVENT_BUTTON_NONE = 0, + /** 鼠标左键。 */ + UI_MOUSE_EVENT_BUTTON_LEFT = 1, + /** 鼠标右键。 */ + UI_MOUSE_EVENT_BUTTON_RIGHT = 2, + /** 鼠标中键。 */ + UI_MOUSE_EVENT_BUTTON_MIDDLE = 3, + /** 鼠标左侧后退键。 */ + UI_MOUSE_EVENT_BUTTON_BACK = 4, + /** 鼠标左侧前进键。 */ + UI_MOUSE_EVENT_BUTTON_FORWARD = 5, +}; + /** * @brief Obtains the type of this UI input event. * @@ -629,6 +666,24 @@ double OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(const ArkUI_UIInputEvent* event */ int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* event, HitTestMode mode); +/** + * @brief 获取鼠标事件的按键类型的值。 + * + * @param event 表示指向当前UI输入事件的指针。 + * @return 返回鼠标按键类型,1为左键,2为右键,3为中键,4为后退键,5为前进键。 + * @since 12 + */ +int32_t OH_ArkUI_MouseEvent_GetMouseButton(const ArkUI_UIInputEvent* event); + +/** + * @brief 获取鼠标事件的鼠标动作类型的值。 + * + * @param event 表示指向当前UI输入事件的指针。 + * @return 返回鼠标动作类型,1表示按键按下,2表示按键松开,3表示鼠标移动。 + * @since 12 + */ +int32_t OH_ArkUI_MouseEvent_GetMouseAction(const ArkUI_UIInputEvent* event); + #ifdef __cplusplus }; #endif