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 TapGestureDetector::SetTapsRequired
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.
48 * The application programmer can use this gesture detector as follows:
50 * TapGestureDetector detector = TapGestureDetector::New();
51 * detector.Attach(myActor);
52 * detector.DetectedSignal().Connect(this, &MyApplication::OnTap);
57 * @note Multi-touch taps are not currently supported. However, multiple taps (double & triple tap etc.) ARE supported.
60 * | %Signal Name | Method |
61 * |--------------|-----------------------|
62 * | tap-detected | @ref DetectedSignal() |
64 class DALI_IMPORT_API TapGestureDetector : public GestureDetector
69 * @brief Signal type for detected signal.
71 typedef Signal< void ( Actor, const TapGesture& ) > DetectedSignalType;
73 public: // Creation & Destruction
76 * @brief Create an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New().
78 * Calling member functions with an uninitialized Dali::Object is not allowed.
83 * @brief Create an initialized TapGestureDetector.
85 * By default, this would create a gesture detector which requires one tap with one touch.
86 * @return A handle to a newly allocated Dali resource.
88 static TapGestureDetector New();
91 * @brief Create an initialized TapGestureDetector with the specified parameters.
93 * @param[in] tapsRequired The minimum & maximum number of taps required.
94 * @return A handle to a newly allocated Dali resource.
96 static TapGestureDetector New( unsigned int tapsRequired );
99 * @brief Downcast an Object handle to TapGestureDetector handle.
101 * If handle points to a TapGestureDetector object the
102 * downcast produces valid handle. If not the returned handle is left uninitialized.
103 * @param[in] handle to An object
104 * @return handle to a TapGestureDetector object or an uninitialized handle
106 static TapGestureDetector DownCast( BaseHandle handle );
111 * This is non-virtual since derived Handle types must not contain data or virtual methods.
113 ~TapGestureDetector();
116 * @brief This copy constructor is required for (smart) pointer semantics.
118 * @param [in] handle A reference to the copied handle
120 TapGestureDetector(const TapGestureDetector& handle);
123 * @brief This assignment operator is required for (smart) pointer semantics.
125 * @param [in] rhs A reference to the copied handle
126 * @return A reference to this
128 TapGestureDetector& operator=(const TapGestureDetector& rhs);
133 * @brief Set the minimum number of taps required.
135 * The tap count is the number of times a user should "tap" the screen.
136 * @param[in] minimumTaps The minimum taps required.
137 * @pre The gesture detector has been initialized.
138 * @note The default is '1'.
140 void SetMinimumTapsRequired( unsigned int minimumTaps );
143 * @brief Set the maximum number of taps required.
145 * The tap count is the number of times a user should "tap" the screen.
146 * @param[in] maximumTaps The maximum taps required.
147 * @pre The gesture detector has been initialized.
148 * @note The default is '1'.
150 void SetMaximumTapsRequired( unsigned int maximumTaps );
155 * @brief Retrieves the minimum number of taps required.
157 * @return The minimum taps required.
158 * @pre The gesture detector has been initialized.
160 unsigned int GetMinimumTapsRequired() const;
163 * @brief Retrieves the maximum number of taps required.
165 * @return The maximum taps required.
166 * @pre The gesture detector has been initialized.
168 unsigned int GetMaximumTapsRequired() const;
173 * @brief This signal is emitted when the specified tap is detected on the attached actor.
175 * A callback of the following type may be connected:
177 * void YourCallbackName( Actor actor, const TapGesture& gesture );
179 * @pre The gesture detector has been initialized.
180 * @return The signal to connect to.
182 DetectedSignalType& DetectedSignal();
184 public: // Not intended for Application developers
187 * @brief This constructor is used by Dali New() methods.
189 * @param [in] internal A pointer to a newly allocated Dali resource.
191 explicit DALI_INTERNAL TapGestureDetector(Internal::TapGestureDetector* internal);
200 #endif // __DALI_TAP_GESTURE_DETECTOR_H__