/*
- * Copyright(c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
[EditorBrowsable(EditorBrowsableState.Never)]
public class PinchGestureDetector : GestureDetector
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ /// <summary>
+ /// Creates an initialized PinchGestureDetector.
+ /// </summary>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetectorNew(), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ }
- internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
+ /// <summary>
+ /// The copy constructor.
+ /// </summary>
+ /// <param name="handle">A reference to the copied handle</param>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.NewPinchGestureDetector(PinchGestureDetector.getCPtr(handle)), true)
{
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
+ internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetectorUpcast(cPtr), cMemoryOwn)
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
+ private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void DetectedCallbackType(IntPtr actor, IntPtr pinchGesture);
+ private DetectedCallbackType _detectedCallback;
+ private PinchGestureDetectedSignal detectedSignal;
+
/// <summary>
- /// Dispose.
+ /// This signal is emitted when the specified pinch is detected on the attached view.
/// </summary>
- /// <param name="type">The dispose type</param>
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
+ public event DaliEventHandler<object, DetectedEventArgs> Detected
{
- if (disposed)
+ add
{
- return;
+ if (_detectedEventHandler == null)
+ {
+ _detectedCallback = OnPinchGestureDetected;
+ detectedSignal = DetectedSignal();
+ detectedSignal.Connect(_detectedCallback);
+ }
+
+ _detectedEventHandler += value;
}
- if (type == DisposeTypes.Explicit)
+ remove
{
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
+ _detectedEventHandler -= value;
+ if (_detectedEventHandler == null && detectedSignal?.Empty() == false)
+ {
+ detectedSignal.Disconnect(_detectedCallback);
+ detectedSignal.Dispose();
+ detectedSignal = null;
+ }
}
+ }
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //Because the execution order of Finalizes is non-deterministic.
+ internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
+ {
+ PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ internal new static PinchGestureDetector DownCast(BaseHandle handle)
+ {
+ PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
+ {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
+ }
+
+ internal PinchGestureDetector Assign(PinchGestureDetector rhs)
+ {
+ PinchGestureDetector ret = new PinchGestureDetector(Interop.PinchGesture.PinchGestureDetectorAssign(SwigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ internal PinchGestureDetectedSignal DetectedSignal()
+ {
+ PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetectorDetectedSignal(SwigCPtr), false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ /// This will not be public opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ if (_detectedCallback != null)
{
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- NDalicPINVOKE.delete_PinchGestureDetector(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ detectedSignal?.Disconnect(_detectedCallback);
+ detectedSignal?.Dispose();
}
- base.Dispose(type);
+ Interop.PinchGesture.DeletePinchGestureDetector(swigCPtr);
+ }
+
+ private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
+ {
+ DetectedEventArgs e = new DetectedEventArgs();
+
+ // Populate all members of "e" (DetectedEventArgs) with real data.
+ e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
+ if (null == e.View)
+ {
+ e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
+ }
+
+ e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
+
+ if (_detectedEventHandler != null)
+ {
+ //Here we send all data to user event handlers.
+ _detectedEventHandler(this, e);
+ }
}
/// <summary>
}
}
}
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
- private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
- private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
-
- /// <summary>
- /// This signal is emitted when the specified pinch is detected on the attached view.
- /// </summary>
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event DaliEventHandler<object, DetectedEventArgs> Detected
- {
- add
- {
- lock (this)
- {
- // Restricted to only one listener
- if (_pinchGestureEventHandler == null)
- {
- _pinchGestureEventHandler += value;
-
- _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
- this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock (this)
- {
- if (_pinchGestureEventHandler != null)
- {
- this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
- }
-
- _pinchGestureEventHandler -= value;
- }
- }
- }
-
- private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
- {
- DetectedEventArgs e = new DetectedEventArgs();
-
- // Populate all members of "e" (DetectedEventArgs) with real data.
- e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
- e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
-
- if (_pinchGestureEventHandler != null)
- {
- //Here we send all data to user event handlers.
- _pinchGestureEventHandler(this, e);
- }
-
- }
-
-
- internal static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
- {
- PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- /// <summary>
- /// Creates an initialized PinchGestureDetector.
- /// </summary>
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public PinchGestureDetector() : this(NDalicPINVOKE.PinchGestureDetector_New(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- }
-
- internal new static PinchGestureDetector DownCast(BaseHandle handle)
- {
- PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- /// <summary>
- /// The copy constructor.
- /// </summary>
- /// <param name="handle">A reference to the copied handle</param>
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public PinchGestureDetector(PinchGestureDetector handle) : this(NDalicPINVOKE.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal PinchGestureDetector Assign(PinchGestureDetector rhs)
- {
- PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal PinchGestureDetectedSignal DetectedSignal()
- {
- PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(NDalicPINVOKE.PinchGestureDetector_DetectedSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
}
-
}