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>
27 namespace Internal DALI_INTERNAL
33 * @addtogroup dali_core_events
38 * @brief A PanGesture is emitted when the user moves one or more fingers in a particular direction.
40 * This gesture can be in one of three states, when the pan gesture is first detected: GestureState::STARTED
41 * when the pan gesture is continuing: GestureState::CONTINUING and finally, when the pan gesture ends:
42 * GestureState::FINISHED.
44 * A pan gesture will end in the following ways:
45 * - User releases the primary finger (the first touch).
46 * - User has more fingers on the screen than the maximum specified.
47 * - User has less fingers on the screen than the minimum specified.
48 * - Cancelled by the system.
50 * A pan gesture will continue to be sent to the actor under than initial pan until it ends.
53 class DALI_CORE_API PanGesture : public Gesture
57 * @brief Creates an uninitialized PanGesture handle.
59 * Calling member functions with an uninitialized Actor handle is not allowed.
65 * @brief Copy constructor.
67 * @param[in] rhs A reference to the copied handle
69 PanGesture(const PanGesture& rhs);
72 * @brief Move constructor.
74 * @param[in] rhs A reference to the moved handle
76 PanGesture(PanGesture&& rhs);
79 * @brief Assignment operator.
81 * @param[in] rhs A reference to the copied handle
82 * @return A reference to this
84 PanGesture& operator=(const PanGesture& rhs);
87 * @brief Move assignment operator.
89 * @param[in] rhs A reference to the moved handle
90 * @return A reference to this
92 PanGesture& operator=(PanGesture&& rhs);
95 * @brief Non virtual destructor.
101 * @brief The velocity at which the user is moving their fingers.
103 * This is represented as a Vector2 and is the pixel movement per millisecond.
104 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
105 * A positive y value shows that the user is panning downwards, a negative y values means upwards.
106 * This value represents the local coordinates of the actor attached to the PanGestureDetector.
108 * @return The velocity of the pan
110 const Vector2& GetVelocity() const;
113 * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or,
114 * if the gesture has just started, then the amount panned since the user touched the screen.
116 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
117 * A positive y value shows that the user is panning downwards, a negative y value means upwards.
118 * This value is in local actor coordinates, the actor being the one attached to the
119 * PanGestureDetector.
121 * @return The displacement of the pan
123 const Vector2& GetDisplacement() const;
126 * @brief This current touch position of the primary touch point in local actor coordinates.
128 * @return The current position of the pan (in local actor coordinates)
130 const Vector2& GetPosition() const;
133 * @brief The velocity at which the user is moving their fingers.
135 * This is represented as a Vector2 and is the pixel movement per millisecond.
136 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
137 * A positive y value shows that the user is panning downwards, a negative y values means upwards.
138 * This value represents the screen coordinates.
140 * @return The velocity of the pan (in screen coordinates)
142 const Vector2& GetScreenVelocity() const;
145 * @brief This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or,
146 * if the gesture has just started, then the amount panned since the user touched the screen.
148 * A positive x value shows that the user is panning to the right, a negative x value means the opposite.
149 * A positive y value shows that the user is panning downwards, a negative y value means upwards.
150 * This value is in screen coordinates.
152 * @return The displacement of the pan (in screen coordinates)
154 const Vector2& GetScreenDisplacement() const;
157 * @brief This current touch position of the primary touch point in screen coordinates.
159 * @return The current position of the pan (in screen coordinates)
161 const Vector2& GetScreenPosition() const;
164 * @brief The total number of fingers touching the screen in a pan gesture.
166 * @return The number of touches in the pan
168 uint32_t GetNumberOfTouches() const;
170 // Convenience Methods
173 * @brief Returns the speed at which the user is moving their fingers.
175 * This is the pixel movement per millisecond.
177 * @return The speed of the pan (in pixels per millisecond)
179 float GetSpeed() const;
182 * @brief This returns the distance the user has panned (dragged) since the last pan gesture or,
183 * if the gesture has just started, then the distance moved since the user touched the screen.
185 * This is always a positive value.
187 * @return The distance, as a float, a user's finger has panned
189 float GetDistance() const;
192 * @brief Returns the speed at which the user is moving their fingers relative to screen coordinates.
194 * This is the pixel movement per millisecond.
196 * @return The speed of the pan (in pixels per millisecond)
198 float GetScreenSpeed() const;
201 * @brief This returns the distance the user has panned (dragged) since the last pan gesture in screen
202 * coordinates or, if the gesture has just started, then the distance in screen coordinates moved
203 * since the user touched the screen.
205 * This is always a positive value.
207 * @return The distance, as a float, a user's finger has panned
209 float GetScreenDistance() const;
211 public: // Not intended for application developers
214 * @brief This constructor is used internally to Create an initialized PanGesture handle.
216 * @param[in] panGesture A pointer to a newly allocated Dali resource
219 explicit DALI_INTERNAL PanGesture(Internal::PanGesture* panGesture);
228 #endif // DALI_PAN_GESTURE_H