1 #ifndef __DALI_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_TAP_GESTURE_DETECTOR_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/events/gesture-detector.h>
23 #include <dali/public-api/signals/dali-signal.h>
28 * @addtogroup dali_core_events
32 namespace Internal DALI_INTERNAL
34 class TapGestureDetector;
40 * @brief This class emits a signal when a tap gesture occurs that meets the requirements set by the
43 * See @ref TapGestureDetector::SetMinimumTapsRequired
44 * See @ref TapGestureDetector::SetMaximumTapsRequired
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.
49 * The application programmer can use this gesture detector as follows:
51 * TapGestureDetector detector = TapGestureDetector::New();
52 * detector.Attach(myActor);
53 * detector.DetectedSignal().Connect(this, &MyApplication::OnTap);
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.
61 * | %Signal Name | Method |
62 * |--------------|-----------------------|
63 * | tapDetected | @ref DetectedSignal() |
67 class DALI_IMPORT_API TapGestureDetector : public GestureDetector
72 * @brief Signal type for detected signal.
75 typedef Signal< void ( Actor, const TapGesture& ) > DetectedSignalType;
77 public: // Creation & Destruction
80 * @brief Creates an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New().
82 * Calling member functions with an uninitialized TapGestureDetector handle is not allowed.
88 * @brief Creates an initialized TapGestureDetector.
90 * By default, this would create a gesture detector which requires one tap with one touch.
92 * @return A handle to a newly allocated Dali resource
94 static TapGestureDetector New();
97 * @brief Creates an initialized TapGestureDetector with the specified parameters.
100 * @param[in] tapsRequired The minimum & maximum number of taps required
101 * @return A handle to a newly allocated Dali resource
103 static TapGestureDetector New( unsigned int tapsRequired );
106 * @brief Downcasts a handle to TapGestureDetector handle.
108 * If handle points to a TapGestureDetector object, the
109 * downcast produces valid handle. If not, the returned handle is left uninitialized.
111 * @param[in] handle Handle to an object
112 * @return Handle to a TapGestureDetector object or an uninitialized handle
114 static TapGestureDetector DownCast( BaseHandle handle );
119 * This is non-virtual since derived Handle types must not contain data or virtual methods.
122 ~TapGestureDetector();
125 * @brief This copy constructor is required for (smart) pointer semantics.
128 * @param[in] handle A reference to the copied handle
130 TapGestureDetector(const TapGestureDetector& handle);
133 * @brief This assignment operator is required for (smart) pointer semantics.
136 * @param[in] rhs A reference to the copied handle
137 * @return A reference to this
139 TapGestureDetector& operator=(const TapGestureDetector& rhs);
144 * @brief Sets the minimum number of taps required.
146 * The tap count is the number of times a user should "tap" the screen.
148 * @param[in] minimumTaps The minimum taps required
149 * @pre The gesture detector has been initialized.
150 * @note The default is '1'.
152 void SetMinimumTapsRequired( unsigned int minimumTaps );
155 * @brief Sets the maximum number of taps required.
157 * The tap count is the number of times a user should "tap" the screen.
159 * @param[in] maximumTaps The maximum taps required
160 * @pre The gesture detector has been initialized.
161 * @note The default is '1'.
163 void SetMaximumTapsRequired( unsigned int maximumTaps );
168 * @brief Retrieves the minimum number of taps required.
171 * @return The minimum taps required
172 * @pre The gesture detector has been initialized.
174 unsigned int GetMinimumTapsRequired() const;
177 * @brief Retrieves the maximum number of taps required.
180 * @return The maximum taps required
181 * @pre The gesture detector has been initialized.
183 unsigned int GetMaximumTapsRequired() const;
188 * @brief This signal is emitted when the specified tap is detected on the attached actor.
190 * A callback of the following type may be connected:
192 * void YourCallbackName( Actor actor, const TapGesture& gesture );
195 * @return The signal to connect to
196 * @pre The gesture detector has been initialized.
198 DetectedSignalType& DetectedSignal();
200 public: // Not intended for Application developers
204 * @brief This constructor is used by TapGestureDetector::New() methods.
207 * @param[in] internal A pointer to a newly allocated Dali resource
209 explicit DALI_INTERNAL TapGestureDetector(Internal::TapGestureDetector* internal);
219 #endif // __DALI_TAP_GESTURE_DETECTOR_H__