[Tizen] Adding Property Notification support 89/149089/1
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 4 Sep 2017 14:21:34 +0000 (15:21 +0100)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 11 Sep 2017 07:46:18 +0000 (16:46 +0900)
Moving Property files from internal to public
Creating helper class to be used when animatables provide properties as strings not indexes.
Animatables can now connect to Notify and use the defined conditional functions

Change-Id: Iac5d5e7b6ced6df9d2b651d36559f223e5a06fdc

Tizen.NUI/src/internal/NDalic.cs
Tizen.NUI/src/internal/PropertyHelper.cs [new file with mode: 0755]
Tizen.NUI/src/public/Animatable.cs
Tizen.NUI/src/public/Animation.cs
Tizen.NUI/src/public/PropertyCondition.cs [moved from Tizen.NUI/src/internal/PropertyCondition.cs with 53% similarity]
Tizen.NUI/src/public/PropertyNotification.cs [moved from Tizen.NUI/src/internal/PropertyNotification.cs with 97% similarity]
Tizen.NUI/src/public/PropertyNotifySignal.cs [moved from Tizen.NUI/src/internal/PropertyNotifySignal.cs with 97% similarity]

index b9b3ce3..13697ac 100755 (executable)
@@ -187,48 +187,6 @@ namespace Tizen.NUI
             return ret;
         }
 
-        public static PropertyCondition LessThanCondition(float arg)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.LessThanCondition(arg), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        public static PropertyCondition GreaterThanCondition(float arg)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.GreaterThanCondition(arg), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        public static PropertyCondition InsideCondition(float arg0, float arg1)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.InsideCondition(arg0, arg1), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        public static PropertyCondition OutsideCondition(float arg0, float arg1)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.OutsideCondition(arg0, arg1), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        public static PropertyCondition StepCondition(float stepAmount, float initialValue)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_0(stepAmount, initialValue), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        public static PropertyCondition StepCondition(float stepAmount)
-        {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_1(stepAmount), true);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
         public static int WEIGHT
         {
             get
diff --git a/Tizen.NUI/src/internal/PropertyHelper.cs b/Tizen.NUI/src/internal/PropertyHelper.cs
new file mode 100755 (executable)
index 0000000..e2b6311
--- /dev/null
@@ -0,0 +1,40 @@
+/** 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.
+*
+*/
+
+namespace Tizen.NUI
+{
+    internal static class PropertyHelper
+    {
+        ///<summary>
+        /// Returns a Property if stringProperty is a valid index
+        ///</summary>
+        internal static Property GetPropertyFromString(Animatable handle, string stringProperty)
+        {
+            /// Convert property string to be lowercase
+            string str1 = stringProperty.Substring(0, 1);
+            string str2 = stringProperty.Substring(1);
+            string str = str1.ToLower() + str2;
+
+            Property property = new Property(handle, str);
+            if (property.propertyIndex == Property.INVALID_INDEX)
+            {
+                throw new System.ArgumentException("string property is invalid");
+            }
+
+            return property;
+        }
+    }
+}
index 578477f..b5c056e 100755 (executable)
@@ -137,9 +137,9 @@ namespace Tizen.NUI
             return ret;
         }
 
-        internal PropertyNotification AddPropertyNotification(int index, PropertyCondition condition)
+        public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
         {
-            PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_0(swigCPtr, index, PropertyCondition.getCPtr(condition)), true);
+            PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_0(swigCPtr, PropertyHelper.GetPropertyFromString(this, property).propertyIndex, PropertyCondition.getCPtr(condition)), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -151,13 +151,13 @@ namespace Tizen.NUI
             return ret;
         }
 
-        internal void RemovePropertyNotification(PropertyNotification propertyNotification)
+        public void RemovePropertyNotification(PropertyNotification propertyNotification)
         {
             NDalicPINVOKE.Handle_RemovePropertyNotification(swigCPtr, PropertyNotification.getCPtr(propertyNotification));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal void RemovePropertyNotifications()
+        public void RemovePropertyNotifications()
         {
             NDalicPINVOKE.Handle_RemovePropertyNotifications(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
index 558a861..5c2b257 100755 (executable)
@@ -445,15 +445,7 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
-
-            Property _prop = new Property(target, _str);
-            if (_prop.propertyIndex == Property.INVALID_INDEX)
-            {
-                throw new System.ArgumentException("second argument string property is invalid parameter!");
-            }
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
             if(propertyType.Equals(PropertyType.Float))
@@ -489,15 +481,7 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
-
-            Property _prop = new Property(target, _str);
-            if (_prop.propertyIndex == Property.INVALID_INDEX)
-            {
-                throw new System.ArgumentException("second argument string property is invalid parameter!");
-            }
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
             if(propertyType.Equals(PropertyType.Float))
@@ -533,15 +517,7 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
-
-            Property _prop = new Property(target, _str);
-            if (_prop.propertyIndex == Property.INVALID_INDEX)
-            {
-                throw new System.ArgumentException("second argument string property is invalid parameter!");
-            }
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
             if(propertyType.Equals(PropertyType.Float))
@@ -578,15 +554,7 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
-
-            Property _prop = new Property(target, _str);
-            if (_prop.propertyIndex == Property.INVALID_INDEX)
-            {
-                throw new System.ArgumentException("second argument string property is invalid parameter!");
-            }
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
             if(propertyType.Equals(PropertyType.Float))
@@ -623,11 +591,8 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
-            Property _prop = new Property(target, _str);
             if (_prop.propertyIndex == Property.INVALID_INDEX)
             {
                 throw new System.ArgumentException("second argument string property is invalid parameter!");
@@ -656,15 +621,7 @@ namespace Tizen.NUI
         /// <param name="alphaFunction">The alpha function to apply.</param>
         public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
         {
-            string _str1 = property.Substring(0, 1);
-            string _str2 = property.Substring(1);
-            string _str = _str1.ToLower() + _str2;
-
-            Property _prop = new Property(target, _str);
-            if (_prop.propertyIndex == Property.INVALID_INDEX)
-            {
-                throw new System.ArgumentException("second argument string property is invalid parameter!");
-            }
+            Property _prop = PropertyHelper.GetPropertyFromString(target, property);
 
             Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
             if (alphaFunction != null)
similarity index 53%
rename from Tizen.NUI/src/internal/PropertyCondition.cs
rename to Tizen.NUI/src/public/PropertyCondition.cs
index 278349f..4fc3f66 100755 (executable)
 
 namespace Tizen.NUI
 {
-
-    internal class PropertyCondition : BaseHandle
+    /// <summary>
+    /// A condition that can be evaluated on a Property Value
+    /// </summary>
+    public class PropertyCondition : BaseHandle
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
@@ -69,28 +71,81 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        public PropertyCondition(PropertyCondition handle) : this(NDalicPINVOKE.new_PropertyCondition__SWIG_1(PropertyCondition.getCPtr(handle)), true)
+        /// <summary>
+        /// Retrieves the arguments that this condition uses.
+        /// </summary>
+        public uint GetArgumentCount()
         {
+            uint ret = NDalicPINVOKE.PropertyCondition_GetArgumentCount(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+        ///<summary>
+        /// Retrieves the arguments that this condition uses
+        ///</summary>
+        public float GetArgument(uint index)
+        {
+            float ret = NDalicPINVOKE.PropertyCondition_GetArgument(swigCPtr, index);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
         }
 
-        public PropertyCondition Assign(PropertyCondition rhs)
+        ///<summary>
+        /// LessThan condition compares whether property is less than arg.
+        ///</summary>
+        public static PropertyCondition LessThan(float arg)
         {
-            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyCondition_Assign(swigCPtr, PropertyCondition.getCPtr(rhs)), false);
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.LessThanCondition(arg), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
 
-        public uint GetArgumentCount()
+        ///<summary>
+        /// GreaterThan condition compares whether property is greater than arg.
+        ///</summary>
+        public static PropertyCondition GreaterThan(float arg)
         {
-            uint ret = NDalicPINVOKE.PropertyCondition_GetArgumentCount(swigCPtr);
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.GreaterThanCondition(arg), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
 
-        public float GetArgument(uint index)
+        ///<summary>
+        /// Inside condition compares whether property is greater than arg0 and less than arg1.
+        ///</summary>
+        public static PropertyCondition Inside(float arg0, float arg1)
         {
-            float ret = NDalicPINVOKE.PropertyCondition_GetArgument(swigCPtr, index);
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.InsideCondition(arg0, arg1), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        ///<summary>
+        /// Outside condition compares whether property is less than arg0 or greater than arg1
+        ///</summary>
+        public static PropertyCondition Outside(float arg0, float arg1)
+        {
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.OutsideCondition(arg0, arg1), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        ///<summary>
+        /// Detects when a property changes by stepAmount from initialValue, in both positive and negative directions. This will continue checking for multiples of stepAmount.
+        ///</summary>
+        public static PropertyCondition Step(float stepAmount, float initialValue)
+        {
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_0(stepAmount, initialValue), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        ///<summary>
+        /// Receives notifications as a property goes above/below the inputted values. Values must be ordered and can be either ascending or descending.
+        ///</summary>
+        public static PropertyCondition Step(float stepAmount)
+        {
+            PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_1(stepAmount), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
similarity index 97%
rename from Tizen.NUI/src/internal/PropertyNotification.cs
rename to Tizen.NUI/src/public/PropertyNotification.cs
index 50dc344..3b0fc65 100755 (executable)
@@ -20,8 +20,11 @@ namespace Tizen.NUI
     using System;
     using System.Runtime.InteropServices;
 
-
-    internal class PropertyNotification : BaseHandle
+    ///<summary>
+    /// Issues a notification upon a condition of the property being met.
+    /// See PropertyCondition for available defined conditions.
+    ///</summary>
+    public class PropertyNotification : BaseHandle
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
similarity index 97%
rename from Tizen.NUI/src/internal/PropertyNotifySignal.cs
rename to Tizen.NUI/src/public/PropertyNotifySignal.cs
index 59e96cb..4919007 100755 (executable)
 namespace Tizen.NUI
 {
 
-    internal class PropertyNotifySignal : global::System.IDisposable
+    ///<summary>
+    /// Signal connection class for PropertyNotification
+    ///</summary>
+    public class PropertyNotifySignal : global::System.IDisposable
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
         protected bool swigCMemOwn;