1 #ifndef __DALI_LONG_PRESS_GESTURE_DETECTOR_H__
2 #define __DALI_LONG_PRESS_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 LongPressGestureDetector;
37 struct LongPressGesture;
40 * @brief This class emits a signals when a long press gesture occurs that meets the requirements set by the application.
43 * For any valid long press, two signals will be emitted:
44 * - First identifying the beginning (state = Started) i.e. when fingers held down for the required time.
45 * - Second identifying the ending (state = Finished) i.e. when fingers are released.
47 * The application programmer can use this gesture detector as follows:
49 * LongPressGestureDetector detector = LongPressGestureDetector::New();
50 * detector.Attach(myActor);
51 * detector.DetectedSignal().Connect(this, &MyApplication::OnLongPress);
54 * @see LongPressGesture
57 * | %Signal Name | Method |
58 * |-------------------|-----------------------|
59 * | longPressDetected | @ref DetectedSignal() |
61 class DALI_IMPORT_API LongPressGestureDetector : public GestureDetector
65 typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type @SINCE_1_0.0
67 public: // Creation & Destruction
70 * @brief Creates an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
72 * Calling member functions with an uninitialized LongPressGestureDetector handle is not allowed.
75 LongPressGestureDetector();
78 * @brief Creates an initialized LongPressGestureDetector.
80 * By default, this would create a gesture detector that requires only one touch.
82 * @return A handle to a newly allocated Dali resource
84 static LongPressGestureDetector New();
87 * @brief Creates an initialized LongPressGestureDetector with the number of touches required.
89 * A long press gesture will be emitted from this detector if the number of fingers touching the
90 * screen is equal to the touches required.
92 * @param[in] touchesRequired The number of touches required
93 * @return A handle to a newly allocated Dali resource
95 static LongPressGestureDetector New(unsigned int touchesRequired);
98 * @brief Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
100 * A long press gesture will be emitted from this detector if the number of fingers touching the screen
101 * falls between the minimum and maximum touches set.
103 * @param[in] minTouches The minimum number of touches required
104 * @param[in] maxTouches The maximum number of touches required
105 * @return A handle to a newly allocated Dali resource
107 static LongPressGestureDetector New(unsigned int minTouches, unsigned int maxTouches);
110 * @brief Downcasts a handle to LongPressGestureDetector handle.
112 * If handle points to a LongPressGestureDetector object, the
113 * downcast produces valid handle. If not, the returned handle is left uninitialized.
115 * @param[in] handle Handle to an object
116 * @return Handle to a LongPressGestureDetector object or an uninitialized handle
118 static LongPressGestureDetector DownCast( BaseHandle handle );
123 * This is non-virtual since derived Handle types must not contain data or virtual methods.
126 ~LongPressGestureDetector();
129 * @brief This copy constructor is required for (smart) pointer semantics.
132 * @param[in] handle A reference to the copied handle
134 LongPressGestureDetector(const LongPressGestureDetector& handle);
137 * @brief This assignment operator is required for (smart) pointer semantics.
140 * @param[in] rhs A reference to the copied handle
141 * @return A reference to this
143 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
148 * @brief Sets the number of touches required.
150 * The number of touches corresponds to the number of fingers a user
151 * has on the screen. This sets the minimum and maximum touches to
152 * the input parameter.
155 * @param[in] touches Touches required
156 * @pre The gesture detector has been initialized.
157 * @note The default is '1'.
159 void SetTouchesRequired(unsigned int touches);
162 * @brief Sets the minimum and maximum touches required.
164 * The number of touches corresponds to the number of fingers a user
168 * @param[in] minTouches Minimum Touches required
169 * @param[in] maxTouches Maximum Touches required
170 * @pre The gesture detector has been initialized.
171 * @note The default is '1'.
173 void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
178 * @brief Retrieves the minimum number of touches required.
181 * @return The minimum number of touches required
182 * @pre The gesture detector has been initialized.
184 unsigned int GetMinimumTouchesRequired() const;
187 * @brief Retrieves the maximum number of touches required.
190 * @return The maximum number of touches required
191 * @pre The gesture detector has been initialized.
193 unsigned int GetMaximumTouchesRequired() const;
198 * @brief This signal is emitted when the specified long press is detected on the attached actor.
200 * A callback of the following type may be connected:
202 * void YourCallbackName( Actor actor, const LongPressGesture& gesture );
205 * @return The signal to connect to
206 * @pre The gesture detector has been initialized.
208 DetectedSignalType& DetectedSignal();
210 public: // Not intended for Application developers
214 * @brief This constructor is used by LongPressGestureDetector::New() methods.
217 * @param[in] internal A pointer to a newly allocated Dali resource
219 explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal);
229 #endif // __DALI_LONG_PRESS_GESTURE_DETECTOR_H__