diff --git a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js index 13920cdcd5d4bd4a1633e134f77dd9ad04cbc1ef..ee0cd9d3ce6fa919b0edec111b1b4a1aeb1af60f 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js +++ b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js @@ -2765,6 +2765,7 @@ var DragPreviewMode; (function (DragPreviewMode) { DragPreviewMode["AUTO"] = 1; DragPreviewMode["DISABLE_SCALE"] = 2; + DragPreviewMode["ENABLE_DEFAULT_RADIUS"] = 4; })(DragPreviewMode || (DragPreviewMode = {})); var FoldStatus; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp index cff329dcc16d607373f9e80b945b9f6d7b7d24eb..9c942edbeadebaf406a80ae625e9cbd02a15edd1 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp @@ -5713,9 +5713,15 @@ NG::DragPreviewOption JSViewAbstract::ParseDragPreviewOptions (const JSCallbackI auto mode = obj->GetProperty("mode"); if (mode->IsNumber()) { int32_t modeValue = mode->ToNumber(); - if (modeValue >= static_cast(NG::DragPreviewMode::AUTO) && - modeValue <= static_cast(NG::DragPreviewMode::DISABLE_SCALE)) { - previewOption.mode = static_cast(modeValue); + JSViewAbstract::SetDragPreviewOptionMode(modeValue, previewOption); + } else if (mode->IsArray()) { + auto arr = JSRef::Cast(mode); + for (int32_t i = 0; i < arr->Length(); ++i) { + auto arrItem = arr->GetValueAt(i); + if (arrItem->IsNumber()) { + int32_t modeValue = arrItem->ToNumber(); + JSViewAbstract::SetDragPreviewOptionMode(modeValue, previewOption); + } } } @@ -9362,6 +9368,16 @@ bool JSViewAbstract::ParseBorderRadius(const JSRef& args, NG::BorderRadiu return true; } +void JSViewAbstract::SetDragPreviewOptionMode(const int32_t modeValue, NG::DragPreviewOption& previewOption) +{ + if (modeValue >= static_cast(NG::DragPreviewMode::AUTO) && + modeValue <= static_cast(NG::DragPreviewMode::DISABLE_SCALE)) { + previewOption.mode = static_cast(modeValue); + } else if (modeValue == static_cast(NG::DragPreviewMode::ENABLE_DEFAULT_RADIUS)) { + previewOption.radius = static_cast(modeValue); + } +} + void JSViewAbstract::SetDragPreviewOptionApply(const JSCallbackInfo& info, NG::DragPreviewOption& option) { JSRef obj = JSRef::Cast(info[0]); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h index 72106c456fce63880bc39947658b43b8b6863225..df9cb1634817a5f4f6bc2f4ba7d4a4641c168bd3 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h @@ -114,6 +114,7 @@ public: static void NewGetJsGradientColorStops(NG::Gradient& gradient, const JSRef& colorStops); static void JsScale(const JSCallbackInfo& info); + static void SetDragPreviewOptionMode(const int32_t modeValue, NG::DragPreviewOption& previewOption); static void SetDragPreviewOptionApply(const JSCallbackInfo& info, NG::DragPreviewOption& previewOption); static void SetDefaultScale(); static void JsScaleX(const JSCallbackInfo& info); diff --git a/frameworks/core/components_ng/event/drag_event.cpp b/frameworks/core/components_ng/event/drag_event.cpp index 9ed5c2e59575a73ea124cf21a3aded2adc1e5b74..0f582f0b550ca7272bd666ab0f33d922f9358367 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -73,6 +73,7 @@ constexpr Dimension PIXELMAP_BORDER_RADIUS = 16.0_vp; constexpr float DEFAULT_ANIMATION_SCALE = 0.95f; constexpr Dimension BADGE_RELATIVE_OFFSET = 8.0_vp; constexpr float DEFAULT_OPACITY = 0.95f; +constexpr Dimension PREVIEW_BORDER_RADIUS = 12.0_vp; #if defined(PIXEL_MAP_SUPPORTED) constexpr int32_t CREATE_PIXELMAP_TIME = 80; #endif @@ -923,6 +924,7 @@ void DragEventActuator::SetPixelMap(const RefPtr& actuator) []() { return AceType::MakeRefPtr(); }); imageNode->SetDragPreviewOptions(frameNode->GetDragPreviewOption()); ApplyNewestOptionExecutedFromModifierToNode(frameNode, imageNode); + ApplyBorderRadiusDragPreviewOptionToNode(frameNode, imageNode); auto renderProps = imageNode->GetPaintProperty(); renderProps->UpdateImageInterpolation(ImageInterpolation::HIGH); auto props = imageNode->GetLayoutProperty(); @@ -995,6 +997,11 @@ void DragEventActuator::UpdatePreviewOptionFromModifier(const RefPtr& options.opacity = DEFAULT_OPACITY; } + auto modifierBorderRadius = imageContext->GetBorderRadius(); + if (modifierBorderRadius.has_value()) { + options.borderRadius = modifierBorderRadius.value(); + } + // get the old preview option DragPreviewOption dragPreviewOption = frameNode->GetDragPreviewOption(); dragPreviewOption.options = options; // replace the options with the new one after applied @@ -1012,6 +1019,33 @@ void DragEventActuator::ApplyNewestOptionExecutedFromModifierToNode( ACE_UPDATE_NODE_RENDER_CONTEXT(Opacity, optionsFromModifier.opacity, targetNode); } +void DragEventActuator::ApplyBorderRadiusDragPreviewOptionToNode( + const RefPtr& optionHolderNode, const RefPtr& targetNode) +{ + const auto& target = targetNode->GetRenderContext(); + BorderRadiusProperty modifierBorderRadius = optionHolderNode->GetDragPreviewOption().options.borderRadius; + if (modifierBorderRadius.radiusTopLeft.has_value() || modifierBorderRadius.radiusTopRight.has_value() || + modifierBorderRadius.radiusBottomLeft.has_value() || modifierBorderRadius.radiusBottomRight.has_value()) { + target->UpdateBorderRadius(modifierBorderRadius); + target->UpdateClipEdge(true); + return; + } + + if (optionHolderNode->GetDragPreviewOption().radius != NG::DragPreviewMode::ENABLE_DEFAULT_RADIUS) { + TAG_LOGD(AceLogTag::ACE_DRAG, "radius is null"); + return; + } + + BorderRadiusProperty defaultBorderRadius; + defaultBorderRadius.SetRadius(PREVIEW_BORDER_RADIUS); + target->UpdateBorderRadius(defaultBorderRadius); + target->UpdateClipEdge(true); + + DragPreviewOption dragPreviewOption = optionHolderNode->GetDragPreviewOption(); + dragPreviewOption.options.borderRadius = defaultBorderRadius; + optionHolderNode->SetDragPreviewOptions(dragPreviewOption); +} + void DragEventActuator::SetEventColumn(const RefPtr& actuator) { TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent start set eventColumn."); @@ -1242,6 +1276,7 @@ void DragEventActuator::SetTextAnimation(const RefPtr& gestureH CHECK_NULL_VOID(dragNode); dragNode->SetDragPreviewOptions(frameNode->GetDragPreviewOption()); ApplyNewestOptionExecutedFromModifierToNode(frameNode, dragNode); + ApplyBorderRadiusDragPreviewOptionToNode(frameNode, dragNode); // create columnNode auto columnNode = FrameNode::CreateFrameNode(V2::COLUMN_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr(true)); diff --git a/frameworks/core/components_ng/event/drag_event.h b/frameworks/core/components_ng/event/drag_event.h index 5a94fc0ccf4a7aab1d91ec3a82d74eb1cc01c1ae..ff92fd2803c69bf27ab71a0758da7b76a662e811 100644 --- a/frameworks/core/components_ng/event/drag_event.h +++ b/frameworks/core/components_ng/event/drag_event.h @@ -226,6 +226,8 @@ private: void UpdatePreviewOptionFromModifier(const RefPtr& frameNode); void ApplyNewestOptionExecutedFromModifierToNode( const RefPtr& optionHolderNode, const RefPtr& targetNode); + void ApplyBorderRadiusDragPreviewOptionToNode( + const RefPtr& optionHolderNode, const RefPtr& targetNode); // check global dragging status bool IsGlobalStatusSuitableForDragging(); // check the current node's status to decide if it can initiate one drag operation diff --git a/frameworks/core/components_ng/event/gesture_event_hub.cpp b/frameworks/core/components_ng/event/gesture_event_hub.cpp index 3cf4a5c7ecaabe019e1435314a0cc9b5028f20b9..25f700f2d0b98300ccef227fb56d2db6f7721dd0 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub.cpp @@ -946,6 +946,7 @@ void GestureEventHub::OnDragStart(const GestureEvent& info, const RefPtrGetDipScale(); arkExtraInfoJson->Put("dip_scale", dipScale); UpdateExtraInfo(frameNode, arkExtraInfoJson); + UpdateExtraInfoRadius(frameNode, arkExtraInfoJson); auto container = Container::Current(); CHECK_NULL_VOID(container); auto windowId = container->GetWindowId(); @@ -1027,6 +1028,13 @@ void GestureEventHub::UpdateExtraInfo(const RefPtr& frameNode, std::u arkExtraInfoJson->Put("dip_opacity", opacity); } +void GestureEventHub::UpdateExtraInfoRadius(const RefPtr& frameNode, + std::unique_ptr& arkExtraInfoJson) +{ + BorderRadiusProperty borderRadius = frameNode->GetDragPreviewOption().options.borderRadius; + arkExtraInfoJson->Put("dip_radius", borderRadius.ToString().c_str()); +} + int32_t GestureEventHub::RegisterCoordinationListener(const RefPtr& context) { auto pipeline = AceType::DynamicCast(context); diff --git a/frameworks/core/components_ng/event/gesture_event_hub.h b/frameworks/core/components_ng/event/gesture_event_hub.h index f4fc16ddae4d14e115e170c858150bedb14ea729..a2afaaff5e3f5d6a219b6981b41243fb5de9a850 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.h +++ b/frameworks/core/components_ng/event/gesture_event_hub.h @@ -664,6 +664,7 @@ private: void OnDragStart(const GestureEvent& info, const RefPtr& context, const RefPtr frameNode, DragDropInfo dragDropInfo, const RefPtr& dragEvent); void UpdateExtraInfo(const RefPtr& frameNode, std::unique_ptr& arkExtraInfoJson); + void UpdateExtraInfoRadius(const RefPtr& frameNode, std::unique_ptr& arkExtraInfoJson); WeakPtr eventHub_; RefPtr scrollableActuator_; diff --git a/frameworks/core/components_ng/gestures/gesture_info.h b/frameworks/core/components_ng/gestures/gesture_info.h index dd687f6f4102d47849f6b3d1839811df24ad4e78..56bd3d28d5718c00b4920ee666ad2f99c1abadd9 100644 --- a/frameworks/core/components_ng/gestures/gesture_info.h +++ b/frameworks/core/components_ng/gestures/gesture_info.h @@ -22,6 +22,7 @@ #include "base/memory/ace_type.h" #include "base/utils/macros.h" #include "core/components_ng/event/gesture_info.h" +#include "core/components_ng/property/border_property.h" #include "core/gestures/gesture_event.h" #include "core/gestures/gesture_info.h" #include "core/gestures/gesture_type.h" @@ -35,10 +36,12 @@ class NGGestureRecognizer; enum class DragPreviewMode : int32_t { AUTO = 1, DISABLE_SCALE = 2, + ENABLE_DEFAULT_RADIUS = 4, }; typedef struct { double opacity; + BorderRadiusProperty borderRadius; } OptionsAfterApplied; struct DragPreviewOption { @@ -61,6 +64,7 @@ struct DragPreviewOption { } std::function)> onApply; OptionsAfterApplied options; // options from modifier after applied + DragPreviewMode radius = DragPreviewMode::AUTO; }; class ACE_EXPORT Gesture : public virtual AceType {