Merge "[Nsd] Fix feature name"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / Slider.cs
index dad5552..3bb0e12 100755 (executable)
 * limitations under the License.
 *
 */
-// This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
-//------------------------------------------------------------------------------
-// <auto-generated />
-//
-// This file was automatically generated by SWIG (http://www.swig.org).
-// Version 3.0.9
-//
-// Do not make changes to this file unless you know what you are doing--modify
-// the SWIG interface file instead.
-//------------------------------------------------------------------------------
 
 namespace Tizen.NUI.UIComponents
 {
@@ -30,7 +20,7 @@ namespace Tizen.NUI.UIComponents
     using System;
     using System.Runtime.InteropServices;
     using Tizen.NUI.BaseComponents;
-    
+
     /// <summary>
     /// Slider is a control to enable sliding an indicator between two values.
     /// </summary>
@@ -48,39 +38,55 @@ namespace Tizen.NUI.UIComponents
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        ~Slider()
-        {
-            DisposeQueue.Instance.Add(this);
-        }
-
         /// <summary>
         /// Dispose
         /// </summary>
-        public override void Dispose()
+        protected override void Dispose(DisposeTypes type)
         {
-            if (!Stage.IsInstalled())
+            if (disposed)
             {
-                DisposeQueue.Instance.Add(this);
                 return;
             }
 
-            lock (this)
+            if (type == DisposeTypes.Explicit)
             {
-                if (swigCPtr.Handle != global::System.IntPtr.Zero)
+                //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 (_sliderValueChangedCallbackDelegate != null)
+            {
+                ValueChangedSignal().Disconnect(_sliderValueChangedCallbackDelegate);
+            }
+
+            if (_sliderSlidingFinishedCallbackDelegate != null)
+            {
+                SlidingFinishedSignal().Disconnect(_sliderSlidingFinishedCallbackDelegate);
+            }
+
+            if (_sliderMarkReachedCallbackDelegate != null)
+            {
+                MarkReachedSignal().Disconnect(_sliderMarkReachedCallbackDelegate);
+            }
+
+            if (swigCPtr.Handle != global::System.IntPtr.Zero)
+            {
+                if (swigCMemOwn)
                 {
-                    if (swigCMemOwn)
-                    {
-                        swigCMemOwn = false;
-                        NDalicPINVOKE.delete_Slider(swigCPtr);
-                    }
-                    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+                    swigCMemOwn = false;
+                    NDalicPINVOKE.delete_Slider(swigCPtr);
                 }
-                global::System.GC.SuppressFinalize(this);
-                base.Dispose();
+                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
             }
-        }
-
 
+            base.Dispose(type);
+        }
 
         /// <summary>
         /// Value changed event arguments.
@@ -366,26 +372,69 @@ namespace Tizen.NUI.UIComponents
                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
             }
 
+            //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;
+
             ~Property()
             {
-                Dispose();
+                if (!isDisposeQueued)
+                {
+                    isDisposeQueued = true;
+                    DisposeQueue.Instance.Add(this);
+                }
+            }
+
+            public void Dispose()
+            {
+                //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);
+                }
             }
 
-            public virtual void Dispose()
+            protected virtual void Dispose(DisposeTypes type)
             {
-                lock (this)
+                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 (swigCPtr.Handle != global::System.IntPtr.Zero)
+                    if (swigCMemOwn)
                     {
-                        if (swigCMemOwn)
-                        {
-                            swigCMemOwn = false;
-                            NDalicPINVOKE.delete_Slider_Property(swigCPtr);
-                        }
-                        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+                        swigCMemOwn = false;
+                        NDalicPINVOKE.delete_Slider_Property(swigCPtr);
                     }
-                    global::System.GC.SuppressFinalize(this);
+                    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
                 }
+
+                disposed = true;
             }
 
             internal Property() : this(NDalicPINVOKE.new_Slider_Property(), true)
@@ -440,7 +489,7 @@ namespace Tizen.NUI.UIComponents
         /// <returns>Handle to a Slider or an uninitialized handle</returns>
         public new static Slider DownCast(BaseHandle handle)
         {
-            Slider ret = new Slider(NDalicPINVOKE.Slider_DownCast(BaseHandle.getCPtr(handle)), true);
+            Slider ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as Slider;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -466,12 +515,6 @@ namespace Tizen.NUI.UIComponents
             return ret;
         }
 
-        internal enum PropertyRange
-        {
-            PROPERTY_START_INDEX = PropertyRanges.PROPERTY_REGISTRATION_START_INDEX,
-            PROPERTY_END_INDEX = View.PropertyRange.PROPERTY_START_INDEX + 1000
-        }
-
         /// <summary>
         /// Lower bound property
         /// </summary>
@@ -480,7 +523,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 float temp = 0.0f;
-                GetProperty(Slider.Property.LOWER_BOUND).Get(ref temp);
+                GetProperty(Slider.Property.LOWER_BOUND).Get(out temp);
                 return temp;
             }
             set
@@ -497,7 +540,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 float temp = 0.0f;
-                GetProperty(Slider.Property.UPPER_BOUND).Get(ref temp);
+                GetProperty(Slider.Property.UPPER_BOUND).Get(out temp);
                 return temp;
             }
             set
@@ -514,7 +557,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 float temp = 0.0f;
-                GetProperty(Slider.Property.VALUE).Get(ref temp);
+                GetProperty(Slider.Property.VALUE).Get(out temp);
                 return temp;
             }
             set
@@ -633,7 +676,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 int temp = 0;
-                GetProperty(Slider.Property.VALUE_PRECISION).Get(ref temp);
+                GetProperty(Slider.Property.VALUE_PRECISION).Get(out temp);
                 return temp;
             }
             set
@@ -650,7 +693,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 bool temp = false;
-                GetProperty(Slider.Property.SHOW_POPUP).Get(ref temp);
+                GetProperty(Slider.Property.SHOW_POPUP).Get(out temp);
                 return temp;
             }
             set
@@ -667,7 +710,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 bool temp = false;
-                GetProperty(Slider.Property.SHOW_VALUE).Get(ref temp);
+                GetProperty(Slider.Property.SHOW_VALUE).Get(out temp);
                 return temp;
             }
             set
@@ -701,7 +744,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 bool temp = false;
-                GetProperty(Slider.Property.SNAP_TO_MARKS).Get(ref temp);
+                GetProperty(Slider.Property.SNAP_TO_MARKS).Get(out temp);
                 return temp;
             }
             set
@@ -718,7 +761,7 @@ namespace Tizen.NUI.UIComponents
             get
             {
                 float temp = 0.0f;
-                GetProperty(Slider.Property.MARK_TOLERANCE).Get(ref temp);
+                GetProperty(Slider.Property.MARK_TOLERANCE).Get(out temp);
                 return temp;
             }
             set