1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include "core/components_ng/event/target_component.h" 16 17 #include "core/components_ng/base/ui_node.h" 18 #include "core/components_ng/gestures/recognizers/gesture_recognizer.h" 19 20 namespace OHOS::Ace::NG { 21 SetNode(const WeakPtr<UINode> & uiNode)22void TargetComponent::SetNode(const WeakPtr<UINode>& uiNode) 23 { 24 node_ = uiNode; 25 } 26 SetNodeLinkGesture(const RefPtr<NGGestureRecognizer> & nodeLinkGesture)27void TargetComponent::SetNodeLinkGesture(const RefPtr<NGGestureRecognizer>& nodeLinkGesture) 28 { 29 nodeLinkGesture_ = nodeLinkGesture; 30 } 31 SetNodeGesture(const RefPtr<NGGestureRecognizer> & nodeGesture)32void TargetComponent::SetNodeGesture(const RefPtr<NGGestureRecognizer>& nodeGesture) 33 { 34 nodeGesture_ = nodeGesture; 35 } 36 GetUINode()37WeakPtr<UINode> TargetComponent::GetUINode() 38 { 39 return node_; 40 } 41 AddChild(const RefPtr<TargetComponent> & child)42void TargetComponent::AddChild(const RefPtr<TargetComponent>& child) 43 { 44 targetComponentChildren_.emplace_back(child); 45 } 46 AddPath(int32_t pathId)47void TargetComponent::AddPath(int32_t pathId) 48 { 49 path_.emplace(pathId); 50 } 51 SetSourceType(SourceType sourceType)52void TargetComponent::SetSourceType(SourceType sourceType) 53 { 54 sourceType_ = sourceType; 55 } 56 SetOnGestureJudgeBegin(GestureJudgeFunc && onGestureJudgeBegin)57void TargetComponent::SetOnGestureJudgeBegin(GestureJudgeFunc&& onGestureJudgeBegin) 58 { 59 onGestureJudgeBegin_ = std::move(onGestureJudgeBegin); 60 } 61 SetOnGestureJudgeNativeBegin(GestureJudgeFunc && onGestureJudgeBegin)62void TargetComponent::SetOnGestureJudgeNativeBegin(GestureJudgeFunc&& onGestureJudgeBegin) 63 { 64 onGestureJudgeNativeBegin_ = std::move(onGestureJudgeBegin); 65 } 66 SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc)67void TargetComponent::SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc) 68 { 69 gestureRecognizerJudgeFunc_ = std::move(gestureRecognizerJudgeFunc); 70 } 71 GetOnGestureRecognizerJudgeBegin() const72GestureRecognizerJudgeFunc TargetComponent::GetOnGestureRecognizerJudgeBegin() const 73 { 74 return gestureRecognizerJudgeFunc_; 75 } 76 } // namespace OHOS::Ace::NG 77