X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-swig%2FSWIG%2Fevents%2Fanimation-event.i;h=41e816a16925f6923f552d9283538bee3693271b;hb=60235b1a08bbb136246bc87939b771e19aa8c55c;hp=e921f7669df125fb4a13f7f977fea0a6c3e63996;hpb=ed59234dddddba1caa4acecc638c0ad6b8a9150b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-swig/SWIG/events/animation-event.i b/plugins/dali-swig/SWIG/events/animation-event.i old mode 100644 new mode 100755 index e921f76..41e816a --- a/plugins/dali-swig/SWIG/events/animation-event.i +++ b/plugins/dali-swig/SWIG/events/animation-event.i @@ -26,58 +26,25 @@ using System.Runtime.InteropServices; %define Animation_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName) %typemap(cscode) NameSpace::ClassName %{ - /** - * @brief Event arguments that passed via Finished signal - * - */ - public class FinishedEventArgs : EventArgs - { - private Animation _animation; - - /** - * @brief Animation - is the Animation which has finished with the animation. - * - */ - public Animation Animation - { - get - { - return _animation; - } - set - { - _animation = value; - } - } - } - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void FinishedEventCallbackDelegate(IntPtr Animation); - private DaliEventHandler _animationFinishedEventHandler; - private FinishedEventCallbackDelegate _animationFinishedEventCallbackDelegate; + private EventCallbackDelegateType1 _animationFinishedEventCallbackDelegate; + private event EventHandler _animationFinishedEventHandler; /** * @brief Event for Finished signal which can be used to subscribe/unsubscribe the event handler - * (in the type of FinishedEventHandler - DaliEventHandler) provided by the user. * Finished signal is emitted when an Animation's animations have finished. */ - public event DaliEventHandler Finished + public event EventHandler Finished { add { lock(this) { - // Restricted to only one listener - if (_animationFinishedEventHandler == null) - { - _animationFinishedEventHandler += value; - - _animationFinishedEventCallbackDelegate = new FinishedEventCallbackDelegate(OnFinished); - this.FinishedSignal().Connect(_animationFinishedEventCallbackDelegate); - } + _animationFinishedEventHandler += value; + _animationFinishedEventCallbackDelegate = OnFinished; + this.FinishedSignal().Connect(_animationFinishedEventCallbackDelegate); } } - remove { lock(this) @@ -86,7 +53,6 @@ using System.Runtime.InteropServices; { this.FinishedSignal().Disconnect(_animationFinishedEventCallbackDelegate); } - _animationFinishedEventHandler -= value; } } @@ -95,36 +61,38 @@ using System.Runtime.InteropServices; // Callback for Animation FinishedSignal private void OnFinished(IntPtr data) { - FinishedEventArgs e = new FinishedEventArgs(); - - // Populate all members of "e" (FinishedEventArgs) with real data - e.Animation = Animation.GetAnimationFromPtr(data); - if (_animationFinishedEventHandler != null) { //here we send all data to user event handlers - _animationFinishedEventHandler(this, e); + _animationFinishedEventHandler(this, null); } } - public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) { ClassName ret = new ClassName(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + private float MilliSecondsToSeconds( int millisec ) + { + return (float)millisec / 1000.0f; + } - public float Duration + private int SecondsToMilliSeconds( float sec ) + { + return (int)( sec * 1000 ); + } + + public int Duration { set { - SetDuration(value); + SetDuration( MilliSecondsToSeconds( value ) ); } get { - float ret = GetDuration(); - return ret; + return SecondsToMilliSeconds( GetDuration() ); } } @@ -145,11 +113,352 @@ using System.Runtime.InteropServices; { get { - Animation.State ret = GetState(); - return ret; + return GetState(); + } + } + + public int LoopCount + { + set + { + SetLoopCount(value); + } + get + { + int ret = GetLoopCount(); + return ret; + } + } + + public bool Looping + { + set + { + SetLooping(value); + } + get + { + bool ret = IsLooping(); + return ret; + } + } + + public Animation.EndActions EndAction + { + set + { + SetEndAction(value); + } + get + { + return GetEndAction(); } } + public void Stop(Animation.EndActions action) + { + SetEndAction(action); + NDalicPINVOKE.Animation_Stop(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public int StartTime { set; get; } + public int EndTime { set; get; } + public string TargetProperty { set; get; } + public object Destination { set; get; } + public Dali.AlphaFunction AlphaFunction { set; get; } + + + public void AnimateBy(Actor target) + { + string _str1 = TargetProperty.Substring(0, 1); + string _str2 = TargetProperty.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)Destination; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateBy(Actor target, string propertyIndex) + { + string _str1 = propertyIndex.Substring(0, 1); + string _str2 = propertyIndex.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)Destination; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateBy(Actor target, string propertyIndex, object relativeValue) + { + string _str1 = propertyIndex.Substring(0, 1); + string _str2 = propertyIndex.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)relativeValue; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBy(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBy(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateTo(Actor target) + { + string _str1 = TargetProperty.Substring(0, 1); + string _str2 = TargetProperty.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)Destination; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateTo(Actor target, string propertyIndex) + { + string _str1 = propertyIndex.Substring(0, 1); + string _str2 = propertyIndex.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)Destination; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateTo(Actor target, string propertyIndex, object destinationValue) + { + string _str1 = propertyIndex.Substring(0, 1); + string _str2 = propertyIndex.Substring(1); + string _str = _str1.ToLower() + _str2; + + dynamic obj = (object)destinationValue; + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time ); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateTo(new Property(target, _str), new Property.Value(obj) ); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateTo(new Property(target, _str), new Property.Value(obj), time ); + } + } + } + + public void AnimateBetween(Actor target, KeyFrames keyFrames) + { + string _str1 = TargetProperty.Substring(0, 1); + string _str2 = TargetProperty.Substring(1); + string _str = _str1.ToLower() + _str2; + + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, time); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBetween(new Property(target, _str), keyFrames); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBetween(new Property(target, _str), keyFrames, time); + } + } + } + + public void AnimateBetween(Actor target, KeyFrames keyFrames, Animation.Interpolation interpolation) + { + string _str1 = TargetProperty.Substring(0, 1); + string _str2 = TargetProperty.Substring(1); + string _str = _str1.ToLower() + _str2; + + + if( this.AlphaFunction != null ) + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, interpolation); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, time, interpolation); + } + } + else + { + if( this.StartTime == 0 && this.EndTime == 0 ) + { + AnimateBetween(new Property(target, _str), keyFrames, interpolation); + } + else + { + Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) ); + AnimateBetween(new Property(target, _str), keyFrames, time, interpolation); + } + } + } + + + /** + * @brief Create an initialized Animation. + * + * The animation will not loop. + * The default end action is "Bake". + * The default Alpha function is linear. + * @since 1.0.0 + * @param [in] durationmSeconds The duration in milli seconds (int). + * @return A handle to a newly allocated Dali resource. + * @pre DurationmSeconds must be greater than zero. + */ + public Animation (int durationmSeconds) : this (NDalicPINVOKE.Animation_New((float)durationmSeconds/1000.0f), true) { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public Animation () : this (NDalicPINVOKE.Animation_New( 0.0f ), true ) { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + %} %enddef @@ -163,4 +472,21 @@ using System.Runtime.InteropServices; namespace Dali { DALI_animation_EVENTHANDLER_PARAM( Dali, Animation); + +%typemap(cscode) Dali::KeyFrames %{ + + public void Add(float progress, object value) + { + dynamic obj = value; + Add(progress, new Property.Value(obj)); + } + + public void Add(float progress, object value, AlphaFunction alpha) + { + dynamic obj = value; + Add(progress, new Property.Value(obj), alpha); + } + +%} + }