Animation ProgressReached API added
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 9 Jun 2017 16:05:24 +0000 (17:05 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 9 Jun 2017 16:48:04 +0000 (17:48 +0100)
Change-Id: Id96f8e69503be6ab2110353a6dddf915106f7486

src/Tizen.NUI/src/internal/NDalicPINVOKE.cs
src/Tizen.NUI/src/public/Animation.cs

index d38a44e..6a175b3 100755 (executable)
@@ -4580,9 +4580,18 @@ class NDalicPINVOKE {
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_Clear")]
   public static extern void Animation_Clear(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_SetProgressNotification")]
+  public static extern void Animation_SetProgressNotification(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2);
+
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_GetProgressNotification")]
+  public static extern float Animation_GetProgressNotification(global::System.Runtime.InteropServices.HandleRef jarg1);
+
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_FinishedSignal")]
   public static extern global::System.IntPtr Animation_FinishedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_ProgressReachedSignal")]
+  public static extern global::System.IntPtr Animation_ProgressReachedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Animation_AnimateBy__SWIG_0")]
   public static extern void Animation_AnimateBy__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
 
index 5b264dd..42c553c 100755 (executable)
@@ -146,6 +146,60 @@ namespace Tizen.NUI
             }
         }
 
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
+        private AnimationProgressReachedEventCallbackType _animationProgressReachedEventCallback;
+        private event EventHandler _animationProgressReachedEventHandler;
+        /**
+        * @brief Event for ProgressReached signal which can be used to subscribe/unsubscribe the event handler.
+        * ProgressReached signal is emitted when the Animation has reached a given progress percentage, this is set in the api SetProgressNotification.
+        */
+        public event EventHandler ProgressReached
+        {
+            add
+            {
+                if (_animationProgressReachedEventHandler == null)
+                {
+#if DEBUG_ON
+                    Tizen.Log.Debug("NUI", "con1) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
+                    Tizen.Log.Debug("NUI", "con2) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
+#endif
+                    _animationProgressReachedEventCallback = OnProgressReached;
+                    ProgressReachedSignal().Connect(_animationProgressReachedEventCallback);
+#if DEBUG_ON
+                    Tizen.Log.Debug("NUI", "con3) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
+                    Tizen.Log.Debug("NUI", "con4) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
+#endif
+                }
+
+                _animationProgressReachedEventHandler += value;
+            }
+            remove
+            {
+                _animationProgressReachedEventHandler -= value;
+
+                if (_animationProgressReachedEventHandler == null && ProgressReachedSignal().Empty() == false)
+                {
+#if DEBUG_ON
+                    Tizen.Log.Debug("NUI", "discon1) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
+                    Tizen.Log.Debug("NUI", "discon2) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
+#endif
+                    ProgressReachedSignal().Disconnect(_animationProgressReachedEventHandler);
+#if DEBUG_ON
+                    Tizen.Log.Debug("NUI", "discon3) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
+                    Tizen.Log.Debug("NUI", "discon4) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
+#endif
+                }
+            }
+        }
+        private void OnProgressReached(IntPtr data)
+        {
+            if (_animationProgressReachedEventHandler != null)
+            {
+                //here we send all data to user event handlers
+                _animationProgressReachedEventHandler(this, null);
+            }
+        }
 
         internal static Animation GetAnimationFromPtr(global::System.IntPtr cPtr)
         {
@@ -370,6 +424,27 @@ namespace Tizen.NUI
             }
         }
 
+
+        /// <summary>
+        /// Gets/Sets the Progress notification marker which triggers the ProgressReachedSignal.<br>
+        /// percentage of animation progress should be greater than 0 and less than 1, e.g 0.3 for 30% <br>
+        /// One notification can be set on each animation
+        /// </summary>
+        public float ProgressNotification
+        {
+            set
+            {
+                NDalicPINVOKE.Animation_SetProgressNotification(swigCPtr, value);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+            get
+            {
+                float ret = NDalicPINVOKE.Animation_GetProgressNotification(swigCPtr);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                return ret;
+            }
+        }
+
         /// <summary>
         /// Animates a property value by a relative amount.<br>
         /// </summary>
@@ -889,6 +964,13 @@ namespace Tizen.NUI
             return ret;
         }
 
+        internal AnimationSignal ProgressReachedSignal()
+        {
+            AnimationSignal ret = new AnimationSignal(NDalicPINVOKE.Animation_ProgressReachedSignal(swigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         internal void AnimateBy(Property target, PropertyValue relativeValue)
         {
             NDalicPINVOKE.Animation_AnimateBy__SWIG_0(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));