1 /* 2 * Copyright (c) 2021-2022 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_GESTURE_LISTENER_RENDER_GESTURE_LISTENER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_GESTURE_LISTENER_RENDER_GESTURE_LISTENER_H 18 19 #include "core/components/proxy/render_proxy.h" 20 #include "core/gestures/click_recognizer.h" 21 #include "core/gestures/drag_recognizer.h" 22 #include "core/gestures/long_press_recognizer.h" 23 #include "core/gestures/pinch_recognizer.h" 24 #include "base/window/drag_window.h" 25 26 namespace OHOS::Ace { 27 28 class GestureListenerComponent; 29 30 class ACE_EXPORT RenderGestureListener final : public RenderProxy { 31 DECLARE_ACE_TYPE(RenderGestureListener, RenderProxy); 32 33 public: 34 static RefPtr<RenderNode> Create(); 35 void Update(const RefPtr<Component>& component) override; 36 37 bool GetVisible() const override; 38 void UpdateTouchRect() override; 39 40 void SetRemoteMessageCallback(const ClickCallback& callback); 41 void SetOnClickCallback(const ClickCallback& callback); 42 void SetOnDoubleClickCallback(const ClickCallback& callback); 43 void SetOnLongPressCallback(const OnLongPress& callback); 44 void SetOnPinchStartCallback(const GestureEventFunc& callback); 45 void SetOnPinchUpdateCallback(const GestureEventFunc& callback); 46 void SetOnPinchEndCallback(const GestureEventFunc& callback); 47 void SetOnPinchCancelCallback(const GestureEventNoParameter& callback); 48 RefPtr<DragWindow> dragWindow_; 49 protected: 50 void OnTouchTestHit( 51 const Offset& coordinateOffset, const TouchRestrict& touchRestrict, TouchTestResult& result) override; 52 53 private: 54 void SetRemoteMessageCallback(const RefPtr<GestureListenerComponent>& component); 55 void SetOnClickCallback(const RefPtr<GestureListenerComponent>& component); 56 void SetOnDoubleClickCallback(const RefPtr<GestureListenerComponent>& component); 57 void SetOnLongPressCallback(const RefPtr<GestureListenerComponent>& component); 58 void SetOnPinchStartCallback(const RefPtr<GestureListenerComponent>& component); 59 void SetOnPinchUpdateCallback(const RefPtr<GestureListenerComponent>& component); 60 void SetOnPinchEndCallback(const RefPtr<GestureListenerComponent>& component); 61 void SetOnPinchCancelCallback(const RefPtr<GestureListenerComponent>& component); 62 void SetDragCallBack(RefPtr<FreeDragRecognizer>& recognizer, RefPtr<GestureListenerComponent> component); 63 64 RefPtr<ClickRecognizer> clickRecognizer_; 65 RefPtr<ClickRecognizer> doubleClickRecognizer_; 66 RefPtr<LongPressRecognizer> longPressRecognizer_; 67 RefPtr<PinchRecognizer> pinchRecognizer_; 68 RefPtr<FreeDragRecognizer> freeDragRecognizer_; 69 RefPtr<VerticalDragRecognizer> verticalDragRecognizer_; 70 RefPtr<HorizontalDragRecognizer> horizontalDragRecognizer_; 71 bool isVisible_ = true; 72 TouchEvent touchpoint_; 73 RefPtr<RenderNode> dragTarget_ = nullptr; 74 }; 75 76 } // namespace OHOS::Ace 77 78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_GESTURE_LISTENER_RENDER_GESTURE_LISTENER_H 79