[NUI] Change all CallingConvention to `Cdecl`
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / LongPressGestureDetector.cs
index 4d4bad1..16e536b 100755 (executable)
@@ -82,7 +82,7 @@ namespace Tizen.NUI
         }
 
         private DaliEventHandler<object, DetectedEventArgs> detectedEventHandler;
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void DetectedCallbackType(IntPtr actor, IntPtr longPressGesture);
         private DetectedCallbackType detectedCallback;
 
@@ -195,19 +195,45 @@ namespace Tizen.NUI
             return ret;
         }
 
-        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj)
+        /// <summary>
+        /// override it to clean-up your own resources.
+        /// </summary>
+        /// <param name="type"></param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void Dispose(DisposeTypes type)
         {
-            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.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 (HasBody())
+            {
+                if (detectedCallback != null)
+                {
+                    using LongPressGestureDetectedSignal signal = new LongPressGestureDetectedSignal(Interop.LongPressGestureDetector.DetectedSignal(GetBaseHandleCPtrHandleRef), false);
+                    signal?.Disconnect(detectedCallback);
+                    detectedCallback = null;
+                }
+            }
+            base.Dispose(type);
         }
 
         /// This will not be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            if (detectedEventHandler == null && DetectedSignal().Empty() == false)
-            {
-                DetectedSignal().Disconnect(detectedCallback);
-            }
             Interop.LongPressGestureDetector.DeleteLongPressGestureDetector(swigCPtr);
         }
 
@@ -222,6 +248,12 @@ namespace Tizen.NUI
                 e.View = Registry.GetManagedBaseHandleFromRefObject(actor) as View;
             }
 
+            // If DispatchGestureEvents is false, no gesture events are dispatched.
+            if (e.View != null && e.View.DispatchGestureEvents == false)
+            {
+                return;
+            }
+
             e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
 
             if (detectedEventHandler != null)
@@ -241,6 +273,7 @@ namespace Tizen.NUI
         {
             private View view;
             private LongPressGesture longPressGesture;
+            private bool handled = true;
 
             /// <summary>
             /// View the attached view.
@@ -277,6 +310,22 @@ namespace Tizen.NUI
                     longPressGesture = value;
                 }
             }
+
+            /// <summary>
+            /// Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Handled
+            {
+                get => handled;
+                set
+                {
+                    handled = value;
+                    Interop.Actor.SetNeedGesturePropagation(View.getCPtr(view), !value);
+                    if (NDalicPINVOKE.SWIGPendingException.Pending)
+                        throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
         }
     }
 }