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