已合并
add drag and select api to grid #4191
zcdqs创建于 2025年11月4日
add drag and select api to grid #4191
已合并
共 1 个文件变更+202-0
| @@ -7516,6 +7516,58 @@ typedef enum { | |||
| 7516 | */ | 7516 | */ |
| 7517 | NODE_GRID_COLUMN_TEMPLATE_ITEMFILLPOLICY = 1013010, | 7517 | NODE_GRID_COLUMN_TEMPLATE_ITEMFILLPOLICY = 1013010, |
| 7518 | 7518 | ||
| 7519 | + /** | ||
| 7520 | + * @brief Specifies whether to enable edit mode for the <b>Grid</b> component. | ||
| 7521 | + * In edit mode, <b>GridItem</b> components can be dragged through the <b>NODE_GRID_ON_ITEM_DRAG_START</b> event. | ||
| 7522 | + * This attribute can be set, reset, and obtained as required through APIs. | ||
| 7523 | + * | ||
| 7524 | + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n | ||
| 7525 | + * .value[0].i32: whether to enable edit mode for the <b>Grid</b> component. | ||
| 7526 | + * </b>: Disable edit mode. <b>1</b>: Enable edit mode. Default value: <b>0</b>.\n | ||
| 7527 | + * \n | ||
| 7528 | + * Format of the return value {@link ArkUI_AttributeItem}:\n | ||
| 7529 | + * .value[0].i32: whether to enable edit mode for the <b>Grid</b> component. | ||
| 7530 | + * <b>0</b>: Disable edit mode. <b>1</b>: Enable edit mode. \n | ||
| 7531 | + * | ||
| 7532 | + * @since 23 | ||
| 7533 | + */ | ||
| 7534 | + NODE_GRID_EDIT_MODE = 1013011, | ||
| 7535 | + | ||
| 7536 | + /** | ||
| 7537 | + * @brief Specifies whether to enable the drag animation for <b>GridItem</b> components in the <b>Grid</b> | ||
| 7538 | + * container. This attribute can be set, reset, and obtained as required through APIs. | ||
| 7539 | + * Animations are supported only in scrolling mode (when either <b>NODE_GRID_ROW_TEMPLATE</b> or | ||
| 7540 | + * <b>NODE_GRID_COLUMN_TEMPLATE</b> is set, but not both). Drag animations are only supported in regularly sized | ||
| 7541 | + * grid layouts; scenarios involving spanning across rows or columns are not supported. | ||
| 7542 | + * | ||
| 7543 | + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n | ||
| 7544 | + * .value[0].i32: whether to enable the drag animation for <b>GridItem</b> components in the <b>Grid</b> container. | ||
| 7545 | + * <b>0</b>: Disable the drag animation. <b>1</b>: Enable the drag animation. Default value: <b>0</b>.\n | ||
| 7546 | + * \n | ||
| 7547 | + * Format of the return value {@link ArkUI_AttributeItem}:\n | ||
| 7548 | + * .value[0].i32: whether to enable the drag animation for <b>GridItem</b> components in the <b>Grid</b> container. | ||
| 7549 | + * <b>0</b>: Disable the drag animation. <b>1</b>: Enable the drag animation. \n | ||
| 7550 | + * | ||
| 7551 | + * @since 23 | ||
| 7552 | + */ | ||
| 7553 | + NODE_GRID_DRAG_ANIMATION = 1013012, | ||
| 7554 | + | ||
| 7555 | + /** | ||
| 7556 | + * @brief Specifies whether to enable mouse-based multi-selection in the <b>Grid</b> container. This attribute can | ||
| 7557 | + * be set, reset, and obtained as required through APIs. When enabled, mouse-based multi-selection within the | ||
| 7558 | + * <b>Grid</b> area triggers the <b>NODE_GRID_ITEM_EVENT_ON_SELECT</b> event on <b>GridItem</b> components. | ||
| 7559 | + * | ||
| 7560 | + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n | ||
| 7561 | + * .value[0].i32: whether to enable mouse-based multi-selection. | ||
| 7562 | + * <b>0</b>: Disable mouse-based multi-selection. <b>1</b>: Enable mouse-based multi-selection. Default value: | ||
| 7563 | + * <b>0</b>.\n \n Format of the return value {@link ArkUI_AttributeItem}:\n .value[0].i32: whether to enable | ||
| 7564 | + * mouse-based multi-selection. <b>0</b>: Disable mouse-based multi-selection. <b>1</b>: Enable mouse-based | ||
| 7565 | + * multi-selection. \n | ||
| 7566 | + * | ||
| 7567 | + * @since 23 | ||
| 7568 | + */ | ||
| 7569 | + NODE_GRID_MULTI_SELECTABLE = 1013013, | ||
| 7570 | + | ||
| 7519 | /** | 7571 | /** |
| 7520 | * @brief Sets the style of the <b>GridItem</b> component. | 7572 | * @brief Sets the style of the <b>GridItem</b> component. |
| 7521 | * This attribute can be set, reset, and obtained as required through APIs. | 7573 | * This attribute can be set, reset, and obtained as required through APIs. |
| @@ -7531,6 +7583,37 @@ typedef enum { | |||
| 7531 | */ | 7583 | */ |
| 7532 | NODE_GRID_ITEM_STYLE = MAX_NODE_SCOPE_NUM * ARKUI_NODE_GRID_ITEM, | 7584 | NODE_GRID_ITEM_STYLE = MAX_NODE_SCOPE_NUM * ARKUI_NODE_GRID_ITEM, |
| 7533 | 7585 | ||
| 7586 | + /** | ||
| 7587 | + * @brief Specifies whether the <b>GridItem</b> component can be selected using mouse-based multi-selection. | ||
| 7588 | + * This attribute can be set, reset, and obtained as required through APIs. | ||
| 7589 | + * | ||
| 7590 | + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n | ||
| 7591 | + * .value[0].i32: whether the <b>GridItem</b> component can be selected using mouse-based multi-selection. | ||
| 7592 | + * <b>0</b>: not selectable. <b>1</b>: selectable. Default value: <b>1</b>.\n | ||
| 7593 | + * \n | ||
| 7594 | + * Format of the return value {@link ArkUI_AttributeItem}:\n | ||
| 7595 | + * .value[0].i32: whether the <b>GridItem</b> component can be selected using mouse-based multi-selection. | ||
| 7596 | + * <b>0</b>: not selectable. <b>1</b>: selectable. \n | ||
| 7597 | + * | ||
| 7598 | + * @since 23 | ||
| 7599 | + */ | ||
| 7600 | + NODE_GRID_ITEM_SELECTABLE = 1014001, | ||
| 7601 | + | ||
| 7602 | + /** | ||
| 7603 | + * @brief Sets the selected state of the <b>GridItem</b> component. | ||
| 7604 | + * This attribute can be set, reset, and obtained as required through APIs. | ||
| 7605 | + * | ||
| 7606 | + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n | ||
| 7607 | + * .value[0].i32: selected state of the <b>GridItem</b> component. | ||
| 7608 | + * <b>0</b>: not selected. <b>1</b>: selected. Default value: <b>0</b>.\n | ||
| 7609 | + * \n | ||
| 7610 | + * Format of the return value {@link ArkUI_AttributeItem}:\n | ||
| 7611 | + * .value[0].i32: selected state of the <b>GridItem</b> component. <b>0</b>: not selected. <b>1</b>: selected. \n | ||
| 7612 | + * | ||
| 7613 | + * @since 23 | ||
| 7614 | + */ | ||
| 7615 | + NODE_GRID_ITEM_SELECTED = 1014002, | ||
| 7616 | + | ||
| 7534 | /** | 7617 | /** |
| 7535 | * @brief Defines the column width of the text picker. | 7618 | * @brief Defines the column width of the text picker. |
| 7536 | * This attribute can be set, reset, and obtained as required through APIs. | 7619 | * This attribute can be set, reset, and obtained as required through APIs. |
| @@ -9248,6 +9331,125 @@ typedef enum { | |||
| 9248 | * @since 22 | 9331 | * @since 22 |
| 9249 | */ | 9332 | */ |
| 9250 | NODE_GRID_ON_SCROLL_BAR_UPDATE = 1013003, | 9333 | NODE_GRID_ON_SCROLL_BAR_UPDATE = 1013003, |
| 9334 | + | ||
| 9335 | + /** | ||
| 9336 | + * @brief Defines the <b>Grid</b> component's child drag start event. | ||
| 9337 | + * | ||
| 9338 | + * This event is triggered under the following scenarios: \n | ||
| 9339 | + * 1. <b>NODE_GRID_EDIT_MODE</b> is set to <b>1</b>. \n | ||
| 9340 | + * 2. The user long-presses and drags a <b>Grid</b> child component with sufficient displacement. \n | ||
| 9341 | + * The event parameter is {@link ArkUI_NodeEvent}. \n | ||
| 9342 | + * value.f32 at index 0: x-coordinate of the current drag point relative to the <b>Grid</b> component, in vp, | ||
| 9343 | + * obtained using <b>OH_ArkUI_NodeEvent_GetNumberValue</b>. \n | ||
| 9344 | + * value.f32 at index 1: y-coordinate of the current drag point relative to the <b>Grid</b> component, in vp, | ||
| 9345 | + * obtained using <b>OH_ArkUI_NodeEvent_GetNumberValue</b>. \n | ||
| 9346 | + * value.i32 at index 2: index of the dragged child component in the <b>Grid</b> component, | ||
| 9347 | + * obtained using <b>OH_ArkUI_NodeEvent_GetNumberValue</b>. \n | ||
| 9348 | + * | ||
| 9349 | + * @return Whether the drag operation is allowed. \n | ||
| 9350 | + * You can set the return value using <b>OH_ArkUI_NodeEvent_SetReturnNumberValue</b>. \n | ||
| 9351 | + * value.i32 at index 0 in the return value indicates whether dragging is allowed. | ||
| 9352 | + * <b>0</b>: not allowed. <b>1</b>: allowed. \n | ||
| 9353 | + * | ||
| 9354 | + * @since 23 | ||
| 9355 | + */ | ||
| 9356 | + NODE_GRID_ON_ITEM_DRAG_START = 1013004, | ||
| 9357 | + | ||
| 9358 | + /** | ||
| 9359 | + * @brief Defines the event triggered when a dragged child component enters this <b>Grid</b> component's area. | ||
| 9360 | + * | ||
| 9361 | + * This event is triggered under the following scenarios:\n | ||
| 9362 | + * A child component successfully dragged using <b>NODE_GRID_ON_ITEM_DRAG_START</b> enters the current <b>Grid</b> | ||
| 9363 | + * component's area. \n | ||
| 9364 | + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is | ||
| 9365 | + * {@link ArkUI_NodeComponentEvent}. \n | ||
| 9366 | + * {@link ArkUI_NodeComponentEvent} contains two parameters:\n | ||
| 9367 | + * <b>ArkUI_NodeComponentEvent.data[0].f32</b>: x-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9368 | + * component, in vp. \n | ||
| 9369 | + * <b>ArkUI_NodeComponentEvent.data[1].f32</b>: y-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9370 | + * component, in vp. \n | ||
| 9371 | + * | ||
| 9372 | + * @since 23 | ||
| 9373 | + */ | ||
| 9374 | + NODE_GRID_ON_ITEM_DRAG_ENTER = 1013005, | ||
| 9375 | + | ||
| 9376 | + /** | ||
| 9377 | + * @brief Defines the event triggered when a dragged child component moves within this <b>Grid</b> component's area. | ||
| 9378 | + * | ||
| 9379 | + * This event is triggered under the following scenarios:\n | ||
| 9380 | + * A child component successfully dragged using <b>NODE_GRID_ON_ITEM_DRAG_START</b> moves within the current | ||
| 9381 | + * <b>Grid</b> component's area. \n | ||
| 9382 | + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is | ||
| 9383 | + * {@link ArkUI_NodeComponentEvent}. \n | ||
| 9384 | + * {@link ArkUI_NodeComponentEvent} contains four parameters: \n | ||
| 9385 | + * <b>ArkUI_NodeComponentEvent.data[0].f32</b>: x-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9386 | + * component, in vp. \n | ||
| 9387 | + * <b>ArkUI_NodeComponentEvent.data[1].f32</b>: y-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9388 | + * component, in vp. \n | ||
| 9389 | + * <b>ArkUI_NodeComponentEvent.data[2].i32</b>: index of the dragged child component in the source <b>Grid</b> | ||
| 9390 | + * component. \n | ||
| 9391 | + * <b>ArkUI_NodeComponentEvent.data[3].i32</b>: index of the dragged child component in the current <b>Grid</b> | ||
| 9392 | + * component. \n | ||
| 9393 | + * | ||
| 9394 | + * @since 23 | ||
| 9395 | + */ | ||
| 9396 | + NODE_GRID_ON_ITEM_DRAG_MOVE = 1013006, | ||
| 9397 | + | ||
| 9398 | + /** | ||
| 9399 | + * @brief Defines the event triggered when a dragged child component leaves this <b>Grid</b> component's area. | ||
| 9400 | + * | ||
| 9401 | + * This event is triggered under the following scenarios:\n | ||
| 9402 | + * A child component successfully dragged using <b>NODE_GRID_ON_ITEM_DRAG_START</b> leaves the current <b>Grid</b> | ||
| 9403 | + * component's area. \n | ||
| 9404 | + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is | ||
| 9405 | + * {@link ArkUI_NodeComponentEvent}. \n | ||
| 9406 | + * {@link ArkUI_NodeComponentEvent} contains three parameters:\n | ||
| 9407 | + * <b>ArkUI_NodeComponentEvent.data[0].f32</b>: x-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9408 | + * component, in vp. \n | ||
| 9409 | + * <b>ArkUI_NodeComponentEvent.data[1].f32</b>: y-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9410 | + * component, in vp. \n | ||
| 9411 | + * <b>ArkUI_NodeComponentEvent.data[2].i32</b>: index of the dragged child component in the source <b>Grid</b> | ||
| 9412 | + * component. \n | ||
| 9413 | + * | ||
| 9414 | + * @since 23 | ||
| 9415 | + */ | ||
| 9416 | + NODE_GRID_ON_ITEM_DRAG_LEAVE = 1013007, | ||
| 9417 | + | ||
| 9418 | + /** | ||
| 9419 | + * @brief Defines the event triggered when a dragged child component is released. | ||
| 9420 | + * | ||
| 9421 | + * This event is triggered under the following scenarios:\n | ||
| 9422 | + * A child component successfully dragged using <b>NODE_GRID_ON_ITEM_DRAG_START</b> is released. \n | ||
| 9423 | + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is | ||
| 9424 | + * {@link ArkUI_NodeComponentEvent}. \n | ||
| 9425 | + * {@link ArkUI_NodeComponentEvent} contains five parameters: \n | ||
| 9426 | + * <b>ArkUI_NodeComponentEvent.data[0].f32</b>: x-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9427 | + * component, in vp. \n | ||
| 9428 | + * <b>ArkUI_NodeComponentEvent.data[1].f32</b>: y-coordinate of the current drag point relative to the <b>Grid</b> | ||
| 9429 | + * component, in vp. \n | ||
| 9430 | + * <b>ArkUI_NodeComponentEvent.data[2].i32</b>: index of the dragged child component in the source <b>Grid</b> | ||
| 9431 | + * component. \n | ||
| 9432 | + * <b>ArkUI_NodeComponentEvent.data[3].i32</b>: index of the dragged child component in the current <b>Grid</b> | ||
| 9433 | + * component. \n | ||
| 9434 | + * <b>ArkUI_NodeComponentEvent.data[4].i32</b>: whether the dragged child component is successfully released. \n | ||
| 9435 | + * <b>1</b>: The component is released within the <b>Grid</b> component's area. | ||
| 9436 | + * <b>0</b>: The component is released outside the <b>Grid</b> component's area. \n | ||
| 9437 | + * | ||
| 9438 | + * @since 23 | ||
| 9439 | + */ | ||
| 9440 | + NODE_GRID_ON_ITEM_DROP = 1013008, | ||
| 9441 | + | ||
| 9442 | + /** | ||
| 9443 | + * @brief Defines the selected state change event of the <b>GridItem</b> component. | ||
| 9444 | + * | ||
| 9445 | + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is | ||
| 9446 | + * {@link ArkUI_NodeComponentEvent}. \n | ||
| 9447 | + * {@link ArkUI_NodeComponentEvent} contains one parameter:\n | ||
| 9448 | + * <b>ArkUI_NodeComponentEvent.data[0].i32</b>: selected state. <b>0</b>: not selected. <b>1</b>: selected. \n | ||
| 9449 | + * | ||
| 9450 | + * @since 23 | ||
| 9451 | + */ | ||
| 9452 | + NODE_GRID_ITEM_ON_SELECT = MAX_NODE_SCOPE_NUM * ARKUI_NODE_GRID_ITEM, | ||
| 9251 | } ArkUI_NodeEventType; | 9453 | } ArkUI_NodeEventType; |
| 9252 | 9454 | ||
| 9253 | /** | 9455 | /** |