2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 %define Animation_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define Animation_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
30 private EventCallbackDelegateType1<IntPtr> _animationFinishedEventCallbackDelegate;
31 private event EventHandler _animationFinishedEventHandler;
34 * @brief Event for Finished signal which can be used to subscribe/unsubscribe the event handler
35 * Finished signal is emitted when an Animation's animations have finished.
37 public event EventHandler Finished
43 _animationFinishedEventHandler += value;
44 _animationFinishedEventCallbackDelegate = OnFinished;
45 this.FinishedSignal().Connect(_animationFinishedEventCallbackDelegate);
52 if (_animationFinishedEventHandler != null)
54 this.FinishedSignal().Disconnect(_animationFinishedEventCallbackDelegate);
56 _animationFinishedEventHandler -= value;
61 // Callback for Animation FinishedSignal
62 private void OnFinished(IntPtr data)
64 if (_animationFinishedEventHandler != null)
66 //here we send all data to user event handlers
67 _animationFinishedEventHandler(this, null);
71 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
72 ClassName ret = new ClassName(cPtr, false);
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77 private float MilliSecondsToSeconds( int millisec )
79 return (float)millisec / 1000.0f;
82 private int SecondsToMilliSeconds( float sec )
84 return (int)( sec * 1000 );
91 SetDuration( MilliSecondsToSeconds( value ) );
95 return SecondsToMilliSeconds( GetDuration() );
99 public AlphaFunction DefaultAlphaFunction
103 SetDefaultAlphaFunction(value);
107 AlphaFunction ret = GetDefaultAlphaFunction();
112 public Animation.State Status
128 int ret = GetLoopCount();
141 bool ret = IsLooping();
146 public Animation.EndActions EndAction
154 return GetEndAction();
158 public void Stop(Animation.EndActions action)
160 SetEndAction(action);
161 NDalicPINVOKE.Animation_Stop(swigCPtr);
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public int StartTime { set; get; }
166 public int EndTime { set; get; }
167 public string TargetProperty { set; get; }
168 public object Destination { set; get; }
169 public Dali.AlphaFunction AlphaFunction { set; get; }
172 public void AnimateBy(Actor target)
174 string _str1 = TargetProperty.Substring(0, 1);
175 string _str2 = TargetProperty.Substring(1);
176 string _str = _str1.ToLower() + _str2;
178 dynamic obj = (object)Destination;
180 if( this.AlphaFunction != null )
182 if( this.StartTime == 0 && this.EndTime == 0 )
184 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
188 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
189 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
194 if( this.StartTime == 0 && this.EndTime == 0 )
196 AnimateBy(new Property(target, _str), new Property.Value(obj) );
200 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
201 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
206 public void AnimateBy(Actor target, string propertyIndex)
208 string _str1 = propertyIndex.Substring(0, 1);
209 string _str2 = propertyIndex.Substring(1);
210 string _str = _str1.ToLower() + _str2;
212 dynamic obj = (object)Destination;
214 if( this.AlphaFunction != null )
216 if( this.StartTime == 0 && this.EndTime == 0 )
218 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
222 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
223 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
228 if( this.StartTime == 0 && this.EndTime == 0 )
230 AnimateBy(new Property(target, _str), new Property.Value(obj) );
234 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
235 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
240 public void AnimateBy(Actor target, string propertyIndex, object relativeValue)
242 string _str1 = propertyIndex.Substring(0, 1);
243 string _str2 = propertyIndex.Substring(1);
244 string _str = _str1.ToLower() + _str2;
246 dynamic obj = (object)relativeValue;
248 if( this.AlphaFunction != null )
250 if( this.StartTime == 0 && this.EndTime == 0 )
252 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
256 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
257 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
262 if( this.StartTime == 0 && this.EndTime == 0 )
264 AnimateBy(new Property(target, _str), new Property.Value(obj) );
268 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
269 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
274 public void AnimateTo(Actor target)
276 string _str1 = TargetProperty.Substring(0, 1);
277 string _str2 = TargetProperty.Substring(1);
278 string _str = _str1.ToLower() + _str2;
280 dynamic obj = (object)Destination;
282 if( this.AlphaFunction != null )
284 if( this.StartTime == 0 && this.EndTime == 0 )
286 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
290 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
291 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
296 if( this.StartTime == 0 && this.EndTime == 0 )
298 AnimateTo(new Property(target, _str), new Property.Value(obj) );
302 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
303 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
308 public void AnimateTo(Actor target, string propertyIndex)
310 string _str1 = propertyIndex.Substring(0, 1);
311 string _str2 = propertyIndex.Substring(1);
312 string _str = _str1.ToLower() + _str2;
314 dynamic obj = (object)Destination;
316 if( this.AlphaFunction != null )
318 if( this.StartTime == 0 && this.EndTime == 0 )
320 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
324 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
325 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
330 if( this.StartTime == 0 && this.EndTime == 0 )
332 AnimateTo(new Property(target, _str), new Property.Value(obj) );
336 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
337 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
342 public void AnimateTo(Actor target, string propertyIndex, object destinationValue)
344 string _str1 = propertyIndex.Substring(0, 1);
345 string _str2 = propertyIndex.Substring(1);
346 string _str = _str1.ToLower() + _str2;
348 dynamic obj = (object)destinationValue;
350 if( this.AlphaFunction != null )
352 if( this.StartTime == 0 && this.EndTime == 0 )
354 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
358 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
359 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
364 if( this.StartTime == 0 && this.EndTime == 0 )
366 AnimateTo(new Property(target, _str), new Property.Value(obj) );
370 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
371 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
376 public void AnimateBetween(Actor target, KeyFrames keyFrames)
378 string _str1 = TargetProperty.Substring(0, 1);
379 string _str2 = TargetProperty.Substring(1);
380 string _str = _str1.ToLower() + _str2;
383 if( this.AlphaFunction != null )
385 if( this.StartTime == 0 && this.EndTime == 0 )
387 AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction);
391 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
392 AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, time);
397 if( this.StartTime == 0 && this.EndTime == 0 )
399 AnimateBetween(new Property(target, _str), keyFrames);
403 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
404 AnimateBetween(new Property(target, _str), keyFrames, time);
409 public void AnimateBetween(Actor target, KeyFrames keyFrames, Animation.Interpolation interpolation)
411 string _str1 = TargetProperty.Substring(0, 1);
412 string _str2 = TargetProperty.Substring(1);
413 string _str = _str1.ToLower() + _str2;
416 if( this.AlphaFunction != null )
418 if( this.StartTime == 0 && this.EndTime == 0 )
420 AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, interpolation);
424 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
425 AnimateBetween(new Property(target, _str), keyFrames, this.AlphaFunction, time, interpolation);
430 if( this.StartTime == 0 && this.EndTime == 0 )
432 AnimateBetween(new Property(target, _str), keyFrames, interpolation);
436 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime - this.StartTime ) );
437 AnimateBetween(new Property(target, _str), keyFrames, time, interpolation);
444 * @brief Create an initialized Animation.
446 * The animation will not loop.
447 * The default end action is "Bake".
448 * The default Alpha function is linear.
450 * @param [in] durationmSeconds The duration in milli seconds (int).
451 * @return A handle to a newly allocated Dali resource.
452 * @pre DurationmSeconds must be greater than zero.
454 public Animation (int durationmSeconds) : this (NDalicPINVOKE.Animation_New((float)durationmSeconds/1000.0f), true) {
455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 public Animation () : this (NDalicPINVOKE.Animation_New( 0.0f ), true ) {
459 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 %define DALI_animation_EVENTHANDLER_PARAM( NameSpace, ClassName)
468 Animation_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
469 Animation_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
474 DALI_animation_EVENTHANDLER_PARAM( Dali, Animation);
476 %typemap(cscode) Dali::KeyFrames %{
478 public void Add(float progress, object value)
481 Add(progress, new Property.Value(obj));
484 public void Add(float progress, object value, AlphaFunction alpha)
487 Add(progress, new Property.Value(obj), alpha);