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.
42 * @see LongPressGestureDetector::SetTouchesRequired.
44 * For any valid long press, two signals will be emitted:
45 * - First identifying the beginning (state = Started) i.e. when fingers held down for the required time.
46 * - Second identifying the ending (state = Finished) i.e. when fingers are released.
48 * The application programmer can use this gesture detector as follows:
50 * LongPressGestureDetector detector = LongPressGestureDetector::New();
51 * detector.Attach(myActor);
52 * detector.DetectedSignal().Connect(this, &MyApplication::OnLongPress);
55 * @see LongPressGesture
58 * | %Signal Name | Method |
59 * |-------------------|-----------------------|
60 * | longPressDetected | @ref DetectedSignal() |
62 class DALI_IMPORT_API LongPressGestureDetector : public GestureDetector
66 typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type @SINCE_1_0.0
68 public: // Creation & Destruction
71 * @brief Create an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
73 * Calling member functions with an uninitialized LongPressGestureDetector handle is not allowed.
76 LongPressGestureDetector();
79 * @brief Create an initialized LongPressGestureDetector.
81 * By default, this would create a gesture detector that requires only one touch.
83 * @return A handle to a newly allocated Dali resource.
85 static LongPressGestureDetector New();
88 * @brief Create an initialized LongPressGestureDetector with the number of touches required.
90 * A long press gesture will be emitted from this detector if the number of fingers touching the
91 * screen is equal to the touches required.
93 * @param[in] touchesRequired The number of touches required.
94 * @return A handle to a newly allocated Dali resource.
96 static LongPressGestureDetector New(unsigned int touchesRequired);
99 * @brief Create an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
101 * A long press gesture will be emitted from this detector if the number of fingers touching the screen
102 * falls between the minimum and maximum touches set.
104 * @param[in] minTouches The minimum number of touches required.
105 * @param[in] maxTouches The maximum number of touches required.
106 * @return A handle to a newly allocated Dali resource.
108 static LongPressGestureDetector New(unsigned int minTouches, unsigned int maxTouches);
111 * @brief Downcast a handle to LongPressGestureDetector handle.
113 * If handle points to a LongPressGestureDetector object the
114 * downcast produces valid handle. If not the returned handle is left uninitialized.
116 * @param[in] handle Handle to an object
117 * @return Handle to a LongPressGestureDetector object or an uninitialized handle
119 static LongPressGestureDetector DownCast( BaseHandle handle );
124 * This is non-virtual since derived Handle types must not contain data or virtual methods.
127 ~LongPressGestureDetector();
130 * @brief This copy constructor is required for (smart) pointer semantics.
133 * @param [in] handle A reference to the copied handle
135 LongPressGestureDetector(const LongPressGestureDetector& handle);
138 * @brief This assignment operator is required for (smart) pointer semantics.
141 * @param [in] rhs A reference to the copied handle
142 * @return A reference to this
144 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
149 * @brief Set the number of touches required.
151 * The number of touches corresponds to the number of fingers a user
152 * has on the screen. This sets the minimum and maximum touches to
153 * the input parameter.
156 * @param[in] touches Touches required.
157 * @pre The gesture detector has been initialized.
158 * @note The default is '1'.
160 void SetTouchesRequired(unsigned int touches);
163 * @brief Sets the minimum and maximum touches required.
165 * The number of touches corresponds to the number of fingers a user
169 * @param[in] minTouches Minimum Touches required.
170 * @param[in] maxTouches Maximum Touches required.
171 * @pre The gesture detector has been initialized.
172 * @note The default is '1'.
174 void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
179 * @brief Retrieves the minimum number of touches required.
182 * @return The minimum number of touches required.
183 * @pre The gesture detector has been initialized.
185 unsigned int GetMinimumTouchesRequired() const;
188 * @brief Retrieves the maximum number of touches required.
191 * @return The maximum number of touches required.
192 * @pre The gesture detector has been initialized.
194 unsigned int GetMaximumTouchesRequired() const;
199 * @brief This signal is emitted when the specified long press is detected on the attached actor.
201 * A callback of the following type may be connected:
203 * void YourCallbackName( Actor actor, const LongPressGesture& gesture );
206 * @return The signal to connect to.
207 * @pre The gesture detector has been initialized.
209 DetectedSignalType& DetectedSignal();
211 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);
228 #endif // __DALI_LONG_PRESS_GESTURE_DETECTOR_H__