2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 using System.Runtime.InteropServices;
23 using Tizen.NUI.BaseComponents;
26 internal class PanGestureDetector : GestureDetector
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal PanGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PanGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PanGestureDetector obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 protected override void Dispose(DisposeTypes type)
47 if (type == DisposeTypes.Explicit)
50 //Release your own managed resources here.
51 //You should release all of your own disposable objects here.
55 //Release your own unmanaged resources here.
56 //You should not access any managed member here except static instance.
57 //because the execution order of Finalizes is non-deterministic.
59 if (swigCPtr.Handle != global::System.IntPtr.Zero)
64 NDalicPINVOKE.delete_PanGestureDetector(swigCPtr);
66 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 /// <since_tizen> 3 </since_tizen>
75 public class DetectedEventArgs : EventArgs
78 private PanGesture _panGesture;
80 /// <since_tizen> 3 </since_tizen>
93 /// <since_tizen> 3 </since_tizen>
94 public PanGesture PanGesture
107 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
108 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr panGesture);
109 private DaliEventHandler<object, DetectedEventArgs> _panGestureEventHandler;
110 private DetectedCallbackDelegate _panGestureCallbackDelegate;
113 public event DaliEventHandler<object, DetectedEventArgs> Detected
119 // Restricted to only one listener
120 if (_panGestureEventHandler == null)
122 _panGestureEventHandler += value;
124 _panGestureCallbackDelegate = new DetectedCallbackDelegate(OnPanGestureDetected);
125 this.DetectedSignal().Connect(_panGestureCallbackDelegate);
134 if (_panGestureEventHandler != null)
136 this.DetectedSignal().Disconnect(_panGestureCallbackDelegate);
139 _panGestureEventHandler -= value;
144 private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
146 DetectedEventArgs e = new DetectedEventArgs();
148 // Populate all members of "e" (PanGestureEventArgs) with real data
149 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
150 e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
152 if (_panGestureEventHandler != null)
154 //here we send all data to user event handlers
155 _panGestureEventHandler(this, e);
161 public static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
163 PanGestureDetector ret = new PanGestureDetector(cPtr, false);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// <since_tizen> 3 </since_tizen>
170 public class Property : global::System.IDisposable
172 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
173 /// <since_tizen> 3 </since_tizen>
174 protected bool swigCMemOwn;
176 internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
178 swigCMemOwn = cMemoryOwn;
179 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
182 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
184 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
187 //A Flag to check who called Dispose(). (By User or DisposeQueue)
188 private bool isDisposeQueued = false;
189 //A Flat to check if it is already disposed.
190 /// <since_tizen> 3 </since_tizen>
191 protected bool disposed = false;
196 if (!isDisposeQueued)
198 isDisposeQueued = true;
199 DisposeQueue.Instance.Add(this);
203 /// <since_tizen> 3 </since_tizen>
204 public void Dispose()
206 //Throw excpetion if Dispose() is called in separate thread.
207 if (!Window.IsInstalled())
209 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
214 Dispose(DisposeTypes.Implicit);
218 Dispose(DisposeTypes.Explicit);
219 System.GC.SuppressFinalize(this);
223 /// <since_tizen> 3 </since_tizen>
224 protected virtual void Dispose(DisposeTypes type)
231 if (type == DisposeTypes.Explicit)
234 //Release your own managed resources here.
235 //You should release all of your own disposable objects here.
239 //Release your own unmanaged resources here.
240 //You should not access any managed member here except static instance.
241 //because the execution order of Finalizes is non-deterministic.
243 if (swigCPtr.Handle != global::System.IntPtr.Zero)
248 NDalicPINVOKE.delete_PanGestureDetector_Property(swigCPtr);
250 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
256 /// <since_tizen> 3 </since_tizen>
257 public Property() : this(NDalicPINVOKE.new_PanGestureDetector_Property(), true)
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// <since_tizen> 3 </since_tizen>
263 public static readonly int SCREEN_POSITION = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_POSITION_get();
264 /// <since_tizen> 3 </since_tizen>
265 public static readonly int SCREEN_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_DISPLACEMENT_get();
266 /// <since_tizen> 3 </since_tizen>
267 public static readonly int SCREEN_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_VELOCITY_get();
268 /// <since_tizen> 3 </since_tizen>
269 public static readonly int LOCAL_POSITION = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_POSITION_get();
270 /// <since_tizen> 3 </since_tizen>
271 public static readonly int LOCAL_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_DISPLACEMENT_get();
272 /// <since_tizen> 3 </since_tizen>
273 public static readonly int LOCAL_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_VELOCITY_get();
274 /// <since_tizen> 3 </since_tizen>
275 public static readonly int PANNING = NDalicPINVOKE.PanGestureDetector_Property_PANNING_get();
279 public static Radian DIRECTION_LEFT
283 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_LEFT_get();
284 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 public static Radian DIRECTION_RIGHT
294 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_RIGHT_get();
295 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 public static Radian DIRECTION_UP
305 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_UP_get();
306 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 public static Radian DIRECTION_DOWN
316 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_DOWN_get();
317 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 public static Radian DIRECTION_HORIZONTAL
327 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_HORIZONTAL_get();
328 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 public static Radian DIRECTION_VERTICAL
338 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_VERTICAL_get();
339 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345 public static Radian DEFAULT_THRESHOLD
349 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DEFAULT_THRESHOLD_get();
350 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 public PanGestureDetector() : this(NDalicPINVOKE.PanGestureDetector_New(), true)
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361 public new static PanGestureDetector DownCast(BaseHandle handle)
363 PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368 public PanGestureDetector(PanGestureDetector handle) : this(NDalicPINVOKE.new_PanGestureDetector__SWIG_1(PanGestureDetector.getCPtr(handle)), true)
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 public PanGestureDetector Assign(PanGestureDetector rhs)
375 PanGestureDetector ret = new PanGestureDetector(NDalicPINVOKE.PanGestureDetector_Assign(swigCPtr, PanGestureDetector.getCPtr(rhs)), false);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 public void SetMinimumTouchesRequired(uint minimum)
382 NDalicPINVOKE.PanGestureDetector_SetMinimumTouchesRequired(swigCPtr, minimum);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 public void SetMaximumTouchesRequired(uint maximum)
388 NDalicPINVOKE.PanGestureDetector_SetMaximumTouchesRequired(swigCPtr, maximum);
389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 public uint GetMinimumTouchesRequired()
394 uint ret = NDalicPINVOKE.PanGestureDetector_GetMinimumTouchesRequired(swigCPtr);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 public uint GetMaximumTouchesRequired()
401 uint ret = NDalicPINVOKE.PanGestureDetector_GetMaximumTouchesRequired(swigCPtr);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 public void AddAngle(Radian angle, Radian threshold)
408 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_0(swigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 public void AddAngle(Radian angle)
414 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_1(swigCPtr, Radian.getCPtr(angle));
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 public void AddDirection(Radian direction, Radian threshold)
420 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_0(swigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 public void AddDirection(Radian direction)
426 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_1(swigCPtr, Radian.getCPtr(direction));
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 public uint GetAngleCount()
432 uint ret = NDalicPINVOKE.PanGestureDetector_GetAngleCount(swigCPtr);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 internal AngleThresholdPair GetAngle(uint index)
439 AngleThresholdPair ret = new AngleThresholdPair(NDalicPINVOKE.PanGestureDetector_GetAngle(swigCPtr, index), true);
440 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 public void ClearAngles()
446 NDalicPINVOKE.PanGestureDetector_ClearAngles(swigCPtr);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 public void RemoveAngle(Radian angle)
452 NDalicPINVOKE.PanGestureDetector_RemoveAngle(swigCPtr, Radian.getCPtr(angle));
453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 public void RemoveDirection(Radian direction)
458 NDalicPINVOKE.PanGestureDetector_RemoveDirection(swigCPtr, Radian.getCPtr(direction));
459 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 internal PanGestureDetectedSignal DetectedSignal()
464 PanGestureDetectedSignal ret = new PanGestureDetectedSignal(NDalicPINVOKE.PanGestureDetector_DetectedSignal(swigCPtr), false);
465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 public static void SetPanGestureProperties(PanGesture pan)
471 NDalicPINVOKE.PanGestureDetector_SetPanGestureProperties(PanGesture.getCPtr(pan));
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 public Vector2 ScreenPosition
479 Vector2 temp = new Vector2(0.0f, 0.0f);
480 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_POSITION).Get(temp);
484 public Vector2 ScreenDisplacement
488 Vector2 temp = new Vector2(0.0f, 0.0f);
489 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_DISPLACEMENT).Get(temp);
493 public Vector2 ScreenVelocity
497 Vector2 temp = new Vector2(0.0f, 0.0f);
498 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_VELOCITY).Get(temp);
502 public Vector2 LocalPosition
506 Vector2 temp = new Vector2(0.0f, 0.0f);
507 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_POSITION).Get(temp);
511 public Vector2 LocalDisplacement
515 Vector2 temp = new Vector2(0.0f, 0.0f);
516 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_DISPLACEMENT).Get(temp);
520 public Vector2 LocalVelocity
524 Vector2 temp = new Vector2(0.0f, 0.0f);
525 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_VELOCITY).Get(temp);
534 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.PANNING).Get(out temp);