/*
- * 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;
-
- private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
- private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
-
-
/// <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.PinchGestureDetector_New(), true)
+ public PinchGestureDetector() : this(Interop.PinchGesture.PinchGestureDetectorNew(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// <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.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
+ public PinchGestureDetector(PinchGestureDetector handle) : this(Interop.PinchGesture.NewPinchGestureDetector(PinchGestureDetector.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
+ internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PinchGesture.PinchGestureDetectorUpcast(cPtr), cMemoryOwn)
{
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
+ private DaliEventHandler<object, DetectedEventArgs> _detectedEventHandler;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
+ private delegate void DetectedCallbackType(IntPtr actor, IntPtr pinchGesture);
+ private DetectedCallbackType _detectedCallback;
+ private PinchGestureDetectedSignal detectedSignal;
/// <summary>
/// This signal is emitted when the specified pinch is detected on the attached view.
{
add
{
- lock (this)
+ if (_detectedEventHandler == null)
{
- // Restricted to only one listener
- if (_pinchGestureEventHandler == null)
- {
- _pinchGestureEventHandler += value;
-
- _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
- this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
- }
+ _detectedCallback = OnPinchGestureDetected;
+ detectedSignal = DetectedSignal();
+ detectedSignal.Connect(_detectedCallback);
}
+
+ _detectedEventHandler += value;
}
remove
{
- lock (this)
- {
- if (_pinchGestureEventHandler != null)
- {
- this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
- }
+ _detectedEventHandler -= value;
- _pinchGestureEventHandler -= value;
+ if (_detectedEventHandler == null && detectedSignal?.Empty() == false)
+ {
+ detectedSignal.Disconnect(_detectedCallback);
+ detectedSignal.Dispose();
+ detectedSignal = null;
}
}
}
internal new static PinchGestureDetector DownCast(BaseHandle handle)
{
- PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
+ PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
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;
+ 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.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
+ 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.PinchGestureDetector_DetectedSignal(swigCPtr), false);
+ PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetectorDetectedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- /// <summary>
- /// Dispose.
- /// </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.
+ /// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //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.
-
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ if (_detectedCallback != null)
{
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.PinchGesture.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)
// 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 (_pinchGestureEventHandler != null)
+ if (_detectedEventHandler != null)
{
//Here we send all data to user event handlers.
- _pinchGestureEventHandler(this, e);
+ _detectedEventHandler(this, e);
}
-
}
/// <summary>
}
}
}
-
}
-
}