1 #ifndef DALI_PAN_GESTURE_H
2 #define DALI_PAN_GESTURE_H
5 * Copyright (c) 2020 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.h>
23 #include <dali/public-api/math/vector2.h>
28 namespace Internal DALI_INTERNAL
34 * @addtogroup dali_core_events
39 * @brief A PanGesture is emitted when the user moves one or more fingers in a particular direction.
41 * This gesture can be in one of three states, when the pan gesture is first detected: Gesture::Started
42 * when the pan gesture is continuing: Gesture::Continuing and finally, when the pan gesture ends:
45 * A pan gesture will end in the following ways:
46 * - User releases the primary finger (the first touch).
47 * - User has more fingers on the screen than the maximum specified.
48 * - User has less fingers on the screen than the minimum specified.
49 * - Cancelled by the system.
51 * A pan gesture will continue to be sent to the actor under than initial pan until it ends.
54 class DALI_CORE_API PanGesture: public Gesture
59 * @brief Creates an uninitialized PanGesture handle.
61 * Calling member functions with an uninitialized Actor handle is not allowed.
67 * @brief Copy constructor.
69 * @param[in] rhs A reference to the copied handle
71 PanGesture( const PanGesture& rhs );
74 * @brief Move constructor.
76 * @param[in] rhs A reference to the moved handle
78 PanGesture( PanGesture&& rhs );
81 * @brief Assignment operator.
83 * @param[in] rhs A reference to the copied handle
84 * @return A reference to this
86 PanGesture& operator=( const PanGesture& rhs );
89 * @brief Move assignment operator.
91 * @param[in] rhs A reference to the moved handle
92 * @return A reference to this
94 PanGesture& operator=( PanGesture&& rhs );
97 * @brief Non virtual destructor.
103 * @brief The velocity at which the user is moving their fingers.
105 * This is represented as a Vector2 and is the pixel movement per millisecond.
106 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
107 * A positive y value shows that the user is panning downwards, a negative y values means upwards.
108 * This value represents the local coordinates of the actor attached to the PanGestureDetector.
110 * @return The velocity of the pan
112 const Vector2& GetVelocity() const;
115 * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or,
116 * if the gesture has just started, then the amount panned since the user touched the screen.
118 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
119 * A positive y value shows that the user is panning downwards, a negative y value means upwards.
120 * This value is in local actor coordinates, the actor being the one attached to the
121 * PanGestureDetector.
123 * @return The displacement of the pan
125 const Vector2& GetDisplacement() const;
128 * @brief This current touch position of the primary touch point in local actor coordinates.
130 * @return The current position of the pan (in local actor coordinates)
132 const Vector2& GetPosition() const;
135 * @brief The velocity at which the user is moving their fingers.
137 * This is represented as a Vector2 and is the pixel movement per millisecond.
138 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
139 * A positive y value shows that the user is panning downwards, a negative y values means upwards.
140 * This value represents the screen coordinates.
142 * @return The velocity of the pan (in screen coordinates)
144 const Vector2& GetScreenVelocity() const;
147 * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or,
148 * if the gesture has just started, then the amount panned since the user touched the screen.
150 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
151 * A positive y value shows that the user is panning downwards, a negative y value means upwards.
152 * This value is in screen coordinates.
154 * @return The displacement of the pan (in screen coordinates)
156 const Vector2& GetScreenDisplacement() const;
159 * @brief This current touch position of the primary touch point in screen coordinates.
161 * @return The current position of the pan (in screen coordinates)
163 const Vector2& GetScreenPosition() const;
166 * @brief The total number of fingers touching the screen in a pan gesture.
168 * @return The number of touches in the pan
170 uint32_t GetNumberOfTouches() const;
172 // Convenience Methods
175 * @brief Returns the speed at which the user is moving their fingers.
177 * This is the pixel movement per millisecond.
179 * @return The speed of the pan (in pixels per millisecond)
181 float GetSpeed() const;
184 * @brief This returns the distance the user has panned (dragged) since the last pan gesture or,
185 * if the gesture has just started, then the distance moved since the user touched the screen.
187 * This is always a positive value.
189 * @return The distance, as a float, a user's finger has panned
191 float GetDistance() const;
194 * @brief Returns the speed at which the user is moving their fingers relative to screen coordinates.
196 * This is the pixel movement per millisecond.
198 * @return The speed of the pan (in pixels per millisecond)
200 float GetScreenSpeed() const;
203 * @brief This returns the distance the user has panned (dragged) since the last pan gesture in screen
204 * coordinates or, if the gesture has just started, then the distance in screen coordinates moved
205 * since the user touched the screen.
207 * This is always a positive value.
209 * @return The distance, as a float, a user's finger has panned
211 float GetScreenDistance() const;
213 public: // Not intended for application developers
217 * @brief This constructor is used internally to Create an initialized PanGesture handle.
219 * @param[in] panGesture A pointer to a newly allocated Dali resource
222 explicit DALI_INTERNAL PanGesture( Internal::PanGesture* panGesture );
232 #endif // DALI_PAN_GESTURE_H