Add BuildPickingRay to devel api
[platform/core/uifw/dali-core.git] / dali / public-api / events / gesture-detector.h
1 #ifndef DALI_GESTURE_DETECTOR_H
2 #define DALI_GESTURE_DETECTOR_H
3
4 /*
5  * Copyright (c) 2022 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 // INTERNAL INCLUDES
22 #include <dali/public-api/object/handle.h>
23
24 namespace Dali
25 {
26 /**
27  * @addtogroup dali_core_events
28  * @{
29  */
30
31 namespace Internal DALI_INTERNAL
32 {
33 class GestureDetector;
34 }
35
36 class Actor;
37
38 /**
39  * @brief GestureDetectors analyse a stream of touch events and attempt to determine the intention of the user.
40  *
41  * An actor is attached to a gesture detector and if the detector recognises a pattern in its analysis, it will
42  * emit a detected signal to the application.
43  *
44  * This is the base class for different gesture detectors available and provides functionality that is common
45  * to all the gesture detectors.
46  *
47  * @SINCE_1_0.0
48  * @see Gesture
49  */
50 class DALI_CORE_API GestureDetector : public Handle
51 {
52 public: // Creation & Destruction
53   /**
54    * @brief Creates an uninitialized GestureDetector.
55    *
56    * This can be initialized with one of the derived gesture detectors' New() methods. For example, PanGestureDetector::New().
57    *
58    * Calling member functions with an uninitialized Dali::GestureDetector handle is not allowed.
59    * @SINCE_1_0.0
60    */
61   GestureDetector();
62
63   /**
64    * @brief Downcasts a handle to GestureDetector handle.
65    *
66    * If handle points to a GestureDetector object, the downcast produces valid handle.
67    * If not, the returned handle is left uninitialized.
68    * @SINCE_1_0.0
69    * @param[in] handle Handle to an object
70    * @return Handle to a GestureDetector object or an uninitialized handle
71    */
72   static GestureDetector DownCast(BaseHandle handle);
73
74   /**
75    * @brief Dali::GestureDetector is intended as a base class.
76    *
77    * This is non-virtual since derived Handle types must not contain data or virtual methods.
78    * @SINCE_1_0.0
79    */
80   ~GestureDetector();
81
82   /**
83    * @brief This copy constructor is required for (smart) pointer semantics.
84    *
85    * @SINCE_1_0.0
86    * @param[in] handle A reference to the copied handle
87    */
88   GestureDetector(const GestureDetector& handle);
89
90   /**
91    * @brief This assignment operator is required for (smart) pointer semantics.
92    *
93    * @SINCE_1_0.0
94    * @param[in] rhs A reference to the copied handle
95    * @return A reference to this
96    */
97   GestureDetector& operator=(const GestureDetector& rhs);
98
99   /**
100    * @brief This move constructor is required for (smart) pointer semantics.
101    *
102    * @SINCE_2_2.4
103    * @param[in] handle A reference to the moved handle
104    */
105   GestureDetector(GestureDetector&& handle);
106
107   /**
108    * @brief This move assignment operator is required for (smart) pointer semantics.
109    *
110    * @SINCE_2_2.4
111    * @param[in] rhs A reference to the moved handle
112    * @return A reference to this
113    */
114   GestureDetector& operator=(GestureDetector&& rhs);
115
116 public: // Actor related
117   /**
118    * @brief Attaches an actor to the gesture.
119    *
120    * The detected signal will be dispatched when the gesture occurs on
121    * the attached actor.
122    * @SINCE_1_0.0
123    * @param[in] actor The actor to attach to the gesture detector
124    * @pre The gesture detector has been initialized.
125    * @note You can attach several actors to a gesture detector.
126    */
127   void Attach(Actor actor);
128
129   /**
130    * @brief Detaches the attached actor from the gesture detector.
131    *
132    * @SINCE_1_0.0
133    * @param[in] actor The actor to detach from the gesture detector
134    * @pre The gesture detector has been initialized.
135    * @pre The specified actor has been attached to the gesture detector.
136    */
137   void Detach(Actor actor);
138
139   /**
140    * @brief Detaches all the actors that have been attached to the gesture detector.
141    *
142    * @SINCE_1_0.0
143    * @pre The gesture detector has been initialized.
144    * @pre At least one actor has been attached to the gesture detector.
145    */
146   void DetachAll();
147
148   /**
149    * @brief Returns the number of actors attached to the gesture detector.
150    *
151    * @SINCE_1_0.0
152    * @return The count
153    * @pre The gesture detector has been initialized.
154    */
155   size_t GetAttachedActorCount() const;
156
157   /**
158    * @brief Returns an actor by index. An empty handle if the index is not valid.
159    *
160    * @SINCE_1_0.0
161    * @param[in] index The attached actor's index
162    * @return The attached actor or an empty handle
163    * @pre The gesture detector has been initialized.
164    */
165   Actor GetAttachedActor(size_t index) const;
166
167 protected:
168   /// @cond internal
169   /**
170    * @brief This constructor is used by New() methods of derived classes (For example, PanGestureDetector::New()).
171    *
172    * @SINCE_1_0.0
173    * @param[in] internal A pointer to a newly allocated Dali resource
174    */
175   explicit DALI_INTERNAL GestureDetector(Internal::GestureDetector* internal);
176   /// @endcond
177 };
178
179 /**
180  * @}
181  */
182 } // namespace Dali
183
184 #endif // DALI_GESTURE_DETECTOR_H