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