2 * Copyright(c) 2019 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.
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
25 /// This class emits a signals when a pan gesture occurs.<br />
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
32 /// Creates an initialized PanGestureDetector.
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)
38 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43 /// The copy constructor.
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)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53 internal PanGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
57 private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
58 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59 private delegate void DetectedCallbackType(IntPtr actor, IntPtr panGesture);
60 private DetectedCallbackType _detectedCallback;
63 /// This signal is emitted when the specified pan is detected on the attached view.
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
71 if (_detectedEventHandler == null)
73 _detectedCallback = OnPanGestureDetected;
74 DetectedSignal().Connect(_detectedCallback);
77 _detectedEventHandler += value;
82 _detectedEventHandler -= value;
84 if (_detectedEventHandler == null && DetectedSignal().Empty() == false)
86 DetectedSignal().Disconnect(_detectedCallback);
92 /// For a left pan (-PI Radians).
94 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 public static Radian DirectionLeft
100 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionLeftGet();
101 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
108 /// For a right pan (0 Radians).
110 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
111 [EditorBrowsable(EditorBrowsableState.Never)]
112 public static Radian DirectionRight
116 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionRightGet();
117 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
124 /// For an up pan (-0.5 * PI Radians).
126 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
127 [EditorBrowsable(EditorBrowsableState.Never)]
128 public static Radian DirectionUp
132 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionUpGet();
133 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
140 /// For a down pan (0.5 * PI Radians).
142 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143 [EditorBrowsable(EditorBrowsableState.Never)]
144 public static Radian DirectionDown
148 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionDownGet();
149 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
156 /// For a left and right pan (PI Radians). Useful for AddDirection().
158 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 public static Radian DirectionHorizontal
164 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionHorizontalGet();
165 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
172 /// For an up and down pan (-0.5 * PI Radians). Useful for AddDirection().
174 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
175 [EditorBrowsable(EditorBrowsableState.Never)]
176 public static Radian DirectionVertical
180 global::System.IntPtr cPtr = Interop.PanGestureDetector.DirectionVerticalGet();
181 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
188 /// The default threshold is PI * 0.25 radians (or 45 degrees).
190 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
191 [EditorBrowsable(EditorBrowsableState.Never)]
192 public static Radian DefaultThreshold
196 global::System.IntPtr cPtr = Interop.PanGestureDetector.DefaultThresholdGet();
197 Radian ret = (cPtr == global::System.IntPtr.Zero) ? null : new Radian(cPtr, false);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
204 /// Retrieves the screen position.
206 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
207 [EditorBrowsable(EditorBrowsableState.Never)]
208 public Vector2 ScreenPosition
212 Vector2 temp = new Vector2(0.0f, 0.0f);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
219 /// Retrieves the screen displacement.
221 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
222 [EditorBrowsable(EditorBrowsableState.Never)]
223 public Vector2 ScreenDisplacement
227 Vector2 temp = new Vector2(0.0f, 0.0f);
228 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenDisplacement);
236 /// Retrieves the screen velocity.
238 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
239 [EditorBrowsable(EditorBrowsableState.Never)]
240 public Vector2 ScreenVelocity
244 Vector2 temp = new Vector2(0.0f, 0.0f);
245 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenVelocity);
253 /// Retrieves the local position.
255 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
256 [EditorBrowsable(EditorBrowsableState.Never)]
257 public Vector2 LocalPosition
261 Vector2 temp = new Vector2(0.0f, 0.0f);
262 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalPosition);
270 /// Retrieves the local displacement
272 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
273 [EditorBrowsable(EditorBrowsableState.Never)]
274 public Vector2 LocalDisplacement
278 Vector2 temp = new Vector2(0.0f, 0.0f);
279 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalDisplacement);
287 /// Retrieves the local velocity.
289 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
290 [EditorBrowsable(EditorBrowsableState.Never)]
291 public Vector2 LocalVelocity
295 Vector2 temp = new Vector2(0.0f, 0.0f);
296 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalVelocity);
304 /// Retrieves the panning flag.
306 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
307 [EditorBrowsable(EditorBrowsableState.Never)]
313 var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.PANNING);
314 pValue.Get(out temp);
321 /// This is the minimum number of touches required for the pan gesture to be detected.
323 /// <param name="minimum">Minimum touches required</param>
324 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
325 [EditorBrowsable(EditorBrowsableState.Never)]
326 public void SetMinimumTouchesRequired(uint minimum)
328 Interop.PanGestureDetector.SetMinimumTouchesRequired(SwigCPtr, minimum);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// This is the maximum number of touches required for the pan gesture to be detected.
335 /// <param name="maximum">Maximum touches required</param>
336 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
337 [EditorBrowsable(EditorBrowsableState.Never)]
338 public void SetMaximumTouchesRequired(uint maximum)
340 Interop.PanGestureDetector.SetMaximumTouchesRequired(SwigCPtr, maximum);
341 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345 /// Retrieves the minimum number of touches required for the pan gesture to be detected.
347 /// <returns>The minimum touches required</returns>
348 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
349 [EditorBrowsable(EditorBrowsableState.Never)]
350 public uint GetMinimumTouchesRequired()
352 uint ret = Interop.PanGestureDetector.GetMinimumTouchesRequired(SwigCPtr);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 /// Retrieves the maximum number of touches required for the pan gesture to be detected.
360 /// <returns>The maximum touches required</returns>
361 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
362 [EditorBrowsable(EditorBrowsableState.Never)]
363 public uint GetMaximumTouchesRequired()
365 uint ret = Interop.PanGestureDetector.GetMaximumTouchesRequired(SwigCPtr);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371 /// The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance.<br />
372 /// 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 />
373 /// 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.
374 /// The user can add as many angles as they require.
376 /// <param name="angle">The angle that pan should be allowed</param>
377 /// <param name="threshold">The threshold around that angle</param>
378 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
379 [EditorBrowsable(EditorBrowsableState.Never)]
380 public void AddAngle(Radian angle, Radian threshold)
382 Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle), Radian.getCPtr(threshold));
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 /// 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 />
388 /// 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 />
389 /// The user can add as many angles as they require.<br />
391 /// <param name="angle">The angle that pan should be allowed</param>
392 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
393 [EditorBrowsable(EditorBrowsableState.Never)]
394 public void AddAngle(Radian angle)
396 Interop.PanGestureDetector.AddAngle(SwigCPtr, Radian.getCPtr(angle));
397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 /// A helper method for adding bi-directional angles where the pan should take place.<br />
402 /// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.<br />
404 /// <param name="direction">The direction of panning required</param>
405 /// <param name="threshold">The threshold</param>
406 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
407 [EditorBrowsable(EditorBrowsableState.Never)]
408 public void AddDirection(Radian direction, Radian threshold)
410 Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction), Radian.getCPtr(threshold));
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 /// A helper method for adding bi-directional angles where the pan should take place.
416 /// In other words, if 0 is requested, then PI will also be added so that we have both left and right scrolling.<br />
417 /// The default threshold (PI * 0.25) is used.
419 /// <param name="direction">The direction of panning required</param>
420 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
421 [EditorBrowsable(EditorBrowsableState.Never)]
422 public void AddDirection(Radian direction)
424 Interop.PanGestureDetector.AddDirection(SwigCPtr, Radian.getCPtr(direction));
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 /// Returns the count of angles that this pan gesture detector emits a signal.
431 /// <returns>The gesture detector has been initialized.</returns>
432 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
433 [EditorBrowsable(EditorBrowsableState.Never)]
434 public uint GetAngleCount()
436 uint ret = Interop.PanGestureDetector.GetAngleCount(SwigCPtr);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442 /// Clears any directional angles that are used by the gesture detector.
444 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
445 [EditorBrowsable(EditorBrowsableState.Never)]
446 public void ClearAngles()
448 Interop.PanGestureDetector.ClearAngles(SwigCPtr);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 /// Removes the angle specified from the container. This will only remove the first instance of the angle found from the container.
455 /// <param name="angle">The angle to remove</param>
456 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
457 [EditorBrowsable(EditorBrowsableState.Never)]
458 public void RemoveAngle(Radian angle)
460 Interop.PanGestureDetector.RemoveAngle(SwigCPtr, Radian.getCPtr(angle));
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465 /// Removes the two angles that make up the direction from the container.
467 /// <param name="direction">The direction to remove</param>
468 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
469 [EditorBrowsable(EditorBrowsableState.Never)]
470 public void RemoveDirection(Radian direction)
472 Interop.PanGestureDetector.RemoveDirection(SwigCPtr, Radian.getCPtr(direction));
473 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
477 /// Allows setting of the pan properties that are returned in constraints.
479 /// <param name="pan">The pan gesture to set</param>
480 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
481 [EditorBrowsable(EditorBrowsableState.Never)]
482 public static void SetPanGestureProperties(PanGesture pan)
484 Interop.PanGestureDetector.SetPanGestureProperties(PanGesture.getCPtr(pan));
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 internal static PanGestureDetector GetPanGestureDetectorFromPtr(global::System.IntPtr cPtr)
490 PanGestureDetector ret = new PanGestureDetector(cPtr, false);
491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PanGestureDetector obj)
497 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
500 internal new static PanGestureDetector DownCast(BaseHandle handle)
502 PanGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PanGestureDetector;
503 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
507 internal AngleThresholdPair GetAngle(uint index)
509 AngleThresholdPair ret = new AngleThresholdPair(Interop.PanGestureDetector.GetAngle(SwigCPtr, index), true);
510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 internal PanGestureDetector Assign(PanGestureDetector rhs)
516 PanGestureDetector ret = new PanGestureDetector(Interop.PanGestureDetector.Assign(SwigCPtr, PanGestureDetector.getCPtr(rhs)), false);
517 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 internal PanGestureDetectedSignal DetectedSignal()
523 PanGestureDetectedSignal ret = new PanGestureDetectedSignal(Interop.PanGestureDetector.DetectedSignal(SwigCPtr), false);
524 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528 /// This will not be public opened.
529 [EditorBrowsable(EditorBrowsableState.Never)]
530 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
532 if (_detectedCallback != null)
534 DetectedSignal().Disconnect(_detectedCallback);
537 Interop.PanGestureDetector.DeletePanGestureDetector(swigCPtr);
540 private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
542 DetectedEventArgs e = new DetectedEventArgs();
544 // Populate all members of "e" (PanGestureEventArgs) with real data
545 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
548 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
551 e.PanGesture = Tizen.NUI.PanGesture.GetPanGestureFromPtr(panGesture);
553 if (_detectedEventHandler != null)
555 _detectedEventHandler(this, e);
560 /// Event arguments that are passed via the PanGestureEvent signal.
562 /// <since_tizen> 5 </since_tizen>
563 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
564 [EditorBrowsable(EditorBrowsableState.Never)]
565 public class DetectedEventArgs : EventArgs
568 private PanGesture _panGesture;
571 /// The attached view.
573 /// <since_tizen> 5 </since_tizen>
574 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
575 [EditorBrowsable(EditorBrowsableState.Never)]
591 /// <since_tizen> 5 </since_tizen>
592 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
593 [EditorBrowsable(EditorBrowsableState.Never)]
594 public PanGesture PanGesture
607 internal class Property
609 internal static readonly int ScreenPosition = Interop.PanGestureDetector.ScreenPositionGet();
610 internal static readonly int ScreenDisplacement = Interop.PanGestureDetector.ScreenDisplacementGet();
611 internal static readonly int ScreenVelocity = Interop.PanGestureDetector.ScreenVelocityGet();
612 internal static readonly int LocalPosition = Interop.PanGestureDetector.LocalPositionGet();
613 internal static readonly int LocalDisplacement = Interop.PanGestureDetector.LocalDisplacementGet();
614 internal static readonly int LocalVelocity = Interop.PanGestureDetector.LocalVelocityGet();
615 internal static readonly int PANNING = Interop.PanGestureDetector.PanningGet();