• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/gestures/recognizers/gesture_recognizer.h"
18 
19 namespace OHOS::Ace::NG {
20 
SetNode(const WeakPtr<UINode> & uiNode)21 void TargetComponent::SetNode(const WeakPtr<UINode>& uiNode)
22 {
23     node_ = uiNode;
24 }
25 
SetNodeLinkGesture(const RefPtr<NGGestureRecognizer> & nodeLinkGesture)26 void TargetComponent::SetNodeLinkGesture(const RefPtr<NGGestureRecognizer>& nodeLinkGesture)
27 {
28     nodeLinkGesture_ = nodeLinkGesture;
29 }
30 
SetNodeGesture(const RefPtr<NGGestureRecognizer> & nodeGesture)31 void TargetComponent::SetNodeGesture(const RefPtr<NGGestureRecognizer>& nodeGesture)
32 {
33     nodeGesture_ = nodeGesture;
34 }
35 
GetUINode()36 WeakPtr<UINode> TargetComponent::GetUINode()
37 {
38     return node_;
39 }
40 
AddChild(const RefPtr<TargetComponent> & child)41 void TargetComponent::AddChild(const RefPtr<TargetComponent>& child)
42 {
43     targetComponentChildren_.emplace_back(child);
44 }
45 
AddPath(int32_t pathId)46 void TargetComponent::AddPath(int32_t pathId)
47 {
48     path_.emplace(pathId);
49 }
50 
SetSourceType(SourceType sourceType)51 void TargetComponent::SetSourceType(SourceType sourceType)
52 {
53     sourceType_ = sourceType;
54 }
55 
SetOnGestureJudgeBegin(GestureJudgeFunc && onGestureJudgeBegin)56 void TargetComponent::SetOnGestureJudgeBegin(GestureJudgeFunc&& onGestureJudgeBegin)
57 {
58     onGestureJudgeBegin_ = std::move(onGestureJudgeBegin);
59 }
60 
SetOnGestureJudgeNativeBegin(GestureJudgeFunc && onGestureJudgeBegin)61 void TargetComponent::SetOnGestureJudgeNativeBegin(GestureJudgeFunc&& onGestureJudgeBegin)
62 {
63     onGestureJudgeNativeBegin_ = std::move(onGestureJudgeBegin);
64 }
65 
SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc)66 void TargetComponent::SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc)
67 {
68     gestureRecognizerJudgeFunc_ = std::move(gestureRecognizerJudgeFunc);
69 }
70 
GetOnGestureRecognizerJudgeBegin() const71 GestureRecognizerJudgeFunc TargetComponent::GetOnGestureRecognizerJudgeBegin() const
72 {
73     return gestureRecognizerJudgeFunc_;
74 }
75 } // namespace OHOS::Ace::NG
76