[Tizen] Not execute the remove callback
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-recognizer.h
1 #ifndef DALI_INTERNAL_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_GESTURE_RECOGNIZER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/internal/event/events/gesture-event.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/events/gesture.h>
25 #include <dali/public-api/math/vector2.h>
26 #include <dali/public-api/object/ref-object.h>
27
28 namespace Dali
29 {
30 namespace Integration
31 {
32 struct TouchEvent;
33 }
34
35 namespace Internal
36 {
37 struct GestureRequest;
38 class Scene;
39
40 template<typename T>
41 class RecognizerObserver
42 {
43 public:
44   virtual void Process(Scene& scene, const T& event) = 0;
45
46   virtual ~RecognizerObserver() = default;
47   ;
48 };
49
50 /**
51  * Abstract Base class for all adaptor gesture detectors.
52  *
53  * @note this may be replaced by gesture events sent directly from X.
54  */
55 class GestureRecognizer : public RefObject
56 {
57 public:
58   /**
59    * Called when it gets a touch event.  The gesture recognizer should
60    * evaluate this event along with previously received events to determine
61    * whether the gesture they require has taken place.
62    * @param[in]  event  The latest touch event.
63    */
64   virtual void SendEvent(const Integration::TouchEvent& event) = 0;
65
66   /**
67    * Called when Core updates the gesture's detection requirements.
68    * @param[in]  request  The updated detection requirements.
69    */
70   virtual void Update(const GestureRequest& request) = 0;
71
72   /**
73    * Returns the type of gesture detector.
74    * @return Type of gesture detector.
75    */
76   GestureType::Value GetType() const
77   {
78     return mType;
79   }
80
81   /**
82    * Called when we get a touch event.
83    * @param[in]  scene  The scene the touch event has occurred on
84    * @param[in]  event  The latest touch event
85    */
86   void SendEvent(Scene& scene, const Integration::TouchEvent& event)
87   {
88     mScene = &scene;
89     SendEvent(event);
90   }
91
92 protected:
93   /**
94    * Protected Constructor. Should only be able to create derived class objects.
95    * @param[in]  screenSize    The size of the screen.
96    * @param[in]  detectorType  The type of gesture detector.
97    */
98   GestureRecognizer(Vector2 screenSize, GestureType::Value detectorType)
99   : mScreenSize(screenSize),
100     mType(detectorType),
101     mScene(nullptr)
102   {
103   }
104
105   /**
106    * Protected Constructor. Should only be able to create derived class objects.
107    *
108    * Use this constructor with the screen size is not used in the dereived class.
109    * @param[in]  detectorType  The type of gesture detector.
110    */
111   GestureRecognizer(GestureType::Value detectorType)
112   : GestureRecognizer(Vector2::ZERO, detectorType)
113   {
114   }
115
116   /**
117    * Virtual destructor.
118    */
119   ~GestureRecognizer() override = default;
120
121 protected:
122   Vector2            mScreenSize;
123   GestureType::Value mType;
124   Scene*             mScene;
125 };
126
127 using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
128
129 } // namespace Internal
130
131 } // namespace Dali
132
133 #endif // DALI_INTERNAL_GESTURE_RECOGNIZER_H