1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
25 internal class PanGestureDetector : GestureDetector
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal PanGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PanGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PanGestureDetector obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 protected override void Dispose(DisposeTypes type)
46 if (type == DisposeTypes.Explicit)
49 //Release your own managed resources here.
50 //You should release all of your own disposable objects here.
54 //Release your own unmanaged resources here.
55 //You should not access any managed member here except static instance.
56 //because the execution order of Finalizes is non-deterministic.
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 NDalicPINVOKE.delete_PanGestureDetector(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73 public class DetectedEventArgs : EventArgs
76 private PanGesture _panGesture;
90 public PanGesture PanGesture
103 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
104 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr panGesture);
105 private DaliEventHandler<object, DetectedEventArgs> _panGestureEventHandler;
106 private DetectedCallbackDelegate _panGestureCallbackDelegate;
109 public event DaliEventHandler<object, DetectedEventArgs> Detected
115 // Restricted to only one listener
116 if (_panGestureEventHandler == null)
118 _panGestureEventHandler += value;
120 _panGestureCallbackDelegate = new DetectedCallbackDelegate(OnPanGestureDetected);
121 this.DetectedSignal().Connect(_panGestureCallbackDelegate);
130 if (_panGestureEventHandler != null)
132 this.DetectedSignal().Disconnect(_panGestureCallbackDelegate);
135 _panGestureEventHandler -= value;
140 private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
142 DetectedEventArgs e = new DetectedEventArgs();
144 // Populate all members of "e" (PanGestureEventArgs) with real data
145 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
146 e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
148 if (_panGestureEventHandler != null)
150 //here we send all data to user event handlers
151 _panGestureEventHandler(this, e);
157 public static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
159 PanGestureDetector ret = new PanGestureDetector(cPtr, false);
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public class Property : global::System.IDisposable
167 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
168 protected bool swigCMemOwn;
170 internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
172 swigCMemOwn = cMemoryOwn;
173 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
176 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
178 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
181 //A Flag to check who called Dispose(). (By User or DisposeQueue)
182 private bool isDisposeQueued = false;
183 //A Flat to check if it is already disposed.
184 protected bool disposed = false;
189 if (!isDisposeQueued)
191 isDisposeQueued = true;
192 DisposeQueue.Instance.Add(this);
196 public void Dispose()
198 //Throw excpetion if Dispose() is called in separate thread.
199 if (!Window.IsInstalled())
201 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
206 Dispose(DisposeTypes.Implicit);
210 Dispose(DisposeTypes.Explicit);
211 System.GC.SuppressFinalize(this);
215 protected virtual void Dispose(DisposeTypes type)
222 if (type == DisposeTypes.Explicit)
225 //Release your own managed resources here.
226 //You should release all of your own disposable objects here.
230 //Release your own unmanaged resources here.
231 //You should not access any managed member here except static instance.
232 //because the execution order of Finalizes is non-deterministic.
234 if (swigCPtr.Handle != global::System.IntPtr.Zero)
239 NDalicPINVOKE.delete_PanGestureDetector_Property(swigCPtr);
241 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
247 public Property() : this(NDalicPINVOKE.new_PanGestureDetector_Property(), true)
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 public static readonly int SCREEN_POSITION = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_POSITION_get();
253 public static readonly int SCREEN_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_DISPLACEMENT_get();
254 public static readonly int SCREEN_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_SCREEN_VELOCITY_get();
255 public static readonly int LOCAL_POSITION = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_POSITION_get();
256 public static readonly int LOCAL_DISPLACEMENT = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_DISPLACEMENT_get();
257 public static readonly int LOCAL_VELOCITY = NDalicPINVOKE.PanGestureDetector_Property_LOCAL_VELOCITY_get();
258 public static readonly int PANNING = NDalicPINVOKE.PanGestureDetector_Property_PANNING_get();
262 public static Radian DIRECTION_LEFT
266 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_LEFT_get();
267 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 public static Radian DIRECTION_RIGHT
277 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_RIGHT_get();
278 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 public static Radian DIRECTION_UP
288 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_UP_get();
289 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 public static Radian DIRECTION_DOWN
299 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_DOWN_get();
300 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 public static Radian DIRECTION_HORIZONTAL
310 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_HORIZONTAL_get();
311 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 public static Radian DIRECTION_VERTICAL
321 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DIRECTION_VERTICAL_get();
322 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
323 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328 public static Radian DEFAULT_THRESHOLD
332 global::System.IntPtr cPtr = NDalicPINVOKE.PanGestureDetector_DEFAULT_THRESHOLD_get();
333 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
334 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 public PanGestureDetector() : this(NDalicPINVOKE.PanGestureDetector_New(), true)
341 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 public new static PanGestureDetector DownCast(BaseHandle handle)
346 PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351 public PanGestureDetector(PanGestureDetector handle) : this(NDalicPINVOKE.new_PanGestureDetector__SWIG_1(PanGestureDetector.getCPtr(handle)), true)
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 public PanGestureDetector Assign(PanGestureDetector rhs)
358 PanGestureDetector ret = new PanGestureDetector(NDalicPINVOKE.PanGestureDetector_Assign(swigCPtr, PanGestureDetector.getCPtr(rhs)), false);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 public void SetMinimumTouchesRequired(uint minimum)
365 NDalicPINVOKE.PanGestureDetector_SetMinimumTouchesRequired(swigCPtr, minimum);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 public void SetMaximumTouchesRequired(uint maximum)
371 NDalicPINVOKE.PanGestureDetector_SetMaximumTouchesRequired(swigCPtr, maximum);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 public uint GetMinimumTouchesRequired()
377 uint ret = NDalicPINVOKE.PanGestureDetector_GetMinimumTouchesRequired(swigCPtr);
378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382 public uint GetMaximumTouchesRequired()
384 uint ret = NDalicPINVOKE.PanGestureDetector_GetMaximumTouchesRequired(swigCPtr);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 public void AddAngle(Radian angle, Radian threshold)
391 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_0(swigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 public void AddAngle(Radian angle)
397 NDalicPINVOKE.PanGestureDetector_AddAngle__SWIG_1(swigCPtr, Radian.getCPtr(angle));
398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 public void AddDirection(Radian direction, Radian threshold)
403 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_0(swigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407 public void AddDirection(Radian direction)
409 NDalicPINVOKE.PanGestureDetector_AddDirection__SWIG_1(swigCPtr, Radian.getCPtr(direction));
410 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 public uint GetAngleCount()
415 uint ret = NDalicPINVOKE.PanGestureDetector_GetAngleCount(swigCPtr);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 internal AngleThresholdPair GetAngle(uint index)
422 AngleThresholdPair ret = new AngleThresholdPair(NDalicPINVOKE.PanGestureDetector_GetAngle(swigCPtr, index), true);
423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 public void ClearAngles()
429 NDalicPINVOKE.PanGestureDetector_ClearAngles(swigCPtr);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433 public void RemoveAngle(Radian angle)
435 NDalicPINVOKE.PanGestureDetector_RemoveAngle(swigCPtr, Radian.getCPtr(angle));
436 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 public void RemoveDirection(Radian direction)
441 NDalicPINVOKE.PanGestureDetector_RemoveDirection(swigCPtr, Radian.getCPtr(direction));
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
445 internal PanGestureDetectedSignal DetectedSignal()
447 PanGestureDetectedSignal ret = new PanGestureDetectedSignal(NDalicPINVOKE.PanGestureDetector_DetectedSignal(swigCPtr), false);
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 public static void SetPanGestureProperties(PanGesture pan)
454 NDalicPINVOKE.PanGestureDetector_SetPanGestureProperties(PanGesture.getCPtr(pan));
455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 public Vector2 ScreenPosition
462 Vector2 temp = new Vector2(0.0f, 0.0f);
463 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_POSITION).Get(temp);
467 public Vector2 ScreenDisplacement
471 Vector2 temp = new Vector2(0.0f, 0.0f);
472 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_DISPLACEMENT).Get(temp);
476 public Vector2 ScreenVelocity
480 Vector2 temp = new Vector2(0.0f, 0.0f);
481 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.SCREEN_VELOCITY).Get(temp);
485 public Vector2 LocalPosition
489 Vector2 temp = new Vector2(0.0f, 0.0f);
490 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_POSITION).Get(temp);
494 public Vector2 LocalDisplacement
498 Vector2 temp = new Vector2(0.0f, 0.0f);
499 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_DISPLACEMENT).Get(temp);
503 public Vector2 LocalVelocity
507 Vector2 temp = new Vector2(0.0f, 0.0f);
508 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.LOCAL_VELOCITY).Get(temp);
517 Tizen.NUI.Object.GetProperty(swigCPtr, PanGestureDetector.Property.PANNING).Get(out temp);