[NUI] Remove duplicate getCPtr from BaseHandle subclasses (#3545)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / PanGesture.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// A PanGesture is emitted when the user moves one or more fingers in a particular direction.<br />
23     /// A pan gesture will end in the following ways:<br />
24     /// - User releases the primary finger (the first touch).<br />
25     /// - User has more fingers on the screen than the maximum specified.<br />
26     /// - User has less fingers on the screen than the minimum specified.<br />
27     /// - Cancelled by the system.<br />
28     /// A pan gesture will continue to be sent to the actor under than initial pan until it ends.<br />
29     /// </summary>
30     /// <since_tizen> 3 </since_tizen>
31     public class PanGesture : Gesture
32     {
33
34         /// <summary>
35         /// The default constructor.
36         /// </summary>
37         /// <since_tizen> 3 </since_tizen>
38         public PanGesture() : this(Interop.PanGestureDetector.PanGestureNew(0), true)
39         {
40             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41         }
42
43         /// <summary>
44         /// The constructor.
45         /// </summary>
46         /// <param name="state">The state of the gesture</param>
47         internal PanGesture(Gesture.StateType state) : this(Interop.PanGestureDetector.PanGestureNew((int)state), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         internal PanGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PanGestureDetector.PanGestureUpcast(cPtr), cMemoryOwn)
53         {
54         }
55
56         /// <summary>
57         /// The velocity at which the user is moving their fingers.<br />
58         /// This is represented as a Vector2 and is the pixel movement per millisecond.<br />
59         /// A positive x value shows that the user is panning to the right, a negative x value means the opposite.<br />
60         /// A positive y value shows that the user is panning downwards, a negative y values means upwards.<br />
61         /// </summary>
62         /// <since_tizen> 3 </since_tizen>
63         public Vector2 Velocity
64         {
65             get
66             {
67                 return velocity;
68             }
69         }
70
71         /// <summary>
72         /// This is a Vector2 showing how much the user has panned (dragged) since the last pan gesture or,
73         /// if the gesture has just started, then the amount panned since the user touched the screen.<br />
74         /// A positive x value shows that the user is panning to the right, a negative x value means the opposite.<br />
75         /// A positive y value shows that the user is panning downwards, a negative y value means upwards.<br />
76         /// </summary>
77         /// <since_tizen> 3 </since_tizen>
78         public Vector2 Displacement
79         {
80             get
81             {
82                 return displacement;
83             }
84         }
85
86         /// <summary>
87         /// The current touch position of the primary touch point in local actor coordinates.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public Vector2 Position
91         {
92             get
93             {
94                 return position;
95             }
96         }
97
98         /// <summary>
99         /// The velocity at which the user is moving their fingers.<br />
100         /// This is represented as a Vector2 and is the pixel movement per millisecond.<br />
101         /// A positive x value shows that the user is panning to the right, a negative x value means the opposite.<br />
102         /// A positive y value shows that the user is panning downwards, a negative y values means upwards.<br />
103         /// This value represents the screen coordinates.<br />
104         /// </summary>
105         /// <since_tizen> 3 </since_tizen>
106         public Vector2 ScreenVelocity
107         {
108             get
109             {
110                 return screenVelocity;
111             }
112         }
113
114         /// <summary>
115         /// 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.<br />
117         /// A positive x value shows that the user is panning to the right, a negative x value means the opposite.<br />
118         /// A positive y value shows that the user is panning downwards, a negative y value means upwards.<br />
119         /// This value is in screen coordinates.<br />
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         public Vector2 ScreenDisplacement
123         {
124             get
125             {
126                 return screenDisplacement;
127             }
128         }
129
130         /// <summary>
131         /// The current touch position of the primary touch point in screen coordinates.
132         /// </summary>
133         /// <since_tizen> 3 </since_tizen>
134         public Vector2 ScreenPosition
135         {
136             get
137             {
138                 return screenPosition;
139             }
140         }
141
142         /// <summary>
143         /// The total number of fingers touching the screen in a pan gesture.
144         /// </summary>
145         /// <since_tizen> 3 </since_tizen>
146         public uint NumberOfTouches
147         {
148             get
149             {
150                 return numberOfTouches;
151             }
152         }
153
154
155         private Vector2 velocity
156         {
157             set
158             {
159                 Interop.PanGestureDetector.PanGestureVelocitySet(SwigCPtr, Vector2.getCPtr(value));
160                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161             }
162             get
163             {
164                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGestureVelocityGet(SwigCPtr);
165                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
166                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167                 return ret;
168             }
169         }
170
171         private Vector2 displacement
172         {
173             set
174             {
175                 Interop.PanGestureDetector.PanGestureDisplacementSet(SwigCPtr, Vector2.getCPtr(value));
176                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177             }
178             get
179             {
180                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGestureDisplacementGet(SwigCPtr);
181                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
182                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183                 return ret;
184             }
185         }
186
187         private Vector2 position
188         {
189             set
190             {
191                 Interop.PanGestureDetector.PanGesturePositionSet(SwigCPtr, Vector2.getCPtr(value));
192                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193             }
194             get
195             {
196                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGesturePositionGet(SwigCPtr);
197                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
198                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199                 return ret;
200             }
201         }
202
203         private Vector2 screenVelocity
204         {
205             set
206             {
207                 Interop.PanGestureDetector.PanGestureScreenVelocitySet(SwigCPtr, Vector2.getCPtr(value));
208                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209             }
210             get
211             {
212                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGestureScreenVelocityGet(SwigCPtr);
213                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
214                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215                 return ret;
216             }
217         }
218
219         private Vector2 screenDisplacement
220         {
221             set
222             {
223                 Interop.PanGestureDetector.PanGestureScreenDisplacementSet(SwigCPtr, Vector2.getCPtr(value));
224                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             }
226             get
227             {
228                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGestureScreenDisplacementGet(SwigCPtr);
229                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
230                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231                 return ret;
232             }
233         }
234
235         private Vector2 screenPosition
236         {
237             set
238             {
239                 Interop.PanGestureDetector.PanGestureScreenPositionSet(SwigCPtr, Vector2.getCPtr(value));
240                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             }
242             get
243             {
244                 global::System.IntPtr cPtr = Interop.PanGestureDetector.PanGestureScreenPositionGet(SwigCPtr);
245                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
246                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247                 return ret;
248             }
249         }
250
251         private uint numberOfTouches
252         {
253             set
254             {
255                 Interop.PanGestureDetector.PanGestureNumberOfTouchesSet(SwigCPtr, value);
256                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257             }
258             get
259             {
260                 uint ret = Interop.PanGestureDetector.PanGestureNumberOfTouchesGet(SwigCPtr);
261                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262                 return ret;
263             }
264         }
265
266
267         /// <summary>
268         /// Returns the speed at which the user is moving their fingers.<br />
269         /// This is the pixel movement per millisecond.<br />
270         /// </summary>
271         /// <returns>The speed of the pan (in pixels per millisecond).</returns>
272         /// <since_tizen> 3 </since_tizen>
273         public float GetSpeed()
274         {
275             float ret = Interop.PanGestureDetector.PanGestureGetSpeed(SwigCPtr);
276             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277             return ret;
278         }
279
280         /// <summary>
281         /// Returns the distance the user has panned (dragged) since the last pan gesture or,
282         /// if the gesture has just started, then the distance moved since the user touched the screen.<br />
283         /// This is always a positive value.<br />
284         /// </summary>
285         /// <returns>The distance, as a float, a user's finger has panned.</returns>
286         /// <since_tizen> 3 </since_tizen>
287         public float GetDistance()
288         {
289             float ret = Interop.PanGestureDetector.PanGestureGetDistance(SwigCPtr);
290             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291             return ret;
292         }
293
294         /// <summary>
295         /// Returns the speed at which the user is moving their fingers relative to screen coordinates.<br />
296         /// This is the pixel movement per millisecond.<br />
297         /// </summary>
298         /// <returns>The speed of the pan (in pixels per millisecond).</returns>
299         /// <since_tizen> 3 </since_tizen>
300         public float GetScreenSpeed()
301         {
302             float ret = Interop.PanGestureDetector.PanGestureGetScreenSpeed(SwigCPtr);
303             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             return ret;
305         }
306
307         /// <summary>
308         /// Returns the distance the user has panned (dragged) since the last pan gesture in screen
309         /// coordinates or, if the gesture has just started, then the distance in screen coordinates moved
310         /// since the user touched the screen.<br />
311         /// This is always a positive value.<br />
312         /// </summary>
313         /// <returns>The distance, as a float, a user's finger has panned.</returns>
314         /// <since_tizen> 3 </since_tizen>
315         public float GetScreenDistance()
316         {
317             float ret = Interop.PanGestureDetector.PanGestureGetScreenDistance(SwigCPtr);
318             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319             return ret;
320         }
321
322         internal static PanGesture GetPanGestureFromPtr(global::System.IntPtr cPtr)
323         {
324             PanGesture ret = new PanGesture(cPtr, false);
325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326             return ret;
327         }
328
329         /// This will not be public opened.
330         [EditorBrowsable(EditorBrowsableState.Never)]
331         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
332         {
333             Interop.PanGestureDetector.DeletePanGesture(swigCPtr);
334         }
335     }
336 }