From b763492f0ee9696cc68b51cb35616f14a229ce77 Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Fri, 9 Jun 2017 17:05:24 +0100 Subject: [PATCH] Animation ProgressReached API added Change-Id: Id96f8e69503be6ab2110353a6dddf915106f7486 --- src/Tizen.NUI/src/internal/NDalicPINVOKE.cs | 9 ++++ src/Tizen.NUI/src/public/Animation.cs | 82 +++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs b/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs index d38a44e..6a175b3 100755 --- a/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs @@ -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); diff --git a/src/Tizen.NUI/src/public/Animation.cs b/src/Tizen.NUI/src/public/Animation.cs index 5b264dd..42c553c 100755 --- a/src/Tizen.NUI/src/public/Animation.cs +++ b/src/Tizen.NUI/src/public/Animation.cs @@ -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 } } + + /// + /// Gets/Sets the Progress notification marker which triggers the ProgressReachedSignal.
+ /// percentage of animation progress should be greater than 0 and less than 1, e.g 0.3 for 30%
+ /// One notification can be set on each animation + ///
+ 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; + } + } + /// /// Animates a property value by a relative amount.
///
@@ -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)); -- 2.7.4