• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 drag and drop APIs of ArkUI on the native side.
21  *
22  * @since 12
23  */
24 
25 /**
26  * @file drag_and_drop.h
27  *
28  * @brief Defines the native drag and drop APIs.
29  *
30  * @library libace_ndk.z.so
31  * @kit ArkUI
32  * @syscap SystemCapability.ArkUI.ArkUI.Full
33  * @since 12
34  */
35 
36 #ifndef ARKUI_NATIVE_DRAG_AND_DROP_H
37 #define ARKUI_NATIVE_DRAG_AND_DROP_H
38 
39 #include <stdint.h>
40 
41 #include "native_type.h"
42 #include "database/udmf/udmf.h"
43 #include "multimedia/image_framework/image/pixelmap_native.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Defines an enum for drag results, which are set by the data receiver and transferred by the system to the
51  *        drag source so that the drag source is aware of the data processing result of the receiver.
52  *
53  * @since 12
54  */
55 typedef enum {
56     /** The drag and drop operation succeeded. */
57     ARKUI_DRAG_RESULT_SUCCESSFUL = 0,
58     /** The drag and drop operation failed. */
59     ARKUI_DRAG_RESULT_FAILED,
60     /** The drag and drop operation was canceled. */
61     ARKUI_DRAG_RESULT_CANCELED,
62 } ArkUI_DragResult;
63 
64 /**
65  * @brief Defines an enum for data processing modes used when data is dropped, which affects the display of the badge.
66  *
67  * @since 12
68  */
69 typedef enum {
70     /** Copy. */
71     ARKUI_DROP_OPERATION_COPY = 0,
72     /** Cut. */
73     ARKUI_DROP_OPERATION_MOVE,
74 } ArkUI_DropOperation;
75 
76 /**
77  * @brief Defines an enum for interaction states prior to a drop and drop operation.
78  *
79  * @since 12
80  */
81 typedef enum {
82     /** Unknown. */
83     ARKUI_PRE_DRAG_STATUS_UNKNOWN = -1,
84     /** A drag gesture is being detected. */
85     ARKUI_PRE_DRAG_STATUS_ACTION_DETECTING,
86     /** The component is ready to be dragged. */
87     ARKUI_PRE_DRAG_STATUS_READY_TO_TRIGGER_DRAG,
88     /** A lift animation is started. */
89     ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_STARTED,
90     /** A lift animation is finished. */
91     ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_FINISHED,
92     /** A drop animation is started. */
93     ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_STARTED,
94     /** A drop animation is finished. */
95     ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_FINISHED,
96     /** A drop animation is terminated. */
97     ARKUI_PRE_DRAG_STATUS_CANCELED_BEFORE_DRAG,
98 } ArkUI_PreDragStatus;
99 
100 /**
101  * @brief Defines an enum for drag preview scale modes.
102  *
103  * @since 12
104  */
105 typedef enum {
106     /**
107      * The system automatically changes the position of the dragged point based on the scenario and
108      * scales the drag preview based on set rules.
109      */
110     ARKUI_DRAG_PREVIEW_SCALE_AUTO = 0,
111     /** The system does not scale the drag preview. */
112     ARKUI_DRAG_PREVIEW_SCALE_DISABLED,
113 } ArkUI_DragPreviewScaleMode;
114 
115 /**
116  * @brief Defines an enum for drag states.
117  *
118  * @since 12
119  */
120 typedef enum {
121     /** Unknown. */
122     ARKUI_DRAG_STATUS_UNKNOWN = -1,
123     /** Started. */
124     ARKUI_DRAG_STATUS_STARTED,
125     /** Ended. */
126     ARKUI_DRAG_STATUS_ENDED,
127 } ArkUI_DragStatus;
128 
129 /**
130  * @brief Defines a struct for a component event.
131  *
132  * @since 12
133  */
134 typedef struct ArkUI_NodeEvent ArkUI_NodeEvent;
135 
136 /**
137  * @brief Defines a struct for a UI context object.
138  *
139  * @since 12
140  */
141 typedef struct ArkUI_Context ArkUI_Context;
142 
143 /**
144  * @brief Defines a struct for a UI context object pointer.
145  *
146  * @since 12
147  */
148 typedef struct ArkUI_Context* ArkUI_ContextHandle;
149 
150 /**
151  * @brief Defines a struct for a drag event.
152  *
153  * @since 12
154  */
155 typedef struct ArkUI_DragEvent ArkUI_DragEvent;
156 
157 /**
158  * @brief Defines a struct for custom drag preview options.
159  *
160  * @since 12
161  */
162 typedef struct ArkUI_DragPreviewOption ArkUI_DragPreviewOption;
163 
164 /**
165  * @brief Defines a struct for a drag action.
166  *
167  * @since 12
168  */
169 typedef struct ArkUI_DragAction ArkUI_DragAction;
170 
171 /**
172  * @brief Defines a struct for drag and drop information returned through a drag status listener.
173  *
174  * @since 12
175  */
176 typedef struct ArkUI_DragAndDropInfo ArkUI_DragAndDropInfo;
177 
178 /**
179  * @brief Obtains a <b>ArkUI_DragEvent</b> object from the specified <b>ArkUI_NodeEvent</b> object.
180  *
181  * @param nodeEvent Indicates the pointer to an <b>ArkUI_NodeEvent</b> object.
182  * @return Returns the pointer to an <b>ArkUI_DragEvent</b> object.
183  *         Returns <b>null</b> if the parameter passed in is invalid or is not a drag-related event.
184  * @since 12
185  */
186 ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent);
187 
188 /**
189  * @brief Obtains the interaction state prior to a drop and drop operation.
190  *
191  * @param nodeEvent Indicates the pointer to an <b>ArkUI_NodeEvent</b> object.
192  * @return Returns the interaction state prior to the drop and drop operation.
193  * @since 12
194  */
195 ArkUI_PreDragStatus OH_ArkUI_NodeEvent_GetPreDragStatus(ArkUI_NodeEvent* nodeEvent);
196 
197 /**
198  * @brief Sets whether to disable the default drop animation.
199  * The default drop animation is enabled by default and can be disabled to apply a custom drop animation.
200  *
201  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
202  * @param disable Indicates whether to disable the default drop animation.
203  * The value <b>true</b> means to disable the default drop animation, and <b>false</b> means the opposite.
204  * @return Returns the result code.
205  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
206  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
207  * @since 12
208  */
209 int32_t OH_ArkUI_DragEvent_DisableDefaultDropAnimation(ArkUI_DragEvent* event, bool disable);
210 
211 /**
212  * @brief Sets the data processing mode.
213  *
214  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
215  * @param dropOperation Indicates the data processing mode.
216  * @return Returns the result code.
217  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
218  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
219  * @since 12
220  */
221 int32_t OH_ArkUI_DragEvent_SetSuggestedDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation dropOperation);
222 
223 /**
224  * @brief Sets the result for a drag event.
225  *
226  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
227  * @param result Indicates the drag result.
228  * @return Returns the result code.
229  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
230  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
231  * @since 12
232  */
233 int32_t OH_ArkUI_DragEvent_SetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult result);
234 
235 /**
236  * @brief Set drag data for a drag event.
237  *
238  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
239  * @param data Indicates the drag data.
240  * @return Returns the result code.
241  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
242  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
243  * @since 12
244  */
245 int32_t OH_ArkUI_DragEvent_SetData(ArkUI_DragEvent* event, OH_UdmfData* data);
246 
247 /**
248  * @brief Obtains the default drag data from a drag event.
249  *
250  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
251  * @param data Indicates the pointer to an <b>OH_UdmfData</b> object. The application needs to create a pointer
252  *             for receiving data by using the {@link OH_UdmfData_Create} method.
253  * @return Returns the result code.
254  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
255  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
256  * @since 12
257  */
258 int32_t OH_ArkUI_DragEvent_GetUdmfData(ArkUI_DragEvent* event, OH_UdmfData *data);
259 
260 /**
261  * @brief Obtains the number of drag data types from a drag event.
262  *
263  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
264  * @param count Indicates the number of drag data types returned.
265  * @return Returns the result code.
266  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
267  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
268  * @since 12
269  */
270 int32_t OH_ArkUI_DragEvent_GetDataTypeCount(ArkUI_DragEvent* event, int32_t* count);
271 
272 /**
273  * @brief Obtains the list of drag data types from a drag event.
274  *
275  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
276  * @param eventTypeArray Indicates the list of the drag data types. You need to create a string array first.
277  * @param length Indicates the total length of the list array. It must be greater than or equal to the number obtained
278  *        by using {@link OH_ArkUI_DragEvent_GetDataTypeCount}.
279  * @param maxStrLen Indicates the max string length of drag data types.
280  * @return Returns the result code.
281  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
282  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
283  *         Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR} if the giving buffer is not enough for string copy.
284  * @since 12
285  */
286 int32_t OH_ArkUI_DragEvent_GetDataTypes(
287     ArkUI_DragEvent *event, char *eventTypeArray[], int32_t length, int32_t maxStrLen);
288 
289 /**
290  * @brief Obtains the drag result from a drag event.
291  *
292  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
293  * @param result Indicates the drag result returned.
294  * @return Returns the result code.
295  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
296  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
297  * @since 12
298  */
299 int32_t OH_ArkUI_DragEvent_GetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult* result);
300 
301 /**
302  * @brief Obtains the drop operation from a drag event.
303  *
304  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
305  * @param operation Indicates the drop operation which the data receiver set.
306  * @return Returns the result code.
307  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
308  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
309  *                 Possible causes: 1. The given parameters are null or the given event is not a valid DragEvent.
310  * @since 12
311  */
312 int32_t OH_ArkUI_DragEvent_GetDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation* operation);
313 
314 /**
315  * @brief Obtains the X coordinate of the touch point for a drag preview from a drag event.
316  *
317  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
318  * @return Returns the X coordinate of the touch point, in px.
319  *         Returns the default value <b>0</b> if the input parameter is invalid.
320  * @since 12
321  */
322 float OH_ArkUI_DragEvent_GetPreviewTouchPointX(ArkUI_DragEvent* event);
323 
324 /**
325  * @brief Obtains the Y coordinate of the touch point for a drag preview from a drag event.
326  *
327  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
328  * @return Returns the Y coordinate of the touch point, in px.
329  *         Returns the default value <b>0</b> if the input parameter is invalid.
330  * @since 12
331  */
332 float OH_ArkUI_DragEvent_GetPreviewTouchPointY(ArkUI_DragEvent* event);
333 
334 /**
335  * @brief Obtains the width of a drag preview from a drag event.
336  *
337  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
338  * @return Returns the width of the drag preview, in px.
339  *         Returns the default value <b>0</b> if the input parameter is invalid.
340  * @since 12
341  */
342 float OH_ArkUI_DragEvent_GetPreviewRectWidth(ArkUI_DragEvent* event);
343 
344 /**
345  * @brief Obtains the height of a drag preview from a drag event.
346  *
347  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
348  * @return Returns the height of the drag preview, in px.
349  *         Returns the default value <b>0</b> if the input parameter is invalid.
350  * @since 12
351  */
352 float OH_ArkUI_DragEvent_GetPreviewRectHeight(ArkUI_DragEvent* event);
353 
354 /**
355  * @brief Obtains the X coordinate of the touch point relative to the window from a drag event.
356  *
357  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
358  * @return Returns the X coordinate of the touch point relative to the window, in px.
359  *         Returns the default value <b>0</b> if the input parameter is invalid.
360  * @since 12
361  */
362 float OH_ArkUI_DragEvent_GetTouchPointXToWindow(ArkUI_DragEvent* event);
363 
364 /**
365  * @brief Obtains the Y coordinate of the touch point relative to the window from a drag event.
366  *
367  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
368  * @return Returns the Y coordinate of the touch point relative to the window, in px.
369  *         Returns the default value <b>0</b> if the input parameter is invalid.
370  * @since 12
371  */
372 float OH_ArkUI_DragEvent_GetTouchPointYToWindow(ArkUI_DragEvent* event);
373 
374 /**
375  * @brief Obtains the X coordinate of the touch point relative to the current display from a drag event.
376  *
377  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
378  * @return Returns the X coordinate of the touch point relative to the current display, in px.
379  *         Returns the default value <b>0</b> if the input parameter is invalid.
380  * @since 12
381  */
382 float OH_ArkUI_DragEvent_GetTouchPointXToDisplay(ArkUI_DragEvent* event);
383 
384 /**
385  * @brief Obtains the Y coordinate of the touch point relative to the current display from a drag event.
386  *
387  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
388  * @return Returns the Y coordinate of the touch point relative to the current display, in px.
389  *         Returns the default value <b>0</b> if the input parameter is invalid.
390  * @since 12
391  */
392 float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event);
393 
394 /**
395  * @brief Obtains the dragging velocity along the x-axis.
396  *
397  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
398  * @return Returns the dragging velocity along the x-axis, in px.
399  *         Returns the default value <b>0</b> if the input parameter is invalid.
400  * @since 12
401  */
402 float OH_ArkUI_DragEvent_GetVelocityX(ArkUI_DragEvent* event);
403 
404 /**
405  * @brief Obtains the dragging velocity along the y-axis.
406  *
407  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
408  * @return Returns the dragging velocity along the y-axis, in px.
409  *         Returns the default value <b>0</b> if the input parameter is invalid.
410  * @since 12
411  */
412 float OH_ArkUI_DragEvent_GetVelocityY(ArkUI_DragEvent* event);
413 
414 /**
415  * @brief Obtains the dragging velocity along the main axis.
416  *
417  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
418  * @return Returns the dragging velocity along the main axis, in px.
419  *         Returns the default value <b>0</b> if the input parameter is invalid.
420  * @since 12
421  */
422 float OH_ArkUI_DragEvent_GetVelocity(ArkUI_DragEvent* event);
423 
424 /**
425  * @brief Obtains the pressed status of modifier keys from a drag event.
426  *
427  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
428  * @param keys Indicates the returned combination of modifier keys that are currently pressed.
429  *             The application can determine the pressed modifier keys through bitwise operations.
430  * @return Returns the result code.
431  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
432  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
433  * @since 12
434  */
435 int32_t OH_ArkUI_DragEvent_GetModifierKeyStates(ArkUI_DragEvent* event, uint64_t* keys);
436 
437 /**
438  * @brief Request to start the data sync process with the sync option.
439  *
440  * @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
441  * @param options Indicates the pointer to an <b>OH_UdmfGetDataParams</b> object.
442  * @param key Represents return value after set data to database successfully, it should be not
443  *            less than {@link UDMF_KEY_BUFFER_LEN}.
444  * @param keyLen Represents the length of key string.
445  * @return Returns the result code.
446  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
447  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
448  *         Returns {@link ARKUI_ERROR_CODE_DRAG_DATA_SYNC_FAILED} if the data sync is not allowed or failed.
449  * @since 15
450  */
451 int32_t OH_ArkUI_DragEvent_StartDataLoading(
452     ArkUI_DragEvent* event, OH_UdmfGetDataParams* options, char* key, unsigned int keyLen);
453 
454 /**
455  * @brief Cancel the data sync process.
456  *
457  * @param uiContext Indicates the pointer to a UI instance.
458  * @param key Represents the data key returned by {@link OH_ArkUI_DragEvent_StartDataLoading}.
459  * @return Returns the result code.
460  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
461  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
462  *         Returns {@link ARKUI_ERROR_CODE_OPERATION_FAILED} if no any data sync is in progress.
463  * @since 15
464  */
465 int32_t OH_ArkUI_CancelDataLoading(ArkUI_ContextHandle uiContext, const char* key);
466 
467 /**
468  * @brief Sets whether to disable data prefetch process before the onDrop callback executing.
469  *        The system will retry to getting data until the max time limit (2.4s for now) reaches,
470  *        this's useful for the cross device draging operation, as the system helps to eliminate
471  *        the communication instability, but it's redundant for {@link OH_ArkUI_DragEvent_StartDataLoading}
472  *        method, as it will take care the data fetching with asynchronous mechanism, so must set this
473  *        field to true if using {@link OH_ArkUI_DragEvent_StartDataLoading} in onDrop to avoid the data is
474  *        fetched before onDrop executing unexpectedly.
475  *
476  * @param node Indicates the pointer to a component node.
477  * @param disabled Indicates whether to disable the data pre-fetch process, true for disable, false for not.
478  * @return Returns the result code.
479  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
480  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
481  * @since 15
482  */
483 int32_t OH_ArkUI_DisableDropDataPrefetchOnNode(ArkUI_NodeHandle node, bool disabled);
484 
485 /**
486  * @brief Sets whether to enable strict reporting on drag events.
487  *        This feature is disabled by default, and you are advised to enable it.
488  *        If this feature is disabled, the parent component is not notified when an item in it is dragged over its child
489  *        component. If this feature is enabled, the component is notified of the dragged item's leaving, and the chil
490  *        component to which the dragged item is dropped is notified of the item's entering. This configuration is
491  *        related to a specific UI instance. You can pass in a specific component node on the current UI instance
492  *        for association.
493  *
494  * @param node Indicates the pointer to a component node.
495  * @param enabled Indicates whether to enable strict reporting on drag events.
496  * @return Returns the result code.
497  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
498  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
499  * @since 12
500  */
501 int32_t OH_ArkUI_SetDragEventStrictReportWithNode(ArkUI_NodeHandle node, bool enabled);
502 
503 /**
504  * @brief Sets whether to enable strict reporting on drag events.
505  *        This feature is disabled by default, and you are advised to enable it.
506  *        If this feature is disabled, the parent component is not notified when an item in it is dragged over its child
507  *        component. If this feature is enabled, the component is notified of the dragged item's leaving, and the child
508  *        component to which the dragged item is dropped is notified of the item's entering. This configuration is
509  *        related to a specific UI instance. You can pass in a specific UI instance for association.
510  *
511  * @param uiContext Indicates the pointer to a UI instance.
512  * @param enabled Indicates whether to enable strict reporting on drag events.
513  * @return Returns the result code.
514  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
515  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
516  * @since 12
517  */
518 int32_t OH_ArkUI_SetDragEventStrictReportWithContext(ArkUI_ContextHandle uiContext, bool enabled);
519 
520 /**
521  * @brief Sets the types of data that can be dropped to the specified component. This API resets the settings configured
522  *        through {@link OH_ArkUI_DisallowNodeAnyDropDataTypes} and {@link OH_ArkUI_AllowNodeAllDropDataTypes}.
523  *
524  * @param node Indicates the pointer to a component node.
525  * @param typesArray Indicates the array of types of data that can be dropped.
526  * @param count Indicates length of an array.
527  * @return Returns the result code.
528  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
529  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
530  * @since 12
531  */
532 int32_t OH_ArkUI_SetNodeAllowedDropDataTypes(ArkUI_NodeHandle node, const char* typesArray[], int32_t count);
533 
534 /**
535  * @brief Configures the specified component to disallow any data types. This API resets the settings configured through
536  *        {@link OH_ArkUI_SetNodeAllowedDropDataTypes}.
537  *
538  * @param node Indicates the pointer to a component node.
539  * @return Returns the result code.
540  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
541  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
542  * @since 12
543  */
544 int32_t OH_ArkUI_DisallowNodeAnyDropDataTypes(ArkUI_NodeHandle node);
545 
546 /**
547  * @brief Configures the specified component to allow any data types. This API resets the settings configured through
548  *        {@link OH_ArkUI_SetNodeAllowedDropDataTypes}.
549  *
550  * @param node Indicates the pointer to a component node.
551  * @return Returns the result code.
552  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
553  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
554  * @since 12
555  */
556 int32_t OH_ArkUI_AllowNodeAllDropDataTypes(ArkUI_NodeHandle node);
557 
558 /**
559  * @brief Sets whether the specified component is draggable.
560  *
561  * @param node Indicates the pointer to a component node.
562  * @param bool Indicates whether the component is draggable.
563  * @return Returns the result code.
564  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
565  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
566  * @since 12
567  */
568 int32_t OH_ArkUI_SetNodeDraggable(ArkUI_NodeHandle node, bool enabled);
569 
570 /**
571  * @brief Sets a custom drag preview for the specified component.
572  *
573  * @param node Indicates the pointer to a component node.
574  * @param preview Indicates the custom drag preview, which is a pixel map.
575  * @return Returns the result code.
576  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
577  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
578  * @since 12
579  */
580 int32_t OH_ArkUI_SetNodeDragPreview(ArkUI_NodeHandle node, OH_PixelmapNative* preview);
581 
582 /**
583  * @brief Creates an <b>ArkUI_DragPreviewOption</b> object.
584  *
585  * @return Returns the created <b>ArkUI_DragPreviewOption</b> object.
586  * @since 12
587  */
588 ArkUI_DragPreviewOption* OH_ArkUI_CreateDragPreviewOption(void);
589 
590 /**
591  * @brief Disposes of a <b>ArkUI_DragPreviewOption</b> object.
592  *
593  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
594  * @since 12
595  */
596 void OH_ArkUI_DragPreviewOption_Dispose(ArkUI_DragPreviewOption* option);
597 
598 /**
599  * @brief Sets the scale mode for an <b>ArkUI_DragPreviewOption</b> object.
600  *
601  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
602  * @param scaleMode Indicates the scale mode.
603  * @return Returns the result code.
604  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
605  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
606  * @since 12
607  */
608 int32_t OH_ArkUI_DragPreviewOption_SetScaleMode(ArkUI_DragPreviewOption* option, ArkUI_DragPreviewScaleMode scaleMode);
609 
610 /**
611  * @brief Sets whether to enable the shadow effect for an <b>ArkUI_DragPreviewOption</b> object.
612  *        The shadow effect is enabled by default.
613  *
614  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
615  * @param enabled Indicates whether to enable the shadow effect.
616  * @return Returns the result code.
617  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
618  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
619  * @since 12
620  */
621 int32_t OH_ArkUI_DragPreviewOption_SetDefaultShadowEnabled(ArkUI_DragPreviewOption* option, bool enabled);
622 
623 /**
624  * @brief Sets whether to enable the rounded corner effect for an <b>ArkUI_DragPreviewOption</b> object.
625  *        The rounded corner effect is enabled by default.
626  *
627  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
628  * @param enabled Indicates whether to enable the rounded corner effect.
629  * @return Returns the result code.
630  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
631  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
632  * @since 12
633  */
634 int32_t OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled(ArkUI_DragPreviewOption* option, bool enabled);
635 
636 /**
637  * @brief Sets whether to enable the badge for an <b>ArkUI_DragPreviewOption</b> object.
638  *        If this feature is enabled, a badge that contains the number of dragged items is displayed.
639  *
640  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
641  * @param enabled Indicates whether to enable badge.
642  * @return Returns the result code.
643  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
644  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
645  * @since 12
646  */
647 int32_t OH_ArkUI_DragPreviewOption_SetNumberBadgeEnabled(ArkUI_DragPreviewOption* option, bool enabled);
648 
649 /**
650  * @brief Sets the count on the badge.
651  *        The settings will overwrite the value in the <b>SetDragPreviewNumberBadgeEnabled</b> API.
652  *
653  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
654  * @param forcedNumber Indicates the count on the badge.
655  * @return Returns the result code.
656  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
657  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
658  * @since 12
659  */
660 int32_t OH_ArkUI_DragPreviewOption_SetBadgeNumber(ArkUI_DragPreviewOption* option, uint32_t forcedNumber);
661 
662 /**
663  * @brief Sets whether to enable the default animation on a click or touch, it's not used in drag action.
664  *
665  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
666  * @param enabled Indicates whether to enable the default animation on a click or touch.
667  * @return Returns the result code.
668  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
669  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
670  * @since 12
671  */
672 int32_t OH_ArkUI_DragPreviewOption_SetDefaultAnimationBeforeLiftingEnabled(
673     ArkUI_DragPreviewOption* option, bool enabled);
674 /**
675  * @brief Sets an <b>ArkUI_DragPreviewOption</b> object for the specified component.
676  *
677  * @param node Indicates the pointer to a component node.
678  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
679  * @return Returns the result code.
680  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
681  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
682  * @since 12
683  */
684 int32_t OH_ArkUI_SetNodeDragPreviewOption(ArkUI_NodeHandle node, ArkUI_DragPreviewOption* option);
685 
686 /**
687  * @brief Creates a drag action object for a UI instance based on the specified component node of the current
688  *        UI instance.
689  *
690  * @param node Indicates the pointer to a component node.
691  * @return Returns the pointer to the created drag action object; returns null if the operation fails.
692  * @since 12
693  */
694 ArkUI_DragAction* OH_ArkUI_CreateDragActionWithNode(ArkUI_NodeHandle node);
695 
696 /**
697  * @brief Creates a drag action object for the specified UI instance.
698  *
699  * @param uiContext Indicates the pointer to a UI instance.
700  * @return Returns the pointer to the created drag action object; returns null if the operation fails.
701  * @since 12
702  */
703 ArkUI_DragAction* OH_ArkUI_CreateDragActionWithContext(ArkUI_ContextHandle uiContext);
704 
705 /**
706  * @brief Disposes of a drag action object.
707  *
708  * @param dragAction Indicates the pointer to the target drag action object.
709  * @since 12
710  */
711 void OH_ArkUI_DragAction_Dispose(ArkUI_DragAction* dragAction);
712 
713 /**
714  * @brief Sets the pointer ID. If only one finger is operating on the screen, the pointer ID is 0.
715  *        In general cases, you can set the pointer ID to 0.
716  *
717  * @param dragAction Indicates the pointer to the target drag action object.
718  * @param pointer Indicates the pointer ID. The value ranges from 0 to 9.
719  * @return Returns the result code.
720  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
721  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
722  * @since 12
723  */
724 int32_t OH_ArkUI_DragAction_SetPointerId(ArkUI_DragAction* dragAction, int32_t pointer);
725 
726 /**
727  * @brief Sets the drag previews for a drag action.
728  *
729  * @param dragAction Indicates the pointer to the target drag action object.
730  * @param pixelmapArray Indicates the array of the drag previews to set, which must be pixel maps.
731  * @param size Indicates the size of the drag preview array.
732  * @return Returns the result code.
733  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
734  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
735  * @since 12
736  */
737 int32_t OH_ArkUI_DragAction_SetPixelMaps(
738     ArkUI_DragAction* dragAction, OH_PixelmapNative* pixelmapArray[], int32_t size);
739 
740 /**
741  * @brief Sets the touch point relative to the upper left corner of the first drag preview (pixel map).
742  *
743  * @param dragAction Indicates the pointer to the target drag action object.
744  * @param x Indicates the X coordinate of the touch point.
745  * @return Returns the result code.
746  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
747  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
748  * @since 12
749  */
750 int32_t OH_ArkUI_DragAction_SetTouchPointX(ArkUI_DragAction* dragAction, float x);
751 
752 /**
753  * @brief Sets the touch point relative to the upper left corner of the first drag preview (pixel map).
754  *
755  * @param dragAction Indicates the pointer to the target drag action object.
756  * @param y Indicates the Y coordinate of the touch point.
757  * @return Returns the result code.
758  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
759  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
760  * @since 12
761  */
762 int32_t OH_ArkUI_DragAction_SetTouchPointY(ArkUI_DragAction* dragAction, float y);
763 
764 /**
765  * @brief Sets the drag data.
766  *
767  * @param dragAction Indicates the pointer to the target drag action object.
768  * @param data Indicates the drag data.
769  * @return Returns the result code.
770  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
771  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
772  * @since 12
773  */
774 int32_t OH_ArkUI_DragAction_SetData(ArkUI_DragAction* dragAction, OH_UdmfData* data);
775 
776 /**
777  * @brief Sets an <b>ArkUI_DragPreviewOption</b> object for the specified drag action object.
778  *
779  * @param dragAction Indicates the pointer to the target drag action object.
780  * @param option Indicates the pointer to an <b>ArkUI_DragPreviewOption</b> object.
781  * @return Returns the result code.
782  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
783  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
784  * @since 12
785  */
786 int32_t OH_ArkUI_DragAction_SetDragPreviewOption(ArkUI_DragAction* dragAction, ArkUI_DragPreviewOption* option);
787 
788 /**
789  * @brief Registers a drag status listener.
790  *        This listener can be used to check whether the data is successfully  received and processed.
791  *
792  * @param dragAction Indicates the pointer to the target drag action object.
793  * @param userData Indicates the custom user data.
794  * @param listener
795  * Indicates the listener to register. When the callback is invoked, the system returns a pointer to the drag status
796  * object. The pointer is destroyed after the callback is complete and the application should not hold it anymore.
797  * @return Returns the result code.
798  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
799  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
800  * @since 12
801  */
802 int32_t OH_ArkUI_DragAction_RegisterStatusListener(ArkUI_DragAction* dragAction, void* userData,
803     void(*listener)(ArkUI_DragAndDropInfo* dragAndDropInfo, void* userData));
804 
805 /**
806  * @brief Unregisters a drag status listener.
807  *
808  * @param dragAction Indicates the pointer to the target drag action object.
809  * @since 12
810  */
811 void OH_ArkUI_DragAction_UnregisterStatusListener(ArkUI_DragAction* dragAction);
812 
813 /**
814  * @brief Obtains the drag status of a drag action.
815  *
816  * @param dragAndDropInfo Indicates the drag and drop information returned by the drag status listener.
817  * @return Returns an <b>ArkUI_DragStatus</b> object; returns <b>ArkUI_DRAG_STATUS_UNKNOWN</b> if an error occurs.
818  * @since 12
819  */
820 ArkUI_DragStatus OH_ArkUI_DragAndDropInfo_GetDragStatus(ArkUI_DragAndDropInfo* dragAndDropInfo);
821 
822 /**
823  * @brief Obtains a drag event based on the specified drag and drop information.
824  *        The drag event can then be used to obtain the drag result and the drag behavior, please note
825  *        other info is not included in such a drag event.
826  *
827  * @param dragAndDropInfo Indicates the drag and drop information returned by the drag status listener.
828  * @return Returns an <b>ArkUI_DragEvent</b> object; returns null if an error occurs.
829  * @since 12
830  */
831 ArkUI_DragEvent* OH_ArkUI_DragAndDropInfo_GetDragEvent(ArkUI_DragAndDropInfo* dragAndDropInfo);
832 
833 /**
834  * @brief Initiates a drag action through the specified drag action object.
835  *
836  * @param dragAction Indicates a drag action object.
837  * @return Returns the result code.
838  *         Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
839  *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
840  * @since 12
841  */
842 int32_t OH_ArkUI_StartDrag(ArkUI_DragAction* dragAction);
843 
844 #ifdef __cplusplus
845 };
846 #endif
847 
848 #endif // ARKUI_NATIVE_DRAG_AND_DROP_H
849 /** @} */