[NUI] sync with dalihub (#746)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Color.cs
index 0bb24ea..13f59f6 100755 (executable)
@@ -17,6 +17,7 @@
 
 using System;
 using Tizen.NUI.Binding;
+using System.ComponentModel;
 
 namespace Tizen.NUI
 {
@@ -24,7 +25,7 @@ namespace Tizen.NUI
     /// <summary>
     /// The Color class.
     /// </summary>
-    [TypeConverter(typeof(ColorTypeConverter))]
+    [Tizen.NUI.Binding.TypeConverter(typeof(ColorTypeConverter))]
     public class Color : global::System.IDisposable
     {
 
@@ -98,6 +99,8 @@ namespace Tizen.NUI
         //A Flag to check who called Dispose(). (By User or DisposeQueue)
         private bool isDisposeQueued = false;
 
+        private readonly bool hashDummy;
+
         /// <summary>
         /// Default constructor
         /// </summary>
@@ -135,6 +138,7 @@ namespace Tizen.NUI
         {
             swigCMemOwn = cMemoryOwn;
             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+                       hashDummy = false;
         }
 
         /// <summary>
@@ -617,6 +621,55 @@ namespace Tizen.NUI
             return ret;
         }
 
+        private static bool EqualsColorValue(float f1, float f2)
+        {
+            float EPS = (float)Math.Abs(f1 * .00001);
+            if(Math.Abs(f1 - f2) <= EPS)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        private static bool EqualsColor(Color c1, Color c2)
+        {
+            return EqualsColorValue(c1.R, c2.R) && EqualsColorValue(c1.G, c2.G)
+                && EqualsColorValue(c1.B, c2.B) && EqualsColorValue(c1.A, c2.A);
+        }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj">The object to compare with the current object.</param>
+        /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+        /// 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 override bool Equals(System.Object obj)
+        {
+            Color color = obj as Color;
+            bool equal = false;
+            if (color == null)
+            {
+                return equal;
+            }
+
+            if (EqualsColor(this, color))
+            {
+                equal = true;
+            }
+            return equal;
+        }
+
+        /// 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 override int GetHashCode()
+        {
+            return hashDummy.GetHashCode();
+        }
+
         private float ValueOfIndex(uint index)
         {
             float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);