3f6b00277a216da6c38e8d47f127060dfca87bce
[platform/core/uifw/dali-core.git] / dali / public-api / events / tap-gesture-detector.h
1 #ifndef __DALI_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_TAP_GESTURE_DETECTOR_H__
3
4 /*
5  * Copyright (c) 2015 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/events/gesture-detector.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 namespace Dali
26 {
27 /**
28  * @addtogroup dali_core_events
29  * @{
30  */
31
32 namespace Internal DALI_INTERNAL
33 {
34 class TapGestureDetector;
35 }
36
37 struct TapGesture;
38
39 /**
40  * @brief This class emits a signal when a tap gesture occurs that meets the requirements set by the
41  * application.
42  *
43  * See TapGestureDetector::SetTapsRequired
44  *
45  * A Tap Gesture is a discrete gesture, which means it does not have any state information attached
46  * to it.  Please see TapGesture for more information.
47  *
48  * The application programmer can use this gesture detector as follows:
49  * @code
50  * TapGestureDetector detector = TapGestureDetector::New();
51  * detector.Attach(myActor);
52  * detector.DetectedSignal().Connect(this, &MyApplication::OnTap);
53  * @endcode
54  *
55  * @SINCE_1_0.0
56  * @note Multi-touch taps are not currently supported. However, multiple taps (double & triple tap etc.) ARE supported.
57  *
58  * Signals
59  * | %Signal Name | Method                |
60  * |--------------|-----------------------|
61  * | tapDetected  | @ref DetectedSignal() |
62  * @see TapGesture
63  *
64  */
65 class DALI_IMPORT_API TapGestureDetector : public GestureDetector
66 {
67 public: // Typedefs
68
69   /**
70    * @brief Signal type for detected signal.
71    * @SINCE_1_0.0
72    */
73   typedef Signal< void ( Actor, const TapGesture& ) > DetectedSignalType;
74
75 public: // Creation & Destruction
76
77   /**
78    * @brief Create an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New().
79    *
80    * Calling member functions with an uninitialized Dali::Object is not allowed.
81    * @SINCE_1_0.0
82    */
83   TapGestureDetector();
84
85   /**
86    * @brief Create an initialized TapGestureDetector.
87    *
88    * By default, this would create a gesture detector which requires one tap with one touch.
89    * @SINCE_1_0.0
90    * @return A handle to a newly allocated Dali resource.
91    */
92   static TapGestureDetector New();
93
94   /**
95    * @brief Create an initialized TapGestureDetector with the specified parameters.
96    *
97    * @SINCE_1_0.0
98    * @param[in]  tapsRequired     The minimum & maximum number of taps required.
99    * @return A handle to a newly allocated Dali resource.
100    */
101   static TapGestureDetector New( unsigned int tapsRequired );
102
103   /**
104    * @brief Downcast an Object handle to TapGestureDetector handle.
105    *
106    * If handle points to a TapGestureDetector object the
107    * downcast produces valid handle. If not the returned handle is left uninitialized.
108    * @SINCE_1_0.0
109    * @param[in] handle to An object
110    * @return handle to a TapGestureDetector object or an uninitialized handle
111    */
112   static TapGestureDetector DownCast( BaseHandle handle );
113
114   /**
115    * @brief Destructor
116    *
117    * This is non-virtual since derived Handle types must not contain data or virtual methods.
118    * @SINCE_1_0.0
119    */
120   ~TapGestureDetector();
121
122   /**
123    * @brief This copy constructor is required for (smart) pointer semantics.
124    *
125    * @SINCE_1_0.0
126    * @param [in] handle A reference to the copied handle
127    */
128   TapGestureDetector(const TapGestureDetector& handle);
129
130   /**
131    * @brief This assignment operator is required for (smart) pointer semantics.
132    *
133    * @SINCE_1_0.0
134    * @param [in] rhs  A reference to the copied handle
135    * @return A reference to this
136    */
137   TapGestureDetector& operator=(const TapGestureDetector& rhs);
138
139 public: // Setters
140
141   /**
142    * @brief Set the minimum number of taps required.
143    *
144    * The tap count is the number of times a user should "tap" the screen.
145    * @SINCE_1_0.0
146    * @param[in]  minimumTaps  The minimum taps required.
147    * @pre The gesture detector has been initialized.
148    * @note The default is '1'.
149    */
150   void SetMinimumTapsRequired( unsigned int minimumTaps );
151
152   /**
153    * @brief Set the maximum number of taps required.
154    *
155    * The tap count is the number of times a user should "tap" the screen.
156    * @SINCE_1_0.0
157    * @param[in]  maximumTaps  The maximum taps required.
158    * @pre The gesture detector has been initialized.
159    * @note The default is '1'.
160    */
161   void SetMaximumTapsRequired( unsigned int maximumTaps );
162
163 public: // Getters
164
165   /**
166    * @brief Retrieves the minimum number of taps required.
167    *
168    * @SINCE_1_0.0
169    * @return The minimum taps required.
170    * @pre The gesture detector has been initialized.
171    */
172   unsigned int GetMinimumTapsRequired() const;
173
174   /**
175    * @brief Retrieves the maximum number of taps required.
176    *
177    * @SINCE_1_0.0
178    * @return The maximum taps required.
179    * @pre The gesture detector has been initialized.
180    */
181   unsigned int GetMaximumTapsRequired() const;
182
183 public: // Signals
184
185   /**
186    * @brief This signal is emitted when the specified tap is detected on the attached actor.
187    *
188    * A callback of the following type may be connected:
189    * @code
190    *   void YourCallbackName( Actor actor, const TapGesture& gesture );
191    * @endcode
192    * @SINCE_1_0.0
193    * @return The signal to connect to.
194    * @pre The gesture detector has been initialized.
195    */
196   DetectedSignalType& DetectedSignal();
197
198 public: // Not intended for Application developers
199
200   /**
201    * @brief This constructor is used by Dali New() methods.
202    *
203    * @SINCE_1_0.0
204    * @param [in]  internal  A pointer to a newly allocated Dali resource.
205    */
206   explicit DALI_INTERNAL TapGestureDetector(Internal::TapGestureDetector* internal);
207 };
208
209 /**
210  * @}
211  */
212
213 } // namespace Dali
214
215 #endif // __DALI_TAP_GESTURE_DETECTOR_H__