mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
!38612 【基础能力】ArkUI C-API支持通用拖拽控制能力
Merge pull request !38612 from Zhang Jinyu/capiDragControl
This commit is contained in:
commit
4a91320e26
@ -2639,6 +2639,8 @@ frameworks/core/interfaces/native/node/data_panel_modifier.cpp @arkui_image
|
||||
frameworks/core/interfaces/native/node/data_panel_modifier.h @arkui_image
|
||||
frameworks/core/interfaces/native/node/divider_modifier.cpp @arkuilayout
|
||||
frameworks/core/interfaces/native/node/divider_modifier.h @arkuilayout
|
||||
frameworks/core/interfaces/native/node/drag_adapter_impl.cpp @arkuievent
|
||||
frameworks/core/interfaces/native/node/drag_adapter_impl.h @arkuievent
|
||||
frameworks/core/interfaces/native/node/extension_companion_node.cpp @arkuiframework
|
||||
frameworks/core/interfaces/native/node/extension_companion_node.h @arkuiframework
|
||||
frameworks/core/interfaces/native/node/extension_custom_node.cpp @arkuiframework
|
||||
|
@ -4632,6 +4632,15 @@ void ViewAbstract::SetDragEventStrictReportingEnabled(bool dragEventStrictReport
|
||||
dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetDragEventStrictReportingEnabled(int32_t instanceId, bool dragEventStrictReportingEnabled)
|
||||
{
|
||||
auto pipeline = PipelineContext::GetContextByContainerId(instanceId);
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto dragDropManager = pipeline->GetDragDropManager();
|
||||
CHECK_NULL_VOID(dragDropManager);
|
||||
dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
|
||||
}
|
||||
|
||||
void ViewAbstract::SetDisallowDropForcedly(bool isDisallowDropForcedly)
|
||||
{
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
|
@ -656,6 +656,7 @@ public:
|
||||
static TextDirection GetDirection(FrameNode* frameNode);
|
||||
static std::map<AlignDirection, AlignRule> GetAlignRules(FrameNode* frameNode);
|
||||
static FlexAlign GetAlignSelf(FrameNode* frameNode);
|
||||
static void SetDragEventStrictReportingEnabled(int32_t instanceId, bool dragEventStrictReportingEnabled);
|
||||
// used in JS FrameNode
|
||||
static void SetJSFrameNodeOnClick(FrameNode* frameNode, GestureEventFunc&& clickEventFunc);
|
||||
static void SetJSFrameNodeOnTouch(FrameNode* frameNode, TouchEventFunc&& touchEventFunc);
|
||||
|
@ -1326,6 +1326,17 @@ struct ArkUIDragInteractionOptions {
|
||||
ArkUI_Bool defaultAnimationBeforeLifting;
|
||||
};
|
||||
|
||||
struct ArkUIDragPreViewAndInteractionOptions {
|
||||
bool isScaleEnabled = false;
|
||||
bool defaultAnimationBeforeLifting = false;
|
||||
bool isMultiSelectionEnabled = false;
|
||||
bool isNumberBadgeEnabled = false;
|
||||
bool isDefaultShadowEnabled = false;
|
||||
bool isDefaultRadiusEnabled = false;
|
||||
ArkUI_Int32 badgeNumber = 0;
|
||||
bool isShowBadge = true;
|
||||
};
|
||||
|
||||
struct ArkUI_DialogDismissEvent;
|
||||
typedef ArkUI_DialogDismissEvent* ArkUIDialogDismissEvent;
|
||||
|
||||
@ -1768,6 +1779,7 @@ struct ArkUICommonModifier {
|
||||
void (*setFocusBoxStyle)(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Int32 marginUnit,
|
||||
ArkUI_Float32 valueStrokeWidth, ArkUI_Int32 widthUnit, ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue);
|
||||
void (*resetFocusBoxStyle)(ArkUINodeHandle node);
|
||||
void (*setDisAllowDrop)(ArkUINodeHandle node);
|
||||
};
|
||||
|
||||
struct ArkUICommonShapeModifier {
|
||||
@ -4832,6 +4844,12 @@ typedef struct {
|
||||
ArkUINodeAdapterHandle (*getNodeAdapter)(ArkUINodeHandle host);
|
||||
} ArkUINodeAdapterAPI;
|
||||
|
||||
typedef struct {
|
||||
void (*setDragPreview)(ArkUINodeHandle node, void* dragPreview);
|
||||
void (*setDragEventStrictReportingEnabledWithNode)(bool enabled);
|
||||
void (*setDragEventStrictReportingEnabledWithContext)(ArkUI_Int32 instanceId, bool enabled);
|
||||
} ArkUIDragAdapterAPI;
|
||||
|
||||
/**
|
||||
* An API to control an implementation. When making changes modifying binary
|
||||
* layout, i.e. adding new events - increase ARKUI_NODE_API_VERSION above for binary
|
||||
@ -4848,6 +4866,7 @@ struct ArkUIFullNodeAPI {
|
||||
const ArkUIDialogAPI* (*getDialogAPI)();
|
||||
const ArkUIExtendedNodeAPI* (*getExtendedAPI)();
|
||||
const ArkUINodeAdapterAPI* (*getNodeAdapterAPI)();
|
||||
const ArkUIDragAdapterAPI* (*getDragAdapterAPI)();
|
||||
};
|
||||
|
||||
struct ArkUIAnyAPI {
|
||||
|
@ -43,6 +43,7 @@ template("ace_core_interfaces_native_node") {
|
||||
"node/custom_dialog_model.cpp",
|
||||
"node/data_panel_modifier.cpp",
|
||||
"node/divider_modifier.cpp",
|
||||
"node/drag_adapter_impl.cpp",
|
||||
"node/extension_companion_node.cpp",
|
||||
"node/extension_custom_node.cpp",
|
||||
"node/flex_modifier.cpp",
|
||||
|
54
frameworks/core/interfaces/native/node/drag_adapter_impl.cpp
Normal file
54
frameworks/core/interfaces/native/node/drag_adapter_impl.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "core/interfaces/native/node/drag_adapter_impl.h"
|
||||
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
#include "core/components_ng/base/view_abstract.h"
|
||||
#include "core/components_ng/event/gesture_event_hub.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
|
||||
namespace OHOS::Ace::DragAdapter {
|
||||
namespace {
|
||||
|
||||
void SetDragPreview(ArkUINodeHandle node, void* dragPreview)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<NG::FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
NG::DragDropInfo dragPreviewInfo;
|
||||
dragPreviewInfo.pixelMap = PixelMap::CreatePixelMap(dragPreview);
|
||||
NG::ViewAbstract::SetDragPreview(frameNode, dragPreviewInfo);
|
||||
}
|
||||
|
||||
void SetDragEventStrictReportingEnabledWithNode(bool enabled)
|
||||
{
|
||||
NG::ViewAbstract::SetDragEventStrictReportingEnabled(enabled);
|
||||
}
|
||||
|
||||
void SetDragEventStrictReportingEnabledWithContext(ArkUI_Int32 instanceId, bool enabled)
|
||||
{
|
||||
NG::ViewAbstract::SetDragEventStrictReportingEnabled(instanceId, enabled);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
const ArkUIDragAdapterAPI* GetDragAdapterAPI()
|
||||
{
|
||||
static const ArkUIDragAdapterAPI impl {
|
||||
SetDragPreview,
|
||||
SetDragEventStrictReportingEnabledWithNode,
|
||||
SetDragEventStrictReportingEnabledWithContext
|
||||
};
|
||||
return &impl;
|
||||
}
|
||||
} // namespace OHOS::Ace::DragAdapter
|
34
frameworks/core/interfaces/native/node/drag_adapter_impl.h
Normal file
34
frameworks/core/interfaces/native/node/drag_adapter_impl.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODED_DRAG_ADAPTER_IMPL_H
|
||||
#define FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODED_DRAG_ADAPTER_IMPL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/error/error_code.h"
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/memory/referenced.h"
|
||||
#include "core/components_ng/base/ui_node.h"
|
||||
#include "core/interfaces/arkoala/arkoala_api.h"
|
||||
|
||||
|
||||
namespace OHOS::Ace::DragAdapter {
|
||||
const ArkUIDragAdapterAPI* GetDragAdapterAPI();
|
||||
} // namespace OHOS::Ace::DragAdapter
|
||||
#endif // FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODED_DRAG_ADAPTER_IMPL_H
|
@ -34,7 +34,9 @@
|
||||
#include "core/interfaces/native/node/calendar_picker_modifier.h"
|
||||
#include "core/interfaces/native/node/canvas_rendering_context_2d_modifier.h"
|
||||
#include "core/interfaces/native/node/custom_dialog_model.h"
|
||||
#include "core/interfaces/native/node/drag_adapter_impl.h"
|
||||
#include "core/interfaces/native/node/grid_modifier.h"
|
||||
#include "core/interfaces/native/node/image_animator_modifier.h"
|
||||
#include "core/interfaces/native/node/node_adapter_impl.h"
|
||||
#include "core/interfaces/native/node/node_animate.h"
|
||||
#include "core/interfaces/native/node/node_canvas_modifier.h"
|
||||
@ -43,6 +45,7 @@
|
||||
#include "core/interfaces/native/node/node_drag_modifier.h"
|
||||
#include "core/interfaces/native/node/node_date_picker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_image_modifier.h"
|
||||
#include "core/interfaces/native/node/node_list_item_modifier.h"
|
||||
#include "core/interfaces/native/node/node_list_modifier.h"
|
||||
#include "core/interfaces/native/node/node_refresh_modifier.h"
|
||||
#include "core/interfaces/native/node/node_scroll_modifier.h"
|
||||
@ -54,18 +57,12 @@
|
||||
#include "core/interfaces/native/node/node_textpicker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_timepicker_modifier.h"
|
||||
#include "core/interfaces/native/node/node_toggle_modifier.h"
|
||||
#include "core/interfaces/native/node/image_animator_modifier.h"
|
||||
#include "core/interfaces/native/node/util_modifier.h"
|
||||
#include "core/interfaces/native/node/grid_modifier.h"
|
||||
#include "core/interfaces/native/node/alphabet_indexer_modifier.h"
|
||||
#include "core/interfaces/native/node/search_modifier.h"
|
||||
#include "core/interfaces/native/node/radio_modifier.h"
|
||||
#include "core/interfaces/native/node/search_modifier.h"
|
||||
#include "core/interfaces/native/node/select_modifier.h"
|
||||
#include "core/interfaces/native/node/util_modifier.h"
|
||||
#include "core/interfaces/native/node/view_model.h"
|
||||
#include "core/interfaces/native/node/water_flow_modifier.h"
|
||||
#include "core/interfaces/native/node/node_list_item_modifier.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
@ -2018,6 +2015,7 @@ ArkUIFullNodeAPI impl_full = {
|
||||
GetDialogAPI,
|
||||
GetExtendedAPI, // Extended
|
||||
NodeAdapter::GetNodeAdapterAPI, // adapter.
|
||||
DragAdapter::GetDragAdapterAPI, // drag adapter.
|
||||
};
|
||||
/* clang-format on */
|
||||
} // namespace
|
||||
|
@ -2825,6 +2825,13 @@ void ResetAllowDrop(ArkUINodeHandle node)
|
||||
ViewAbstract::SetAllowDrop(frameNode, allowDrop);
|
||||
}
|
||||
|
||||
void SetDisAllowDrop(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
frameNode->SetDisallowDropForcedly(true);
|
||||
}
|
||||
|
||||
void SetAccessibilityLevel(ArkUINodeHandle node, ArkUI_CharPtr value)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
@ -6178,7 +6185,7 @@ const ArkUICommonModifier* GetCommonModifier()
|
||||
ResetAccessibilityActions, GetAccessibilityActions, SetAccessibilityRole, ResetAccessibilityRole,
|
||||
GetAccessibilityRole, SetFocusScopeId, ResetFocusScopeId, SetFocusScopePriority, ResetFocusScopePriority,
|
||||
SetPixelRound, ResetPixelRound, SetBorderDashParams, GetExpandSafeArea, SetTransition, SetDragPreview,
|
||||
ResetDragPreview, GetNodeUniqueId, SetFocusBoxStyle, ResetFocusBoxStyle };
|
||||
ResetDragPreview, GetNodeUniqueId, SetFocusBoxStyle, ResetFocusBoxStyle, SetDisAllowDrop };
|
||||
|
||||
return &modifier;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void SetDragEventProperty(const RefPtr<OHOS::Ace::DragEvent>& info, ArkUINodeEve
|
||||
++index;
|
||||
}
|
||||
event.dragEvent.dataTypes = strList.data();
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength;
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength + 1;
|
||||
}
|
||||
|
||||
void SetOnDragDrop(ArkUINodeHandle node, void* extraParam)
|
||||
@ -272,7 +272,7 @@ void SetOnDragEnd(ArkUINodeHandle node, void* extraParam)
|
||||
++index;
|
||||
}
|
||||
event.dragEvent.dataTypes = strList.data();
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength;
|
||||
event.dragEvent.dataTypesMaxStrLength = maxLength + 1;
|
||||
|
||||
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
|
||||
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
||||
*/
|
||||
typedef enum {
|
||||
/** The drag and drop operation succeeded. */
|
||||
ARKUI_DRAG_RESULT_SUCCESSFUL,
|
||||
ARKUI_DRAG_RESULT_SUCCESSFUL = 0,
|
||||
/** The drag and drop operation failed. */
|
||||
ARKUI_DRAG_RESULT_FAILED,
|
||||
/** The drag and drop operation was canceled. */
|
||||
@ -66,7 +66,7 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
/** Copy. */
|
||||
ARKUI_DROP_OPERATION_COPY,
|
||||
ARKUI_DROP_OPERATION_COPY = 0,
|
||||
/** Cut. */
|
||||
ARKUI_DROP_OPERATION_MOVE,
|
||||
} ArkUI_DropOperation;
|
||||
@ -105,7 +105,7 @@ typedef enum {
|
||||
* The system automatically changes the position of the dragged point based on the scenario and
|
||||
* scales the drag preview based on set rules.
|
||||
*/
|
||||
ARKUI_DRAG_PREVIEW_SCALE_AUTO,
|
||||
ARKUI_DRAG_PREVIEW_SCALE_AUTO = 0,
|
||||
/** The system does not scale the drag preview. */
|
||||
ARKUI_DRAG_PREVIEW_SCALE_DISABLED,
|
||||
} ArkUI_DragPreviewScaleMode;
|
||||
@ -117,7 +117,7 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
/** Unknown. */
|
||||
ARKUI_DRAG_STATUS_UNKNOWN = 0,
|
||||
ARKUI_DRAG_STATUS_UNKNOWN = -1,
|
||||
/** Started. */
|
||||
ARKUI_DRAG_STATUS_STARTED,
|
||||
/** Ended. */
|
||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetModifierKeyStates(ArkUI_DragEvent* event, int64_t* keys)
|
||||
{
|
||||
if (event == NULL || keys == NULL) {
|
||||
if (!event || !keys) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
@ -96,11 +96,12 @@ int32_t OH_ArkUI_DragEvent_GetDataTypes(
|
||||
}
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
if (dragEvent->dataTypes[i]) {
|
||||
auto ret = strncpy_s(eventTypeArray[i], maxStrLen, dragEvent->dataTypes[i], maxStrLen);
|
||||
auto strLeng = strlen(dragEvent->dataTypes[i]) + 1;
|
||||
auto ret = strncpy_s(eventTypeArray[i], strLeng, dragEvent->dataTypes[i], strLeng - 1);
|
||||
if (ret != 0) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
eventTypeArray[i][maxStrLen] = '\0';
|
||||
eventTypeArray[i][strLeng] = '\0';
|
||||
} else {
|
||||
eventTypeArray[i][0] = '\0';
|
||||
}
|
||||
@ -108,6 +109,364 @@ int32_t OH_ArkUI_DragEvent_GetDataTypes(
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent* nodeEvent)
|
||||
{
|
||||
if (!nodeEvent || nodeEvent->category != static_cast<int32_t>(NODE_EVENT_CATEGORY_COMPONENT_EVENT)) {
|
||||
return ArkUI_PreviewDragStatus::ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN;
|
||||
}
|
||||
const auto* originNodeEvent = reinterpret_cast<ArkUINodeEvent*>(nodeEvent->origin);
|
||||
if (!originNodeEvent) {
|
||||
return ArkUI_PreviewDragStatus::ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN;
|
||||
}
|
||||
auto status = static_cast<ArkUI_PreviewDragStatus>(originNodeEvent->componentAsyncEvent.data[0].i32);
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_DisableDefaultDropAnimation(ArkUI_DragEvent* event, bool disable)
|
||||
{
|
||||
if (!event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
dragEvent->useCustomDropAnimation = disable;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetNodeDraggable(ArkUI_NodeHandle node, bool enabled)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !node) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
impl->getNodeModifiers()->getCommonModifier()->setDraggable(node->uiNodeHandle, enabled);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_DragPreviewOption* OH_ArkUI_CreateDragPreviewOption(void)
|
||||
{
|
||||
auto* previewOptions = new ArkUIDragPreViewAndInteractionOptions();
|
||||
return reinterpret_cast<ArkUI_DragPreviewOption*>(previewOptions);
|
||||
}
|
||||
|
||||
void OH_ArkUI_DragPreviewOption_Dispose(ArkUI_DragPreviewOption* option)
|
||||
{
|
||||
delete reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
option = nullptr;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetScaleMode(ArkUI_DragPreviewOption* option, ArkUI_DragPreviewScaleMode scaleMode)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
if (scaleMode == ArkUI_DragPreviewScaleMode::ARKUI_DRAG_PREVIEW_SCALE_AUTO) {
|
||||
options->isScaleEnabled = true;
|
||||
options->isDefaultShadowEnabled = false;
|
||||
options->isDefaultRadiusEnabled = false;
|
||||
} else {
|
||||
options->isScaleEnabled = false;
|
||||
}
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultShadowEnabled(ArkUI_DragPreviewOption* option, bool enabled)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
options->isDefaultShadowEnabled = enabled;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled(ArkUI_DragPreviewOption* option, bool enabled)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
options->isDefaultRadiusEnabled = enabled;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetNumberBadgeEnabled(ArkUI_DragPreviewOption* option, bool enabled)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
options->isNumberBadgeEnabled = enabled;
|
||||
options->badgeNumber = static_cast<ArkUI_Int32>(enabled);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetBadgeNumber(ArkUI_DragPreviewOption* option, uint32_t forcedNumber)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
options->badgeNumber = static_cast<ArkUI_Int32>(forcedNumber);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragPreviewOption_SetDefaultAnimationBeforeLiftingEnabled(
|
||||
ArkUI_DragPreviewOption* option, bool enabled)
|
||||
{
|
||||
if (!option) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* options = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
options->defaultAnimationBeforeLifting = enabled;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetNodeDragPreviewOption(ArkUI_NodeHandle node, ArkUI_DragPreviewOption* option)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !node) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* previewOption = reinterpret_cast<ArkUIDragPreViewAndInteractionOptions*>(option);
|
||||
ArkUIDragPreViewOptions dragPreviewOptions;
|
||||
ArkUI_Int32 modeArray[3] = { -1, -1, -1 };
|
||||
ArkUI_Int32 modeSize = 0;
|
||||
|
||||
if (previewOption->isScaleEnabled) {
|
||||
modeArray[modeSize] = 1; // 1: DragPreviewMode::AUTO
|
||||
modeSize++;
|
||||
} else {
|
||||
modeArray[modeSize] = 2; // 2: DragPreviewMode::DISABLE_SCAL
|
||||
modeSize++;
|
||||
if (previewOption->isDefaultShadowEnabled) {
|
||||
modeArray[modeSize] = 3; // 3: DragPreviewMode::ENABLE_DEFAULT_SHADOW
|
||||
modeSize++;
|
||||
}
|
||||
if (previewOption->isDefaultRadiusEnabled) {
|
||||
modeArray[modeSize] = 4; // 4: DragPreviewMode::ENABLE_DEFAULT_RADIUS
|
||||
modeSize++;
|
||||
}
|
||||
}
|
||||
dragPreviewOptions.isModeArray = true;
|
||||
dragPreviewOptions.modeArray = modeArray;
|
||||
dragPreviewOptions.modeArrayLength = modeSize;
|
||||
dragPreviewOptions.isBadgeNumber = previewOption->isNumberBadgeEnabled;
|
||||
dragPreviewOptions.badgeNumber = previewOption->badgeNumber;
|
||||
dragPreviewOptions.isShowBadge = previewOption->isShowBadge;
|
||||
|
||||
ArkUIDragInteractionOptions dragInteractionOptions;
|
||||
dragInteractionOptions.defaultAnimationBeforeLifting = previewOption->defaultAnimationBeforeLifting;
|
||||
dragInteractionOptions.isMultiSelectionEnabled = previewOption->isMultiSelectionEnabled;
|
||||
|
||||
impl->getNodeModifiers()->getCommonModifier()->setDragPreviewOptions(
|
||||
node->uiNodeHandle, dragPreviewOptions, dragInteractionOptions);
|
||||
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetNodeDragPreview(ArkUI_NodeHandle node, OH_PixelmapNative* preview)
|
||||
{
|
||||
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!impl || !node || !preview) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto previewPixelNative = reinterpret_cast<OH_PixelmapNativeHandle>(preview);
|
||||
auto pixelMap = previewPixelNative->GetInnerPixelmap();
|
||||
impl->getDragAdapterAPI()->setDragPreview(node->uiNodeHandle, &pixelMap);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
int32_t OH_ArkUI_SetNodeAllowedDropDataTypes(ArkUI_NodeHandle node, const char* typesArray[], int32_t count)
|
||||
{
|
||||
auto* fullImpl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!fullImpl || !node || !typesArray) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
fullImpl->getNodeModifiers()->getCommonModifier()->setAllowDrop(node->uiNodeHandle, typesArray, count);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetDragEventStrictReportWithNode(ArkUI_NodeHandle node, bool enabled)
|
||||
{
|
||||
auto* fullImpl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!fullImpl || !node) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
fullImpl->getDragAdapterAPI()->setDragEventStrictReportingEnabledWithNode(enabled);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetDragEventStrictReportWithContext(ArkUI_ContextHandle uiContext, bool enabled)
|
||||
{
|
||||
auto* fullImpl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!fullImpl || !uiContext) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* context = reinterpret_cast<ArkUI_Context*>(uiContext);
|
||||
auto id = context->id;
|
||||
fullImpl->getDragAdapterAPI()->setDragEventStrictReportingEnabledWithContext(id, enabled);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DisallowNodeAnyDropDataTypes(ArkUI_NodeHandle node)
|
||||
{
|
||||
auto* fullImpl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!fullImpl || !node) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
fullImpl->getNodeModifiers()->getCommonModifier()->setDisAllowDrop(node->uiNodeHandle);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_AllowNodeAllDropDataTypes(ArkUI_NodeHandle node)
|
||||
{
|
||||
auto* fullImpl = OHOS::Ace::NodeModel::GetFullImpl();
|
||||
if (!fullImpl || !node) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
fullImpl->getNodeModifiers()->getCommonModifier()->resetAllowDrop(node->uiNodeHandle);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult* result)
|
||||
{
|
||||
if (!event || !result) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
*result = static_cast<ArkUI_DragResult>(dragEvent->dragResult);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_SetDragResult(ArkUI_DragEvent* event, ArkUI_DragResult result)
|
||||
{
|
||||
if (!event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
dragEvent->dragResult = static_cast<ArkUI_Int32>(result);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_SetSuggestedDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation proposal)
|
||||
{
|
||||
if (!event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
dragEvent->dragBehavior = static_cast<ArkUI_Int32>(proposal);
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetPreviewTouchPointX(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->touchPointX);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetPreviewTouchPointY(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->touchPointY);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetPreviewRectWidth(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->previewRectWidth);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetPreviewRectHeight(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->previewRectHeight);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetTouchPointXToWindow(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->windowX);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetTouchPointYToWindow(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->windowY);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetTouchPointXToDisplay(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->displayX);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->displayY);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetVelocityX(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->velocityX);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetVelocityY(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->velocityY);
|
||||
return result;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetVelocity(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
return 0.0f;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
auto result = static_cast<float>(dragEvent->velocity);
|
||||
return result;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user