diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index dc3d30be4c1491c195b569a958e86367b7945d40..2f99b8e4645d47838c9a89568ce6b131024bf0df 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -4138,5 +4138,29 @@ { "first_introduced": "21", "name": "OH_ArkUI_ContentTransitionEffect_Create" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_UIInputEvent_GetCoastingAxisEvent" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_CoastingAxisEvent_GetEventTime" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_CoastingAxisEvent_GetPhase" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_CoastingAxisEvent_GetDeltaX" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_CoastingAxisEvent_GetDeltaY" + }, + { + "first_introduced": "21", + "name": "OH_ArkUI_CoastingAxisEvent_SetPropagation" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 5cbcdce4fe3a2dc29ba2d8d8b50f0cefecea390e..ba70c98b28c39cc65312a48abe18ab5a26cd1115 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -7546,6 +7546,22 @@ typedef enum { */ NODE_ON_SIZE_CHANGE = 30, + /** + * @brief Defines the coasting axis event. + * + * The event is triggered when user swipes with two fingers on the touchpad, the system constructs + * sliding events based on the speed at the moment the fingers are lifted, according to a certain + * decay curve. You can listen for such events to handle the flick effect immediately after the + * regular axis events. \n + * When the event callback occurs, the {@link ArkUI_UIInputEvent} object can be obtained from the + * {@link ArkUI_NodeEvent} object through {@link OH_ArkUI_NodeEvent_GetInputEvent}. + * And the {@link ArkUI_CoastingAxisEvent} object can be obtained from the {@link ArkUI_UIInputEvent} + * object through {@link OH_ArkUI_UIInputEvent_GetCoastingAxisEvent}. \n + * + * @since 21 + */ + NODE_ON_COASTING_AXIS_EVENT = 31, + /** * @brief Triggers onDetectResultUpdate callback * when the text is set to TextDataDetectorConfig and recognized successfully. diff --git a/arkui/ace_engine/native/ui_input_event.h b/arkui/ace_engine/native/ui_input_event.h index 1e74a9ff75b05a103684fc1f90528b8fa5b5a80c..af5cdd0e518fb9e9f0600506f6a3605e3ed6d1d8 100644 --- a/arkui/ace_engine/native/ui_input_event.h +++ b/arkui/ace_engine/native/ui_input_event.h @@ -50,6 +50,20 @@ extern "C" { */ typedef struct ArkUI_UIInputEvent ArkUI_UIInputEvent; +/** + * @brief Defines the coasting axis event. + * When a user swipes with two fingers on the touchpad, the system constructs + * sliding events based on the speed at the moment the fingers are lifted according to + * a certain decay curve. You can listen for such events to handle the flick effect + * immediately after the regular axis events. + * + * It only can be received when user flings on the touchpad with two fingers and any components register + * NODE_ON_COASTING_AXIS_EVENT through {@link registerNodeEvent} exist under the pointer location. + * + * @since 21 + */ +typedef struct ArkUI_CoastingAxisEvent ArkUI_CoastingAxisEvent; + /** * @brief Enumerates the UI input event types. * @@ -69,6 +83,22 @@ typedef enum { ARKUI_UIINPUTEVENT_TYPE_KEY = 4, } ArkUI_UIInputEvent_Type; +/** + * @brief Enumerates the coasting axis event phases. + * + * @since 21 + */ +typedef enum { + /** Idle phase, indicating no-coasting phase. */ + ARKUI_COASTING_AXIS_EVENT_PHASE_NONE = 0, + /** Coasting begin, this is the first coasting event. */ + ARKUI_COASTING_AXIS_EVENT_PHASE_BEGIN = 1, + /** Coasting ongoing. */ + ARKUI_COASTING_AXIS_EVENT_PHASE_UPDATE = 2, + /** Coasting end, this is the last coasting event. */ + ARKUI_COASTING_AXIS_EVENT_PHASE_END = 3, +} ArkUI_CoastingAxisEventPhase; + /** * @brief Defines the action code of the input event. * @@ -1395,6 +1425,71 @@ int32_t OH_ArkUI_PointerEvent_PostClonedEvent(ArkUI_NodeHandle node, const ArkUI */ ArkUI_ErrorCode OH_ArkUI_UIInputEvent_GetLatestStatus(); +/** + * @brief Obtains the coasting axis event from a component event, valid event only can be + * fetched only when user flings on the touchpad with two fingers and any components register + * NODE_ON_COASTING_AXIS_EVENT exist under the pointer location. + * Call this method after the {@link ArkUI_UIInputEvent} object is obtained from the {@link ArkUI_NodeEvent} object. + * + * @param event Indicates the pointer to the UI input event. + * @return Returns the pointer to the coasting axis event, return null if no any coasting axis event occurs. + * @since 21 + */ +ArkUI_CoastingAxisEvent* OH_ArkUI_UIInputEvent_GetCoastingAxisEvent(ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the time when this coasting event occurs. + * + * @param event Indicates the pointer to the coasting axis event. + * @return Returns the time when the UI input event occurs; returns 0 if any parameter error occurs. + * + * @since 21 + */ +int64_t OH_ArkUI_CoastingAxisEvent_GetEventTime(ArkUI_CoastingAxisEvent* event); + +/** + * @brief Obtains the coasting phase when this coasting event occurs. + * + * @param event Indicates the pointer to the coasting axis event. + * @return Returns the event phase, see {@link ArkUI_CoastingAxisEventPhase}; + * returns ARKUI_COASTING_AXIS_EVENT_PHASE_NONE if any parameter error occurs. + * + * @since 21 + */ +ArkUI_CoastingAxisEventPhase OH_ArkUI_CoastingAxisEvent_GetPhase(ArkUI_CoastingAxisEvent* event); + +/** + * @brief Obtains the horizontal delta value. + * + * @param event Indicates the pointer to the coasting axis event. + * @return Returns delta X value, count in PX; returns 0 if any parameter error occurs. + * + * @since 21 + */ +float OH_ArkUI_CoastingAxisEvent_GetDeltaX(ArkUI_CoastingAxisEvent* event); + +/** + * @brief Obtains the vertical delta value. + * + * @param event Indicates the pointer to the coasting axis event. + * @return Returns delta Y value, count in PX; returns 0 if any parameter error occurs. + * + * @since 21 + */ +float OH_ArkUI_CoastingAxisEvent_GetDeltaY(ArkUI_CoastingAxisEvent* event); + +/** + * @brief Sets whether to enable coasting axis event propagation. + * + * @param event Pointer to the coasting axis event. + * @param propagation Whether to enable event propagation. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 21 + */ +int32_t OH_ArkUI_CoastingAxisEvent_SetPropagation(ArkUI_CoastingAxisEvent* event, bool propagation); + #ifdef __cplusplus }; #endif