diff --git a/zh-cn/native_sdk/ace/native_interface_xcomponent.h b/zh-cn/native_sdk/ace/native_interface_xcomponent.h
index 82fed4a92f8854147d215db9fe19588dbd9358d1..2a66629cce287061962d39bcb43e5569e33bd054 100644
--- a/zh-cn/native_sdk/ace/native_interface_xcomponent.h
+++ b/zh-cn/native_sdk/ace/native_interface_xcomponent.h
@@ -17,7 +17,7 @@
* @addtogroup OH_NativeXComponent Native XComponent
* @{
*
- * @brief Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGLES and media data input and displayed on the ArkUI XComponent.
+ * @brief 描述ArkUI XComponent持有的surface和触摸事件,该事件可用于EGL/OpenGLES和媒体数据输入,并显示在ArkUI XComponent上。
*
* @since 8
* @version 1.0
@@ -26,7 +26,7 @@
/**
* @file native_interface_xcomponent.h
*
- * @brief Declares APIs for accessing a Native XComponent.
+ * @brief 声明用于访问Native XComponent的API。
*
* @since 8
* @version 1.0
@@ -42,30 +42,30 @@ extern "C" {
#endif
/**
- * @brief Enumerates the API access states.
+ * @brief 枚举API访问状态。
*
* @since 8
* @version 1.0
*/
enum {
- /** Success result. */
+ /** 成功结果。 */
OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0,
- /** Failed result. */
+ /** 失败结果。 */
OH_NATIVEXCOMPONENT_RESULT_FAILED = -1,
- /** Invalid parameters. */
+ /** 无效参数。 */
OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2,
};
enum OH_NativeXComponent_TouchEventType {
- /** Trigger a touch event when a finger is pressed. */
+ /** 手指按下时触发触摸事件。 */
OH_NATIVEXCOMPONENT_DOWN = 0,
- /** Trigger a touch event when a finger is lifted. */
+ /** 手指抬起时触发触摸事件。 */
OH_NATIVEXCOMPONENT_UP,
- /** Trigger a touch event when a finger moves on the screen in pressed state. */
+ /** 手指按下状态下在屏幕上移动时触发触摸事件。 */
OH_NATIVEXCOMPONENT_MOVE,
- /** Trigger an event when a touch event is canceled. */
+ /** 触摸事件取消时触发事件。 */
OH_NATIVEXCOMPONENT_CANCEL,
- /** Invalid touch type. */
+ /** 无效的触摸类型。 */
OH_NATIVEXCOMPONENT_UNKNOWN,
};
@@ -74,58 +74,63 @@ const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128;
const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10;
struct OH_NativeXComponent_TouchPoint {
- /** Unique identifier of a finger. */
+ /** 手指的唯一标识符。 */
int32_t id = 0;
- /** X coordinate of the touch point relative to the left edge of the screen. */
+ /** 触摸点相对于屏幕左边缘的x坐标。 */
float screenX = 0.0;
- /** Y coordinate of the touch point relative to the upper edge of the screen. */
+ /** 触摸点相对于屏幕上边缘的y坐标。 */
float screenY = 0.0;
- /** X coordinate of the touch point relative to the left edge of the element to touch. */
+ /** 触摸点相对于XComponent组件左边缘的x坐标。 */
float x = 0.0;
- /** Y coordinate of the touch point relative to the upper edge of the element to touch. */
+ /** 触摸点相对于XComponent组件上边缘的y坐标。 */
float y = 0.0;
- /** Touch type of the touch event. */
+ /** 触摸事件的触摸类型。 */
OH_NativeXComponent_TouchEventType type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN;
- /** Contact area between the finger pad and the screen. */
+ /** 指垫和屏幕之间的接触面积。 */
double size = 0.0;
- /** Pressure of the current touch event. */
+ /** 当前触摸事件的压力。 */
float force = 0.0;
- /** Timestamp of the current touch event. */
+ /** 当前触摸事件的时间戳。 */
long long timeStamp = 0;
- /** Whether the current point is pressed. */
+ /** 当前点是否被按下。 */
bool isPressed = false;
};
-// Represents the touch point information.
+/**
+ * @brief 代表接触点信息。
+ *
+ * @since 8
+ * @version 1.0
+ */
struct OH_NativeXComponent_TouchEvent {
- /** Unique identifier of a finger. */
+ /** 手指的唯一标识符。 */
int32_t id = 0;
- /** X coordinate of the touch point relative to the left edge of the screen. */
+ /** 触摸点相对于屏幕左边缘的x坐标。 */
float screenX = 0.0;
- /** Y coordinate of the touch point relative to the upper edge of the screen. */
+ /** 触摸点相对于屏幕上边缘的y坐标。 */
float screenY = 0.0;
- /** X coordinate of the touch point relative to the left edge of the element to touch. */
+ /** 触摸点相对于XComponent组件左边缘的x坐标。 */
float x = 0.0;
- /** Y coordinate of the touch point relative to the upper edge of the element to touch. */
+ /** 触摸点相对于XComponent组件上边缘的y坐标。 */
float y = 0.0;
- /** Touch type of the touch event. */
+ /** 触摸事件的触摸类型。 */
OH_NativeXComponent_TouchEventType type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN;
- /** Contact area between the finger pad and the screen. */
+ /** 指垫和屏幕之间的接触面积。 */
double size = 0.0;
- /** Pressure of the current touch event. */
+ /** 当前触摸事件的压力。 */
float force = 0.0;
- /** ID of the device where the current touch event is generated. */
+ /** 产生当前触摸事件的设备的ID。 */
int64_t deviceId = 0;
- /** Timestamp of the current touch event. */
+ /** 当前触摸事件的时间戳。 */
long long timeStamp = 0;
- /** Array of the current touch points. */
+ /** 当前触摸点的数组。 */
OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER];
- /** Number of current touch points. */
+ /** 当前接触点的数量。 */
uint32_t numPoints = 0;
};
/**
- * @brief Provides an encapsulated OH_NativeXComponent instance.
+ * @brief 提供封装的OH_NativeXComponent实例。
*
* @since 8
* @version 1.0
@@ -133,48 +138,44 @@ struct OH_NativeXComponent_TouchEvent {
typedef struct OH_NativeXComponent OH_NativeXComponent;
/**
- * @brief Registers the surface lifecycle and touch event callbacks.
+ * @brief 注册surface生命周期和触摸事件回调。
*
* @since 8
* @version 1.0
*/
typedef struct OH_NativeXComponent_Callback {
- /** Called when the surface is created. */
+ /** 创建surface时调用。 */
void (*OnSurfaceCreated)(OH_NativeXComponent* component, void* window);
- /**
- * Called when the surface is changed.\n
- * This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.\n
- */
+ /** 当surface改变时调用。 */
void (*OnSurfaceChanged)(OH_NativeXComponent* component, void* window);
- /** Called when the surface is destroyed. */
+ /** 当surface被破坏时调用。 */
void (*OnSurfaceDestroyed)(OH_NativeXComponent* component, void* window);
- /** Called when a touch event is triggered. */
+ /** 当触摸事件被触发时调用。 */
void (*DispatchTouchEvent)(OH_NativeXComponent* component, void* window);
} OH_NativeXComponent_Callback;
/**
- * @brief Obtains the ID of the ArkUI XComponent.
+ * @brief 获取ArkUI XComponent的id。
*
- * @param component Indicates the pointer to this OH_NativeXComponent instance.
- * @param id Indicates the char buffer to keep the ID of this OH_NativeXComponent instance.\n
- * Note that a null-terminator will be appended to the char buffer, so the size of the
- * char buffer should be at least as large as the size of the real id length plus 1.\n
- * It is recommended that the size of the char buffer be [OH_XCOMPONENT_ID_LEN_MAX + 1].
- * @param size Indicates the pointer to the length of id, which you can set and receive.
- * @return Returns the status code of the execution.
+ * @param component 表示指向OH_NativeXComponent实例的指针。
+ * @param id 指示用于保存此OH_NativeXComponent实例的ID的字符缓冲区。
+ * 请注意,空终止符将附加到字符缓冲区,因此字符缓冲区的大小应至少比真实id长度大一个单位。
+ * 建议字符缓冲区的大小为[OH_XCOMPONENT_ID_LEN_MAX + 1]。
+ * @param size 指示指向id长度的指针。
+ * @return 返回执行的状态代码。
* @since 8
* @version 1.0
*/
int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size);
/**
- * @brief Obtains the size of the surface held by the ArkUI XComponent.
+ * @brief 获取ArkUI XComponent持有的surface的大小。
*
- * @param component Indicates the pointer to this OH_NativeXComponent instance.
- * @param window Indicates the native window handler.
- * @param width Indicates the pointer to the width of the current surface.
- * @param height Indicates the pointer to the height of the current surface.
- * @return Returns the status code of the execution.
+ * @param component 表示指向OH_NativeXComponent实例的指针。
+ * @param window 表示NativeWindow句柄。
+ * @param width 指示指向当前surface宽度的指针。
+ * @param height 指示指向当前surface高度的指针。
+ * @return 返回执行的状态代码。
* @since 8
* @version 1.0
*/
@@ -182,13 +183,13 @@ int32_t OH_NativeXComponent_GetXComponentSize(
OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height);
/**
- * @brief Obtains the offset of the surface held by the ArkUI XComponent.
+ * @brief 获取ArkUI XComponent组件相对屏幕左上顶点的偏移量。
*
- * @param component Indicates the pointer to this OH_NativeXComponent instance.
- * @param window Indicates the native window handler.
- * @param x Indicates the pointer to the x coordinate of the current surface.
- * @param y Indicates the pointer to the y coordinate of the current surface.
- * @return Returns the status code of the execution.
+ * @param component 表示指向OH_NativeXComponent实例的指针。
+ * @param window 表示NativeWindow句柄。
+ * @param x 指示指向当前surface的x坐标的指针。
+ * @param y 指示指向当前surface的y坐标的指针。
+ * @return 返回执行的状态代码。
* @since 8
* @version 1.0
*/
@@ -196,12 +197,12 @@ int32_t OH_NativeXComponent_GetXComponentOffset(
OH_NativeXComponent* component, const void* window, double* x, double* y);
/**
- * @brief Obtains the touch event dispatched by the ArkUI XComponent.
+ * @brief 获取ArkUI XComponent调度的触摸事件。
*
- * @param component Indicates the pointer to this OH_NativeXComponent instance.
- * @param window Indicates the native window handler.
- * @param touchEvent Indicates the pointer to the current touch event.
- * @return Returns the status code of the execution.
+ * @param component 表示指向OH_NativeXComponent实例的指针。
+ * @param window 表示NativeWindow句柄。
+ * @param touchEvent 指示指向当前触摸事件的指针。
+ * @return 返回执行的状态代码。
* @since 8
* @version 1.0
*/
@@ -209,11 +210,11 @@ int32_t OH_NativeXComponent_GetTouchEvent(
OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent);
/**
- * @brief Registers a callback for this OH_NativeXComponent instance.
+ * @brief 为此OH_NativeXComponent实例注册回调。
*
- * @param component Indicates the pointer to this OH_NativeXComponent instance.
- * @param callback Indicates the pointer to a surface lifecycle and touch event callback.
- * @return Returns the status code of the execution.
+ * @param component 表示指向OH_NativeXComponent实例的指针。
+ * @param callback 指示指向surface生命周期和触摸事件回调的指针。
+ * @return 返回执行的状态代码。
* @since 8
* @version 1.0
*/