X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Fpublic%2FAnimation.cs;h=682f2b43de2659f1caf1c9ec2a0bdb9e3b21fba9;hb=0eeef17fb8c79910223a298c9819b95974a71525;hp=57b41a4db42c573aaedba1959eddbfbf8ed2078f;hpb=f6621f9d36a2827540089ef205162bb35e12ea58;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/Tizen.NUI/src/public/Animation.cs b/src/Tizen.NUI/src/public/Animation.cs
index 57b41a4..682f2b4 100755
--- a/src/Tizen.NUI/src/public/Animation.cs
+++ b/src/Tizen.NUI/src/public/Animation.cs
@@ -1,5 +1,5 @@
/*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2019 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.
@@ -17,7 +17,6 @@
namespace Tizen.NUI
{
-
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
@@ -43,78 +42,18 @@ namespace Tizen.NUI
/// 3
public class Animation : BaseHandle
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Animation_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-
- _animationFinishedEventCallback = OnFinished;
- _finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(_animationFinishedEventCallback);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animation obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- ///
- /// To make animation instance be disposed.
- ///
- /// 3
- protected override void Dispose(DisposeTypes type)
- {
- if (this != null)
- {
- if (_animationFinishedEventCallback != null)
- {
- FinishedSignal().Disconnect(_finishedCallbackOfNative);
- }
-
- if (_animationProgressReachedEventCallback != null)
- {
-
- ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback);
- }
- }
-
- 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.
-
- }
- else if(type == DisposeTypes.Implicit)
- {
-
- }
+ private static bool? disableAnimation = null;
- if (this != null)
- {
- this.Clear();
- }
- //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.
+ private AnimationFinishedEventCallbackType _animationFinishedEventCallback;
+ private System.IntPtr _finishedCallbackOfNative;
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- NDalicPINVOKE.delete_Animation(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
+ private AnimationProgressReachedEventCallbackType _animationProgressReachedEventCallback;
- base.Dispose(type);
- }
+ private string[] _properties = null;
+ private string[] _destValue = null;
+ private int[] _startTime = null;
+ private int[] _endTime = null;
///
/// Creates an initialized animation.
@@ -125,17 +64,25 @@ namespace Tizen.NUI
/// DurationmSeconds must be greater than zero.
/// The duration in milliseconds.
/// 3
- public Animation(int durationMilliSeconds) : this(NDalicPINVOKE.Animation_New((float)durationMilliSeconds / 1000.0f), true)
+ public Animation(int durationMilliSeconds) : this(Interop.Animation.Animation_New((float)durationMilliSeconds / 1000.0f), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- private AnimationFinishedEventCallbackType _animationFinishedEventCallback;
+ internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Animation.Animation_SWIGUpcast(cPtr), cMemoryOwn)
+ {
+
+ _animationFinishedEventCallback = OnFinished;
+ _finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(_animationFinishedEventCallback);
+ }
+
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void AnimationFinishedEventCallbackType(IntPtr data);
- private event EventHandler _animationFinishedEventHandler;
- private System.IntPtr _finishedCallbackOfNative;
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
+
+ private event EventHandler _animationFinishedEventHandler;
/**
* @brief Event for the finished signal which can be used to subscribe or unsubscribe the event handler.
@@ -162,23 +109,13 @@ namespace Tizen.NUI
}
}
}
- private void OnFinished(IntPtr data)
- {
- if (_animationFinishedEventHandler != null)
- {
- //here we send all data to user event handlers
- _animationFinishedEventHandler(this, null);
- }
- }
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
- private AnimationProgressReachedEventCallbackType _animationProgressReachedEventCallback;
private event EventHandler _animationProgressReachedEventHandler;
+
/**
- * @brief Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.
- * The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.
- */
+ * @brief Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.
+ * The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.
+ */
/// 3
public event EventHandler ProgressReached
{
@@ -202,26 +139,64 @@ namespace Tizen.NUI
}
}
}
- private void OnProgressReached(IntPtr data)
+
+ ///
+ /// Enumeration for what to do when the animation ends, stopped, or destroyed.
+ ///
+ /// 3
+ public enum EndActions
{
- if (_animationProgressReachedEventHandler != null)
- {
- //here we send all data to user event handlers
- _animationProgressReachedEventHandler(this, null);
- }
+ ///
+ /// When the animation ends, the animated property values are saved.
+ ///
+ Cancel,
+ ///
+ /// When the animation ends, the animated property values are forgotten.
+ ///
+ Discard,
+ ///
+ /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like cancel.
+ ///
+ StopFinal
}
- private float MilliSecondsToSeconds(int millisec)
+ ///
+ /// Enumeration for what interpolation method to use on key-frame animations.
+ ///
+ /// 3
+ public enum Interpolation
{
- return (float)millisec / 1000.0f;
+ ///
+ /// Values in between key frames are interpolated using a linear polynomial. (Default)
+ ///
+ Linear,
+ ///
+ /// Values in between key frames are interpolated using a cubic polynomial.
+ ///
+ Cubic
}
- private int SecondsToMilliSeconds(float sec)
+ ///
+ /// Enumeration for what state the animation is in.
+ ///
+ /// Calling Reset() on this class will not reset the animation. It will call the BaseHandle.Reset() which drops the object handle.
+ /// 3
+ public enum States
{
- return (int)(sec * 1000);
+ ///
+ /// The animation has stopped.
+ ///
+ Stopped,
+ ///
+ /// The animation is playing.
+ ///
+ Playing,
+ ///
+ /// The animation is paused.
+ ///
+ Paused
}
-
///
/// Gets or sets the duration in milliseconds of the animation.
///
@@ -326,19 +301,6 @@ namespace Tizen.NUI
}
}
-
- ///
- /// Stops the animation.
- ///
- /// The end action can be set.
- /// 3
- public void Stop(EndActions action = EndActions.Cancel)
- {
- SetEndAction(action);
- NDalicPINVOKE.Animation_Stop(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
///
/// Gets the current loop count.
/// A value 0 indicating the current loop count when looping.
@@ -362,12 +324,12 @@ namespace Tizen.NUI
{
set
{
- NDalicPINVOKE.Animation_SetDisconnectAction(swigCPtr, (int)value);
+ Interop.Animation.Animation_SetDisconnectAction(swigCPtr, (int)value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
- Animation.EndActions ret = (Animation.EndActions)NDalicPINVOKE.Animation_GetDisconnectAction(swigCPtr);
+ Animation.EndActions ret = (Animation.EndActions)Interop.Animation.Animation_GetDisconnectAction(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
@@ -385,12 +347,12 @@ namespace Tizen.NUI
{
set
{
- NDalicPINVOKE.Animation_SetCurrentProgress(swigCPtr, value);
+ Interop.Animation.Animation_SetCurrentProgress(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
- float ret = NDalicPINVOKE.Animation_GetCurrentProgress(swigCPtr);
+ float ret = Interop.Animation.Animation_GetCurrentProgress(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
@@ -407,12 +369,12 @@ namespace Tizen.NUI
{
set
{
- NDalicPINVOKE.Animation_SetSpeedFactor(swigCPtr, value);
+ Interop.Animation.Animation_SetSpeedFactor(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
- float ret = NDalicPINVOKE.Animation_GetSpeedFactor(swigCPtr);
+ float ret = Interop.Animation.Animation_GetSpeedFactor(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
@@ -428,12 +390,12 @@ namespace Tizen.NUI
{
set
{
- NDalicPINVOKE.Animation_SetPlayRange(swigCPtr, Vector2.getCPtr(value));
+ Interop.Animation.Animation_SetPlayRange(swigCPtr, Vector2.getCPtr(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
- Vector2 ret = new Vector2(NDalicPINVOKE.Animation_GetPlayRange(swigCPtr), true);
+ Vector2 ret = new Vector2(Interop.Animation.Animation_GetPlayRange(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
@@ -450,132 +412,20 @@ namespace Tizen.NUI
{
set
{
- NDalicPINVOKE.Animation_SetProgressNotification(swigCPtr, value);
+ Interop.Animation.Animation_SetProgressNotification(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
- float ret = NDalicPINVOKE.Animation_GetProgressNotification(swigCPtr);
+ float ret = Interop.Animation.Animation_GetProgressNotification(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
- /// Animates a property value by a relative amount.
- ///
- /// The target object to animate.
- /// The target property to animate.
- /// The property value will change by this amount.
- /// The alpha function to apply.
- /// 3
- public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
- {
- Property _prop = PropertyHelper.GetPropertyFromString(target, property);
-
- PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
- if(propertyType.Equals(PropertyType.Float))
- {
- System.Type type = relativeValue.GetType();
- if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
- {
- int num = (int)relativeValue;
- relativeValue = (float)num;
- }
- }
-
- PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
-
- if (alphaFunction != null)
- {
- AnimateBy(_prop, val, alphaFunction);
- }
- else
- {
- AnimateBy(_prop, val);
- }
- }
-
- ///
- /// Animates a property value by a relative amount.
- ///
- /// The target object to animate.
- /// The target property to animate.
- /// The property value will change by this amount.
- /// The start time of the animation.
- /// The end time of the animation.
- /// The alpha function to apply.
- /// 3
- public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
- {
- Property _prop = PropertyHelper.GetPropertyFromString(target, property);
-
- PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
- if(propertyType.Equals(PropertyType.Float))
- {
- System.Type type = relativeValue.GetType();
- if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
- {
- int num = (int)relativeValue;
- relativeValue = (float)num;
- }
- }
-
- PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
-
- if (alphaFunction != null)
- {
- Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
- AnimateBy(_prop, val, alphaFunction, time);
- }
- else
- {
- Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
- AnimateBy(_prop, val, time);
- }
- }
-
- ///
- /// Animates a property to a destination value.
- ///
- /// The target object to animate.
- /// The target property to animate.
- /// The destination value.
- /// The alpha function to apply.
- /// 3
- public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
- {
- Property _prop = PropertyHelper.GetPropertyFromString(target, property);
-
- PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
- if(propertyType.Equals(PropertyType.Float))
- {
- System.Type type = destinationValue.GetType();
- if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
- {
- int num = (int)destinationValue;
- destinationValue = (float)num;
- }
- }
-
- PropertyValue val = PropertyValue.CreateFromObject(destinationValue);
-
- if (alphaFunction != null)
- {
- AnimateTo(_prop, val, alphaFunction);
- }
- else
- {
- AnimateTo(_prop, val);
- }
- }
- private string[] _properties = null;
-
- ///
/// Gets or sets the properties of the animation.
///
- /// 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 string[] Properties
{
get
@@ -588,13 +438,9 @@ namespace Tizen.NUI
}
}
- private string[] _destValue = null;
-
///
/// Gets or sets the destination value for each property of the animation.
///
- /// 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 string[] DestValue
{
get
@@ -607,13 +453,9 @@ namespace Tizen.NUI
}
}
- private int[] _startTime = null;
-
///
/// Gets or sets the start time for each property of the animation.
///
- /// 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 int[] StartTime
{
get
@@ -626,13 +468,9 @@ namespace Tizen.NUI
}
}
- private int[] _endTime = null;
-
///
/// Gets or sets the end time for each property of the animation.
///
- /// 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 int[] EndTime
{
get
@@ -645,12 +483,131 @@ namespace Tizen.NUI
}
}
+ private bool DisableAnimation
+ {
+ get
+ {
+ if (disableAnimation.HasValue == false)
+ {
+ string type = Environment.GetEnvironmentVariable("PlatformSmartType");
+ if (type == "Entry")
+ disableAnimation = true;
+ else
+ disableAnimation = false;
+ }
+ return disableAnimation.Value;
+ }
+ }
+
+ ///
+ /// Downcasts a handle to animation handle.
+ /// If handle points to an animation object, the downcast produces a valid handle.
+ /// If not, the returned handle is left uninitialized.
+ ///
+ /// Handle to an object.
+ /// Handle to an animation object or an uninitialized handle.
+ /// 3
+ [Obsolete("Deprecated in API6, Will be removed in API9, Please use as keyword instead!")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Animation DownCast(BaseHandle handle)
+ {
+ Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ ///
+ /// Stops the animation.
+ ///
+ /// The end action can be set.
+ /// 3
+ public void Stop(EndActions action = EndActions.Cancel)
+ {
+ SetEndAction(action);
+ Interop.Animation.Animation_Stop(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ ///
+ /// Animates a property value by a relative amount.
+ ///
+ /// The target object to animate.
+ /// The target property to animate.
+ /// The property value will change by this amount.
+ /// The alpha function to apply.
+ /// 3
+ public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
+ {
+ Property _prop = PropertyHelper.GetPropertyFromString(target, property);
+ relativeValue = AvoidFloatPropertyHasIntegerValue(target, _prop, relativeValue);
+ PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
+
+ if (alphaFunction != null)
+ {
+ AnimateBy(_prop, val, alphaFunction);
+ }
+ else
+ {
+ AnimateBy(_prop, val);
+ }
+ }
+
+ ///
+ /// Animates a property value by a relative amount.
+ ///
+ /// The target object to animate.
+ /// The target property to animate.
+ /// The property value will change by this amount.
+ /// The start time of the animation.
+ /// The end time of the animation.
+ /// The alpha function to apply.
+ /// 3
+ public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
+ {
+ Property _prop = PropertyHelper.GetPropertyFromString(target, property);
+ relativeValue = AvoidFloatPropertyHasIntegerValue(target, _prop, relativeValue);
+ PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
+
+ if (alphaFunction != null)
+ {
+ Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
+ AnimateBy(_prop, val, alphaFunction, time);
+ }
+ else
+ {
+ Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
+ AnimateBy(_prop, val, time);
+ }
+ }
+
+ ///
+ /// Animates a property to a destination value.
+ ///
+ /// The target object to animate.
+ /// The target property to animate.
+ /// The destination value.
+ /// The alpha function to apply.
+ /// 3
+ public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
+ {
+ Property _prop = PropertyHelper.GetPropertyFromString(target, property);
+ destinationValue = AvoidFloatPropertyHasIntegerValue(target, _prop, destinationValue);
+ PropertyValue val = PropertyValue.CreateFromObject(destinationValue);
+
+ if (alphaFunction != null)
+ {
+ AnimateTo(_prop, val, alphaFunction);
+ }
+ else
+ {
+ AnimateTo(_prop, val);
+ }
+ }
+
///
/// Animates one or more properties to a destination value.
///
/// The target object to animate.
- /// 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 void PlayAnimateTo(View target)
{
Clear();
@@ -667,7 +624,7 @@ namespace Tizen.NUI
{
object destinationValue = ConvertTo(_destValue[index], propertyInfo.PropertyType);
- if(destinationValue != null)
+ if (destinationValue != null)
{
AnimateTo(target, _properties[index], destinationValue, _startTime[index], _endTime[index]);
}
@@ -677,147 +634,6 @@ namespace Tizen.NUI
}
}
- internal object ConvertTo(object value, Type toType)
- {
- Func