1 #ifndef __DALI_LONG_PRESS_GESTURE_DETECTOR_H__
2 #define __DALI_LONG_PRESS_GESTURE_DETECTOR_H__
5 * Copyright (c) 2018 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 <cstdint> // uint32_t
25 #include <dali/public-api/events/gesture-detector.h>
26 #include <dali/public-api/signals/dali-signal.h>
31 * @addtogroup dali_core_events
35 namespace Internal DALI_INTERNAL
37 class LongPressGestureDetector;
40 struct LongPressGesture;
43 * @brief This class emits a signals when a long press gesture occurs that meets the requirements set by the application.
46 * For any valid long press, two signals will be emitted:
47 * - First identifying the beginning (state = Started) i.e. when fingers held down for the required time.
48 * - Second identifying the ending (state = Finished) i.e. when fingers are released.
50 * The application programmer can use this gesture detector as follows:
52 * LongPressGestureDetector detector = LongPressGestureDetector::New();
53 * detector.Attach(myActor);
54 * detector.DetectedSignal().Connect(this, &MyApplication::OnLongPress);
57 * @see LongPressGesture
60 * | %Signal Name | Method |
61 * |-------------------|-----------------------|
62 * | longPressDetected | @ref DetectedSignal() |
64 class DALI_CORE_API LongPressGestureDetector : public GestureDetector
68 typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type @SINCE_1_0.0
70 public: // Creation & Destruction
73 * @brief Creates an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
75 * Calling member functions with an uninitialized LongPressGestureDetector handle is not allowed.
78 LongPressGestureDetector();
81 * @brief Creates an initialized LongPressGestureDetector.
83 * By default, this would create a gesture detector that requires only one touch.
85 * @return A handle to a newly allocated Dali resource
87 static LongPressGestureDetector New();
90 * @brief Creates an initialized LongPressGestureDetector with the number of touches required.
92 * A long press gesture will be emitted from this detector if the number of fingers touching the
93 * screen is equal to the touches required.
95 * @param[in] touchesRequired The number of touches required
96 * @return A handle to a newly allocated Dali resource
98 static LongPressGestureDetector New(uint32_t touchesRequired);
101 * @brief Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
103 * A long press gesture will be emitted from this detector if the number of fingers touching the screen
104 * falls between the minimum and maximum touches set.
106 * @param[in] minTouches The minimum number of touches required
107 * @param[in] maxTouches The maximum number of touches required
108 * @return A handle to a newly allocated Dali resource
110 static LongPressGestureDetector New(uint32_t minTouches, uint32_t maxTouches);
113 * @brief Downcasts a handle to LongPressGestureDetector handle.
115 * If handle points to a LongPressGestureDetector object, the
116 * downcast produces valid handle. If not, the returned handle is left uninitialized.
118 * @param[in] handle Handle to an object
119 * @return Handle to a LongPressGestureDetector object or an uninitialized handle
121 static LongPressGestureDetector DownCast( BaseHandle handle );
126 * This is non-virtual since derived Handle types must not contain data or virtual methods.
129 ~LongPressGestureDetector();
132 * @brief This copy constructor is required for (smart) pointer semantics.
135 * @param[in] handle A reference to the copied handle
137 LongPressGestureDetector(const LongPressGestureDetector& handle);
140 * @brief This assignment operator is required for (smart) pointer semantics.
143 * @param[in] rhs A reference to the copied handle
144 * @return A reference to this
146 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
151 * @brief Sets the number of touches required.
153 * The number of touches corresponds to the number of fingers a user
154 * has on the screen. This sets the minimum and maximum touches to
155 * the input parameter.
158 * @param[in] touches Touches required
159 * @pre The gesture detector has been initialized.
160 * @note The default is '1'.
162 void SetTouchesRequired(uint32_t touches);
165 * @brief Sets the minimum and maximum touches required.
167 * The number of touches corresponds to the number of fingers a user
171 * @param[in] minTouches Minimum Touches required
172 * @param[in] maxTouches Maximum Touches required
173 * @pre The gesture detector has been initialized.
174 * @note The default is '1'.
176 void SetTouchesRequired(uint32_t minTouches, uint32_t maxTouches);
181 * @brief Retrieves the minimum number of touches required.
184 * @return The minimum number of touches required
185 * @pre The gesture detector has been initialized.
187 uint32_t GetMinimumTouchesRequired() const;
190 * @brief Retrieves the maximum number of touches required.
193 * @return The maximum number of touches required
194 * @pre The gesture detector has been initialized.
196 uint32_t GetMaximumTouchesRequired() const;
201 * @brief This signal is emitted when the specified long press is detected on the attached actor.
203 * A callback of the following type may be connected:
205 * void YourCallbackName( Actor actor, const LongPressGesture& gesture );
208 * @return The signal to connect to
209 * @pre The gesture detector has been initialized.
211 DetectedSignalType& DetectedSignal();
213 public: // Not intended for Application developers
217 * @brief This constructor is used by LongPressGestureDetector::New() methods.
220 * @param[in] internal A pointer to a newly allocated Dali resource
222 explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal);
232 #endif // __DALI_LONG_PRESS_GESTURE_DETECTOR_H__