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 Dali.Constants.Animation.State Status
116 return (Dali.Constants.Animation.State)GetState();
128 int ret = GetLoopCount();
141 bool ret = IsLooping();
146 public Dali.Constants.Animation.EndAction EndAction
152 case Dali.Constants.Animation.EndAction.Cancel :
153 SetEndAction(Dali.Animation.DaliEndAction.Bake);
155 case Dali.Constants.Animation.EndAction.Discard :
156 SetEndAction(Dali.Animation.DaliEndAction.Discard);
158 case Dali.Constants.Animation.EndAction.Stop :
159 SetEndAction(Dali.Animation.DaliEndAction.BakeFinal);
162 SetEndAction(Dali.Animation.DaliEndAction.Bake);
168 Dali.Animation.DaliEndAction temp = GetEndAction();
171 case Dali.Animation.DaliEndAction.Bake :
172 return Dali.Constants.Animation.EndAction.Cancel;
173 case Dali.Animation.DaliEndAction.Discard :
174 return Dali.Constants.Animation.EndAction.Discard;
175 case Dali.Animation.DaliEndAction.BakeFinal :
176 return Dali.Constants.Animation.EndAction.Stop;
178 return Dali.Constants.Animation.EndAction.Cancel;
183 public void Stop(Dali.Constants.Animation.EndAction action) {
186 case Dali.Constants.Animation.EndAction.Cancel :
187 SetEndAction(Dali.Animation.DaliEndAction.Bake);
189 case Dali.Constants.Animation.EndAction.Discard :
190 SetEndAction(Dali.Animation.DaliEndAction.Discard);
192 case Dali.Constants.Animation.EndAction.Stop :
193 SetEndAction(Dali.Animation.DaliEndAction.BakeFinal);
196 SetEndAction(Dali.Animation.DaliEndAction.Bake);
199 NDalicPINVOKE.Animation_Stop(swigCPtr);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 public int StartTime { set; get; }
204 public int EndTime { set; get; }
205 public string TargetPoperty { set; get; }
206 public object Destination { set; get; }
207 public Dali.AlphaFunction AlphaFunction { set; get; }
210 public void AnimateBy(Actor target)
212 string _str1 = TargetPoperty.Substring(0, 1);
213 string _str2 = TargetPoperty.Substring(1);
214 string _str = _str1.ToLower() + _str2;
216 dynamic obj = (object)Destination;
218 if( this.AlphaFunction != null )
220 if( this.StartTime == 0 && this.EndTime == 0 )
222 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
226 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
227 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
232 if( this.StartTime == 0 && this.EndTime == 0 )
234 AnimateBy(new Property(target, _str), new Property.Value(obj) );
238 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
239 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
244 public void AnimateBy(Actor target, string propertyIndex)
246 string _str1 = propertyIndex.Substring(0, 1);
247 string _str2 = propertyIndex.Substring(1);
248 string _str = _str1.ToLower() + _str2;
250 dynamic obj = (object)Destination;
252 if( this.AlphaFunction != null )
254 if( this.StartTime == 0 && this.EndTime == 0 )
256 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
260 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
261 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
266 if( this.StartTime == 0 && this.EndTime == 0 )
268 AnimateBy(new Property(target, _str), new Property.Value(obj) );
272 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
273 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
278 public void AnimateBy(Actor target, string propertyIndex, object relativeValue)
280 string _str1 = propertyIndex.Substring(0, 1);
281 string _str2 = propertyIndex.Substring(1);
282 string _str = _str1.ToLower() + _str2;
284 dynamic obj = (object)relativeValue;
286 if( this.AlphaFunction != null )
288 if( this.StartTime == 0 && this.EndTime == 0 )
290 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
294 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
295 AnimateBy(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
300 if( this.StartTime == 0 && this.EndTime == 0 )
302 AnimateBy(new Property(target, _str), new Property.Value(obj) );
306 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
307 AnimateBy(new Property(target, _str), new Property.Value(obj), time );
312 public void AnimateTo(Actor target)
314 string _str1 = TargetPoperty.Substring(0, 1);
315 string _str2 = TargetPoperty.Substring(1);
316 string _str = _str1.ToLower() + _str2;
318 dynamic obj = (object)Destination;
320 if( this.AlphaFunction != null )
322 if( this.StartTime == 0 && this.EndTime == 0 )
324 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
328 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
329 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
334 if( this.StartTime == 0 && this.EndTime == 0 )
336 AnimateTo(new Property(target, _str), new Property.Value(obj) );
340 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
341 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
346 public void AnimateTo(Actor target, string propertyIndex)
348 string _str1 = propertyIndex.Substring(0, 1);
349 string _str2 = propertyIndex.Substring(1);
350 string _str = _str1.ToLower() + _str2;
352 dynamic obj = (object)Destination;
354 if( this.AlphaFunction != null )
356 if( this.StartTime == 0 && this.EndTime == 0 )
358 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
362 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
363 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
368 if( this.StartTime == 0 && this.EndTime == 0 )
370 AnimateTo(new Property(target, _str), new Property.Value(obj) );
374 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
375 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
380 public void AnimateTo(Actor target, string propertyIndex, object destinationValue)
382 string _str1 = propertyIndex.Substring(0, 1);
383 string _str2 = propertyIndex.Substring(1);
384 string _str = _str1.ToLower() + _str2;
386 dynamic obj = (object)destinationValue;
388 if( this.AlphaFunction != null )
390 if( this.StartTime == 0 && this.EndTime == 0 )
392 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction );
396 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
397 AnimateTo(new Property(target, _str), new Property.Value(obj), this.AlphaFunction, time );
402 if( this.StartTime == 0 && this.EndTime == 0 )
404 AnimateTo(new Property(target, _str), new Property.Value(obj) );
408 Dali.TimePeriod time = new Dali.TimePeriod( MilliSecondsToSeconds( this.StartTime ), MilliSecondsToSeconds( this.EndTime ) );
409 AnimateTo(new Property(target, _str), new Property.Value(obj), time );
415 * @brief Create an initialized Animation.
417 * The animation will not loop.
418 * The default end action is "Bake".
419 * The default Alpha function is linear.
421 * @param [in] durationmSeconds The duration in milli seconds (int).
422 * @return A handle to a newly allocated Dali resource.
423 * @pre DurationmSeconds must be greater than zero.
425 public Animation (int durationmSeconds) : this (NDalicPINVOKE.Animation_New((float)durationmSeconds/1000.0f), true) {
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 public Animation () : this (NDalicPINVOKE.Animation_New( 0.0f ), true ) {
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438 %define DALI_animation_EVENTHANDLER_PARAM( NameSpace, ClassName)
439 Animation_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
440 Animation_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
445 DALI_animation_EVENTHANDLER_PARAM( Dali, Animation);