mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
nested scroll C-API
Signed-off-by: zhouchaobo <zhouchaobo@huawei.com> Change-Id: I412984041aff90077bd947082f7f75c851aa0252
This commit is contained in:
parent
6b2daf4e0a
commit
5983ff9e43
@ -109,4 +109,8 @@ constexpr int32_t ERROR_CODE_COMPONENT_SNAPSHOT_TIMEOUT = 160002;
|
||||
|
||||
// FromHtml error code
|
||||
constexpr int32_t ERROR_CODE_FROM_HTML_CONVERT_ERROR = 170001;
|
||||
|
||||
// Gesture error code
|
||||
constexpr int32_t ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001;
|
||||
constexpr int32_t ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002;
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -1923,6 +1923,36 @@ class OnGestureJudgeBeginModifier extends ModifierWithKey<GestureJudgeBeginCallb
|
||||
}
|
||||
}
|
||||
|
||||
declare type GestureRecognizerJudgeBeginCallback = (event: BaseGestureEvent, current: GestureRecognizer, recognizers: Array<GestureRecognizer>) => GestureJudgeResult;
|
||||
class OnGestureRecognizerJudgeBeginModifier extends ModifierWithKey<GestureRecognizerJudgeBeginCallback> {
|
||||
constructor(value: GestureRecognizerJudgeBeginCallback) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('onGestureRecognizerJudgeBegin');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().common.resetOnGestureRecognizerJudgeBegin(node);
|
||||
} else {
|
||||
getUINativeModule().common.setOnGestureRecognizerJudgeBegin(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare type ShouldBuiltInRecognizerParallelWithCallback = (current: GestureRecognizer, others: Array<GestureRecognizer>) => GestureRecognizer;
|
||||
class ShouldBuiltInRecognizerParallelWithModifier extends ModifierWithKey<ShouldBuiltInRecognizerParallelWithCallback> {
|
||||
constructor(value: ShouldBuiltInRecognizerParallelWithCallback) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('shouldBuiltInRecognizerParallelWith');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().common.resetShouldBuiltInRecognizerParallelWith(node);
|
||||
} else {
|
||||
getUINativeModule().common.setShouldBuiltInRecognizerParallelWith(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MotionPathModifier extends ModifierWithKey<MotionPathOptions> {
|
||||
constructor(value: MotionPathOptions) {
|
||||
super(value);
|
||||
@ -3182,6 +3212,14 @@ class ArkComponent implements CommonMethod<CommonAttribute> {
|
||||
modifierWithKey(this._modifiersWithKeys, OnGestureJudgeBeginModifier.identity, OnGestureJudgeBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onGestureRecognizerJudgeBegin(callback: (event: BaseGestureEvent, current: GestureRecognizer, recognizers: Array<GestureRecognizer>) => GestureJudgeResult): this {
|
||||
modifierWithKey(this._modifiersWithKeys, OnGestureRecognizerJudgeBeginModifier.identity, OnGestureRecognizerJudgeBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
shouldBuiltInRecognizerParallelWith(callback: (current: GestureRecognizer, others: Array<GestureRecognizer>) => GestureRecognizer): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ShouldBuiltInRecognizerParallelWithModifier.identity, ShouldBuiltInRecognizerParallelWithModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onSizeChange(callback: (oldValue: SizeOptions, newValue: SizeOptions) => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, OnSizeChangeModifier.identity, OnSizeChangeModifier, callback);
|
||||
return this;
|
||||
|
@ -1795,6 +1795,32 @@ class OnGestureJudgeBeginModifier extends ModifierWithKey {
|
||||
}
|
||||
}
|
||||
OnGestureJudgeBeginModifier.identity = Symbol('onGestureJudgeBegin');
|
||||
class OnGestureRecognizerJudgeBeginModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().common.resetOnGestureRecognizerJudgeBegin(node);
|
||||
} else {
|
||||
getUINativeModule().common.setOnGestureRecognizerJudgeBegin(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
OnGestureRecognizerJudgeBeginModifier.identity = Symbol('onGestureRecognizerJudgeBegin');
|
||||
class ShouldBuiltInRecognizerParallelWithModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().common.resetShouldBuiltInRecognizerParallelWith(node);
|
||||
} else {
|
||||
getUINativeModule().common.setShouldBuiltInRecognizerParallelWith(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ShouldBuiltInRecognizerParallelWithModifier.identity = Symbol('shouldBuiltInRecognizerParallelWith');
|
||||
class MotionPathModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
@ -3078,6 +3104,14 @@ class ArkComponent {
|
||||
modifierWithKey(this._modifiersWithKeys, OnGestureJudgeBeginModifier.identity, OnGestureJudgeBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onGestureRecognizerJudgeBegin(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, OnGestureRecognizerJudgeBeginModifier.identity, OnGestureRecognizerJudgeBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
shouldBuiltInRecognizerParallelWith(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, ShouldBuiltInRecognizerParallelWithModifier.identity, ShouldBuiltInRecognizerParallelWithModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onSizeChange(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, OnSizeChangeModifier.identity, OnSizeChangeModifier, callback);
|
||||
return this;
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace OHOS::Ace::Framework {
|
||||
|
||||
RefPtr<NG::NGGestureRecognizer> JsShouldBuiltInRecognizerParallelWithFunction::Execute(
|
||||
const RefPtr<TouchEventTarget>& current, const std::vector<RefPtr<TouchEventTarget>>& others)
|
||||
const RefPtr<NG::NGGestureRecognizer>& current, const std::vector<RefPtr<NG::NGGestureRecognizer>>& others)
|
||||
{
|
||||
CHECK_NULL_RETURN(current, nullptr);
|
||||
auto currentObj = CreateRecognizerObject(current);
|
||||
@ -45,7 +45,7 @@ RefPtr<NG::NGGestureRecognizer> JsShouldBuiltInRecognizerParallelWithFunction::E
|
||||
}
|
||||
|
||||
JSRef<JSObject> JsShouldBuiltInRecognizerParallelWithFunction::CreateRecognizerObject(
|
||||
const RefPtr<TouchEventTarget>& target)
|
||||
const RefPtr<NG::NGGestureRecognizer>& target)
|
||||
{
|
||||
auto panRecognizer = AceType::DynamicCast<NG::PanRecognizer>(target);
|
||||
if (panRecognizer) {
|
||||
@ -58,7 +58,7 @@ JSRef<JSObject> JsShouldBuiltInRecognizerParallelWithFunction::CreateRecognizerO
|
||||
}
|
||||
JSRef<JSObject> recognizerObj = JSClass<JSGestureRecognizer>::NewInstance();
|
||||
auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSGestureRecognizer>());
|
||||
currentRecognizer->SetRecognizer(AceType::DynamicCast<NG::NGGestureRecognizer>(target));
|
||||
currentRecognizer->SetRecognizer(target);
|
||||
return recognizerObj;
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,7 @@ public:
|
||||
JSClass<JSGestureRecognizer>::CustomMethod("isEnabled", &JSGestureRecognizer::IsEnabled);
|
||||
JSClass<JSGestureRecognizer>::CustomMethod("getEventTargetInfo", &JSGestureRecognizer::GetEventTargetInfo);
|
||||
JSClass<JSGestureRecognizer>::CustomMethod("getState", &JSGestureRecognizer::GetRefereeState);
|
||||
JSClass<JSGestureRecognizer>::CustomMethod("isValid", &JSGestureRecognizer::IsValid);
|
||||
JSClass<JSGestureRecognizer>::Bind(
|
||||
globalObj, &JSGestureRecognizer::Constructor, &JSGestureRecognizer::Destructor);
|
||||
}
|
||||
@ -271,6 +272,16 @@ public:
|
||||
args.SetReturnValue(JSRef<JSVal>::Make(ToJSValue(static_cast<int32_t>(state))));
|
||||
}
|
||||
|
||||
void IsValid(const JSCallbackInfo& args)
|
||||
{
|
||||
bool isValid = false;
|
||||
auto recognizer = recognizer_.Upgrade();
|
||||
if (recognizer && recognizer->IsInResponseLinkRecognizers()) {
|
||||
isValid = true;
|
||||
}
|
||||
args.SetReturnValue(JSRef<JSVal>::Make(ToJSValue(isValid)));
|
||||
}
|
||||
|
||||
static GestureRecognizerState ConvertRefereeState(NG::RefereeState state)
|
||||
{
|
||||
switch (state) {
|
||||
@ -323,6 +334,7 @@ public:
|
||||
JSClass<JSPanRecognizer>::CustomMethod("getEventTargetInfo", &JSGestureRecognizer::GetEventTargetInfo);
|
||||
JSClass<JSPanRecognizer>::CustomMethod("getState", &JSGestureRecognizer::GetRefereeState);
|
||||
JSClass<JSPanRecognizer>::CustomMethod("getPanGestureOptions", &JSPanRecognizer::GetPanGestureOptions);
|
||||
JSClass<JSPanRecognizer>::CustomMethod("isValid", &JSGestureRecognizer::IsValid);
|
||||
JSClass<JSPanRecognizer>::Inherit<JSGestureRecognizer>();
|
||||
JSClass<JSPanRecognizer>::Bind(globalObj, &JSPanRecognizer::Constructor, &JSPanRecognizer::Destructor);
|
||||
}
|
||||
@ -377,8 +389,8 @@ public:
|
||||
}
|
||||
|
||||
RefPtr<NG::NGGestureRecognizer> Execute(
|
||||
const RefPtr<TouchEventTarget>& current, const std::vector<RefPtr<TouchEventTarget>>& others);
|
||||
static JSRef<JSObject> CreateRecognizerObject(const RefPtr<TouchEventTarget>& target);
|
||||
const RefPtr<NG::NGGestureRecognizer>& current, const std::vector<RefPtr<NG::NGGestureRecognizer>>& others);
|
||||
static JSRef<JSObject> CreateRecognizerObject(const RefPtr<NG::NGGestureRecognizer>& target);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
||||
|
@ -884,6 +884,15 @@ ArkUINativeModuleValue ArkUINativeModule::GetArkUINativeModule(ArkUIRuntimeCallI
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::SetOnGestureJudgeBegin));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnGestureJudgeBegin"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::ResetOnGestureJudgeBegin));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnGestureRecognizerJudgeBegin"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::SetOnGestureRecognizerJudgeBegin));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnGestureRecognizerJudgeBegin"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::ResetOnGestureRecognizerJudgeBegin));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "setShouldBuiltInRecognizerParallelWith"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::SetShouldBuiltInRecognizerParallelWith));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetShouldBuiltInRecognizerParallelWith"),
|
||||
panda::FunctionRef::New(
|
||||
const_cast<panda::EcmaVM*>(vm), CommonBridge::ResetShouldBuiltInRecognizerParallelWith));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "addTapGesture"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), CommonBridge::AddTapGesture));
|
||||
common->Set(vm, panda::StringRef::NewFromUtf8(vm, "addLongPressGesture"),
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/utils/string_utils.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "bridge/declarative_frontend/engine/functions/js_should_built_in_recognizer_parallel_with_function.h"
|
||||
#include "bridge/declarative_frontend/engine/js_ref_ptr.h"
|
||||
#include "bridge/declarative_frontend/engine/jsi/js_ui_index.h"
|
||||
#include "bridge/declarative_frontend/engine/jsi/jsi_types.h"
|
||||
@ -5881,6 +5882,23 @@ Local<panda::ObjectRef> CommonBridge::SetUniqueAttributes(
|
||||
}
|
||||
}
|
||||
|
||||
Local<panda::ObjectRef> CommonBridge::CreateRecognizerObject(EcmaVM* vm, const RefPtr<NG::NGGestureRecognizer>& target)
|
||||
{
|
||||
auto panRecognizer = AceType::DynamicCast<NG::PanRecognizer>(target);
|
||||
if (panRecognizer) {
|
||||
JSRef<JSObject> recognizerObj = JSClass<JSPanRecognizer>::NewInstance();
|
||||
auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSPanRecognizer>());
|
||||
currentRecognizer->SetRecognizer(panRecognizer);
|
||||
currentRecognizer->SetPanGestureOptions(
|
||||
panRecognizer->GetFingers(), panRecognizer->GetDistance(), panRecognizer->GetDirection());
|
||||
return recognizerObj->GetLocalHandle();
|
||||
}
|
||||
JSRef<JSObject> recognizerObj = JSClass<JSGestureRecognizer>::NewInstance();
|
||||
auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSGestureRecognizer>());
|
||||
currentRecognizer->SetRecognizer(target);
|
||||
return recognizerObj->GetLocalHandle();
|
||||
}
|
||||
|
||||
Local<panda::ObjectRef> CommonBridge::CreateFingerInfo(EcmaVM* vm, const FingerInfo& fingerInfo)
|
||||
{
|
||||
const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_;
|
||||
@ -6831,6 +6849,110 @@ ArkUINativeModuleValue CommonBridge::ResetOnGestureJudgeBegin(ArkUIRuntimeCallIn
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue CommonBridge::SetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
auto* frameNode = GetFrameNode(runtimeCallInfo);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
|
||||
auto obj = secondeArg->ToObject(vm);
|
||||
auto containerId = Container::CurrentId();
|
||||
panda::Local<panda::FunctionRef> func = obj;
|
||||
auto onGestureRecognizerJudgeBegin =
|
||||
[vm, func = panda::CopyableGlobal(vm, func), node = AceType::WeakClaim(frameNode), containerId](
|
||||
const std::shared_ptr<BaseGestureEvent>& info, const RefPtr<NGGestureRecognizer>& current,
|
||||
const std::list<RefPtr<NGGestureRecognizer>>& others) -> GestureJudgeResult {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
ContainerScope scope(containerId);
|
||||
PipelineContext::SetCallBackNode(node);
|
||||
auto gestureInfo = current->GetGestureInfo();
|
||||
CHECK_NULL_RETURN(gestureInfo, GestureJudgeResult::CONTINUE);
|
||||
auto gestureEventObj = CreateGestureEventInfo(vm, gestureInfo->GetType(), info);
|
||||
auto currentObj = CreateRecognizerObject(vm, current);
|
||||
auto othersArr = panda::ArrayRef::New(vm);
|
||||
uint32_t othersIdx = 0;
|
||||
for (const auto& item : others) {
|
||||
auto othersObj = CreateRecognizerObject(vm, item);
|
||||
othersArr->SetValueAt(vm, othersArr, othersIdx++, othersObj);
|
||||
}
|
||||
panda::Local<panda::JSValueRef> params[3] = { gestureEventObj, currentObj, othersArr };
|
||||
auto returnValue = GestureJudgeResult::CONTINUE;
|
||||
auto value = func->Call(vm, func.ToLocal(), params, 3);
|
||||
if (value->IsNumber()) {
|
||||
returnValue = static_cast<GestureJudgeResult>(value->ToNumber(vm)->Value());
|
||||
}
|
||||
return returnValue;
|
||||
};
|
||||
NG::ViewAbstract::SetOnGestureRecognizerJudgeBegin(frameNode, std::move(onGestureRecognizerJudgeBegin));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue CommonBridge::ResetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
|
||||
auto* frameNode = GetFrameNode(runtimeCallInfo);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
ViewAbstract::SetOnGestureRecognizerJudgeBegin(frameNode, nullptr);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue CommonBridge::SetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
auto* frameNode = GetFrameNode(runtimeCallInfo);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
|
||||
auto obj = secondeArg->ToObject(vm);
|
||||
auto containerId = Container::CurrentId();
|
||||
panda::Local<panda::FunctionRef> func = obj;
|
||||
auto shouldBuiltInRecognizerParallelWithFunc =
|
||||
[vm, func = panda::CopyableGlobal(vm, func), node = AceType::WeakClaim(frameNode), containerId](
|
||||
const RefPtr<NG::NGGestureRecognizer>& current,
|
||||
const std::vector<RefPtr<NG::NGGestureRecognizer>>& others) -> RefPtr<NG::NGGestureRecognizer> {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
ContainerScope scope(containerId);
|
||||
PipelineContext::SetCallBackNode(node);
|
||||
auto currentObj = CreateRecognizerObject(vm, current);
|
||||
auto othersArr = panda::ArrayRef::New(vm);
|
||||
uint32_t othersIdx = 0;
|
||||
for (const auto& item : others) {
|
||||
auto othersObj = CreateRecognizerObject(vm, item);
|
||||
othersArr->SetValueAt(vm, othersArr, othersIdx++, othersObj);
|
||||
}
|
||||
panda::Local<panda::JSValueRef> params[2] = { currentObj, othersArr };
|
||||
auto value = func->Call(vm, func.ToLocal(), params, 2);
|
||||
if (!value->IsObject(vm)) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<NG::NGGestureRecognizer> returnValue = nullptr;
|
||||
auto valueObj = value->ToObject(vm);
|
||||
valueObj->Freeze(vm);
|
||||
auto jsObj = JSRef<JSObject>(JSObject(valueObj));
|
||||
returnValue = Referenced::Claim(jsObj->Unwrap<JSGestureRecognizer>())->GetRecognizer().Upgrade();
|
||||
return returnValue;
|
||||
};
|
||||
NG::ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
|
||||
frameNode, std::move(shouldBuiltInRecognizerParallelWithFunc));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue CommonBridge::ResetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
|
||||
auto* frameNode = GetFrameNode(runtimeCallInfo);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
ViewAbstract::SetShouldBuiltInRecognizerParallelWith(frameNode, nullptr);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue CommonBridge::AddTapGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
|
@ -259,6 +259,7 @@ public:
|
||||
EcmaVM* vm, GestureTypeName typeName, const std::shared_ptr<BaseGestureEvent>& info);
|
||||
static Local<panda::ObjectRef> SetUniqueAttributes(
|
||||
EcmaVM* vm, GestureTypeName typeName, const std::shared_ptr<BaseGestureEvent>& info);
|
||||
static Local<panda::ObjectRef> CreateRecognizerObject(EcmaVM* vm, const RefPtr<NG::NGGestureRecognizer>& target);
|
||||
static Local<panda::ObjectRef> CreateFingerInfo(EcmaVM* vm, const FingerInfo& fingerInfo);
|
||||
static Local<panda::ObjectRef> CreateEventTargetObject(EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info);
|
||||
static Local<panda::ObjectRef> CreateAreaObject(EcmaVM* vm, const RectF& rect, const OffsetF& origin);
|
||||
@ -312,6 +313,10 @@ public:
|
||||
static ArkUINativeModuleValue ResetOnAreaChange(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnGestureJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnGestureJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue AddTapGesture(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue AddLongPressGesture(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue AddPanGesture(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
|
@ -9698,8 +9698,8 @@ void JSViewAbstract::JsShouldBuiltInRecognizerParallelWith(const JSCallbackInfo&
|
||||
WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
auto shouldBuiltInRecognizerParallelWithFunc =
|
||||
[execCtx = info.GetExecutionContext(), func = jsParallelInnerGestureToFunc, node = frameNode](
|
||||
const RefPtr<TouchEventTarget>& current,
|
||||
const std::vector<RefPtr<TouchEventTarget>>& others) -> RefPtr<NG::NGGestureRecognizer> {
|
||||
const RefPtr<NG::NGGestureRecognizer>& current,
|
||||
const std::vector<RefPtr<NG::NGGestureRecognizer>>& others) -> RefPtr<NG::NGGestureRecognizer> {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, nullptr);
|
||||
ACE_SCORING_EVENT("shouldBuiltInRecognizerParallelWith");
|
||||
PipelineContext::SetCallBackNode(node);
|
||||
|
@ -115,7 +115,7 @@ void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtr<NG::Fram
|
||||
if (!needAppend && touchTestResults_.empty()) {
|
||||
NG::NGGestureRecognizer::ResetGlobalTransCfg();
|
||||
}
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
// For root node, the parent local point is the same as global point.
|
||||
frameNode->TouchTest(point, point, point, touchRestrict, hitTestResult, touchPoint.id, responseLinkResult);
|
||||
TouchTestResult savePrevHitTestResult = touchTestResults_[touchPoint.id];
|
||||
@ -159,7 +159,7 @@ void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtr<NG::Fram
|
||||
refereeNG_->CleanAll();
|
||||
|
||||
TouchTestResult reHitTestResult;
|
||||
TouchTestResult reResponseLinkResult;
|
||||
ResponseLinkResult reResponseLinkResult;
|
||||
frameNode->TouchTest(point, point, point, touchRestrict,
|
||||
reHitTestResult, touchPoint.id, reResponseLinkResult);
|
||||
SetResponseLinkRecognizers(reHitTestResult, reResponseLinkResult);
|
||||
@ -333,7 +333,7 @@ bool EventManager::PostEventTouchTest(
|
||||
postEventRefereeNG_->CleanAll();
|
||||
}
|
||||
}
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
// For root node, the parent local point is the same as global point.
|
||||
uiNode->TouchTest(point, point, point, touchRestrict, hitTestResult, touchPoint.id, responseLinkResult);
|
||||
for (const auto& item : hitTestResult) {
|
||||
@ -375,7 +375,7 @@ void EventManager::TouchTest(
|
||||
const NG::PointF point { event.x, event.y };
|
||||
// For root node, the parent local point is the same as global point.
|
||||
TouchTestResult hitTestResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->TouchTest(point, point, point, touchRestrict, hitTestResult, event.id, responseLinkResult);
|
||||
SetResponseLinkRecognizers(hitTestResult, responseLinkResult);
|
||||
axisTouchTestResults_[event.id] = std::move(hitTestResult);
|
||||
@ -1090,7 +1090,7 @@ void EventManager::AccessibilityHoverTest(
|
||||
}
|
||||
const NG::PointF point { event.x, event.y };
|
||||
TouchTestResult testResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->TouchTest(
|
||||
point, point, point, touchRestrict, testResult, event.id, responseLinkResult);
|
||||
SetResponseLinkRecognizers(testResult, responseLinkResult);
|
||||
@ -1115,7 +1115,7 @@ void EventManager::MouseTest(
|
||||
} else if ((event.action == MouseAction::MOVE && event.button != MouseButton::NONE_BUTTON)) {
|
||||
testResult = mouseTestResults_[event.GetPointerId(event.id)];
|
||||
} else {
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
if (event.action != MouseAction::MOVE) {
|
||||
touchRestrict.touchEvent.isMouseTouchTest = true;
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ void EventManager::MouseTest(
|
||||
mouseTestResults_[event.GetPointerId(event.id)] = testResult;
|
||||
}
|
||||
} else {
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
if (event.action != MouseAction::MOVE) {
|
||||
touchRestrict.touchEvent.isMouseTouchTest = true;
|
||||
}
|
||||
@ -2057,7 +2057,7 @@ void EventManager::CheckAndLogLastConsumedEventInfo(int32_t eventId, bool logImm
|
||||
}
|
||||
|
||||
void EventManager::SetResponseLinkRecognizers(
|
||||
const TouchTestResult& result, const TouchTestResult& responseLinkRecognizers)
|
||||
const TouchTestResult& result, const ResponseLinkResult& responseLinkRecognizers)
|
||||
{
|
||||
for (const auto& item : result) {
|
||||
auto group = AceType::DynamicCast<NG::RecognizerGroup>(item);
|
||||
@ -2100,7 +2100,7 @@ bool EventManager::TouchTargetHitTest(const TouchEvent& touchPoint, const RefPtr
|
||||
{
|
||||
CHECK_NULL_RETURN(frameNode, false);
|
||||
TouchTestResult hitTestResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
const NG::PointF point { touchPoint.x, touchPoint.y };
|
||||
frameNode->TouchTest(point, point, point, touchRestrict, hitTestResult, touchPoint.id, responseLinkResult);
|
||||
for (const auto& entry : hitTestResult) {
|
||||
|
@ -299,7 +299,7 @@ private:
|
||||
void DispatchTouchEventToTouchTestResult(TouchEvent touchEvent, TouchTestResult touchTestResult,
|
||||
bool sendOnTouch);
|
||||
void CleanRecognizersForDragBegin(TouchEvent& touchEvent);
|
||||
void SetResponseLinkRecognizers(const TouchTestResult& result, const TouchTestResult& responseLinkRecognizers);
|
||||
void SetResponseLinkRecognizers(const TouchTestResult& result, const ResponseLinkResult& responseLinkRecognizers);
|
||||
void MockCancelEventAndDispatch(const TouchEvent& touchPoint);
|
||||
void MockCancelEventAndDispatch(const AxisEvent& axisEvent);
|
||||
void MockHoverCancelEventAndDispatch(const TouchEvent& touchPoint);
|
||||
|
@ -2355,7 +2355,7 @@ void FrameNode::AddJudgeToTargetComponent(RefPtr<TargetComponent>& targetCompone
|
||||
|
||||
HitTestResult FrameNode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
|
||||
TouchTestResult& responseLinkResult, bool isDispatch)
|
||||
ResponseLinkResult& responseLinkResult, bool isDispatch)
|
||||
{
|
||||
if (!isActive_ || !eventHub_->IsEnabled()) {
|
||||
TAG_LOGW(AceLogTag::ACE_UIEVENT, "%{public}s is inActive, need't do touch test", GetTag().c_str());
|
||||
@ -2538,7 +2538,7 @@ HitTestResult FrameNode::TouchTest(const PointF& globalPoint, const PointF& pare
|
||||
auto gestureHub = eventHub_->GetGestureEventHub();
|
||||
if (gestureHub) {
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult newComingResponseLinkTargets;
|
||||
ResponseLinkResult newComingResponseLinkTargets;
|
||||
const auto coordinateOffset = globalPoint - localPoint - localTransformOffset;
|
||||
preventBubbling = gestureHub->ProcessTouchTestHit(coordinateOffset, touchRestrict, newComingTargets,
|
||||
finalResult, touchId, localPoint, targetComponent, newComingResponseLinkTargets);
|
||||
@ -4981,13 +4981,13 @@ int FrameNode::GetValidLeafChildNumber(const RefPtr<FrameNode>& host, int32_t th
|
||||
}
|
||||
|
||||
void FrameNode::TriggerShouldParallelInnerWith(
|
||||
const TouchTestResult& currentRecognizers, const TouchTestResult& responseLinkRecognizers)
|
||||
const ResponseLinkResult& currentRecognizers, const ResponseLinkResult& responseLinkRecognizers)
|
||||
{
|
||||
auto gestureHub = eventHub_->GetGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
auto shouldBuiltInRecognizerParallelWithFunc = gestureHub->GetParallelInnerGestureToFunc();
|
||||
CHECK_NULL_VOID(shouldBuiltInRecognizerParallelWithFunc);
|
||||
std::map<GestureTypeName, std::vector<RefPtr<TouchEventTarget>>> sortedResponseLinkRecognizers;
|
||||
std::map<GestureTypeName, std::vector<RefPtr<NGGestureRecognizer>>> sortedResponseLinkRecognizers;
|
||||
|
||||
for (const auto& item : responseLinkRecognizers) {
|
||||
auto recognizer = AceType::DynamicCast<NGGestureRecognizer>(item);
|
||||
@ -4999,23 +4999,21 @@ void FrameNode::TriggerShouldParallelInnerWith(
|
||||
}
|
||||
|
||||
for (const auto& item : currentRecognizers) {
|
||||
auto currentRecognizer = AceType::DynamicCast<NGGestureRecognizer>(item);
|
||||
if (!currentRecognizer || !currentRecognizer->IsSystemGesture() ||
|
||||
currentRecognizer->GetRecognizerType() != GestureTypeName::PAN_GESTURE) {
|
||||
if (!item->IsSystemGesture() || item->GetRecognizerType() != GestureTypeName::PAN_GESTURE) {
|
||||
continue;
|
||||
}
|
||||
auto multiRecognizer = AceType::DynamicCast<MultiFingersRecognizer>(item);
|
||||
if (!multiRecognizer || multiRecognizer->GetTouchPointsSize() > 1) {
|
||||
continue;
|
||||
}
|
||||
auto iter = sortedResponseLinkRecognizers.find(currentRecognizer->GetRecognizerType());
|
||||
auto iter = sortedResponseLinkRecognizers.find(item->GetRecognizerType());
|
||||
if (iter == sortedResponseLinkRecognizers.end() || iter->second.empty()) {
|
||||
continue;
|
||||
}
|
||||
auto result = shouldBuiltInRecognizerParallelWithFunc(item, iter->second);
|
||||
if (result && currentRecognizer != result) {
|
||||
currentRecognizer->SetBridgeMode(true);
|
||||
result->AddBridgeObj(currentRecognizer);
|
||||
if (result && item != result) {
|
||||
item->SetBridgeMode(true);
|
||||
result->AddBridgeObj(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ public:
|
||||
|
||||
// If return true, will prevent TouchTest Bubbling to parent and brother nodes.
|
||||
HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, TouchTestResult& responseLinkResult,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
|
||||
bool isDispatch = false) override;
|
||||
|
||||
HitTestResult MouseTest(const PointF& globalPoint, const PointF& parentLocalPoint, MouseTestResult& onMouseResult,
|
||||
@ -1139,7 +1139,7 @@ private:
|
||||
HitTestMode TriggerOnTouchIntercept(const TouchEvent& touchEvent);
|
||||
|
||||
void TriggerShouldParallelInnerWith(
|
||||
const TouchTestResult& currentRecognizers, const TouchTestResult& responseLinkRecognizers);
|
||||
const ResponseLinkResult& currentRecognizers, const ResponseLinkResult& responseLinkRecognizers);
|
||||
|
||||
void TriggerRsProfilerNodeMountCallbackIfExist();
|
||||
|
||||
|
@ -977,7 +977,7 @@ RefPtr<PipelineContext> UINode::GetContextRefPtr() const
|
||||
|
||||
HitTestResult UINode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
|
||||
TouchTestResult& responseLinkResult, bool isDispatch)
|
||||
ResponseLinkResult& responseLinkResult, bool isDispatch)
|
||||
{
|
||||
auto children = GetChildren();
|
||||
HitTestResult hitTestResult = HitTestResult::OUT_OF_REGION;
|
||||
|
@ -298,7 +298,7 @@ public:
|
||||
|
||||
virtual HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
|
||||
TouchTestResult& responseLinkResult, bool isDispatch = false);
|
||||
ResponseLinkResult& responseLinkResult, bool isDispatch = false);
|
||||
virtual HitTestMode GetHitTestMode() const
|
||||
{
|
||||
return HitTestMode::HTMDEFAULT;
|
||||
|
@ -4619,6 +4619,24 @@ void ViewAbstract::SetOnSizeChanged(
|
||||
frameNode->SetOnSizeChangeCallback(std::move(onSizeChanged));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetOnGestureRecognizerJudgeBegin(
|
||||
FrameNode* frameNode, GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto gestureHub = frameNode->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
gestureHub->SetOnGestureRecognizerJudgeBegin(std::move(gestureRecognizerJudgeFunc));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
|
||||
FrameNode* frameNode, NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto gestureHub = frameNode->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
gestureHub->SetShouldBuildinRecognizerParallelWithFunc(std::move(shouldBuiltInRecognizerParallelWithFunc));
|
||||
}
|
||||
|
||||
void ViewAbstract::SetFocusBoxStyle(FrameNode* frameNode, const NG::FocusBoxStyle& style)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
|
@ -630,6 +630,10 @@ public:
|
||||
static void SetOnGestureJudgeBegin(FrameNode* frameNode, GestureJudgeFunc&& gestureJudgeFunc);
|
||||
static void SetOnSizeChanged(
|
||||
FrameNode* frameNode, std::function<void(const RectF& oldRect, const RectF& rect)>&& onSizeChanged);
|
||||
static void SetOnGestureRecognizerJudgeBegin(
|
||||
FrameNode* frameNode, GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc);
|
||||
static void SetShouldBuiltInRecognizerParallelWith(
|
||||
FrameNode* frameNode, NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc);
|
||||
static void SetSystemColorModeChangeEvent(FrameNode* frameNode, std::function<void(int32_t)>&& onColorModeChange);
|
||||
static void SetSystemFontChangeEvent(FrameNode* frameNode, std::function<void(float, float)>&& onFontChange);
|
||||
static void SetFocusBoxStyle(FrameNode* frameNode, const NG::FocusBoxStyle& style);
|
||||
|
@ -30,7 +30,7 @@ ClickEventActuator::ClickEventActuator(const WeakPtr<GestureEventHub>& gestureEv
|
||||
{}
|
||||
|
||||
void ClickEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, TouchTestResult& responseLinkResult)
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (clickEvents_.empty() && !clickAfterEvents_ && !userCallback_ && !jsFrameNodeCallback_) {
|
||||
return;
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
TouchTestResult& responseLinkResult) override;
|
||||
ResponseLinkResult& responseLinkResult) override;
|
||||
|
||||
GestureEventFunc GetClickEvent();
|
||||
std::optional<GestureJudgeFunc> GetSysJudgeFunc() const;
|
||||
|
@ -202,7 +202,7 @@ void DragEventActuator::RestartDragTask(const GestureEvent& info)
|
||||
}
|
||||
|
||||
void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, TouchTestResult& responseLinkResult)
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
CHECK_NULL_VOID(userCallback_);
|
||||
isDragUserReject_ = false;
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
TouchTestResult& responseLinkResult) override;
|
||||
ResponseLinkResult& responseLinkResult) override;
|
||||
void SetThumbnailCallback(std::function<void(Offset)>&& callback);
|
||||
void SetFilter(const RefPtr<DragEventActuator>& actuator);
|
||||
static void UpdatePreviewPositionAndScale(const RefPtr<FrameNode>& imageNode, const OffsetF& frameOffset);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
~GestureEventActuator() override = default;
|
||||
|
||||
virtual void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, TouchTestResult& responseLinkResult)
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, ResponseLinkResult& responseLinkResult)
|
||||
{}
|
||||
|
||||
void SetOnAccessibility(OnAccessibilityEventFunc onAccessibilityEvent)
|
||||
|
@ -89,7 +89,7 @@ RefPtr<FrameNode> GestureEventHub::GetFrameNode() const
|
||||
|
||||
bool GestureEventHub::ProcessTouchTestHit(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
TouchTestResult& innerTargets, TouchTestResult& finalResult, int32_t touchId, const PointF& localPoint,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
auto host = GetFrameNode();
|
||||
CHECK_NULL_RETURN(host, false);
|
||||
@ -228,7 +228,7 @@ RefPtr<NGGestureRecognizer> GestureEventHub::PackInnerRecognizer(
|
||||
|
||||
void GestureEventHub::ProcessTouchTestHierarchy(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
std::list<RefPtr<NGGestureRecognizer>>& innerRecognizers, TouchTestResult& finalResult, int32_t touchId,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
auto host = GetFrameNode();
|
||||
if (!host) {
|
||||
|
@ -83,8 +83,8 @@ enum class HitTestMode {
|
||||
|
||||
using TouchInterceptFunc = std::function<NG::HitTestMode(TouchEventInfo&)>;
|
||||
|
||||
using ShouldBuiltInRecognizerParallelWithFunc =
|
||||
std::function<RefPtr<NGGestureRecognizer>(RefPtr<TouchEventTarget>, std::vector<RefPtr<TouchEventTarget>>)>;
|
||||
using ShouldBuiltInRecognizerParallelWithFunc = std::function<RefPtr<NGGestureRecognizer>(
|
||||
const RefPtr<NGGestureRecognizer>&, const std::vector<RefPtr<NGGestureRecognizer>>&)>;
|
||||
|
||||
enum class TouchTestStrategy {
|
||||
DEFAULT = 0,
|
||||
@ -435,7 +435,7 @@ public:
|
||||
// the return value means prevents event bubbling.
|
||||
bool ProcessTouchTestHit(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
TouchTestResult& innerTargets, TouchTestResult& finalResult, int32_t touchId, const PointF& localPoint,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult);
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
|
||||
|
||||
RefPtr<FrameNode> GetFrameNode() const;
|
||||
|
||||
@ -695,7 +695,7 @@ public:
|
||||
private:
|
||||
void ProcessTouchTestHierarchy(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
std::list<RefPtr<NGGestureRecognizer>>& innerRecognizers, TouchTestResult& finalResult, int32_t touchId,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult);
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
|
||||
|
||||
void UpdateGestureHierarchy();
|
||||
|
||||
|
@ -39,7 +39,18 @@ public:
|
||||
explicit GestureInfo(std::string tag) : tag_(std::move(tag)) {}
|
||||
explicit GestureInfo(GestureTypeName type) : type_(type) {}
|
||||
explicit GestureInfo(bool isSystemGesture) : isSystemGesture_(isSystemGesture) {}
|
||||
~GestureInfo() override = default;
|
||||
~GestureInfo() override
|
||||
{
|
||||
if (isCapi_) {
|
||||
return;
|
||||
}
|
||||
if (disposeNotifyFunc_) {
|
||||
disposeNotifyFunc_(userData_);
|
||||
}
|
||||
if (disposeJSRecognizerInfoFunc_) {
|
||||
disposeJSRecognizerInfoFunc_();
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> GetTag() const
|
||||
{
|
||||
@ -111,6 +122,26 @@ public:
|
||||
return disposeTag_;
|
||||
}
|
||||
|
||||
void SetIsCapi(bool isCapi)
|
||||
{
|
||||
isCapi_ = isCapi;
|
||||
}
|
||||
|
||||
bool IsCapi() const
|
||||
{
|
||||
return isCapi_;
|
||||
}
|
||||
|
||||
void SetDisposeNotifyFunc(std::function<void(void*)>&& func)
|
||||
{
|
||||
disposeNotifyFunc_ = std::move(func);
|
||||
}
|
||||
|
||||
void SetDisposeJSRecognizerInfoFunc(std::function<void()>&& func)
|
||||
{
|
||||
disposeJSRecognizerInfoFunc_ = std::move(func);
|
||||
}
|
||||
|
||||
private:
|
||||
std::optional<std::string> tag_;
|
||||
GestureTypeName type_ = GestureTypeName::UNKNOWN;
|
||||
@ -120,6 +151,9 @@ private:
|
||||
bool isSystemGesture_ = false;
|
||||
void* userData_ = nullptr;
|
||||
bool disposeTag_ = false;
|
||||
bool isCapi_ = true;
|
||||
std::function<void(void*)> disposeNotifyFunc_;
|
||||
std::function<void()> disposeJSRecognizerInfoFunc_;
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -28,7 +28,7 @@ LongPressEventActuator::LongPressEventActuator(const WeakPtr<GestureEventHub>& g
|
||||
{}
|
||||
|
||||
void LongPressEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, TouchTestResult& responseLinkResult)
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
CHECK_NULL_VOID(longPressEvent_);
|
||||
auto gestureHub = gestureEventHub_.Upgrade();
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
TouchTestResult& responseLinkResult) override;
|
||||
ResponseLinkResult& responseLinkResult) override;
|
||||
|
||||
GestureEventFunc GetGestureEventFunc();
|
||||
|
||||
|
@ -42,7 +42,7 @@ PanEventActuator::PanEventActuator(const WeakPtr<GestureEventHub>& gestureEventH
|
||||
}
|
||||
|
||||
void PanEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, TouchTestResult& responseLinkResult)
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (panEvents_.empty() && !userCallback_) {
|
||||
return;
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
TouchTestResult& responseLinkResult) override;
|
||||
ResponseLinkResult& responseLinkResult) override;
|
||||
|
||||
PanDirection GetDirection() const
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ bool ScrollableActuator::RemoveScrollEdgeEffect(const RefPtr<ScrollEdgeEffect>&
|
||||
void ScrollableActuator::CollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const PointF& localPoint,
|
||||
const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult)
|
||||
ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
for (const auto& [axis, event] : scrollableEvents_) {
|
||||
if (!event) {
|
||||
@ -118,7 +118,7 @@ void ScrollableActuator::InitClickRecognizer(const OffsetF& coordinateOffset,
|
||||
|
||||
void ScrollableEvent::CollectScrollableTouchTarget(const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (scrollable_) {
|
||||
scrollable_->SetGetEventTargetImpl(getEventTargetImpl);
|
||||
|
@ -34,7 +34,7 @@ constexpr float HTMBLOCK_VELOCITY = 200;
|
||||
class GestureEventHub;
|
||||
|
||||
using BarCollectTouchTargetCallback = std::function<void(const OffsetF&, const GetEventTargetImpl&, TouchTestResult&,
|
||||
const RefPtr<FrameNode>&, const RefPtr<TargetComponent>&, TouchTestResult& responseLinkResult)>;
|
||||
const RefPtr<FrameNode>&, const RefPtr<TargetComponent>&, ResponseLinkResult& responseLinkResult)>;
|
||||
using InBarRegionCallback = std::function<bool(const PointF&, SourceType source)>;
|
||||
using GetAnimateVelocityCallback = std::function<double()>;
|
||||
using ClickJudgeCallback = std::function<bool(const PointF&)>;
|
||||
@ -115,7 +115,7 @@ public:
|
||||
|
||||
void BarCollectTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult)
|
||||
ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (barCollectTouchTarget_) {
|
||||
barCollectTouchTarget_(
|
||||
@ -153,7 +153,7 @@ public:
|
||||
|
||||
void BarCollectLongPressTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult)
|
||||
ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (barCollectLongPressTarget_) {
|
||||
barCollectLongPressTarget_(
|
||||
@ -173,7 +173,7 @@ public:
|
||||
|
||||
void CollectScrollableTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
|
||||
private:
|
||||
Axis axis_ = Axis::VERTICAL;
|
||||
@ -221,7 +221,7 @@ public:
|
||||
void CollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const PointF& localPoint,
|
||||
const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
|
||||
void InitClickRecognizer(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
TouchTestResult& responseLinkResult) override
|
||||
ResponseLinkResult& responseLinkResult) override
|
||||
{
|
||||
SetGetEventTargetImpl(getEventTargetImpl);
|
||||
SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
|
@ -505,15 +505,15 @@ bool NGGestureRecognizer::IsInAttachedNode(const TouchEvent& event, bool isRealT
|
||||
return result;
|
||||
}
|
||||
|
||||
void NGGestureRecognizer::SetResponseLinkRecognizers(const std::list<RefPtr<TouchEventTarget>>& responseLinkResult)
|
||||
void NGGestureRecognizer::SetResponseLinkRecognizers(const ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
responseLinkRecognizer_.clear();
|
||||
for (const auto& item : responseLinkResult) {
|
||||
auto recognizer = AceType::DynamicCast<NGGestureRecognizer>(item);
|
||||
if (recognizer) {
|
||||
responseLinkRecognizer_.emplace_back(recognizer);
|
||||
}
|
||||
}
|
||||
responseLinkRecognizer_ = responseLinkResult;
|
||||
}
|
||||
|
||||
bool NGGestureRecognizer::IsInResponseLinkRecognizers()
|
||||
{
|
||||
return std::any_of(responseLinkRecognizer_.begin(), responseLinkRecognizer_.end(),
|
||||
[recognizer = Claim(this)](const RefPtr<NGGestureRecognizer>& item) { return item == recognizer; });
|
||||
}
|
||||
|
||||
bool NGGestureRecognizer::AboutToAddCurrentFingers(int32_t touchId)
|
||||
|
@ -359,6 +359,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetDisposeNotifyCallback(std::function<void(void*)>&& callback)
|
||||
{
|
||||
if (gestureInfo_) {
|
||||
gestureInfo_->SetDisposeNotifyFunc(std::move(callback));
|
||||
}
|
||||
}
|
||||
|
||||
void SetBridgeMode(bool bridgeMode)
|
||||
{
|
||||
bridgeMode_ = bridgeMode;
|
||||
@ -399,7 +406,9 @@ public:
|
||||
return refereeState_;
|
||||
}
|
||||
|
||||
void SetResponseLinkRecognizers(const std::list<RefPtr<TouchEventTarget>>& responseLinkResult);
|
||||
void SetResponseLinkRecognizers(const ResponseLinkResult& responseLinkResult);
|
||||
|
||||
bool IsInResponseLinkRecognizers();
|
||||
|
||||
virtual bool IsReady()
|
||||
{
|
||||
@ -465,7 +474,7 @@ protected:
|
||||
bool bridgeMode_ = false;
|
||||
std::list<WeakPtr<NGGestureRecognizer>> bridgeObjList_;
|
||||
bool enabled_ = true;
|
||||
std::list<RefPtr<NGGestureRecognizer>> responseLinkRecognizer_;
|
||||
ResponseLinkResult responseLinkRecognizer_;
|
||||
private:
|
||||
WeakPtr<NGGestureRecognizer> gestureGroup_;
|
||||
WeakPtr<NGGestureRecognizer> eventImportGestureGroup_;
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetResponseLinkRecognizersRecursively(const TouchTestResult& responseLinkResult)
|
||||
void SetResponseLinkRecognizersRecursively(const ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
for (const auto& item : recognizers_) {
|
||||
auto group = AceType::DynamicCast<RecognizerGroup>(item);
|
||||
@ -167,14 +167,11 @@ public:
|
||||
group->SetResponseLinkRecognizersRecursively(responseLinkResult);
|
||||
continue;
|
||||
}
|
||||
auto recognizer = AceType::DynamicCast<NG::NGGestureRecognizer>(item);
|
||||
if (recognizer) {
|
||||
recognizer->SetResponseLinkRecognizers(responseLinkResult);
|
||||
}
|
||||
item->SetResponseLinkRecognizers(responseLinkResult);
|
||||
}
|
||||
}
|
||||
|
||||
void CollectResponseLinkRecognizersRecursively(TouchTestResult& responseLinkResult)
|
||||
void CollectResponseLinkRecognizersRecursively(ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
for (const auto& item : recognizers_) {
|
||||
auto group = AceType::DynamicCast<RecognizerGroup>(item);
|
||||
|
@ -162,7 +162,7 @@ FormNode::~FormNode()
|
||||
|
||||
HitTestResult FormNode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
|
||||
TouchTestResult& responseLinkResult, bool isDispatch)
|
||||
ResponseLinkResult& responseLinkResult, bool isDispatch)
|
||||
{
|
||||
// The mousetest has been merged into touchtest.
|
||||
// FormComponent does not support some mouse event(eg. Hover, HoverAnimation..).
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
~FormNode() override;
|
||||
|
||||
HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, TouchTestResult& responseLinkResult,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
|
||||
bool isDispatch = false) override;
|
||||
|
||||
static RefPtr<FormNode> GetOrCreateFormNode(
|
||||
|
@ -655,7 +655,7 @@ void ScrollBar::ProcessFrictionMotionStop()
|
||||
|
||||
void ScrollBar::OnCollectTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult)
|
||||
ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (panRecognizer_ && isScrollable_) {
|
||||
panRecognizer_->SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
@ -690,7 +690,7 @@ void ScrollBar::ScheduleDisappearDelayTask()
|
||||
|
||||
void ScrollBar::OnCollectLongPressTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult)
|
||||
ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (longPressRecognizer_ && isScrollable_) {
|
||||
longPressRecognizer_->SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
|
@ -340,10 +340,10 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
void OnCollectLongPressTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
bool InBarTouchRegion(const Point& point) const;
|
||||
bool InBarHoverRegion(const Point& point) const;
|
||||
bool InBarRectRegion(const Point& point) const;
|
||||
|
@ -122,7 +122,7 @@ void ScrollBarPattern::OnModifyDone()
|
||||
scrollableEvent_->SetBarCollectTouchTargetCallback(
|
||||
[weak = AceType::WeakClaim(this)](const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult) {
|
||||
ResponseLinkResult& responseLinkResult) {
|
||||
auto scrollBarPattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(scrollBarPattern);
|
||||
if (!scrollBarPattern->HasChild()
|
||||
@ -139,7 +139,7 @@ void ScrollBarPattern::OnModifyDone()
|
||||
scrollableEvent_->SetBarCollectClickAndLongPressTargetCallback(
|
||||
[weak = AceType::WeakClaim(this)](const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult) {
|
||||
ResponseLinkResult& responseLinkResult) {
|
||||
auto scrollBar = weak.Upgrade();
|
||||
CHECK_NULL_VOID(scrollBar);
|
||||
scrollBar->OnCollectClickTarget(
|
||||
@ -760,7 +760,7 @@ void ScrollBarPattern::ProcessFrictionMotionStop()
|
||||
|
||||
void ScrollBarPattern::OnCollectTouchTarget(const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (panRecognizer_) {
|
||||
panRecognizer_->SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
@ -777,7 +777,7 @@ void ScrollBarPattern::OnCollectTouchTarget(const OffsetF& coordinateOffset,
|
||||
|
||||
void ScrollBarPattern::OnCollectClickTarget(const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (clickRecognizer_) {
|
||||
clickRecognizer_->SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
@ -801,7 +801,7 @@ void ScrollBarPattern::OnCollectClickTarget(const OffsetF& coordinateOffset,
|
||||
|
||||
void ScrollBarPattern::OnCollectLongPressTarget(const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (longPressRecognizer_) {
|
||||
longPressRecognizer_->SetCoordinateOffset(Offset(coordinateOffset.GetX(), coordinateOffset.GetY()));
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
|
||||
void OnCollectTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
|
||||
float GetMainOffset(const Offset& offset) const
|
||||
{
|
||||
@ -198,10 +198,10 @@ public:
|
||||
void StartLongPressEventTimer();
|
||||
void OnCollectClickTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
void OnCollectLongPressTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
void SetScrollBar(DisplayMode displayMode);
|
||||
void UpdateScrollBarOffset();
|
||||
void HandleScrollBarOutBoundary(float scrollBarOutBoundaryExtent);
|
||||
|
@ -1272,7 +1272,7 @@ inline bool Scrollable::IsMouseWheelScroll(const GestureEvent& info)
|
||||
}
|
||||
|
||||
void Scrollable::OnCollectTouchTarget(TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
if (panRecognizerNG_) {
|
||||
panRecognizerNG_->SetNodeId(frameNode->GetId());
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
}
|
||||
|
||||
void OnCollectTouchTarget(TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult);
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
|
||||
|
||||
void SetDragTouchRestrict(const TouchRestrict& touchRestrict)
|
||||
{
|
||||
|
@ -765,7 +765,7 @@ void ScrollablePattern::InitScrollBarGestureEvent()
|
||||
scrollableEvent_->SetBarCollectTouchTargetCallback(
|
||||
[weak = AceType::WeakClaim(AceType::RawPtr(scrollBar_))](const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult) {
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult) {
|
||||
auto scrollBar = weak.Upgrade();
|
||||
CHECK_NULL_VOID(scrollBar);
|
||||
scrollBar->OnCollectTouchTarget(
|
||||
@ -774,7 +774,7 @@ void ScrollablePattern::InitScrollBarGestureEvent()
|
||||
scrollableEvent_->SetBarCollectClickAndLongPressTargetCallback(
|
||||
[weak = AceType::WeakClaim(AceType::RawPtr(scrollBar_)), this](const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult) {
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult) {
|
||||
auto scrollBar = weak.Upgrade();
|
||||
CHECK_NULL_VOID(scrollBar);
|
||||
scrollBar->OnCollectLongPressTarget(
|
||||
@ -2780,7 +2780,7 @@ void ScrollablePattern::AddHotZoneSenceInterface(SceneStatus scene)
|
||||
|
||||
void ScrollablePattern::OnCollectClickTarget(const OffsetF& coordinateOffset,
|
||||
const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
const RefPtr<TargetComponent>& targetComponent, TouchTestResult& responseLinkResult)
|
||||
const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult)
|
||||
{
|
||||
CHECK_NULL_VOID(GetScrollBar());
|
||||
if (clickRecognizer_) {
|
||||
|
@ -621,7 +621,7 @@ public:
|
||||
|
||||
void OnCollectClickTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
|
||||
TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult);
|
||||
ResponseLinkResult& responseLinkResult);
|
||||
|
||||
virtual void SetAccessibilityAction();
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
namespace OHOS::Ace::NG {
|
||||
HitTestResult ScreenNode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
|
||||
TouchTestResult& responseLinkResult, bool isDispatch)
|
||||
ResponseLinkResult& responseLinkResult, bool isDispatch)
|
||||
{
|
||||
auto testResult = HitTestResult::OUT_OF_REGION;
|
||||
auto pattern = GetPattern<ScreenPattern>();
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
~ScreenNode() override = default;
|
||||
|
||||
HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, TouchTestResult& responseLinkResult,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
|
||||
bool isDispatch = false) override;
|
||||
|
||||
static RefPtr<ScreenNode> GetOrCreateScreenNode(
|
||||
|
@ -905,6 +905,7 @@ protected:
|
||||
};
|
||||
|
||||
using TouchTestResult = std::list<RefPtr<TouchEventTarget>>;
|
||||
using ResponseLinkResult = std::list<RefPtr<NG::NGGestureRecognizer>>;
|
||||
|
||||
class TouchEventInfo : public BaseEventInfo {
|
||||
DECLARE_RELATIONSHIP_OF_CLASSES(TouchEventInfo, BaseEventInfo);
|
||||
|
@ -2689,6 +2689,20 @@ struct ArkUITabsControllerModifier {
|
||||
|
||||
struct ArkUIGesture;
|
||||
|
||||
struct ArkUIGestureEventTargetInfo {
|
||||
void* uiNode = nullptr;
|
||||
};
|
||||
|
||||
struct ArkUIGestureRecognizer {
|
||||
ArkUI_Int32 type = -1;
|
||||
ArkUIGesture* gesture = nullptr;
|
||||
void* extraData = nullptr;
|
||||
void* attachNode = nullptr;
|
||||
bool capi = true;
|
||||
void* recognizer = nullptr;
|
||||
ArkUIGestureEventTargetInfo targetInfo = {};
|
||||
};
|
||||
|
||||
struct ArkUIGestureEvent {
|
||||
ArkUIAPIEventGestureAsyncEvent eventData;
|
||||
void* attachNode;
|
||||
@ -2701,6 +2715,24 @@ struct ArkUIGestureInterruptInfo {
|
||||
void* userData = nullptr;
|
||||
void* inputEvent = nullptr;
|
||||
void* gestureEvent = nullptr;
|
||||
ArkUIGestureRecognizer** responseLinkRecognizer = nullptr;
|
||||
ArkUI_Int32 count = 0;
|
||||
};
|
||||
|
||||
enum ArkUIGestureRecognizerState {
|
||||
RECOGNIZER_STATE_READY = 0,
|
||||
RECOGNIZER_STATE_DETECTING = 1,
|
||||
RECOGNIZER_STATE_PENDING = 2,
|
||||
RECOGNIZER_STATE_BLOCKED = 3,
|
||||
RECOGNIZER_STATE_SUCCESSFUL = 4,
|
||||
RECOGNIZER_STATE_FAILED = 5,
|
||||
};
|
||||
|
||||
struct ArkUIParallelInnerGestureEvent {
|
||||
ArkUIGestureRecognizer* current = nullptr;
|
||||
ArkUIGestureRecognizer** responseLinkRecognizer = nullptr;
|
||||
void* userData = nullptr;
|
||||
ArkUI_Int32 count = 0;
|
||||
};
|
||||
|
||||
struct ArkUIGestureModifier {
|
||||
@ -2727,6 +2759,22 @@ struct ArkUIGestureModifier {
|
||||
void (*clearGestures)(ArkUINodeHandle node);
|
||||
void (*setGestureInterrupterToNode)(
|
||||
ArkUINodeHandle node, ArkUI_Int32 (*interrupter)(ArkUIGestureInterruptInfo* interrupterInfo));
|
||||
ArkUI_Int32 (*setInnerGestureParallelTo)(ArkUINodeHandle node, void* userData,
|
||||
ArkUIGestureRecognizer* (*parallelInnerGesture)(ArkUIParallelInnerGestureEvent* event));
|
||||
ArkUI_Int32 (*setGestureRecognizerEnabled)(ArkUIGestureRecognizer* recognizer, bool enabled);
|
||||
ArkUI_Bool (*getGestureRecognizerEnabled)(ArkUIGestureRecognizer* recognizer);
|
||||
ArkUI_Int32 (*getGestureRecognizerState)(ArkUIGestureRecognizer* recognizer, ArkUIGestureRecognizerState* state);
|
||||
ArkUI_Int32 (*gestureEventTargetInfoIsScrollBegin)(ArkUIGestureEventTargetInfo* info, bool* ret);
|
||||
ArkUI_Int32 (*gestureEventTargetInfoIsScrollEnd)(ArkUIGestureEventTargetInfo* info, bool* ret);
|
||||
ArkUI_Int32 (*getPanGestureDirectionMask)(ArkUIGestureRecognizer* recognizer, ArkUIGestureDirection* direction);
|
||||
ArkUI_Bool (*isBuiltInGesture)(ArkUIGestureRecognizer* recognizer);
|
||||
ArkUI_Int32 (*getGestureTag)(
|
||||
ArkUIGestureRecognizer* recognizer, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* result);
|
||||
ArkUI_Int32 (*getGestureBindNodeId)(
|
||||
ArkUIGestureRecognizer* recognizer, char* nodeId, ArkUI_Int32 size, ArkUI_Int32* result);
|
||||
ArkUI_Bool (*isGestureRecognizerValid)(ArkUIGestureRecognizer* recognizer);
|
||||
ArkUI_Int32 (*setArkUIGestureRecognizerDisposeNotify)(ArkUIGestureRecognizer* recognizer, void* userData,
|
||||
void (*callback)(ArkUIGestureRecognizer* recognizer, void* userData));
|
||||
};
|
||||
|
||||
struct ArkUISliderModifier {
|
||||
|
@ -14,14 +14,21 @@
|
||||
*/
|
||||
|
||||
#include "core/interfaces/native/node/node_gesture_modifier.h"
|
||||
#include <securec.h>
|
||||
|
||||
#include "base/error/error_code.h"
|
||||
#include "core/components_ng/base/ui_node.h"
|
||||
#include "core/components_ng/gestures/long_press_gesture.h"
|
||||
#include "core/components_ng/gestures/recognizers/gesture_recognizer.h"
|
||||
#include "core/components_ng/gestures/recognizers/pan_recognizer.h"
|
||||
#include "core/components_ng/pattern/gesture/gesture_model_ng.h"
|
||||
#include "core/components_ng/gestures/pan_gesture.h"
|
||||
#include "core/components_ng/gestures/pinch_gesture.h"
|
||||
#include "core/components_ng/gestures/rotation_gesture.h"
|
||||
#include "core/components_ng/gestures/swipe_gesture.h"
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
#include "core/components_ng/pattern/scrollable/scrollable_pattern.h"
|
||||
#include "core/components_ng/pattern/swiper/swiper_pattern.h"
|
||||
#include "core/interfaces/native/node/touch_event_convertor.h"
|
||||
#include "core/components_ng/base/view_abstract.h"
|
||||
#include "core/components_ng/base/view_abstract_model_ng.h"
|
||||
@ -280,6 +287,57 @@ void GetBaseGestureEvent(ArkUIAPIEventGestureAsyncEvent* ret, ArkUITouchEvent& r
|
||||
ret->rawPointerEvent = &rawInputEvent;
|
||||
}
|
||||
|
||||
void GetUniqueGestureEvent(ArkUIAPIEventGestureAsyncEvent* ret, GestureTypeName typeName,
|
||||
const std::shared_ptr<BaseGestureEvent>& info)
|
||||
{
|
||||
switch (typeName) {
|
||||
case OHOS::Ace::GestureTypeName::LONG_PRESS_GESTURE: {
|
||||
auto longPressGestureEvent = TypeInfoHelper::DynamicCast<LongPressGestureEvent>(info.get());
|
||||
if (longPressGestureEvent) {
|
||||
ret->repeat = longPressGestureEvent->GetRepeat();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OHOS::Ace::GestureTypeName::PAN_GESTURE: {
|
||||
auto panGestureEvent = TypeInfoHelper::DynamicCast<PanGestureEvent>(info.get());
|
||||
if (panGestureEvent) {
|
||||
ret->x = panGestureEvent->GetOffsetX();
|
||||
ret->y = panGestureEvent->GetOffsetY();
|
||||
ret->velocityX = panGestureEvent->GetVelocity().GetVelocityX();
|
||||
ret->velocityY = panGestureEvent->GetVelocity().GetVelocityY();
|
||||
ret->velocity = panGestureEvent->GetVelocity().GetVelocityValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OHOS::Ace::GestureTypeName::PINCH_GESTURE: {
|
||||
auto pinchGestureEvent = TypeInfoHelper::DynamicCast<PinchGestureEvent>(info.get());
|
||||
if (pinchGestureEvent) {
|
||||
ret->scale = pinchGestureEvent->GetScale();
|
||||
ret->pinchCenterX = pinchGestureEvent->GetPinchCenter().GetX();
|
||||
ret->pinchCenterY = pinchGestureEvent->GetPinchCenter().GetY();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OHOS::Ace::GestureTypeName::ROTATION_GESTURE: {
|
||||
auto rotationGestureEvent = TypeInfoHelper::DynamicCast<RotationGestureEvent>(info.get());
|
||||
if (rotationGestureEvent) {
|
||||
ret->angle = rotationGestureEvent->GetAngle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OHOS::Ace::GestureTypeName::SWIPE_GESTURE: {
|
||||
auto swipeGestureEvent = TypeInfoHelper::DynamicCast<SwipeGestureEvent>(info.get());
|
||||
if (swipeGestureEvent) {
|
||||
ret->angle = swipeGestureEvent->GetAngle();
|
||||
ret->speed = swipeGestureEvent->GetSpeed();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setCancelActionFunc(Gesture* gestureRef, void* extraParam)
|
||||
{
|
||||
auto onActionCancel = [extraParam]() {
|
||||
@ -412,25 +470,240 @@ void setGestureInterrupterToNode(
|
||||
ArkUINodeHandle node, ArkUI_Int32 (*interrupter)(ArkUIGestureInterruptInfo* interrupterInfo))
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
auto onGestureJudgeBegin = [interrupter](const RefPtr<NG::GestureInfo>& gestureInfo,
|
||||
const std::shared_ptr<BaseGestureEvent>& info) -> GestureJudgeResult {
|
||||
auto onGestureRecognizerJudgeBegin = [frameNode, interrupter](const std::shared_ptr<BaseGestureEvent>& info,
|
||||
const RefPtr<NG::NGGestureRecognizer>& current,
|
||||
const std::list<RefPtr<NG::NGGestureRecognizer>>& others) -> GestureJudgeResult {
|
||||
ArkUIAPIEventGestureAsyncEvent gestureEvent;
|
||||
ArkUITouchEvent rawInputEvent;
|
||||
GetBaseGestureEvent(&gestureEvent, rawInputEvent, info);
|
||||
auto gestureInfo = current->GetGestureInfo();
|
||||
CHECK_NULL_RETURN(gestureInfo, GestureJudgeResult::CONTINUE);
|
||||
GetUniqueGestureEvent(&gestureEvent, gestureInfo->GetRecognizerType(), info);
|
||||
ArkUIGestureInterruptInfo interruptInfo;
|
||||
interruptInfo.isSystemGesture = gestureInfo->IsSystemGesture();
|
||||
interruptInfo.systemRecognizerType = static_cast<ArkUI_Int32>(gestureInfo->GetType());
|
||||
interruptInfo.event = &gestureEvent;
|
||||
interruptInfo.userData = gestureInfo->GetUserData();
|
||||
ArkUIGestureRecognizer* currentArkUIGestureRecognizer = NodeModifier::CreateGestureRecognizer(current);
|
||||
interruptInfo.userData = reinterpret_cast<void*>(currentArkUIGestureRecognizer);
|
||||
auto count = static_cast<int32_t>(others.size());
|
||||
ArkUIGestureRecognizer** othersRecognizer = nullptr;
|
||||
if (count > 0) {
|
||||
othersRecognizer = new ArkUIGestureRecognizer* [count];
|
||||
}
|
||||
int32_t index = 0;
|
||||
for (const auto& item : others) {
|
||||
othersRecognizer[index] = NodeModifier::CreateGestureRecognizer(item);
|
||||
index++;
|
||||
}
|
||||
interruptInfo.responseLinkRecognizer = othersRecognizer;
|
||||
interruptInfo.count = count;
|
||||
ArkUI_UIInputEvent inputEvent { ARKUI_UIINPUTEVENT_TYPE_TOUCH, C_TOUCH_EVENT_ID,
|
||||
&rawInputEvent };
|
||||
ArkUIGestureEvent arkUIGestureEvent { gestureEvent, nullptr };
|
||||
interruptInfo.inputEvent = &inputEvent;
|
||||
interruptInfo.gestureEvent = &arkUIGestureEvent;
|
||||
auto result = interrupter(&interruptInfo);
|
||||
delete[] othersRecognizer;
|
||||
return static_cast<GestureJudgeResult>(result);
|
||||
};
|
||||
ViewAbstract::SetOnGestureJudgeBegin(frameNode, std::move(onGestureJudgeBegin));
|
||||
ViewAbstract::SetOnGestureRecognizerJudgeBegin(frameNode, std::move(onGestureRecognizerJudgeBegin));
|
||||
}
|
||||
|
||||
ArkUI_Int32 setInnerGestureParallelTo(ArkUINodeHandle node, void* userData,
|
||||
ArkUIGestureRecognizer* (*parallelInnerGesture)(ArkUIParallelInnerGestureEvent* event))
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
auto parallelInnerGestureTo =
|
||||
[userData, parallelInnerGesture](const RefPtr<NGGestureRecognizer>& current,
|
||||
const std::vector<RefPtr<NGGestureRecognizer>>& others) -> RefPtr<NGGestureRecognizer> {
|
||||
auto* currentArkUIGestureRecognizer = NodeModifier::CreateGestureRecognizer(current);
|
||||
auto count = static_cast<int32_t>(others.size());
|
||||
ArkUIGestureRecognizer** othersArkUIGestureRecognizer = nullptr;
|
||||
if (count > 0) {
|
||||
othersArkUIGestureRecognizer = new ArkUIGestureRecognizer* [count];
|
||||
}
|
||||
for (auto index = 0; index < count; index++) {
|
||||
othersArkUIGestureRecognizer[index] = NodeModifier::CreateGestureRecognizer(others[index]);
|
||||
}
|
||||
ArkUIParallelInnerGestureEvent parallelInnerGestureEvent;
|
||||
parallelInnerGestureEvent.current = currentArkUIGestureRecognizer;
|
||||
parallelInnerGestureEvent.responseLinkRecognizer = othersArkUIGestureRecognizer;
|
||||
parallelInnerGestureEvent.userData = userData;
|
||||
parallelInnerGestureEvent.count = count;
|
||||
auto* result = parallelInnerGesture(¶llelInnerGestureEvent);
|
||||
if (!result || !result->recognizer) {
|
||||
return nullptr;
|
||||
}
|
||||
delete[] othersArkUIGestureRecognizer;
|
||||
return AceType::Claim(reinterpret_cast<NG::NGGestureRecognizer*>(result->recognizer));
|
||||
};
|
||||
ViewAbstract::SetShouldBuiltInRecognizerParallelWith(frameNode, std::move(parallelInnerGestureTo));
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_Int32 setGestureRecognizerEnabled(ArkUIGestureRecognizer* recognizer, bool enabled)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(gestureRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
gestureRecognizer->SetEnabled(enabled);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_Bool getGestureRecognizerEnabled(ArkUIGestureRecognizer* recognizer)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, false);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
return gestureRecognizer->IsEnabled();
|
||||
}
|
||||
|
||||
ArkUI_Int32 getGestureRecognizerState(ArkUIGestureRecognizer* recognizer, ArkUIGestureRecognizerState* state)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
switch (gestureRecognizer->GetRefereeState()) {
|
||||
case NG::RefereeState::READY:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_READY;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
case NG::RefereeState::DETECTING:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_DETECTING;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
case NG::RefereeState::PENDING:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_PENDING;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
case NG::RefereeState::PENDING_BLOCKED:
|
||||
case NG::RefereeState::SUCCEED_BLOCKED:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_BLOCKED;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
case NG::RefereeState::SUCCEED:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_SUCCESSFUL;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
case NG::RefereeState::FAIL:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_FAILED;
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
default:
|
||||
*state = ArkUIGestureRecognizerState::RECOGNIZER_STATE_READY;
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
ArkUI_Int32 gestureEventTargetInfoIsScrollBegin(ArkUIGestureEventTargetInfo* info, bool* ret)
|
||||
{
|
||||
auto frameNode = AceType::Claim(reinterpret_cast<NG::FrameNode*>(info->uiNode));
|
||||
CHECK_NULL_RETURN(frameNode, ERROR_CODE_PARAM_INVALID);
|
||||
auto scrollablePattern = frameNode->GetPattern<NG::ScrollablePattern>();
|
||||
if (scrollablePattern) {
|
||||
*ret = scrollablePattern->IsAtTop();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
auto swiperPattern = frameNode->GetPattern<NG::SwiperPattern>();
|
||||
if (swiperPattern) {
|
||||
*ret = swiperPattern->IsAtStart();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
return ERROR_CODE_NON_SCROLLABLE_CONTAINER;
|
||||
}
|
||||
|
||||
ArkUI_Int32 gestureEventTargetInfoIsScrollEnd(ArkUIGestureEventTargetInfo* info, bool* ret)
|
||||
{
|
||||
auto frameNode = AceType::Claim(reinterpret_cast<NG::FrameNode*>(info->uiNode));
|
||||
CHECK_NULL_RETURN(frameNode, ERROR_CODE_PARAM_INVALID);
|
||||
auto scrollablePattern = frameNode->GetPattern<NG::ScrollablePattern>();
|
||||
if (scrollablePattern) {
|
||||
*ret = scrollablePattern->IsAtBottom();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
auto swiperPattern = frameNode->GetPattern<NG::SwiperPattern>();
|
||||
if (swiperPattern) {
|
||||
*ret = swiperPattern->IsAtEnd();
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
return ERROR_CODE_NON_SCROLLABLE_CONTAINER;
|
||||
}
|
||||
|
||||
ArkUI_Int32 getPanGestureDirectionMask(ArkUIGestureRecognizer* recognizer, ArkUIGestureDirection* direction)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
auto panRecognizer = AceType::DynamicCast<PanRecognizer>(gestureRecognizer);
|
||||
CHECK_NULL_RETURN(panRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
*direction = static_cast<ArkUIGestureDirection>(panRecognizer->GetDirection().type);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_Bool isBuiltInGesture(ArkUIGestureRecognizer* recognizer)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, false);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
return gestureRecognizer->IsSystemGesture();
|
||||
}
|
||||
|
||||
ArkUI_Int32 getGestureTag(ArkUIGestureRecognizer* recognizer, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* result)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
auto gestureInfo = gestureRecognizer->GetGestureInfo();
|
||||
CHECK_NULL_RETURN(gestureRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureTag = gestureInfo->GetTag();
|
||||
CHECK_NULL_RETURN(gestureTag.has_value(), ERROR_CODE_PARAM_INVALID);
|
||||
auto actualSize = static_cast<int32_t>(gestureTag.value().size());
|
||||
*result = actualSize;
|
||||
if (actualSize > bufferSize - 1) {
|
||||
return ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH;
|
||||
}
|
||||
auto count = snprintf_s(buffer, bufferSize, bufferSize - 1, "%s", gestureTag.value().c_str());
|
||||
if (count < 0) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_Int32 getGestureBindNodeId(
|
||||
ArkUIGestureRecognizer* recognizer, char* nodeId, ArkUI_Int32 size, ArkUI_Int32* result)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
auto attachNode = gestureRecognizer->GetAttachedNode().Upgrade();
|
||||
CHECK_NULL_RETURN(attachNode, ERROR_CODE_PARAM_INVALID);
|
||||
auto inspectorId = attachNode->GetInspectorIdValue("");
|
||||
auto actualSize = static_cast<int32_t>(inspectorId.size());
|
||||
*result = actualSize;
|
||||
if (actualSize > size - 1) {
|
||||
return ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH;
|
||||
}
|
||||
auto count = snprintf_s(nodeId, size, size - 1, "%s", inspectorId.c_str());
|
||||
if (count < 0) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_Bool isGestureRecognizerValid(ArkUIGestureRecognizer* recognizer)
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, false);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
return gestureRecognizer->IsInResponseLinkRecognizers();
|
||||
}
|
||||
|
||||
ArkUI_Int32 setArkUIGestureRecognizerDisposeNotify(ArkUIGestureRecognizer* recognizer, void* userData,
|
||||
void (*callback)(ArkUIGestureRecognizer* recognizer, void* userData))
|
||||
{
|
||||
auto* rawRecognizer = reinterpret_cast<NG::NGGestureRecognizer*>(recognizer->recognizer);
|
||||
CHECK_NULL_RETURN(rawRecognizer, ERROR_CODE_PARAM_INVALID);
|
||||
auto gestureRecognizer = AceType::Claim(rawRecognizer);
|
||||
auto disposeNotify = [userData, callback](void* recognizer) {
|
||||
auto* arkuiGestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
callback(arkuiGestureRecognizer, userData);
|
||||
};
|
||||
gestureRecognizer->SetDisposeNotifyCallback(std::move(disposeNotify));
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
namespace NodeModifier {
|
||||
@ -455,6 +728,18 @@ const ArkUIGestureModifier* GetGestureModifier()
|
||||
removeGestureFromNodeByTag,
|
||||
clearGestures,
|
||||
setGestureInterrupterToNode,
|
||||
setInnerGestureParallelTo,
|
||||
setGestureRecognizerEnabled,
|
||||
getGestureRecognizerEnabled,
|
||||
getGestureRecognizerState,
|
||||
gestureEventTargetInfoIsScrollBegin,
|
||||
gestureEventTargetInfoIsScrollEnd,
|
||||
getPanGestureDirectionMask,
|
||||
isBuiltInGesture,
|
||||
getGestureTag,
|
||||
getGestureBindNodeId,
|
||||
isGestureRecognizerValid,
|
||||
setArkUIGestureRecognizerDisposeNotify,
|
||||
};
|
||||
return &modifier;
|
||||
}
|
||||
@ -482,5 +767,32 @@ const CJUIGestureModifier* GetCJUIGestureModifier()
|
||||
};
|
||||
return &modifier;
|
||||
}
|
||||
|
||||
ArkUIGestureRecognizer* CreateGestureRecognizer(const RefPtr<NG::NGGestureRecognizer>& recognizer)
|
||||
{
|
||||
CHECK_NULL_RETURN(recognizer, nullptr);
|
||||
ArkUIGestureRecognizer* arkUIGestureRecognizer;
|
||||
auto gestureInfo = recognizer->GetGestureInfo();
|
||||
CHECK_NULL_RETURN(gestureInfo, nullptr);
|
||||
auto* userData = gestureInfo->GetUserData();
|
||||
if (userData) {
|
||||
arkUIGestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(userData);
|
||||
} else {
|
||||
arkUIGestureRecognizer = new ArkUIGestureRecognizer();
|
||||
arkUIGestureRecognizer->capi = false;
|
||||
gestureInfo->SetUserData(arkUIGestureRecognizer);
|
||||
}
|
||||
arkUIGestureRecognizer->type = static_cast<int32_t>(gestureInfo->GetRecognizerType());
|
||||
arkUIGestureRecognizer->recognizer = reinterpret_cast<void*>(AceType::RawPtr(recognizer));
|
||||
auto attachNode = recognizer->GetAttachedNode().Upgrade();
|
||||
if (attachNode) {
|
||||
arkUIGestureRecognizer->targetInfo.uiNode = reinterpret_cast<void*>(AceType::RawPtr(attachNode));
|
||||
}
|
||||
gestureInfo->SetIsCapi(arkUIGestureRecognizer->capi);
|
||||
gestureInfo->SetDisposeJSRecognizerInfoFunc([arkUIGestureRecognizer]() {
|
||||
delete arkUIGestureRecognizer;
|
||||
});
|
||||
return arkUIGestureRecognizer;
|
||||
}
|
||||
} // namespace NodeModifier
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -21,5 +21,6 @@
|
||||
namespace OHOS::Ace::NG::NodeModifier {
|
||||
const ArkUIGestureModifier* GetGestureModifier();
|
||||
const CJUIGestureModifier* GetCJUIGestureModifier();
|
||||
ArkUIGestureRecognizer* CreateGestureRecognizer(const RefPtr<NG::NGGestureRecognizer>& recognizer);
|
||||
} // namespace OHOS::Ace::NG::NodeModifier
|
||||
#endif
|
@ -183,6 +183,70 @@
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GestureEvent_GetNode"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetResponseRecognizersFromInterruptInfo"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetGestureRecognizerEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetGestureRecognizerEnabled"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetGestureRecognizerState"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetGestureEventTargetInfo"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GestureEventTargetInfo_IsScrollBegin"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GestureEventTargetInfo_IsScrollEnd"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetPanGestureDirectionMask"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_IsBuiltInGesture"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetGestureTag"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_GetGestureBindNodeId"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_IsGestureRecognizerValid"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_ParallelInnerGestureEvent_GetUserData"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_NativeXComponent_RegisterUIInputEventCallback"
|
||||
|
@ -222,6 +222,65 @@ typedef enum {
|
||||
GESTURE_INTERRUPT_RESULT_REJECT,
|
||||
} ArkUI_GestureInterruptResult;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the gesture recognizer states.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum {
|
||||
/** Ready. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0,
|
||||
|
||||
/** Detecting. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1,
|
||||
|
||||
/** Pending. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2,
|
||||
|
||||
/** Blocked. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3,
|
||||
|
||||
/** Successful. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4,
|
||||
|
||||
/** Failed. */
|
||||
ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5,
|
||||
} ArkUI_GestureRecognizerState;
|
||||
|
||||
/**
|
||||
* @brief Defines the gesture recognizer handle.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle;
|
||||
|
||||
/**
|
||||
* @brief Defines the gesture recognizer handle array.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray;
|
||||
|
||||
/**
|
||||
* @brief Defines a <b>GestureEventTargetInfo</b> object that provides information about a gesture event target.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo;
|
||||
|
||||
/**
|
||||
* @brief Defines a parallel internal gesture event.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent;
|
||||
|
||||
/**
|
||||
* @brief Defines a callback function for notifying gesture recognizer destruction.
|
||||
* @since 12
|
||||
*/
|
||||
typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData);
|
||||
|
||||
/**
|
||||
* @brief Checks whether a gesture is a built-in gesture of the component.
|
||||
*
|
||||
@ -399,6 +458,189 @@ float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event);
|
||||
*/
|
||||
float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains information about a gesture response chain.
|
||||
*
|
||||
* @param event Indicates the pointer to the gesture interruption information.
|
||||
* @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain.
|
||||
* @param count Indicates the pointer to the number of gesture recognizers on the response chain.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event,
|
||||
ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count);
|
||||
|
||||
/**
|
||||
* @brief Sets the enabled state of a gesture recognizer.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param enabled Indicates the enabled state.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Obtains the enabled state of a gesture recognizer.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @return Returns <b>true</b> if the gesture recognizer is enabled.
|
||||
* Returns <b>false</b> if the gesture recognizer is disabled.
|
||||
* @since 12
|
||||
*/
|
||||
bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer);
|
||||
|
||||
/**
|
||||
* @brief Obtains the state of a gesture recognizer.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param state Indicates the pointer to the state of the gesture recognizer.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state);
|
||||
|
||||
/**
|
||||
* @brief Obtains the information about a gesture event target.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param info Indicates the information about a gesture event target.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info);
|
||||
|
||||
/**
|
||||
* @brief Obtains whether this scroll container is scrolled to the top.
|
||||
*
|
||||
* @param info Indicates the information about a gesture event target.
|
||||
* @param ret Indicates whether the scroll container is scrolled to the top.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret);
|
||||
|
||||
/**
|
||||
* @brief Obtains whether this scroll container is scrolled to the bottom.
|
||||
*
|
||||
* @param info Indicates the information about a gesture event target.
|
||||
* @param ret Indicates whether the scroll container is scrolled to the bottom.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret);
|
||||
|
||||
/**
|
||||
* @brief Obtains the direction of a pan gesture.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param directionMask Indicates the pan direction.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer,
|
||||
ArkUI_GestureDirectionMask* directionMask);
|
||||
|
||||
/**
|
||||
* @brief Obtains whether a gesture is a built-in gesture.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @return Returns <b>true</b> if the gesture is a built-in gesture; returns <b>false</b> otherwise.
|
||||
* @since 12
|
||||
*/
|
||||
bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer);
|
||||
|
||||
/**
|
||||
* @brief Obtains the tag of a gesture recognizer.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param buffer Indicates the buffer.
|
||||
* @param bufferSize Indicates the buffer size.
|
||||
* @param result Indicates the length of the string to be written to the buffer.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result);
|
||||
|
||||
/**
|
||||
* @brief Obtains the ID of the component linked to a gesture recognizer.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param nodeId Indicates the component ID.
|
||||
* @param size Indicates the buffer size.
|
||||
* @param result Indicates the length of the string to be written to the buffer.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size,
|
||||
int32_t* result);
|
||||
|
||||
/**
|
||||
* @brief Obtains whether a gesture recognizer is valid.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @return Returns <b>true</b> if the gesture recognizer is valid.
|
||||
* Returns <b>false</b> if the gesture recognizer is invalid.
|
||||
* @since 12
|
||||
*/
|
||||
bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer);
|
||||
|
||||
/**
|
||||
* @brief Obtains custom data in the parallel internal gesture event.
|
||||
*
|
||||
* @param event Indicates the pointer to a parallel internal gesture event.
|
||||
* @return Returns the pointer to custom data.
|
||||
* @since 12
|
||||
*/
|
||||
void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the current gesture recognizer in a parallel internal gesture event.
|
||||
*
|
||||
* @param event Indicates the pointer to a parallel internal gesture event.
|
||||
* @return Returns the pointer to the current gesture recognizer.
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer(
|
||||
ArkUI_ParallelInnerGestureEvent* event);
|
||||
|
||||
/**
|
||||
* @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event.
|
||||
*
|
||||
* @param event Indicates the pointer to a parallel internal gesture event.
|
||||
* @param array Indicates the pointer to the array of conflicting gesture recognizers.
|
||||
* @param size Indicates the size of the array of conflicting gesture recognizers.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event,
|
||||
ArkUI_GestureRecognizerHandleArray* array, int32_t* size);
|
||||
|
||||
/**
|
||||
* @brief Sets a callback function for notifying gesture recognizer destruction.
|
||||
*
|
||||
* @param recognizer Indicates the pointer to a gesture recognizer.
|
||||
* @param callback Indicates the callback function for notifying gesture recognizer destruction.
|
||||
* @param userData Indicates the custom data.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
*/
|
||||
int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer,
|
||||
ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData);
|
||||
|
||||
ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event);
|
||||
/**
|
||||
@ -619,6 +861,21 @@ typedef struct {
|
||||
*/
|
||||
ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer);
|
||||
|
||||
/**
|
||||
* @brief Sets the callback function for a parallel internal gesture event.
|
||||
*
|
||||
* @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set.
|
||||
* @param userData Indicates the custom data.
|
||||
* @param parallelInnerGesture Indicates the parallel internal gesture event. <b>event</b> returns the data of the
|
||||
* parallel internal gesture event; <b>parallelInnerGesture</b> returns the pointer to the gesture recognizer
|
||||
* that requires parallel recognition.
|
||||
* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
|
||||
*/
|
||||
int32_t (*setInnerGestureParallelTo)(
|
||||
ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)(
|
||||
ArkUI_ParallelInnerGestureEvent* event));
|
||||
|
||||
/**
|
||||
* @brief Creates a tap gesture that is subject to distance restrictions.
|
||||
*
|
||||
|
@ -1994,6 +1994,10 @@ typedef enum {
|
||||
ARKUI_ERROR_CODE_GET_INFO_FAILED = 106201,
|
||||
/** The buffer size is not large enough. */
|
||||
ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR = 106202,
|
||||
/** The component is not a scroll container. */
|
||||
ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001,
|
||||
/** The buffer is not large enough. */
|
||||
ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002,
|
||||
} ArkUI_ErrorCode;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,15 @@ struct ArkUI_GestureRecognizer {
|
||||
ArkUIGesture* gesture = nullptr;
|
||||
void* extraData = nullptr;
|
||||
void* attachNode = nullptr;
|
||||
bool capi = true;
|
||||
void* recognizer = nullptr;
|
||||
ArkUIGestureEventTargetInfo targetInfo = {};
|
||||
};
|
||||
|
||||
struct ArkUI_GestureEventTargetInfo {
|
||||
void* uiNode = nullptr;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@ -49,6 +57,13 @@ struct ArkUI_GestureInterruptInfo {
|
||||
ArkUIGestureInterruptInfo interruptData;
|
||||
};
|
||||
|
||||
struct ArkUI_ParallelInnerGestureEvent {
|
||||
ArkUIGestureRecognizer* current = nullptr;
|
||||
ArkUIGestureRecognizer** responseLinkRecognizer = nullptr;
|
||||
void* userData = nullptr;
|
||||
int32_t count;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -185,6 +200,178 @@ int32_t OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(const ArkUI_Gestur
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(
|
||||
const ArkUI_GestureInterruptInfo* event, ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count)
|
||||
{
|
||||
CHECK_NULL_RETURN(responseChain, ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(count, ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
*responseChain = reinterpret_cast<ArkUI_GestureRecognizer**>(event->interruptData.responseLinkRecognizer);
|
||||
*count = event->interruptData.count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()
|
||||
->getNodeModifiers()
|
||||
->getGestureModifier()
|
||||
->setGestureRecognizerEnabled(gestureRecognizer, enabled);
|
||||
}
|
||||
|
||||
bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return false;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()
|
||||
->getNodeModifiers()
|
||||
->getGestureModifier()
|
||||
->getGestureRecognizerEnabled(gestureRecognizer);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
ArkUIGestureRecognizerState recognizerState;
|
||||
auto result =
|
||||
OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->getGestureRecognizerState(
|
||||
gestureRecognizer, &recognizerState);
|
||||
*state = static_cast<ArkUI_GestureRecognizerState>(recognizerState);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
*info = reinterpret_cast<ArkUI_GestureEventTargetInfo*>(&gestureRecognizer->targetInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret)
|
||||
{
|
||||
auto* targetInfo = reinterpret_cast<ArkUIGestureEventTargetInfo*>(info);
|
||||
if (!targetInfo) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()
|
||||
->getNodeModifiers()
|
||||
->getGestureModifier()
|
||||
->gestureEventTargetInfoIsScrollBegin(targetInfo, ret);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret)
|
||||
{
|
||||
auto* targetInfo = reinterpret_cast<ArkUIGestureEventTargetInfo*>(info);
|
||||
if (!targetInfo) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()
|
||||
->getNodeModifiers()
|
||||
->getGestureModifier()
|
||||
->gestureEventTargetInfoIsScrollEnd(targetInfo, ret);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetPanGestureDirectionMask(
|
||||
ArkUI_GestureRecognizer* recognizer, ArkUI_GestureDirectionMask* directionMask)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
ArkUIGestureDirection direction = ArkUIGestureDirection::ArkUI_GESTURE_DIRECTION_ALL;
|
||||
auto result =
|
||||
OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->getPanGestureDirectionMask(
|
||||
gestureRecognizer, &direction);
|
||||
*directionMask = static_cast<ArkUI_GestureDirectionMask>(direction);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return false;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->isBuiltInGesture(
|
||||
gestureRecognizer);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->getGestureTag(
|
||||
gestureRecognizer, buffer, bufferSize, result);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size, int32_t* result)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->getGestureBindNodeId(
|
||||
gestureRecognizer, nodeId, size, result);
|
||||
}
|
||||
|
||||
bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer) {
|
||||
return false;
|
||||
}
|
||||
return OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->isGestureRecognizerValid(
|
||||
gestureRecognizer);
|
||||
}
|
||||
|
||||
void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event)
|
||||
{
|
||||
return event->userData;
|
||||
}
|
||||
|
||||
ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer(ArkUI_ParallelInnerGestureEvent* event)
|
||||
{
|
||||
return reinterpret_cast<ArkUI_GestureRecognizer*>(event->current);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(
|
||||
ArkUI_ParallelInnerGestureEvent* event, ArkUI_GestureRecognizerHandleArray* array, int32_t* size)
|
||||
{
|
||||
CHECK_NULL_RETURN(array, ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
CHECK_NULL_RETURN(size, ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
*array = reinterpret_cast<ArkUI_GestureRecognizer**>(event->responseLinkRecognizer);
|
||||
*size = event->count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(
|
||||
ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData)
|
||||
{
|
||||
auto* gestureRecognizer = reinterpret_cast<ArkUIGestureRecognizer*>(recognizer);
|
||||
if (!gestureRecognizer || gestureRecognizer->capi) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto disposeCallback = reinterpret_cast<void (*)(ArkUIGestureRecognizer * recognizer, void* userData)>(callback);
|
||||
OHOS::Ace::NodeModel::GetFullImpl()
|
||||
->getNodeModifiers()
|
||||
->getGestureModifier()
|
||||
->setArkUIGestureRecognizerDisposeNotify(gestureRecognizer, userData, disposeCallback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace OHOS::Ace::GestureModel {
|
||||
|
||||
constexpr int32_t DEFAULT_PAN_FINGERS = 1;
|
||||
@ -318,6 +505,7 @@ int32_t AddGestureToNode(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recogni
|
||||
recognizer->attachNode = node;
|
||||
OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->addGestureToNode(
|
||||
node->uiNodeHandle, recognizer->gesture, priorityNum, mask);
|
||||
recognizer->targetInfo.uiNode = reinterpret_cast<void*>(node->uiNodeHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -325,6 +513,7 @@ int32_t RemoveGestureFromNode(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* re
|
||||
{
|
||||
OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->removeGestureFromNode(
|
||||
node->uiNodeHandle, recognizer->gesture);
|
||||
recognizer->targetInfo.uiNode = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -393,4 +582,14 @@ int32_t SetGestureInterrupterToNode(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetInnerGestureParallelTo(ArkUI_NodeHandle node, void* userData,
|
||||
ArkUI_GestureRecognizer* (*parallelInnerGesture)(ArkUI_ParallelInnerGestureEvent* event))
|
||||
{
|
||||
auto callback =
|
||||
reinterpret_cast<ArkUIGestureRecognizer* (*)(ArkUIParallelInnerGestureEvent * current)>(parallelInnerGesture);
|
||||
OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers()->getGestureModifier()->setInnerGestureParallelTo(
|
||||
node->uiNodeHandle, userData, callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}; // namespace OHOS::Ace::GestureModel
|
@ -61,5 +61,8 @@ void HandleGestureEvent(ArkUINodeEvent* event);
|
||||
int32_t SetGestureInterrupterToNode(
|
||||
ArkUI_NodeHandle node, ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info));
|
||||
|
||||
int32_t SetInnerGestureParallelTo(ArkUI_NodeHandle node, void* userData,
|
||||
ArkUI_GestureRecognizer* (*parallelInnerGesture)(ArkUI_ParallelInnerGestureEvent* event));
|
||||
|
||||
}; // namespace OHOS::Ace::GestureModel
|
||||
#endif
|
@ -131,6 +131,7 @@ ArkUI_NativeGestureAPI_1 gestureImpl_1 = {
|
||||
OHOS::Ace::GestureModel::RemoveGestureFromNode,
|
||||
OHOS::Ace::GestureModel::SetGestureInterrupterToNode,
|
||||
OHOS::Ace::GestureModel::GetGestureType,
|
||||
OHOS::Ace::GestureModel::SetInnerGestureParallelTo,
|
||||
OHOS::Ace::GestureModel::CreateTapGestureWithDistanceThreshold,
|
||||
};
|
||||
|
||||
|
@ -224,7 +224,7 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest, TestSize.Level1)
|
||||
TouchRestrict touchRestrict = { TouchRestrict::NONE };
|
||||
auto globalPoint = PointF(10, 10);
|
||||
auto touchTestResult = std::list<RefPtr<TouchEventTarget>>();
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
|
||||
mockRenderContext->rect_ = RectF(0, 0, 100, 100);
|
||||
EXPECT_CALL(*mockRenderContext, GetPointWithTransform(_)).WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
|
||||
@ -952,7 +952,7 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest0026, TestSize.Level1)
|
||||
PointF parentLocalPoint;
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
SystemProperties::debugEnabled_ = true;
|
||||
FRAME_NODE2->TouchTest(
|
||||
globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
|
||||
|
@ -52,7 +52,7 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest041, TestSize.Level1)
|
||||
PointF parentLocalPoint;
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
/**
|
||||
* @tc.steps: step2. set isActive_ and debugEnabled_ is true and FRAME_NODE2 eventHub is HTMBLOCK.
|
||||
* @tc.expected: expect The function return value is STOP_BUBBLING.
|
||||
@ -81,7 +81,7 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest042, TestSize.Level1)
|
||||
PointF parentLocalPoint;
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. set debugEnabled_ is true.
|
||||
@ -133,7 +133,7 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest043, TestSize.Level1)
|
||||
PointF parentLocalPoint;
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
/**
|
||||
* @tc.steps: step2. eventHub_->GetGestureEventHub() != nullptr and callback != null.
|
||||
* @tc.expected: expect The function return value is STOP_BUBBLING.
|
||||
@ -1090,7 +1090,7 @@ HWTEST_F(FrameNodeTestNg, OnTouchInterceptTest001, TestSize.Level1)
|
||||
PointF parentLocalPoint;
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. create node and set callback.
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
explicit TestNode(int32_t nodeId) : UINode("TestNode", nodeId) {}
|
||||
|
||||
HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, TouchTestResult& responseLinkResult,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
|
||||
bool isDispatch = false) override
|
||||
{
|
||||
return hitTestResult_;
|
||||
@ -784,7 +784,7 @@ HWTEST_F(UINodeTestNg, UINodeTestNg023, TestSize.Level1)
|
||||
* @tc.expected: the return value is meetings expectations
|
||||
*/
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
TouchRestrict restrict;
|
||||
const PointF GLOBAL_POINT { 20.0f, 20.0f };
|
||||
const PointF LOCAL_POINT { 15.0f, 15.0f };
|
||||
|
@ -174,7 +174,7 @@ HWTEST_F(ClickEventTestNg, ClickEventActuatorTest003, TestSize.Level1)
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
clickEventActuator.OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, CLICK_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
EXPECT_TRUE(finalResult.empty());
|
||||
@ -266,7 +266,7 @@ HWTEST_F(ClickEventTestNg, ClickEventActuatorTest004, TestSize.Level1)
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
std::string result;
|
||||
GestureEventFunc callback = [&result](GestureEvent& info) { result = RESULT_SUCCESS; };
|
||||
|
||||
@ -316,7 +316,7 @@ HWTEST_F(ClickEventTestNg, ClickEventActuatorTest005, TestSize.Level1)
|
||||
clickEventActuator.AddClickEvent(clickEvent);
|
||||
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
clickEventActuator.OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, CLICK_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
EXPECT_EQ(finalResult.size(), CLICK_TEST_RESULT_SIZE_1);
|
||||
|
@ -179,7 +179,7 @@ HWTEST_F(DragEventTestNg, DragEventActuatorOnCollectTouchTargetTest003, TestSize
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
framenode->GetOrCreateFocusHub();
|
||||
dragEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
@ -344,7 +344,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg002, TestSize.Level1)
|
||||
* @tc.expected: dragEventActuator's userCallback_ is not null.
|
||||
*/
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
|
||||
GestureEventFunc actionStart = [&unknownPropertyValue](GestureEvent& info) {
|
||||
unknownPropertyValue = info.GetScale();
|
||||
@ -423,7 +423,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg003, TestSize.Level1)
|
||||
* @tc.expected: longPressRecognizer is not nullptr and longPressRecognizer's HasThumbnailCallback() return true.
|
||||
*/
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
EXPECT_EQ(dragEventActuator->longPressRecognizer_->HasThumbnailCallback(), false);
|
||||
@ -493,7 +493,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg004, TestSize.Level1)
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->GetOrCreateFocusHub();
|
||||
dragEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT_MOUSE, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
@ -539,7 +539,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg005, TestSize.Level1)
|
||||
*/
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->GetOrCreateFocusHub();
|
||||
dragEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
@ -632,7 +632,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg006, TestSize.Level1)
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
EXPECT_NE(getEventTargetImpl, nullptr);
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->GetOrCreateFocusHub();
|
||||
dragEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
@ -711,7 +711,7 @@ HWTEST_F(DragEventTestNg, DragEventTestNg007, TestSize.Level1)
|
||||
*/
|
||||
auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
frameNode->GetOrCreateFocusHub();
|
||||
dragEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
|
||||
|
@ -1014,7 +1014,7 @@ HWTEST_F(EventManagerTestNg, EventManagerTest062, TestSize.Level1)
|
||||
auto panHorizontal1 = AceType::MakeRefPtr<PanRecognizer>(
|
||||
DEFAULT_PAN_FINGER, PanDirection { PanDirection::HORIZONTAL }, DEFAULT_PAN_DISTANCE.ConvertToPx());
|
||||
std::list<RefPtr<TouchEventTarget>> result;
|
||||
std::list<RefPtr<TouchEventTarget>> responseLinkRecognizers;
|
||||
ResponseLinkResult responseLinkRecognizers;
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::ROW_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>());
|
||||
panHorizontal1->node_ = frameNode;
|
||||
result.emplace_back(panHorizontal1);
|
||||
@ -1544,7 +1544,7 @@ HWTEST_F(EventManagerTestNg, EventManagerTest080, TestSize.Level1)
|
||||
DEFAULT_PAN_FINGER, PanDirection { PanDirection::HORIZONTAL }, DEFAULT_PAN_DISTANCE.ConvertToPx());
|
||||
|
||||
TouchTestResult resultList;
|
||||
TouchTestResult responseLinkRecognizers;
|
||||
ResponseLinkResult responseLinkRecognizers;
|
||||
resultList.emplace_back(recognizerGroup);
|
||||
resultList.emplace_back(panHorizontal);
|
||||
responseLinkRecognizers.emplace_back(targetLinkHorizontal);
|
||||
|
@ -96,7 +96,7 @@ HWTEST_F(GestureEventHubTestNg, GestureEventHubTest002, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
auto flag = gestureEventHub->ProcessTouchTestHit(
|
||||
COORDINATE_OFFSET, touchRestrict, innerTargets, finalResult, TOUCH_ID, PointF(), nullptr, responseLinkResult);
|
||||
EXPECT_FALSE(flag);
|
||||
@ -651,7 +651,7 @@ HWTEST_F(GestureEventHubTestNg, GestureEventHubTest010, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
std::list<RefPtr<NGGestureRecognizer>> innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
|
||||
std::vector<RefPtr<NGGestureRecognizer>> vc;
|
||||
vc.push_back(AceType::MakeRefPtr<ClickRecognizer>());
|
||||
@ -869,7 +869,7 @@ HWTEST_F(GestureEventHubTestNg, GestureEventHubTest013, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
PointF localPoint;
|
||||
|
||||
PanDirection panDirection;
|
||||
@ -1035,7 +1035,7 @@ HWTEST_F(GestureEventHubTestNg, GestureEventHubTest017, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
PointF localPoint;
|
||||
|
||||
PanDirection panDirection;
|
||||
|
@ -307,7 +307,7 @@ HWTEST_F(GestureEventHubTestNg, GestureEventHubTest032, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
std::list<RefPtr<NGGestureRecognizer>> innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. call externalExclusiveRecognizer_
|
||||
@ -1521,7 +1521,7 @@ HWTEST_F(GestureEventHubTestNg, ProcessTouchTestHit001, TestSize.Level1)
|
||||
TouchRestrict touchRestrict;
|
||||
TouchTestResult innerTargets;
|
||||
TouchTestResult finalResult;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
innerTargets.emplace_back(recognizerGroup);
|
||||
gestureEventHub->redirectClick_=true;
|
||||
auto flag = gestureEventHub->ProcessTouchTestHit(
|
||||
|
@ -119,7 +119,7 @@ HWTEST_F(LongPressEventTestNg, LongPressEventActuatorTest002, TestSize.Level1)
|
||||
* @tc. OnCollectTouchTarget return directly
|
||||
*/
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
longPressEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, LONG_PRESS_TOUCH_RESTRICT, eventHub->CreateGetEventTargetImpl(), result, responseLinkResult);
|
||||
EXPECT_EQ(result.size(), LONG_PRESS_TEST_RESULT_SIZE);
|
||||
|
@ -137,7 +137,7 @@ HWTEST_F(PanEventTestNg, PanEventOnCollectTouchTargetTest002, TestSize.Level1)
|
||||
* @tc.expected: OnCollectTouchTarget function will return directly and result size is 0.
|
||||
*/
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
panEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, PAN_EVENT_RESTRICT, eventHub->CreateGetEventTargetImpl(), result, responseLinkResult);
|
||||
EXPECT_EQ(result.size(), PAN_EVENT_TEST_RESULT_SIZE);
|
||||
|
@ -192,7 +192,7 @@ HWTEST_F(ScrollableEventTestNg, ScrollableEventOnCollectTouchTargetTest003, Test
|
||||
* @tc.expected: Invoke InitializeScrollable. when scrollableEvents_ is empty return directly.
|
||||
*/
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
scrollableActuator->CollectTouchTarget(COORDINATE_OFFSET, SCROLL_RESTRICT, eventHub->CreateGetEventTargetImpl(),
|
||||
result, LOCAL_POINT, frameNode, nullptr, responseLinkResult);
|
||||
@ -291,11 +291,11 @@ HWTEST_F(ScrollableEventTestNg, ScrollableEventOnCollectTouchTargetTest004, Test
|
||||
scrollableEvent->SetBarCollectTouchTargetCallback(
|
||||
[](const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult) { return true; });
|
||||
ResponseLinkResult& responseLinkResult) { return true; });
|
||||
scrollableActuator->AddScrollableEvent(scrollableEvent);
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
scrollableActuator->CollectTouchTarget(COORDINATE_OFFSET, SCROLL_RESTRICT, eventHub->CreateGetEventTargetImpl(),
|
||||
result, LOCAL_POINT, frameNode, nullptr, responseLinkResult);
|
||||
EXPECT_FALSE(results);
|
||||
@ -323,11 +323,11 @@ HWTEST_F(ScrollableEventTestNg, ScrollableEventOnCollectTouchTargetTest005, Test
|
||||
scrollableEvent->SetBarCollectClickAndLongPressTargetCallback(
|
||||
[](const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl, TouchTestResult& result,
|
||||
const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
|
||||
TouchTestResult& responseLinkResult) { return true; });
|
||||
ResponseLinkResult& responseLinkResult) { return true; });
|
||||
scrollableActuator->AddScrollableEvent(scrollableEvent);
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
scrollableActuator->CollectTouchTarget(COORDINATE_OFFSET, SCROLL_RESTRICT, eventHub->CreateGetEventTargetImpl(),
|
||||
result, LOCAL_POINT, frameNode, nullptr, responseLinkResult);
|
||||
EXPECT_FALSE(results);
|
||||
@ -356,7 +356,7 @@ HWTEST_F(ScrollableEventTestNg, ScrollableEventOnCollectTouchTargetTest006, Test
|
||||
scrollableActuator->AddScrollableEvent(scrollableEvent);
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
scrollableActuator->CollectTouchTarget(COORDINATE_OFFSET, SCROLL_RESTRICT, eventHub->CreateGetEventTargetImpl(),
|
||||
result, LOCAL_POINT, frameNode, nullptr, responseLinkResult);
|
||||
scrollableEvent->SetEnabled(true);
|
||||
|
@ -169,7 +169,7 @@ HWTEST_F(TouchEventTestNg, TouchEventActuatorOnCollectTouchTargetTest003, TestSi
|
||||
* @tc.expected: TouchTestResult size has been increased one.
|
||||
*/
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
auto eventHub = AceType::MakeRefPtr<EventHub>();
|
||||
touchEventActuator->OnCollectTouchTarget(
|
||||
COORDINATE_OFFSET, Touch_TOUCH_RESTRICT, eventHub->CreateGetEventTargetImpl(), result, responseLinkResult);
|
||||
|
@ -507,9 +507,9 @@ HWTEST_F(GestureRecognizerTestNg, PanPressRecognizerHandleTouchMoveEventTest007,
|
||||
HWTEST_F(GestureRecognizerTestNg, PanPressRecognizerHandleTouchMoveEventTest008, TestSize.Level1)
|
||||
{
|
||||
LongPressRecognizer recognizerTest(DURATION, FINGER_NUMBER);
|
||||
RefPtr<TouchEventTarget> targetPtr1 = nullptr;
|
||||
RefPtr<TouchEventTarget> targetPtr2 = nullptr;
|
||||
std::list<RefPtr<TouchEventTarget>> responseLinkResult;
|
||||
RefPtr<NGGestureRecognizer> targetPtr1 = nullptr;
|
||||
RefPtr<NGGestureRecognizer> targetPtr2 = nullptr;
|
||||
std::list<RefPtr<NGGestureRecognizer>> responseLinkResult;
|
||||
responseLinkResult.push_back(targetPtr1);
|
||||
responseLinkResult.push_back(targetPtr2);
|
||||
recognizerTest.SetResponseLinkRecognizers(responseLinkResult);
|
||||
|
@ -79,7 +79,7 @@ HWTEST_F(FormNodeTest, FormNodeTest_001, TestSize.Level1)
|
||||
touchRestrict.hitTestType = SourceType::MOUSE;
|
||||
TouchTestResult result;
|
||||
int32_t touchId = 0;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
bool isDispatch = false;
|
||||
auto formNode = CreateFromNode();
|
||||
auto res = formNode->TouchTest(globalPoint, parentLocalPoint,
|
||||
|
@ -212,7 +212,7 @@ HWTEST_F(ScrollBarTestNg, OnCollectTouchTarget001, TestSize.Level1)
|
||||
OffsetF coordinateOffset;
|
||||
GetEventTargetImpl getEventTargetImpl;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
pattern_->scrollableEvent_->BarCollectTouchTarget(
|
||||
coordinateOffset, getEventTargetImpl, result, frameNode_, nullptr, responseLinkResult);
|
||||
EXPECT_EQ(result.size(), 1);
|
||||
@ -1039,7 +1039,7 @@ HWTEST_F(ScrollBarTestNg, RegisterEventByClick001, TestSize.Level1)
|
||||
PointF localPoint;
|
||||
RefPtr<FrameNode> frameNode = frameNode_;
|
||||
RefPtr<TargetComponent> targetComponent;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
auto scrollableActuator = frameNode_->GetOrCreateGestureEventHub()->scrollableActuator_;
|
||||
int32_t nodeId = 123456;
|
||||
frameNode_->UpdateRecycleElmtId(nodeId);
|
||||
|
@ -1246,7 +1246,7 @@ HWTEST_F(ScrollBarTestNg, ScrollBarTest012, TestSize.Level1)
|
||||
OffsetF coordinateOffset;
|
||||
GetEventTargetImpl getEventTargetImpl;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
const int32_t size = result.size();
|
||||
EXPECT_EQ(pattern_->scrollableEvent_->InBarRegion(localPoint, source), true);
|
||||
|
||||
@ -1794,7 +1794,7 @@ HWTEST_F(ScrollBarTestNg, BarCollectLongPressTarget001, TestSize.Level1)
|
||||
OffsetF coordinateOffset;
|
||||
GetEventTargetImpl getEventTargetImpl;
|
||||
TouchTestResult result;
|
||||
TouchTestResult responseLinkResult;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
const int32_t size = result.size();
|
||||
EXPECT_EQ(pattern_->scrollableEvent_->InBarRectRegion(localPoint, source), true);
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::LIST_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
@ -2776,7 +2776,8 @@ HWTEST_F(ScrollBarTestNg, ScrollBarTest084, TestSize.Level1)
|
||||
EXPECT_EQ(scrollBar->displayMode_, DisplayMode::ON);
|
||||
|
||||
GetEventTargetImpl GetEventTargetImpl;
|
||||
TouchTestResult result, responseLinkResult;
|
||||
TouchTestResult result;
|
||||
ResponseLinkResult responseLinkResult;
|
||||
scrollableEvent->BarCollectTouchTarget(
|
||||
OffsetF(1.f, 1.f), GetEventTargetImpl, result, frameNode_, nullptr, responseLinkResult);
|
||||
EXPECT_EQ(result.size(), 1);
|
||||
|
Loading…
Reference in New Issue
Block a user