[NUI] Fix build warning[CA1064]
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Gesture.cs
index 8e8d957..ef85871 100755 (executable)
-/** Copyright (c) 2017 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.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-*/
+/*
+ * Copyright(c) 2020 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System.ComponentModel;
 
 namespace Tizen.NUI
 {
-
     /// <summary>
-    /// Base structure for different gestures that an application can receive.<br>
-    /// A gesture is an event that is produced from a combination of several touch events
-    /// in a particular order or within a certain time frame (e.g pinch).<br>
+    /// Base structure for different gestures that an application can receive.<br />
+    /// A Gesture is an event that is produced from a combination of several touch events
+    /// in a particular order or within a certain time frame (for example, pinch).<br />
     /// </summary>
-    public class Gesture : global::System.IDisposable
+    /// <since_tizen> 3 </since_tizen>
+    public class Gesture : BaseHandle
     {
-        private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-        protected bool swigCMemOwn;
 
-        internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn)
-        {
-            swigCMemOwn = cMemoryOwn;
-            swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-        }
-
-        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Gesture obj)
+        /// <summary>
+        /// The Copy constructor.
+        /// </summary>
+        /// <param name="rhs">A reference to the copied handle</param>
+        /// <since_tizen> 3 </since_tizen>
+        public Gesture(Gesture rhs) : this(Interop.Gesture.NewGesture(Gesture.getCPtr(rhs)), true)
         {
-            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        //A Flag to check who called Dispose(). (By User or DisposeQueue)
-        private bool isDisposeQueued = false;
-        //A Flat to check if it is already disposed.
-        protected bool disposed = false;
-
-        ~Gesture()
+        internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Gesture.Upcast(cPtr), cMemoryOwn)
         {
-            if(!isDisposeQueued)
-            {
-                isDisposeQueued = true;
-                DisposeQueue.Instance.Add(this);
-            }
         }
 
-        public void Dispose()
+        /// <summary>
+        /// Enumeration for type of gesture.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public enum GestureType
         {
-            //Throw excpetion if Dispose() is called in separate thread.
-            if (!Window.IsInstalled())
-            {
-                throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
-            }
-
-            if (isDisposeQueued)
-            {
-                Dispose(DisposeTypes.Implicit);
-            }
-            else
-            {
-                Dispose(DisposeTypes.Explicit);
-                System.GC.SuppressFinalize(this);
-            }
+            /// <summary>
+            /// When two touch points move away or towards each other.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Pinch = 1 << 0,
+            /// <summary>
+            /// When the user drags their finger(s) in a particular direction.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Pan = 1 << 1,
+            /// <summary>
+            /// When the user taps the screen.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Tap = 1 << 2,
+            /// <summary>
+            ///  When the user continues to touch the same area on the screen for the device configured time.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            LongPress = 1 << 3
         }
 
-        protected virtual void Dispose(DisposeTypes type)
+        /// <summary>
+        /// Enumeration for state of the gesture.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public enum StateType
         {
-            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 (swigCMemOwn)
-                {
-                    swigCMemOwn = false;
-                    NDalicPINVOKE.delete_Gesture(swigCPtr);
-                }
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-            }
-            disposed = true;
+            /// <summary>
+            /// There is no state associated with this gesture.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Clear,
+            /// <summary>
+            /// The touched points on the screen have moved enough to be considered a gesture.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Started,
+            /// <summary>
+            /// The gesture is continuing.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Continuing,
+            /// <summary>
+            /// The user has lifted a finger or touched an additional point on the screen.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Finished,
+            /// <summary>
+            /// The gesture has been cancelled.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Cancelled,
+            /// <summary>
+            ///  A gesture is possible.
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
+            Possible
         }
 
-
         /// <summary>
         /// The gesture type.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public Gesture.GestureType Type
         {
             get
@@ -116,6 +122,7 @@ namespace Tizen.NUI
         /// <summary>
         /// The gesture state.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public Gesture.StateType State
         {
             get
@@ -127,6 +134,7 @@ namespace Tizen.NUI
         /// <summary>
         /// The time the gesture took place.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public uint Time
         {
             get
@@ -135,25 +143,16 @@ namespace Tizen.NUI
             }
         }
 
-        /// <summary>
-        /// Copy constructor.
-        /// </summary>
-        /// <param name="rhs">A reference to the copied handle</param>
-        public Gesture(Gesture rhs) : this(NDalicPINVOKE.new_Gesture(Gesture.getCPtr(rhs)), true)
-        {
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
-
         private Gesture.GestureType type
         {
             set
             {
-                NDalicPINVOKE.Gesture_type_set(swigCPtr, (int)value);
+                Interop.Gesture.TypeSet(swigCPtr, (int)value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
             get
             {
-                Gesture.GestureType ret = (Gesture.GestureType)NDalicPINVOKE.Gesture_type_get(swigCPtr);
+                Gesture.GestureType ret = (Gesture.GestureType)Interop.Gesture.TypeGet(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 return ret;
             }
@@ -163,12 +162,12 @@ namespace Tizen.NUI
         {
             set
             {
-                NDalicPINVOKE.Gesture_state_set(swigCPtr, (int)value);
+                Interop.Gesture.StateSet(swigCPtr, (int)value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
             get
             {
-                Gesture.StateType ret = (Gesture.StateType)NDalicPINVOKE.Gesture_state_get(swigCPtr);
+                Gesture.StateType ret = (Gesture.StateType)Interop.Gesture.StateGet(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 return ret;
             }
@@ -178,41 +177,34 @@ namespace Tizen.NUI
         {
             set
             {
-                NDalicPINVOKE.Gesture_time_set(swigCPtr, value);
+                Interop.Gesture.TimeSet(swigCPtr, value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
             get
             {
-                uint ret = NDalicPINVOKE.Gesture_time_get(swigCPtr);
+                uint ret = Interop.Gesture.TimeGet(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 return ret;
             }
         }
 
-        /// <summary>
-        /// Enumeration for type of gesture
-        /// </summary>
-        public enum GestureType
+        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Gesture obj)
         {
-            Pinch = 1 << 0,
-            Pan = 1 << 1,
-            Tap = 1 << 2,
-            LongPress = 1 << 3
+            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        /// <summary>
-        /// Enumeration for state of the gesture.
-        /// </summary>
-        public enum StateType
+        internal static Gesture GetGestureFromPtr(global::System.IntPtr cPtr)
         {
-            Clear,
-            Started,
-            Continuing,
-            Finished,
-            Cancelled,
-            Possible
+            Gesture ret = new Gesture(cPtr, 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)
+        {
+            Interop.Gesture.DeleteGesture(swigCPtr);
+        }
     }
-
 }