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 public class DetectedEventArgs : EventArgs
77 private PanGesture _panGesture;
91 public PanGesture PanGesture
104 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
105 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr panGesture);
106 private DaliEventHandler<object, DetectedEventArgs> _panGestureEventHandler;
107 private DetectedCallbackDelegate _panGestureCallbackDelegate;
110 public event DaliEventHandler<object, DetectedEventArgs> Detected
116 // Restricted to only one listener
117 if (_panGestureEventHandler == null)
119 _panGestureEventHandler += value;
121 _panGestureCallbackDelegate = new DetectedCallbackDelegate(OnPanGestureDetected);
122 this.DetectedSignal().Connect(_panGestureCallbackDelegate);
131 if (_panGestureEventHandler != null)
133 this.DetectedSignal().Disconnect(_panGestureCallbackDelegate);
136 _panGestureEventHandler -= value;
141 private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
143 DetectedEventArgs e = new DetectedEventArgs();
145 // Populate all members of "e" (PanGestureEventArgs) with real data
146 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
147 e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
149 if (_panGestureEventHandler != null)
151 //here we send all data to user event handlers
152 _panGestureEventHandler(this, e);
158 public static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
160 PanGestureDetector ret = new PanGestureDetector(cPtr, false);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 public class Property : global::System.IDisposable
168 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
169 protected bool swigCMemOwn;
171 internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
173 swigCMemOwn = cMemoryOwn;
174 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
177 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
179 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
182 //A Flag to check who called Dispose(). (By User or DisposeQueue)
183 private bool isDisposeQueued = false;
184 //A Flat to check if it is already disposed.
185 protected bool disposed = false;
190 if (!isDisposeQueued)
192 isDisposeQueued = true;
193 DisposeQueue.Instance.Add(this);
197 public void Dispose()
199 //Throw excpetion if Dispose() is called in separate thread.
200 if (!Window.IsInstalled())
202 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
207 Dispose(DisposeTypes.Implicit);
211 Dispose(DisposeTypes.Explicit);
212 System.GC.SuppressFinalize(this);
216 protected virtual void Dispose(DisposeTypes type)
223 if (type == DisposeTypes.Explicit)
226 //Release your own managed resources here.
227 //You should release all of your own disposable objects here.
231 //Release your own unmanaged resources here.
232 //You should not access any managed member here except static instance.
233 //because the execution order of Finalizes is non-deterministic.
235 if (swigCPtr.Handle != global::System.IntPtr.Zero)
240 NDalicPINVOKE.delete_PanGestureDetector_Property(swigCPtr);
242 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
248 public Property() : this(NDalicPINVOKE.new_PanGestureDetector_Property(), true)
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 public static readonly int SCREEN_POSITION = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_POSITION_get();
254 public static readonly int SCREEN_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_DISPLACEMENT_get();
255 public static readonly int SCREEN_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_VELOCITY_get();
256 public static readonly int LOCAL_POSITION = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_POSITION_get();
257 public static readonly int LOCAL_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_DISPLACEMENT_get();
258 public static readonly int LOCAL_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_VELOCITY_get();
259 public static readonly int PANNING = NDalicPINVOKE.PanGestureDetector_Property_PANNING_get();
263 public static Radian DIRECTION_LEFT
267 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_LEFT_get();
268 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 public static Radian DIRECTION_RIGHT
278 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_RIGHT_get();
279 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 public static Radian DIRECTION_UP
289 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_UP_get();
290 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 public static Radian DIRECTION_DOWN
300 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_DOWN_get();
301 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
302 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 public static Radian DIRECTION_HORIZONTAL
311 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_HORIZONTAL_get();
312 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 public static Radian DIRECTION_VERTICAL
322 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_VERTICAL_get();
323 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 public static Radian DEFAULT_THRESHOLD
333 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DEFAULT_THRESHOLD_get();
334 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340 public PanGestureDetector() : this(NDalicPINVOKE.PanGestureDetector_New(), true)
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345 public new static PanGestureDetector DownCast(BaseHandle handle)
347 PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
352 public PanGestureDetector(PanGestureDetector handle) : this(NDalicPINVOKE.new_PanGestureDetector__SWIG_1(PanGestureDetector.getCPtr(handle)), true)
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 public PanGestureDetector Assign(PanGestureDetector rhs)
359 PanGestureDetector ret = new PanGestureDetector(NDalicPINVOKE.PanGestureDetector_Assign(swigCPtr, PanGestureDetector.getCPtr(rhs)), false);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 public void SetMinimumTouchesRequired(uint minimum)
366 NDalicPINVOKE.PanGestureDetector_SetMinimumTouchesRequired(swigCPtr, minimum);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 public void SetMaximumTouchesRequired(uint maximum)
372 NDalicPINVOKE.PanGestureDetector_SetMaximumTouchesRequired(swigCPtr, maximum);
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 public uint GetMinimumTouchesRequired()
378 uint ret = NDalicPINVOKE.PanGestureDetector_GetMinimumTouchesRequired(swigCPtr);
379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
383 public uint GetMaximumTouchesRequired()
385 uint ret = NDalicPINVOKE.PanGestureDetector_GetMaximumTouchesRequired(swigCPtr);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 public void AddAngle(Radian angle, Radian threshold)
392 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_0(swigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
396 public void AddAngle(Radian angle)
398 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_1(swigCPtr, Radian.getCPtr(angle));
399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402 public void AddDirection(Radian direction, Radian threshold)
404 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_0(swigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 public void AddDirection(Radian direction)
410 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_1(swigCPtr, Radian.getCPtr(direction));
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414 public uint GetAngleCount()
416 uint ret = NDalicPINVOKE.PanGestureDetector_GetAngleCount(swigCPtr);
417 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421 internal AngleThresholdPair GetAngle(uint index)
423 AngleThresholdPair ret = new AngleThresholdPair(NDalicPINVOKE.PanGestureDetector_GetAngle(swigCPtr, index), true);
424 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428 public void ClearAngles()
430 NDalicPINVOKE.PanGestureDetector_ClearAngles(swigCPtr);
431 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 public void RemoveAngle(Radian angle)
436 NDalicPINVOKE.PanGestureDetector_RemoveAngle(swigCPtr, Radian.getCPtr(angle));
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
440 public void RemoveDirection(Radian direction)
442 NDalicPINVOKE.PanGestureDetector_RemoveDirection(swigCPtr, Radian.getCPtr(direction));
443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 internal PanGestureDetectedSignal DetectedSignal()
448 PanGestureDetectedSignal ret = new PanGestureDetectedSignal(NDalicPINVOKE.PanGestureDetector_DetectedSignal(swigCPtr), false);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 public static void SetPanGestureProperties(PanGesture pan)
455 NDalicPINVOKE.PanGestureDetector_SetPanGestureProperties(PanGesture.getCPtr(pan));
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459 public Vector2 ScreenPosition
463 Vector2 temp = new Vector2(0.0f, 0.0f);
464 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_POSITION).Get(temp);
468 public Vector2 ScreenDisplacement
472 Vector2 temp = new Vector2(0.0f, 0.0f);
473 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_DISPLACEMENT).Get(temp);
477 public Vector2 ScreenVelocity
481 Vector2 temp = new Vector2(0.0f, 0.0f);
482 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_VELOCITY).Get(temp);
486 public Vector2 LocalPosition
490 Vector2 temp = new Vector2(0.0f, 0.0f);
491 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_POSITION).Get(temp);
495 public Vector2 LocalDisplacement
499 Vector2 temp = new Vector2(0.0f, 0.0f);
500 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_DISPLACEMENT).Get(temp);
504 public Vector2 LocalVelocity
508 Vector2 temp = new Vector2(0.0f, 0.0f);
509 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_VELOCITY).Get(temp);
518 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.PANNING).Get(out temp);