[NUI] Change all CallingConvention to `Cdecl`
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / PanGestureDetector.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;
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// This class emits a signals when a pan gesture occurs.<br />
26     /// </summary>
27     /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class PanGestureDetector : GestureDetector
30     {
31         /// <summary>
32         /// Creates an initialized PanGestureDetector.
33         /// </summary>
34         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35         [EditorBrowsable(EditorBrowsableState.Never)]
36         public PanGestureDetector() : this(Interop.PanGestureDetector.New(), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39
40         }
41
42         /// <summary>
43         /// The copy constructor.
44         /// </summary>
45         /// <param name="handle">A reference to the copied handle</param>
46         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
47         [EditorBrowsable(EditorBrowsableState.Never)]
48         public PanGestureDetector(PanGestureDetector handle) : this(Interop.PanGestureDetector.NewPanGestureDetector(PanGestureDetector.getCPtr(handle)), true)
49         {
50             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51         }
52
53         internal PanGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
54         {
55         }
56
57         private DaliEventHandler<object, DetectedEventArgs> detectedEventHandler;
58         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59         private delegate void DetectedCallbackType(IntPtr actor, IntPtr panGesture);
60         private DetectedCallbackType detectedCallback;
61
62         /// <summary>
63         /// This signal is emitted when the specified pan is detected on the attached view.
64         /// </summary>
65         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public event DaliEventHandler<object, DetectedEventArgs> Detected
68         {
69             add
70             {
71                 if (detectedEventHandler == null)
72                 {
73                     detectedCallback = OnPanGestureDetected;
74                     using PanGestureDetectedSignal signal = new PanGestureDetectedSignal(Interop.PanGestureDetector.DetectedSignal(SwigCPtr), false);
75                     signal?.Connect(detectedCallback);
76                 }
77                 detectedEventHandler += value;
78             }
79             remove
80             {
81                 detectedEventHandler -= value;
82                 if (detectedEventHandler == null)
83                 {
84                     using PanGestureDetectedSignal signal = new PanGestureDetectedSignal(Interop.PanGestureDetector.DetectedSignal(SwigCPtr), false);
85                     if (signal?.Empty() == false)
86                     {
87                         signal?.Disconnect(detectedCallback);
88                         if (signal?.Empty() == true)
89                         {
90                             detectedCallback = null;
91                         }
92                     }
93                 }
94             }
95         }
96
97         /// <summary>
98         /// For a left pan (-PI Radians).
99         /// </summary>
100         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         public static Radian DirectionLeft
103         {
104             get
105             {
106                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionLeftGet();
107                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
109                 return ret;
110             }
111         }
112
113         /// <summary>
114         /// For a right pan (0 Radians).
115         /// </summary>
116         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
117         [EditorBrowsable(EditorBrowsableState.Never)]
118         public static Radian DirectionRight
119         {
120             get
121             {
122                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionRightGet();
123                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
124                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
125                 return ret;
126             }
127         }
128
129         /// <summary>
130         /// For an up pan (-0.5 * PI Radians).
131         /// </summary>
132         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
133         [EditorBrowsable(EditorBrowsableState.Never)]
134         public static Radian DirectionUp
135         {
136             get
137             {
138                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionUpGet();
139                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
140                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
141                 return ret;
142             }
143         }
144
145         /// <summary>
146         /// For a down pan (0.5 * PI Radians).
147         /// </summary>
148         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
149         [EditorBrowsable(EditorBrowsableState.Never)]
150         public static Radian DirectionDown
151         {
152             get
153             {
154                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionDownGet();
155                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
156                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
157                 return ret;
158             }
159         }
160
161         /// <summary>
162         /// For a left and right pan (PI Radians). Useful for AddDirection().
163         /// </summary>
164         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
165         [EditorBrowsable(EditorBrowsableState.Never)]
166         public static Radian DirectionHorizontal
167         {
168             get
169             {
170                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionHorizontalGet();
171                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
172                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
173                 return ret;
174             }
175         }
176
177         /// <summary>
178         /// For an up and down pan (-0.5 * PI Radians). Useful for AddDirection().
179         /// </summary>
180         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
181         [EditorBrowsable(EditorBrowsableState.Never)]
182         public static Radian DirectionVertical
183         {
184             get
185             {
186                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionVerticalGet();
187                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
188                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
189                 return ret;
190             }
191         }
192
193         /// <summary>
194         /// The default threshold is PI * 0.25 radians (or 45 degrees).
195         /// </summary>
196         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
197         [EditorBrowsable(EditorBrowsableState.Never)]
198         public static Radian DefaultThreshold
199         {
200             get
201             {
202                 global::System.IntPtr cPtr = Interop.PanGestureDetector.DefaultThresholdGet();
203                 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
204                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
205                 return ret;
206             }
207         }
208
209         /// <summary>
210         /// Retrieves the screen position.
211         /// </summary>
212         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
213         [EditorBrowsable(EditorBrowsableState.Never)]
214         public Vector2 ScreenPosition
215         {
216             get
217             {
218                 Vector2 temp = new Vector2(0.0f, 0.0f);
219                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
220                 return temp;
221             }
222         }
223
224         /// <summary>
225         /// Retrieves the screen displacement.
226         /// </summary>
227         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
228         [EditorBrowsable(EditorBrowsableState.Never)]
229         public Vector2 ScreenDisplacement
230         {
231             get
232             {
233                 Vector2 temp = new Vector2(0.0f, 0.0f);
234                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenDisplacement);
235                 pValue.Get(temp);
236                 pValue.Dispose();
237                 return temp;
238             }
239         }
240
241         /// <summary>
242         /// Retrieves the screen velocity.
243         /// </summary>
244         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
245         [EditorBrowsable(EditorBrowsableState.Never)]
246         public Vector2 ScreenVelocity
247         {
248             get
249             {
250                 Vector2 temp = new Vector2(0.0f, 0.0f);
251                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenVelocity);
252                 pValue.Get(temp);
253                 pValue.Dispose();
254                 return temp;
255             }
256         }
257
258         /// <summary>
259         /// Retrieves the local position.
260         /// </summary>
261         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
262         [EditorBrowsable(EditorBrowsableState.Never)]
263         public Vector2 LocalPosition
264         {
265             get
266             {
267                 Vector2 temp = new Vector2(0.0f, 0.0f);
268                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalPosition);
269                 pValue.Get(temp);
270                 pValue.Dispose();
271                 return temp;
272             }
273         }
274
275         /// <summary>
276         /// Retrieves the local displacement
277         /// </summary>
278         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
279         [EditorBrowsable(EditorBrowsableState.Never)]
280         public Vector2 LocalDisplacement
281         {
282             get
283             {
284                 Vector2 temp = new Vector2(0.0f, 0.0f);
285                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalDisplacement);
286                 pValue.Get(temp);
287                 pValue.Dispose();
288                 return temp;
289             }
290         }
291
292         /// <summary>
293         /// Retrieves the local velocity.
294         /// </summary>
295         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
296         [EditorBrowsable(EditorBrowsableState.Never)]
297         public Vector2 LocalVelocity
298         {
299             get
300             {
301                 Vector2 temp = new Vector2(0.0f, 0.0f);
302                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalVelocity);
303                 pValue.Get(temp);
304                 pValue.Dispose();
305                 return temp;
306             }
307         }
308
309         /// <summary>
310         /// Retrieves the panning flag.
311         /// </summary>
312         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
313         [EditorBrowsable(EditorBrowsableState.Never)]
314         public bool Panning
315         {
316             get
317             {
318                 bool temp = false;
319                 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.PANNING);
320                 pValue.Get(out temp);
321                 pValue.Dispose();
322                 return temp;
323             }
324         }
325
326         /// <summary>
327         /// This is the minimum number of touches required for the pan gesture to be detected.
328         /// </summary>
329         /// <param name="minimum">Minimum touches required</param>
330         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
331         [EditorBrowsable(EditorBrowsableState.Never)]
332         public void SetMinimumTouchesRequired(uint minimum)
333         {
334             Interop.PanGestureDetector.SetMinimumTouchesRequired(SwigCPtr, minimum);
335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336         }
337
338         /// <summary>
339         /// This is the maximum number of touches required for the pan gesture to be detected.
340         /// </summary>
341         /// <param name="maximum">Maximum touches required</param>
342         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
343         [EditorBrowsable(EditorBrowsableState.Never)]
344         public void SetMaximumTouchesRequired(uint maximum)
345         {
346             Interop.PanGestureDetector.SetMaximumTouchesRequired(SwigCPtr, maximum);
347             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348         }
349
350         /// <summary>
351         /// Set a maximum duration of motion event that is able to live on the pan gesture event queue.
352         /// If duration exceed it, the motion event is discarded.
353         /// </summary>
354         /// <param name="maximumAgeMilliSecond">Maximum age of motion events as milliseconds</param>
355         [EditorBrowsable(EditorBrowsableState.Never)]
356         public void SetMaximumMotionEventAge(uint maximumAgeMilliSecond)
357         {
358             Interop.PanGestureDetector.SetMaximumMotionEventAge(SwigCPtr, maximumAgeMilliSecond);
359             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360         }
361
362         /// <summary>
363         /// Retrieves the minimum number of touches required for the pan gesture to be detected.
364         /// </summary>
365         /// <returns>The minimum touches required</returns>
366         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
367         [EditorBrowsable(EditorBrowsableState.Never)]
368         public uint GetMinimumTouchesRequired()
369         {
370             uint ret = Interop.PanGestureDetector.GetMinimumTouchesRequired(SwigCPtr);
371             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372             return ret;
373         }
374
375         /// <summary>
376         /// Retrieves the maximum number of touches required for the pan gesture to be detected.
377         /// </summary>
378         /// <returns>The maximum touches required</returns>
379         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
380         [EditorBrowsable(EditorBrowsableState.Never)]
381         public uint GetMaximumTouchesRequired()
382         {
383             uint ret = Interop.PanGestureDetector.GetMaximumTouchesRequired(SwigCPtr);
384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385             return ret;
386         }
387
388         /// <summary>
389         /// Retrieves the maximum age for the pan gesture motion as milliseconds.
390         /// </summary>
391         /// <returns>The maximum age of motion events as milliseconds</returns>
392         [EditorBrowsable(EditorBrowsableState.Never)]
393         public uint GetMaximumMotionEventAge()
394         {
395             uint ret = Interop.PanGestureDetector.GetMaximumMotionEventAge(SwigCPtr);
396             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397             return ret;
398         }
399
400         /// <summary>
401         /// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.<br />
402         /// If an angle of 0.0 degrees is specified and the threshold is 45 degrees then the acceptable direction range is from -45 to 45 degrees.<br />
403         /// The angle added using this API is only checked when the gesture first starts, after that, this detector will emit the gesture regardless of what angle the pan is moving.
404         /// The user can add as many angles as they require.
405         /// </summary>
406         /// <param name="angle">The angle that pan should be allowed</param>
407         /// <param name="threshold">The threshold around that angle</param>
408         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
409         [EditorBrowsable(EditorBrowsableState.Never)]
410         public void AddAngle(Radian angle, Radian threshold)
411         {
412             Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
413             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414         }
415
416         /// <summary>
417         /// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance. The default threshold (PI * 0.25) is used.<br />
418         /// The angle added using this API is only checked when the gesture first starts, after that, this detector will emit the gesture regardless of what angle the pan is moving.<br />
419         /// The user can add as many angles as they require.<br />
420         /// </summary>
421         /// <param name="angle">The angle that pan should be allowed</param>
422         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
423         [EditorBrowsable(EditorBrowsableState.Never)]
424         public void AddAngle(Radian angle)
425         {
426             Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle));
427             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428         }
429
430         /// <summary>
431         /// A helper method for adding bi-directional angles where the pan should take place.<br />
432         /// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.<br />
433         /// </summary>
434         /// <param name="direction">The direction of panning required</param>
435         /// <param name="threshold">The threshold</param>
436         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
437         [EditorBrowsable(EditorBrowsableState.Never)]
438         public void AddDirection(Radian direction, Radian threshold)
439         {
440             Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
441             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442         }
443
444         /// <summary>
445         /// A helper method for adding bi-directional angles where the pan should take place.
446         /// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.<br />
447         /// The default threshold (PI * 0.25) is used.
448         /// </summary>
449         /// <param name="direction">The direction of panning required</param>
450         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
451         [EditorBrowsable(EditorBrowsableState.Never)]
452         public void AddDirection(Radian direction)
453         {
454             Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction));
455             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456         }
457
458         /// <summary>
459         /// Returns the count of angles that this pan gesture detector emits a signal.
460         /// </summary>
461         /// <returns>The gesture detector has been initialized.</returns>
462         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
463         [EditorBrowsable(EditorBrowsableState.Never)]
464         public uint GetAngleCount()
465         {
466             uint ret = Interop.PanGestureDetector.GetAngleCount(SwigCPtr);
467             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468             return ret;
469         }
470
471         /// <summary>
472         /// Clears any directional angles that are used by the gesture detector.
473         /// </summary>
474         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
475         [EditorBrowsable(EditorBrowsableState.Never)]
476         public void ClearAngles()
477         {
478             Interop.PanGestureDetector.ClearAngles(SwigCPtr);
479             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480         }
481
482         /// <summary>
483         /// Removes the angle specified from the container. This will only remove the first instance of the angle found from the container.
484         /// </summary>
485         /// <param name="angle">The angle to remove</param>
486         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
487         [EditorBrowsable(EditorBrowsableState.Never)]
488         public void RemoveAngle(Radian angle)
489         {
490             Interop.PanGestureDetector.RemoveAngle(SwigCPtr, Radian.getCPtr(angle));
491             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492         }
493
494         /// <summary>
495         /// Removes the two angles that make up the direction from the container.
496         /// </summary>
497         /// <param name="direction">The direction to remove</param>
498         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
499         [EditorBrowsable(EditorBrowsableState.Never)]
500         public void RemoveDirection(Radian direction)
501         {
502             Interop.PanGestureDetector.RemoveDirection(SwigCPtr, Radian.getCPtr(direction));
503             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
504         }
505
506         /// <summary>
507         /// Allows setting of the pan properties that are returned in constraints.
508         /// </summary>
509         /// <param name="pan">The pan gesture to set</param>
510         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
511         [EditorBrowsable(EditorBrowsableState.Never)]
512         public static void SetPanGestureProperties(PanGesture pan)
513         {
514             Interop.PanGestureDetector.SetPanGestureProperties(PanGesture.getCPtr(pan));
515             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516         }
517
518         internal static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
519         {
520             PanGestureDetector ret = new PanGestureDetector(cPtr, false);
521             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522             return ret;
523         }
524
525         internal new static PanGestureDetector DownCast(BaseHandle handle)
526         {
527             PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         internal AngleThresholdPair GetAngle(uint index)
533         {
534             AngleThresholdPair ret = new AngleThresholdPair(Interop.PanGestureDetector.GetAngle(SwigCPtr, index), true);
535             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536             return ret;
537         }
538
539         internal PanGestureDetector Assign(PanGestureDetector rhs)
540         {
541             PanGestureDetector ret = new PanGestureDetector(Interop.PanGestureDetector.Assign(SwigCPtr, PanGestureDetector.getCPtr(rhs)), false);
542             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543             return ret;
544         }
545
546         /// <summary>
547         /// override it to clean-up your own resources.
548         /// </summary>
549         /// <param name="type"></param>
550         [EditorBrowsable(EditorBrowsableState.Never)]
551         protected override void Dispose(DisposeTypes type)
552         {
553             if (disposed)
554             {
555                 return;
556             }
557
558             if (type == DisposeTypes.Explicit)
559             {
560                 //Called by User
561                 //Release your own managed resources here.
562                 //You should release all of your own disposable objects here.
563             }
564
565             //Release your own unmanaged resources here.
566             //You should not access any managed member here except static instance.
567             //because the execution order of Finalizes is non-deterministic.
568
569             if (HasBody())
570             {
571                 if (detectedCallback != null)
572                 {
573                     using PanGestureDetectedSignal signal = new PanGestureDetectedSignal(Interop.PanGestureDetector.DetectedSignal(GetBaseHandleCPtrHandleRef), false);
574                     signal?.Disconnect(detectedCallback);
575                     detectedCallback = null;
576                 }
577             }
578             base.Dispose(type);
579         }
580
581         /// This will not be public opened.
582         [EditorBrowsable(EditorBrowsableState.Never)]
583         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
584         {
585             Interop.PanGestureDetector.DeletePanGestureDetector(swigCPtr);
586         }
587
588         private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
589         {
590             if (IsNativeHandleInvalid())
591             {
592                 if (this.Disposed)
593                 {
594                     if (detectedEventHandler != null)
595                     {
596                         var process = global::System.Diagnostics.Process.GetCurrentProcess();
597                         var processId = process?.Id ?? -1;
598                         var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
599                         var me = this.GetType().FullName;
600
601                         Tizen.Log.Error("NUI", $"Error! NUI's native dali object is already disposed. " +
602                             $"OR the native dali object handle of NUI becomes null! \n" +
603                             $" process:{processId} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
604
605                         process?.Dispose();
606                     }
607                 }
608                 else
609                 {
610                     if (this.IsDisposeQueued)
611                     {
612                         var process = global::System.Diagnostics.Process.GetCurrentProcess();
613                         var processId = process?.Id ?? -1;
614                         var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
615                         var me = this.GetType().FullName;
616
617                         //in this case, this object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
618                         Tizen.Log.Error("NUI", "in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! just return here! \n" +
619                             $"process:{processId} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
620
621                         process?.Dispose();
622                         return;
623                     }
624                 }
625             }
626
627             if (detectedEventHandler != null)
628             {
629                 DetectedEventArgs e = new DetectedEventArgs();
630
631                 // Populate all members of "e" (PanGestureEventArgs) with real data
632                 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
633                 if (null == e.View)
634                 {
635                     e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
636                 }
637
638                 // If DispatchGestureEvents is false, no gesture events are dispatched.
639                 if (e.View != null && e.View.DispatchGestureEvents == false)
640                 {
641                     return;
642                 }
643
644                 e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
645                 detectedEventHandler(this, e);
646             }
647         }
648
649         /// <summary>
650         /// Event arguments that are passed via the PanGestureEvent signal.
651         /// </summary>
652         /// <since_tizen> 5 </since_tizen>
653         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
654         [EditorBrowsable(EditorBrowsableState.Never)]
655         public class DetectedEventArgs : EventArgs
656         {
657             private View view;
658             private PanGesture panGesture;
659             private bool handled = true;
660
661             /// <summary>
662             /// The attached view.
663             /// </summary>
664             /// <since_tizen> 5 </since_tizen>
665             /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
666             [EditorBrowsable(EditorBrowsableState.Never)]
667             public View View
668             {
669                 get
670                 {
671                     return view;
672                 }
673                 set
674                 {
675                     view = value;
676                 }
677             }
678
679             /// <summary>
680             /// The PanGesture.
681             /// </summary>
682             /// <since_tizen> 5 </since_tizen>
683             /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
684             [EditorBrowsable(EditorBrowsableState.Never)]
685             public PanGesture PanGesture
686             {
687                 get
688                 {
689                     return panGesture;
690                 }
691                 set
692                 {
693                     panGesture = value;
694                 }
695             }
696
697             /// <summary>
698             /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
699             /// </summary>
700             [EditorBrowsable(EditorBrowsableState.Never)]
701             public bool Handled
702             {
703                 get => handled;
704                 set
705                 {
706                     handled = value;
707                     Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
708                     if (NDalicPINVOKE.SWIGPendingException.Pending)
709                         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710                 }
711             }
712         }
713
714         internal class Property
715         {
716             internal static readonly int ScreenPosition = Interop.PanGestureDetector.ScreenPositionGet();
717             internal static readonly int ScreenDisplacement = Interop.PanGestureDetector.ScreenDisplacementGet();
718             internal static readonly int ScreenVelocity = Interop.PanGestureDetector.ScreenVelocityGet();
719             internal static readonly int LocalPosition = Interop.PanGestureDetector.LocalPositionGet();
720             internal static readonly int LocalDisplacement = Interop.PanGestureDetector.LocalDisplacementGet();
721             internal static readonly int LocalVelocity = Interop.PanGestureDetector.LocalVelocityGet();
722             internal static readonly int PANNING = Interop.PanGestureDetector.PanningGet();
723         }
724     }
725 }