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.
41 * @see LongPressGestureDetector::SetTouchesRequired.
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 * | long-press-detected | @ref DetectedSignal() |
61 class DALI_IMPORT_API LongPressGestureDetector : public GestureDetector
65 typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type
67 public: // Creation & Destruction
70 * @brief Create an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
72 * Calling member functions with an uninitialized Dali::Object is not allowed.
74 LongPressGestureDetector();
77 * @brief Create an initialized LongPressGestureDetector.
79 * By default, this would create a gesture detector that requires only one touch.
80 * @return A handle to a newly allocated Dali resource.
82 static LongPressGestureDetector New();
85 * @brief Create an initialized LongPressGestureDetector with the number of touches required.
87 * A long press gesture will be emitted from this detector if the number of fingers touching the
88 * screen is equal to the touches required.
89 * @param[in] touchesRequired The number of touches required.
90 * @return A handle to a newly allocated Dali resource.
92 static LongPressGestureDetector New(unsigned int touchesRequired);
95 * @brief Create an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
97 * A long press gesture will be emitted from this detector if the number of fingers touching the screen
98 * falls between the minimum and maximum touches set.
99 * @param[in] minTouches The minimum number of touches required.
100 * @param[in] maxTouches The maximum number of touches required.
101 * @return A handle to a newly allocated Dali resource.
103 static LongPressGestureDetector New(unsigned int minTouches, unsigned int maxTouches);
106 * @brief Downcast an Object handle to LongPressGestureDetector handle.
108 * If handle points to a LongPressGestureDetector object the
109 * downcast produces valid handle. If not the returned handle is left uninitialized.
110 * @param[in] handle to An object
111 * @return handle to a LongPressGestureDetector object or an uninitialized handle
113 static LongPressGestureDetector DownCast( BaseHandle handle );
118 * This is non-virtual since derived Handle types must not contain data or virtual methods.
120 ~LongPressGestureDetector();
123 * @brief This copy constructor is required for (smart) pointer semantics.
125 * @param [in] handle A reference to the copied handle
127 LongPressGestureDetector(const LongPressGestureDetector& handle);
130 * @brief This assignment operator is required for (smart) pointer semantics.
132 * @param [in] rhs A reference to the copied handle
133 * @return A reference to this
135 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
140 * @brief Set the number of touches required.
142 * The number of touches corresponds to the number of fingers a user
143 * has on the screen. This sets the minimum and maximum touches to
144 * the input parameter.
146 * @param[in] touches Touches required.
147 * @pre The gesture detector has been initialized.
148 * @note The default is '1'.
150 void SetTouchesRequired(unsigned int touches);
153 * @brief Sets the minimum and maximum touches required.
155 * The number of touches corresponds to the number of fingers a user
158 * @param[in] minTouches Minimum Touches required.
159 * @param[in] maxTouches Maximum Touches required.
160 * @pre The gesture detector has been initialized.
161 * @note The default is '1'.
163 void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
168 * @brief Retrieves the minimum number of touches required.
170 * @return The minimum number of touches required.
171 * @pre The gesture detector has been initialized.
173 unsigned int GetMinimumTouchesRequired() const;
176 * @brief Retrieves the maximum number of touches required.
178 * @return The maximum number of touches required.
179 * @pre The gesture detector has been initialized.
181 unsigned int GetMaximumTouchesRequired() const;
186 * @brief This signal is emitted when the specified long press is detected on the attached actor.
188 * A callback of the following type may be connected:
190 * void YourCallbackName( Actor actor, const LongPressGesture& gesture );
192 * @pre The gesture detector has been initialized.
193 * @return The signal to connect to.
195 DetectedSignalType& DetectedSignal();
197 public: // Not intended for Application developers
200 * @brief This constructor is used by Dali New() methods.
202 * @param [in] internal A pointer to a newly allocated Dali resource.
204 explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal);
213 #endif // __DALI_LONG_PRESS_GESTURE_DETECTOR_H__