1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup ArkUI_NativeModule
18  * @{
19  *
20  * @brief Provides UI capabilities of ArkUI on the native side, such as UI component creation and destruction,
21  * tree node operations, attribute setting, and event listening.
22  *
23  * @since 12
24  */
25 
26 /**
27  * @file drawable_descriptor.h
28  *
29  * @brief Defines theNativeDrawableDescriptor for the native module.
30  *
31  * @library libace_ndk.z.so
32  * @syscap SystemCapability.ArkUI.ArkUI.Full
33  * @kit ArkUI
34  * @since 12
35  */
36 
37 #ifndef ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H
38 #define ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H
39 
40 #include <stdint.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Defines the drawable descriptor.
48  *
49  * @since 12
50  */
51 typedef struct ArkUI_DrawableDescriptor ArkUI_DrawableDescriptor;
52 
53 /**
54  * @brief Introduces the native pixel map information defined by Image Kit.
55  *
56  * @since 12
57  */
58 struct OH_PixelmapNative;
59 
60 /**
61  * @brief Defines the pointer to OH_PixelmapNative.
62  *
63  * @since 12
64  */
65 typedef struct OH_PixelmapNative* OH_PixelmapNativeHandle;
66 
67 /**
68  * @brief Creates a DrawableDescriptor from a Pixelmap.
69  *
70  * @param pixelMap Indicates the pointer to a Pixelmap
71  * @return Returns the pointer to the drawableDescriptor.
72  * @since 12
73 */
74 ArkUI_DrawableDescriptor* OH_ArkUI_DrawableDescriptor_CreateFromPixelMap(OH_PixelmapNativeHandle pixelMap);
75 
76 /**
77  * @brief Creates a DrawableDescriptor from a Pixelmap array.
78  *
79  * @param array Indicates the pointer to a Pixelmap array.
80  * @param size Indicates the size of the Pixelmap array.
81  * @return Returns the pointer to the drawableDescriptor.
82  * @since 12
83 */
84 ArkUI_DrawableDescriptor* OH_ArkUI_DrawableDescriptor_CreateFromAnimatedPixelMap(
85     OH_PixelmapNativeHandle* array, int32_t size);
86 
87 /**
88  * @brief Destroys the pointer to the drawableDescriptor.
89  *
90  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
91  * @since 12
92 */
93 void OH_ArkUI_DrawableDescriptor_Dispose(ArkUI_DrawableDescriptor* drawableDescriptor);
94 
95 /**
96  * @brief Obtains the Pixelmap object.
97  *
98  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
99  * @return Returns the pointer to the PixelMap.
100  * @since 12
101 */
102 OH_PixelmapNativeHandle OH_ArkUI_DrawableDescriptor_GetStaticPixelMap(ArkUI_DrawableDescriptor* drawableDescriptor);
103 
104 /**
105  * @brief Obtains the Pixelmap array used to play the animation.
106  *
107  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
108  * @return Returns the pointer to the PixelMap array.
109  * @since 12
110 */
111 OH_PixelmapNativeHandle* OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArray(
112     ArkUI_DrawableDescriptor* drawableDescriptor);
113 
114 /**
115  * @brief Obtains the size of the Pixelmap array used to play the animation.
116  *
117  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
118  * @return Returns the size of the Pixelmap array.
119  * @since 12
120 */
121 int32_t OH_ArkUI_DrawableDescriptor_GetAnimatedPixelMapArraySize(ArkUI_DrawableDescriptor* drawableDescriptor);
122 
123 /**
124  * @brief Sets the total playback duration.
125  *
126  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
127  * @param duration Indicates the total playback duration. The unit is millisecond.
128  * @since 12
129 */
130 void OH_ArkUI_DrawableDescriptor_SetAnimationDuration(ArkUI_DrawableDescriptor* drawableDescriptor, int32_t duration);
131 
132 /**
133  * @brief Obtains the total playback duration.
134  *
135  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
136  * @return Return the total playback duration. The unit is millisecond.
137  * @since 12
138 */
139 int32_t OH_ArkUI_DrawableDescriptor_GetAnimationDuration(ArkUI_DrawableDescriptor* drawableDescriptor);
140 
141 /**
142  * @brief Sets the number of playback times.
143  *
144  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
145  * @param iterations Indicates the number of playback times.
146  * @since 12
147 */
148 void OH_ArkUI_DrawableDescriptor_SetAnimationIteration(
149     ArkUI_DrawableDescriptor* drawableDescriptor, int32_t iteration);
150 
151 /**
152  * @brief Obtains the number of playback times.
153  *
154  * @param drawableDescriptor Indicates the pointer to the drawableDescriptor.
155  * @return Returns the number of playback times.
156  * @since 12
157 */
158 int32_t OH_ArkUI_DrawableDescriptor_GetAnimationIteration(ArkUI_DrawableDescriptor* drawableDescriptor);
159 #ifdef __cplusplus
160 };
161 #endif
162 
163 #endif // ARKUI_NATIVE_DRAWABLE_DESCRIPTOR_H
164 /** @} */
165