• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_EVENT_GESTURE_EVENT_HUB_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_EVENT_GESTURE_EVENT_HUB_H
18 
19 #include <list>
20 #include <vector>
21 
22 #include "base/geometry/ng/point_t.h"
23 #include "base/memory/referenced.h"
24 #include "core/common/interaction/interaction_data.h"
25 #include "core/components/common/layout/constants.h"
26 #include "core/components_ng/event/click_event.h"
27 #include "core/components_ng/event/drag_drop_event.h"
28 #include "core/components_ng/event/event_constants.h"
29 #include "core/components_ng/event/long_press_event.h"
30 #include "core/components_ng/event/pan_event.h"
31 #include "core/components_ng/event/scrollable_event.h"
32 #include "core/components_ng/event/target_component.h"
33 #include "core/components_ng/event/touch_event.h"
34 #include "core/components_ng/gestures/gesture_info.h"
35 #include "core/components_ng/gestures/recognizers/exclusive_recognizer.h"
36 #include "core/components_ng/gestures/recognizers/parallel_recognizer.h"
37 #include "core/components_ng/manager/drag_drop/drag_drop_proxy.h"
38 #include "core/event/pointer_event.h"
39 #include "core/gestures/gesture_info.h"
40 #include "core/components/common/properties/placement.h"
41 
42 namespace OHOS::Ace {
43 struct DragNotifyMsg;
44 struct KeyEvent;
45 class UnifiedData;
46 class Subwindow;
47 }
48 
49 namespace OHOS::Ace::NG {
50 using TouchInterceptFunc = std::function<NG::HitTestMode(TouchEventInfo&)>;
51 
52 using ShouldBuiltInRecognizerParallelWithFunc = std::function<RefPtr<NGGestureRecognizer>(
53     const RefPtr<NGGestureRecognizer>&, const std::vector<RefPtr<NGGestureRecognizer>>&)>;
54 using TouchTestDoneCallback = std::function<void(
55     const std::shared_ptr<BaseGestureEvent>&, const std::list<RefPtr<NGGestureRecognizer>>&)>;
56 
57 struct TouchTestInfo {
58     PointF windowPoint;
59     PointF currentCmpPoint;
60     PointF subCmpPoint;
61     RectF subRect;
62     std::string id;
63 };
64 
65 struct TouchResult {
66     TouchTestStrategy strategy;
67     std::string id;
68 };
69 
70 struct DragDropBaseInfo {
71     RefPtr<AceType> node;
72     RefPtr<PixelMap> pixelMap;
73     std::string extraInfo;
74 };
75 
76 struct BindMenuStatus {
77     bool isBindCustomMenu = false;
78     bool isBindLongPressMenu = false;
79     bool isShow = false;
80     MenuPreviewMode isShowPreviewMode = MenuPreviewMode::NONE;
81     MenuPreviewMode longPressPreviewMode = MenuPreviewMode::NONE;
IsNotNeedShowPreviewBindMenuStatus82     bool IsNotNeedShowPreview() const
83     {
84         return (isBindCustomMenu && isShow) || isBindLongPressMenu;
85     }
86 };
87 
88 struct PreparedInfoForDrag {
89     bool isMenuShow = false;
90     int32_t badgeNumber = 0;
91     float previewScale = 1.0f;
92     bool isNeedCreateTiled = false;
93     OffsetF dragPreviewOffsetToScreen = { 0.0f, 0.0f };
94     OffsetF dragMovePosition = { 0.0f, 0.0f };
95     RefPtr<PixelMap> pixelMap;
96     RefPtr<FrameNode> imageNode;
97     NG::DraggingSizeChangeEffect sizeChangeEffect = DraggingSizeChangeEffect::DEFAULT;
98     RefPtr<FrameNode> relativeContainerNode { nullptr };
99     RefPtr<FrameNode> menuPreviewNode { nullptr };
100     RefPtr<FrameNode> textRowNode { nullptr };
101     RefPtr<FrameNode> textNode { nullptr };
102     RefPtr<FrameNode> menuNode { nullptr };
103     RefPtr<FrameNode> scrollNode { nullptr };
104     // for menu follow animation
105     float menuPositionLeft = 0.0f;
106     float menuPositionTop = 0.0f;
107     float menuPositionRight = 0.0f;
108     float menuPositionBottom = 0.0f;
109     // for menu follow animations
110     Placement menuPosition = Placement::NONE;
111     RectF menuRect;
112     RectF frameNodeRect;
113     RefPtr<FrameNode> menuPreviewImageNode { nullptr };
114     RefPtr<FrameNode> stackNode { nullptr };
115     RefPtr<FrameNode> gatherNode { nullptr };
116     RectF originPreviewRect;
117     RectF dragPreviewRect;
118     BorderRadiusProperty borderRadius = BorderRadiusProperty(0.0_vp);
119     SourceType deviceType = SourceType::NONE;
120     bool isMenuNotShow = false;
121 };
122 
123 struct PreparedAsyncCtxForAnimate {
124     int32_t containerId = -1;
125     bool hasTouchPoint = false;
126     DragPointerEvent dragPointerEvent;
127     DragPreviewOption dragPreviewOption;
128     DimensionOffset touchPoint = DimensionOffset(0.0_vp, 0.0_vp);
129     std::vector<std::shared_ptr<Media::PixelMap>> pixelMapList;
130 };
131 
132 struct DragframeNodeInfo {
133     WeakPtr<FrameNode> frameNode;
134     std::vector<RefPtr<FrameNode>> gatherFrameNode;
135 };
136 
137 using OnDragStartFunc = std::function<DragDropBaseInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>;
138 using OnDragDropFunc = std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>;
139 using OnDragDropSpringLoadingFunc = std::function<void(const RefPtr<DragSpringLoadingContext>& info)>;
140 using OnChildTouchTestFunc = std::function<TouchResult(const std::vector<TouchTestInfo>& touchInfo)>;
141 using OnReponseRegionFunc = std::function<void(const std::vector<DimensionRect>&)>;
142 struct DragDropInfo {
143     RefPtr<UINode> customNode;
144     RefPtr<PixelMap> pixelMap;
145     std::string extraInfo;
146     // The inspectorId acts as a preview surrogate identifier which is used
147     // to retrieve a preview image for the item being dragged.
148     std::string inspectorId;
149     std::function<RefPtr<UINode>()> buildFunc;
150     bool onlyForLifting = false;
151     bool delayCreating = false;
152 };
153 
154 using DragNotifyMsgCore = OHOS::Ace::DragNotifyMsg;
155 using OnDragCallbackCore = std::function<void(const DragNotifyMsgCore&)>;
156 constexpr float PIXELMAP_WIDTH_RATE = -0.5f;
157 constexpr float PIXELMAP_HEIGHT_RATE = -0.2f;
158 constexpr float PIXELMAP_DEFALUT_LIMIT_SCALE = 0.5f;
159 constexpr float PIXELMAP_DRAG_WGR_TEXT_SCALE = 2.0f;
160 constexpr float PIXELMAP_DRAG_WGR_SCALE = 3.0f;
161 constexpr float DEFALUT_DRAG_PPIXELMAP_SCALE = 1.05f;
162 constexpr float PIXELMAP_DRAG_DEFAULT_HEIGHT = -28.0f;
163 
164 class EventHub;
165 class PipelineContext;
166 
167 // The gesture event hub is mainly used to handle common gesture events.
168 class ACE_FORCE_EXPORT GestureEventHub : public Referenced {
169 public:
170     explicit GestureEventHub(const WeakPtr<EventHub>& eventHub);
171     ~GestureEventHub() override = default;
172     void AddGesture(const RefPtr<NG::Gesture>& gesture);
173     // call by CAPI do distinguish with AddGesture called by ARKUI;
174     void ClearGesture();
175     void AttachGesture(const RefPtr<NG::Gesture>& gesture);
176     void RemoveGesture(const RefPtr<NG::Gesture>& gesture);
177     void RemoveGesturesByTag(const std::string& gestureTag);
178     void ClearModifierGesture();
179     void AddScrollableEvent(const RefPtr<ScrollableEvent>& scrollableEvent);
180     void RemoveScrollableEvent(const RefPtr<ScrollableEvent>& scrollableEvent);
181     void AddScrollEdgeEffect(const Axis& axis, RefPtr<ScrollEdgeEffect>& scrollEffect);
182     void RemoveScrollEdgeEffect(const RefPtr<ScrollEdgeEffect>& scrollEffect);
183     void AddPreviewMenuHandleDragEnd(GestureEventFunc&& actionEnd);
184     // Set by user define, which will replace old one.
185     void SetTouchEvent(TouchEventFunc&& touchEventFunc);
186     // Set by node container.
187     void SetOnTouchEvent(TouchEventFunc&& touchEventFunc);
188     // Set by JS FrameNode.
189     void SetJSFrameNodeOnTouchEvent(TouchEventFunc&& touchEventFunc);
190     void AddTouchEvent(const RefPtr<TouchEventImpl>& touchEvent);
191     void AddTouchAfterEvent(const RefPtr<TouchEventImpl>& touchEvent);
192     void RemoveTouchEvent(const RefPtr<TouchEventImpl>& touchEvent);
193     void SetFocusClickEvent(GestureEventFunc&& clickEvent);
194     bool IsClickable() const;
195     bool IsComponentClickable() const;
196     bool IsUserClickable() const;
197     bool IsAccessibilityClickable();
198     bool IsAccessibilityLongClickable();
199     bool ActClick(std::shared_ptr<JsonValue> secComphandle = nullptr);
200     void CheckClickActuator();
201     // Set by user define, which will replace old one.
202     void SetUserOnClick(GestureEventFunc&& clickEvent,
203         double distanceThreshold = std::numeric_limits<double>::infinity());
204     void SetUserOnClick(GestureEventFunc&& clickEvent, Dimension distanceThreshold);
205     void SetNodeClickDistance(double distanceThreshold = std::numeric_limits<double>::infinity());
206      // Set by JS FrameNode.
207     void SetJSFrameNodeOnClick(GestureEventFunc&& clickEvent);
208     void SetOnGestureJudgeBegin(GestureJudgeFunc&& gestureJudgeFunc);
209     void SetOnTouchIntercept(TouchInterceptFunc&& touchInterceptFunc);
210     TouchInterceptFunc GetOnTouchIntercept() const;
211     void SetShouldBuildinRecognizerParallelWithFunc(ShouldBuiltInRecognizerParallelWithFunc&& parallelGestureToFunc);
212     ShouldBuiltInRecognizerParallelWithFunc GetParallelInnerGestureToFunc() const;
213     void SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc);
214     GestureRecognizerJudgeFunc GetOnGestureRecognizerJudgeBegin() const;
215     void SetOnGestureJudgeNativeBegin(GestureJudgeFunc&& gestureJudgeFunc);
216     void SetOnGestureJudgeNativeBeginForMenu(GestureJudgeFunc&& gestureJudgeFunc);
217     TouchTestDoneCallback GetOnTouchTestDoneCallbackForInner() const;
218     void SetOnTouchTestDoneCallbackForInner(TouchTestDoneCallback&& touchTestDoneFunc);
219     TouchTestDoneCallback GetOnTouchTestDoneCallback() const;
220     void SetOnTouchTestDoneCallback(TouchTestDoneCallback&& touchTestDoneFunc);
221     GetEventTargetImpl CreateGetEventTargetImpl() const;
222     GestureJudgeFunc GetOnGestureJudgeBeginCallback() const;
223     GestureJudgeFunc GetOnGestureJudgeNativeBeginCallback();
224     // When the event param is undefined, it will clear the callback.
225     void ClearUserOnClick();
226     void ClearUserOnTouch();
227     void ClearJSFrameNodeOnClick();
228     void ClearJSFrameNodeOnTouch();
229     void AddClickEvent(const RefPtr<ClickEvent>& clickEvent);
230     void AddClickAfterEvent(const RefPtr<ClickEvent>& clickEvent);
231     void RemoveClickEvent(const RefPtr<ClickEvent>& clickEvent);
232     bool IsClickEventsEmpty() const;
233     GestureEventFunc GetClickEvent();
234     void BindMenu(GestureEventFunc&& showMenu);
235     void RegisterMenuOnTouch(TouchEventFunc&& callback);
236     bool IsLongClickable() const;
237     void SetRedirectClick(bool redirectClick);
238     bool ActLongClick();
239     void SetLongPressEvent(const RefPtr<LongPressEvent>& event, bool isForDrag = false, bool isDisableMouseLeft = false,
240         int32_t duration = 500);
241     // Set by user define, which will replace old one.
242     void SetPanEvent(const RefPtr<PanEvent>& panEvent, PanDirection direction, int32_t fingers, Dimension distance);
243     void SetPanEvent(
244         const RefPtr<PanEvent>& panEvent, PanDirection direction, int32_t fingers, PanDistanceMap distanceMap);
245     void AddPanEvent(const RefPtr<PanEvent>& panEvent, PanDirection direction, int32_t fingers, Dimension distance);
246     void AddPanEvent(
247         const RefPtr<PanEvent>& panEvent, PanDirection direction, int32_t fingers, PanDistanceMap distanceMap);
248     void AddPanEvent(const RefPtr<PanEvent>& panEvent,
249         PanDirection direction, int32_t fingers, const PanDistanceMapDimension& distanceMap);
250     void RemovePanEvent(const RefPtr<PanEvent>& panEvent);
251     void SetPanEventType(GestureTypeName typeName);
252     void SetLongPressEventType(GestureTypeName typeName);
253     // Set by user define, which will replace old one.
254     void SetDragEvent(const RefPtr<DragEvent>& dragEvent, PanDirection direction, int32_t fingers, Dimension distance);
255     void SetDragDropEvent();
256     void SetCustomDragEvent(
257         const RefPtr<DragEvent>& dragEvent, PanDirection direction, int32_t fingers, Dimension distance);
258     bool HasDragEvent() const;
259     // the return value means prevents event bubbling.
260     bool ProcessTouchTestHit(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
261         TouchTestResult& innerTargets, TouchTestResult& finalResult, int32_t touchId, const PointF& localPoint,
262         const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
263     bool ProcessEventTouchTestHit(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
264         TouchTestResult& innerTargets, TouchTestResult& finalResult, int32_t touchId, const PointF& localPoint,
265         const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
266 
267     bool ProcessDragEventTouchTestHit(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
268         TouchTestResult& innerTargets, TouchTestResult& finalResult, int32_t touchId, const PointF& localPoint,
269         const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
270     RefPtr<FrameNode> GetFrameNode() const;
OnContextAttached()271     void OnContextAttached() {}
272     static std::string GetHitTestModeStr(const RefPtr<GestureEventHub>& GestureEventHub);
273     HitTestMode GetHitTestMode() const;
274     void SetHitTestMode(HitTestMode hitTestMode);
275     void RemoveDragEvent();
276     void CombineIntoExclusiveRecognizer(
277         const PointF& globalPoint, const PointF& localPoint, TouchTestResult& result, int32_t touchId);
278     const std::vector<DimensionRect>& GetResponseRegion() const;
279     const std::vector<DimensionRect>& GetMouseResponseRegion() const;
280     void SetResponseRegionFunc(const OnReponseRegionFunc& func);
281     void SetResponseRegion(const std::vector<DimensionRect>& responseRegion);
282     void SetOnTouchTestFunc(OnChildTouchTestFunc&& callback);
283     const OnChildTouchTestFunc& GetOnTouchTestFunc();
284     void SetMouseResponseRegion(const std::vector<DimensionRect>& mouseResponseRegion);
285     void AddResponseRect(const DimensionRect& responseRect);
286     void RemoveLastResponseRect();
287     bool GetTouchable() const;
288     void SetTouchable(bool touchable);
289     void SetThumbnailCallback(std::function<void(Offset)>&& callback);
290     bool IsDragForbidden() const;
291     void SetDragForbiddenForcely(bool isDragForbidden);
292     bool GetTextDraggable() const;
293     void SetTextDraggable(bool draggable);
294     void SetIsTextDraggable(bool isTextDraggable);
295     bool GetIsTextDraggable();
296     void SetPreviewMode(MenuPreviewMode mode);
297     MenuPreviewMode GetPreviewMode();
298     void SetContextMenuShowStatus(bool contextMenuShowStatus);
299     bool GetContextMenuShowStatus();
300     void SetMenuBindingType(MenuBindingType menuBindingType);
301     MenuBindingType GetMenuBindingType();
302     void SetPixelMap(RefPtr<PixelMap> pixelMap);
303     RefPtr<PixelMap> GetPixelMap();
304     void SetDragPreviewPixelMap(RefPtr<PixelMap> pixelMap);
305     RefPtr<LongPressRecognizer> GetLongPressRecognizer() const;
306     void SetIsAllowMouse(bool isAllowMouse) const;
307     const RefPtr<ClickEventActuator>& GetUserClickEventActuator();
308     OnDragCallbackCore GetDragCallback(const RefPtr<PipelineBase>& context, const WeakPtr<EventHub>& hub);
309     void GenerateMousePixelMap(const GestureEvent& info);
310     OffsetF GetPixelMapOffset(const GestureEvent& info, const SizeF& size, const PreparedInfoForDrag& dragInfoData,
311         const float scale = 1.0f, const RectF& innerRect = RectF()) const;
312     void CalcFrameNodeOffsetAndSize(const RefPtr<FrameNode> frameNode, bool isMenuShow);
313     OffsetF GetDragPreviewInitPositionToScreen(const RefPtr<PipelineBase>& context, PreparedInfoForDrag& data);
314     int32_t GetBadgeNumber(const RefPtr<OHOS::Ace::DragEvent>& dragEvent);
315     bool TryDoDragStartAnimation(const RefPtr<PipelineBase>& context, const RefPtr<Subwindow>& subwindow,
316         const GestureEvent& info, PreparedInfoForDrag& data);
317     float GetDefaultPixelMapScale(
318         const RefPtr<FrameNode>& frameNode, const GestureEvent& info, bool isMenuShow, RefPtr<PixelMap> pixelMap);
319     RefPtr<PixelMap> GetPreScaledPixelMapIfExist(float targetScale, RefPtr<PixelMap> defaultPixelMap);
320     float GetPixelMapScale(const int32_t height, const int32_t width) const;
321     bool IsPixelMapNeedScale() const;
322     bool CheckAllowDrag(const GestureEvent& info, const RefPtr<PipelineBase>& context,
323         const RefPtr<FrameNode>& frameNode);
324     RefPtr<OHOS::Ace::DragEvent> CreateDragEvent(const GestureEvent& info, const RefPtr<PipelineBase>& context,
325         const RefPtr<FrameNode>& frameNode);
326     void InitDragDropEvent();
327     void HandleOnDragStart(const GestureEvent& info);
328     void HandleDragThroughMouse(const RefPtr<FrameNode> frameNode);
329     void HandleDragThroughTouch(const RefPtr<FrameNode> frameNode);
330     void HandleDragEndAction(const DragframeNodeInfo& info);
331     void HandleOnDragUpdate(const GestureEvent& info);
332     void HandleOnDragEnd(const GestureEvent& info);
333     void HandleOnDragCancel();
334     void StartLongPressActionForWeb();
335     void CancelDragForWeb();
336     bool StartDragTaskForWeb();
337     void ResetDragActionForWeb();
338     void OnModifyDone();
339     bool KeyBoardShortCutClick(const KeyEvent& event, const WeakPtr<NG::FrameNode>& node);
340     bool IsAllowedDrag(RefPtr<EventHub> eventHub);
341     void HandleNotAllowDrag(const GestureEvent& info);
342     RefPtr<DragEventActuator> GetDragEventActuator();
343     bool GetMonopolizeEvents() const;
344     void SetMonopolizeEvents(bool monopolizeEvents);
345     virtual RefPtr<NGGestureRecognizer> PackInnerRecognizer(
346         const Offset& offset, std::list<RefPtr<NGGestureRecognizer>>& innerRecognizers, int32_t touchId,
347         const RefPtr<TargetComponent>& targetComponent);
348     void CleanExternalRecognizers();
349     void CleanInnerRecognizer();
350     void CleanNodeRecognizer();
351     void CopyGestures(const RefPtr<GestureEventHub>& gestureEventHub);
352     void CopyEvent(const RefPtr<GestureEventHub>& gestureEventHub);
353     bool IsTextCategoryComponent(const std::string& frameTag);
354     int32_t RegisterCoordinationListener(const RefPtr<PipelineBase>& context);
355     DragDropInfo GetDragDropInfo(const GestureEvent& info, const RefPtr<FrameNode> frameNode,
356         DragDropInfo& dragPreviewInfo, const RefPtr<OHOS::Ace::DragEvent>& dragEvent);
357     RefPtr<UnifiedData> GetUnifiedData(const std::string& frameTag, DragDropInfo& dragDropInfo,
358         const RefPtr<OHOS::Ace::DragEvent>& dragEvent);
359     int32_t GetSelectItemSize();
360     bool IsNeedSwitchToSubWindow(const PreparedInfoForDrag& dragInfoData) const;
361     RefPtr<PixelMap> GetDragPreviewPixelMap();
362     void SetDragGatherPixelMaps(const GestureEvent& info);
363     void SetMouseDragGatherPixelMaps();
364     void SetNotMouseDragGatherPixelMaps();
365     void FireCustomerOnDragEnd(const RefPtr<PipelineBase>& context, const WeakPtr<EventHub>& hub);
366     void SetMouseDragMonitorState(bool state);
367     bool ParsePixelMapAsync(DragDropInfo& dragDropInfo, const DragDropInfo& dragPreviewInfo,
368         const GestureEvent& info);
369     void DoOnDragStartHandling(const GestureEvent& info, const RefPtr<FrameNode> frameNode,
370         DragDropInfo dragDropInfo, const RefPtr<OHOS::Ace::DragEvent>& event,
371         DragDropInfo dragPreviewInfo, const RefPtr<PipelineContext>& pipeline);
372     void HideMenu();
373     const GestureEvent GetGestureEventInfo();
374     const ClickInfo GetClickInfo();
375 #if defined(PIXEL_MAP_SUPPORTED)
376     static void PrintBuilderNode(const RefPtr<UINode>& customNode);
377     static void PrintIfImageNode(
378         const RefPtr<UINode>& builderNode, int32_t depth, bool& hasImageNode, std::list<RefPtr<FrameNode>>& imageNodes);
379     static void CheckImageDecode(std::list<RefPtr<FrameNode>>& imageNodes);
380     bool StartDragForCustomBuilderSync(const GestureEvent& info, const RefPtr<PipelineBase>& pipeline,
381         const RefPtr<FrameNode> frameNode, DragDropInfo dragDropInfo, const RefPtr<OHOS::Ace::DragEvent>& event);
382     void StartDragForCustomBuilder(const GestureEvent& info, const RefPtr<PipelineBase>& pipeline,
383         const RefPtr<FrameNode> frameNode, DragDropInfo dragDropInfo, const RefPtr<OHOS::Ace::DragEvent>& event);
384 #endif
385     void SetMenuPreviewScale(float menuPreviewScale);
386     float GetMenuPreviewScale() const;
387     void SetBindMenuStatus(bool setIsShow, bool isShow, MenuPreviewMode previewMode);
388     const BindMenuStatus& GetBindMenuStatus() const;
389     bool WillRecreateGesture() const;
390 
391     bool parallelCombineClick = false;
392     RefPtr<ParallelRecognizer> innerParallelRecognizer_;
393 
394     bool IsGestureEmpty() const;
395 
396     bool IsPanEventEmpty() const;
397 
398     void SetExcludedAxisForPanEvent(bool isExcludedAxis);
399 
400     void DumpVelocityInfoFroPanEvent(int32_t fingerId);
401 
402     bool IsDragNewFwk() const;
403     bool TriggerTouchEvent(const TouchEvent& point);
404     void SetRecognizerDelayStatus(const RecognizerDelayStatus& recognizerDelayStatus = RecognizerDelayStatus::NONE);
405     void DragNodeDetachFromParent();
406 private:
407     void ProcessTouchTestHierarchy(const OffsetF& coordinateOffset, const TouchRestrict& touchRestrict,
408         std::list<RefPtr<NGGestureRecognizer>>& innerRecognizers, TouchTestResult& finalResult, int32_t touchId,
409         const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
410 
411     void UpdateGestureHierarchy();
412     void UpdateModifierGestureHierarchy();
413 
414     void AddGestureToGestureHierarchy(const RefPtr<NG::Gesture>& gesture, bool isModifier);
415 
416     // old path.
417     void UpdateExternalNGGestureRecognizer();
418 
419     OnAccessibilityEventFunc GetOnAccessibilityEventFunc();
420 
421     void OnDragStart(const GestureEvent& info, const RefPtr<PipelineBase>& context, const RefPtr<FrameNode> frameNode,
422         DragDropInfo dragDropInfo, const RefPtr<OHOS::Ace::DragEvent>& dragEvent);
423     void PrepareDragStartInfo(
424         RefPtr<PipelineContext>& pipeline, PreparedInfoForDrag& data, const RefPtr<FrameNode> frameNode);
425     void UpdateMenuNode(
426         const RefPtr<FrameNode> menuWrapperNode, PreparedInfoForDrag& data, const RefPtr<FrameNode> frameNode);
427     void StartVibratorByDrag(const RefPtr<FrameNode>& frameNode);
428     void UpdateExtraInfo(const RefPtr<FrameNode>& frameNode, std::unique_ptr<JsonValue>& arkExtraInfoJson, float scale,
429         const PreparedInfoForDrag& dragInfoData);
430     void ProcessMenuPreviewScale(const RefPtr<FrameNode> imageNode, float& scale, float previewScale,
431         float windowScale, float defaultMenuPreviewScale);
432 
433     template<typename T>
434     const RefPtr<T> GetAccessibilityRecognizer();
435 
436     template<typename T>
437     const RefPtr<T> AccessibilityRecursionSearchRecognizer(const RefPtr<NGGestureRecognizer>& recognizer);
438 
439     void ProcessParallelPriorityGesture(const Offset& offset, int32_t touchId,
440         const RefPtr<TargetComponent>& targetComponent, const RefPtr<FrameNode>& host,
441         RefPtr<NGGestureRecognizer>& current, std::list<RefPtr<NGGestureRecognizer>>& recognizers,
442         int32_t& parallelIndex, bool needRebuildForCurrent = false);
443 
444     void ProcessExternalExclusiveRecognizer(const Offset& offset, int32_t touchId,
445         const RefPtr<TargetComponent>& targetComponent, const RefPtr<FrameNode>& host, GesturePriority priority,
446         RefPtr<NGGestureRecognizer>& current, std::list<RefPtr<NGGestureRecognizer>>& recognizers,
447         int32_t& exclusiveIndex, bool needRebuildForCurrent = false);
448 
449     bool CheckLastInnerRecognizerCollected(GesturePriority priority, int32_t gestureGroupIndex = 0);
450 
451     void UpdateNodePositionBeforeStartAnimation(const RefPtr<FrameNode>& frameNode,
452         PreparedInfoForDrag& data);
453 
454     WeakPtr<EventHub> eventHub_;
455     RefPtr<ScrollableActuator> scrollableActuator_;
456     RefPtr<TouchEventActuator> touchEventActuator_;
457     RefPtr<ClickEventActuator> clickEventActuator_;
458     RefPtr<ClickEventActuator> userParallelClickEventActuator_;
459     RefPtr<LongPressEventActuator> longPressEventActuator_;
460     RefPtr<PanEventActuator> panEventActuator_;
461     RefPtr<DragEventActuator> dragEventActuator_;
462     RefPtr<ExclusiveRecognizer> innerExclusiveRecognizer_;
463     RefPtr<ExclusiveRecognizer> nodeExclusiveRecognizer_;
464     RefPtr<ParallelRecognizer> nodeParallelRecognizer_;
465     std::vector<RefPtr<ExclusiveRecognizer>> externalExclusiveRecognizer_;
466     std::vector<RefPtr<ParallelRecognizer>> externalParallelRecognizer_;
467     RefPtr<DragDropProxy> dragDropProxy_;
468 
469     // Set by use gesture, priorityGesture and parallelGesture attribute function.
470     std::list<RefPtr<NG::Gesture>> gestures_;
471     // set by CAPI or modifier do distinguish with gestures_;
472     std::list<RefPtr<NG::Gesture>> modifierGestures_;
473     std::list<RefPtr<NG::Gesture>> backupGestures_;
474     std::list<RefPtr<NG::Gesture>> backupModifierGestures_;
475     std::list<RefPtr<NGGestureRecognizer>> gestureHierarchy_;
476     std::list<RefPtr<NGGestureRecognizer>> modifierGestureHierarchy_;
477 
478     // used in bindMenu, need to delete the old callback when bindMenu runs again
479     RefPtr<ClickEvent> showMenu_;
480     RefPtr<TouchEventImpl> bindMenuTouch_;
481 
482     HitTestMode hitTestMode_ = HitTestMode::HTMDEFAULT;
483     bool recreateGesture_ = true;
484     bool needRecollect_ = false;
485     bool isResponseRegion_ = false;
486     std::vector<DimensionRect> responseRegion_;
487     std::vector<DimensionRect> mouseResponseRegion_;
488     bool touchable_ = true;
489     RefPtr<PixelMap> pixelMap_;
490 
491     // Save dragPreview pixelMap of user setting, transfer to drag framework on drag start.
492     RefPtr<PixelMap> dragPreviewPixelMap_;
493 
494     OffsetF frameNodeOffset_;
495     SizeF frameNodeSize_;
496     std::shared_ptr<GestureEvent> gestureInfoForWeb_;
497     bool isReceivedDragGestureInfo_ = false;
498     OnChildTouchTestFunc onChildTouchTestFunc_;
499     OnReponseRegionFunc responseRegionFunc_;
500     bool redirectClick_  = false;
501 
502     GestureJudgeFunc gestureJudgeFunc_;
503     GestureJudgeFunc gestureJudgeNativeFunc_;
504     GestureJudgeFunc gestureJudgeNativeFuncForMenu_;
505 
506     TouchTestDoneCallback touchTestDoneCallbackForInner_;
507     TouchTestDoneCallback touchTestDoneCallback_;
508 
509     TouchInterceptFunc touchInterceptFunc_;
510 
511     ShouldBuiltInRecognizerParallelWithFunc shouldBuildinRecognizerParallelWithFunc_;
512     GestureRecognizerJudgeFunc gestureRecognizerJudgeFunc_;
513 
514     MenuPreviewMode previewMode_ = MenuPreviewMode::NONE;
515     // the value from show parameter of context menu, which is controlled by caller manually
516     bool contextMenuShowStatus_  = false;
517     MenuBindingType menuBindingType_  = MenuBindingType::LONG_PRESS;
518     BindMenuStatus bindMenuStatus_;
519     DragframeNodeInfo dragframeNodeInfo_;
520     // disable drag for the node itself and its all children
521     bool isDragForbiddenForWholeSubTree_ = false;
522     bool textDraggable_ = false;
523     bool isTextDraggable_ = false;
524     bool monopolizeEvents_ = false;
525     float menuPreviewScale_ = DEFALUT_DRAG_PPIXELMAP_SCALE;
526     bool isDragNewFwk_ = false;
527 };
528 
529 } // namespace OHOS::Ace::NG
530 
531 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_EVENT_GESTURE_EVENT_HUB_H
532