c7dca567e0d61a85a2428c646ec526862f713c89
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / animation-event.i
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 %define Animation_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22 %}
23
24 %enddef
25
26 %define Animation_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27   %typemap(cscode) NameSpace::ClassName %{
28
29     public static readonly int ParentOrigin = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_get();
30     public static readonly int ParentOriginX = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_X_get();
31     public static readonly int ParentOriginY = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_Y_get();
32     public static readonly int ParentOriginZ = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_Z_get();
33     public static readonly int AnchorPoint = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_get();
34     public static readonly int AnchorPointX = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_X_get();
35     public static readonly int AnchorPointY = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_Y_get();
36     public static readonly int AnchorPointZ = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_Z_get();
37     public static readonly int Size = NDalicPINVOKE.Actor_Property_SIZE_get();
38     public static readonly int SizeWidth = NDalicPINVOKE.Actor_Property_SIZE_WIDTH_get();
39     public static readonly int SizeHeight = NDalicPINVOKE.Actor_Property_SIZE_HEIGHT_get();
40     public static readonly int SizeDepth = NDalicPINVOKE.Actor_Property_SIZE_DEPTH_get();
41     public static readonly int Position = NDalicPINVOKE.Actor_Property_POSITION_get();
42     public static readonly int PositionX = NDalicPINVOKE.Actor_Property_POSITION_X_get();
43     public static readonly int PositionY = NDalicPINVOKE.Actor_Property_POSITION_Y_get();
44     public static readonly int PositionZ = NDalicPINVOKE.Actor_Property_POSITION_Z_get();
45     public static readonly int WorldPosition = NDalicPINVOKE.Actor_Property_WORLD_POSITION_get();
46     public static readonly int WorldPositionX = NDalicPINVOKE.Actor_Property_WORLD_POSITION_X_get();
47     public static readonly int WorldPositionY = NDalicPINVOKE.Actor_Property_WORLD_POSITION_Y_get();
48     public static readonly int WorldPositionZ = NDalicPINVOKE.Actor_Property_WORLD_POSITION_Z_get();
49     public static readonly int Orientation = NDalicPINVOKE.Actor_Property_ORIENTATION_get();
50     public static readonly int WorldOrientation = NDalicPINVOKE.Actor_Property_WORLD_ORIENTATION_get();
51     public static readonly int Scale = NDalicPINVOKE.Actor_Property_SCALE_get();
52     public static readonly int ScaleX = NDalicPINVOKE.Actor_Property_SCALE_X_get();
53     public static readonly int ScaleY = NDalicPINVOKE.Actor_Property_SCALE_Y_get();
54     public static readonly int ScaleZ = NDalicPINVOKE.Actor_Property_SCALE_Z_get();
55     public static readonly int WorldScale = NDalicPINVOKE.Actor_Property_WORLD_SCALE_get();
56     public static readonly int Visibile = NDalicPINVOKE.Actor_Property_VISIBLE_get();
57     public static readonly int Color = NDalicPINVOKE.Actor_Property_COLOR_get();
58     public static readonly int ColorRed = NDalicPINVOKE.Actor_Property_COLOR_RED_get();
59     public static readonly int ColorGreeb = NDalicPINVOKE.Actor_Property_COLOR_GREEN_get();
60     public static readonly int ColorBlue = NDalicPINVOKE.Actor_Property_COLOR_BLUE_get();
61     public static readonly int ColorAlpha = NDalicPINVOKE.Actor_Property_COLOR_ALPHA_get();
62     public static readonly int WorldColor = NDalicPINVOKE.Actor_Property_WORLD_COLOR_get();
63     public static readonly int WorldMatrix = NDalicPINVOKE.Actor_Property_WORLD_MATRIX_get();
64     public static readonly int Name = NDalicPINVOKE.Actor_Property_NAME_get();
65     public static readonly int Sensitive = NDalicPINVOKE.Actor_Property_SENSITIVE_get();
66     public static readonly int LeaveRequired = NDalicPINVOKE.Actor_Property_LEAVE_REQUIRED_get();
67     public static readonly int InheritOrientation = NDalicPINVOKE.Actor_Property_INHERIT_ORIENTATION_get();
68     public static readonly int InheritScale = NDalicPINVOKE.Actor_Property_INHERIT_SCALE_get();
69     public static readonly int ColorMode = NDalicPINVOKE.Actor_Property_COLOR_MODE_get();
70     public static readonly int PositionInheritance = NDalicPINVOKE.Actor_Property_POSITION_INHERITANCE_get();
71     public static readonly int DrawMode = NDalicPINVOKE.Actor_Property_DRAW_MODE_get();
72     public static readonly int SizeModeFactor = NDalicPINVOKE.Actor_Property_SIZE_MODE_FACTOR_get();
73     public static readonly int WidthResizePolicy = NDalicPINVOKE.Actor_Property_WIDTH_RESIZE_POLICY_get();
74     public static readonly int HeightResizePolicy = NDalicPINVOKE.Actor_Property_HEIGHT_RESIZE_POLICY_get();
75     public static readonly int SizeScalePolicy = NDalicPINVOKE.Actor_Property_SIZE_SCALE_POLICY_get();
76     public static readonly int WidthForHeight = NDalicPINVOKE.Actor_Property_WIDTH_FOR_HEIGHT_get();
77     public static readonly int HeightForWidth = NDalicPINVOKE.Actor_Property_HEIGHT_FOR_WIDTH_get();
78     public static readonly int Padding = NDalicPINVOKE.Actor_Property_PADDING_get();
79     public static readonly int MinimumSize = NDalicPINVOKE.Actor_Property_MINIMUM_SIZE_get();
80     public static readonly int MaximumSize = NDalicPINVOKE.Actor_Property_MAXIMUM_SIZE_get();
81     public static readonly int InheritPosition = NDalicPINVOKE.Actor_Property_INHERIT_POSITION_get();
82     public static readonly int ClippingMode = NDalicPINVOKE.Actor_Property_CLIPPING_MODE_get();
83     public static readonly int BatchParent = NDalicPINVOKE.Actor_Property_BATCH_PARENT_get();
84
85
86     /**
87       * @brief Event arguments that passed via Finished signal
88       *
89       */
90     public class FinishedEventArgs : EventArgs
91     {
92       private Animation _animation;
93
94       /**
95         * @brief Animation - is the Animation which has finished with the animation.
96         *
97         */
98       public Animation Animation
99       {
100         get
101         {
102           return _animation;
103         }
104         set
105         {
106           _animation = value;
107         }
108       }
109     }
110
111     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
112     private delegate void FinishedEventCallbackDelegate(IntPtr Animation);
113     private DaliEventHandler<object,FinishedEventArgs> _animationFinishedEventHandler;
114     private FinishedEventCallbackDelegate _animationFinishedEventCallbackDelegate;
115
116     /**
117       * @brief Event for Finished signal which can be used to subscribe/unsubscribe the event handler
118       * (in the type of FinishedEventHandler - DaliEventHandler<object,FinishedEventArgs>) provided by the user.
119       * Finished signal is emitted when an Animation's animations have finished.
120       */
121     public event DaliEventHandler<object,FinishedEventArgs> Finished
122     {
123       add
124       {
125         lock(this)
126         {
127           // Restricted to only one listener
128           if (_animationFinishedEventHandler == null)
129           {
130             _animationFinishedEventHandler += value;
131
132             _animationFinishedEventCallbackDelegate = new FinishedEventCallbackDelegate(OnFinished);
133             this.FinishedSignal().Connect(_animationFinishedEventCallbackDelegate);
134           }
135         }
136       }
137
138       remove
139       {
140         lock(this)
141         {
142           if (_animationFinishedEventHandler != null)
143           {
144             this.FinishedSignal().Disconnect(_animationFinishedEventCallbackDelegate);
145           }
146
147           _animationFinishedEventHandler -= value;
148         }
149       }
150     }
151
152     // Callback for Animation FinishedSignal
153     private void OnFinished(IntPtr data)
154     {
155       FinishedEventArgs e = new FinishedEventArgs();
156
157       // Populate all members of "e" (FinishedEventArgs) with real data
158       e.Animation = Animation.GetAnimationFromPtr(data);
159
160       if (_animationFinishedEventHandler != null)
161       {
162         //here we send all data to user event handlers
163         _animationFinishedEventHandler(this, e);
164       }
165     }
166
167
168   public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
169     ClassName ret = new ClassName(cPtr, false);
170     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171     return ret;
172   }
173
174
175   public float Duration
176   {
177     set
178     {
179        SetDuration(value);
180     }
181     get
182     {
183        float ret = GetDuration();
184        return ret;
185     }
186   }
187
188   public int DurationMilliSecs
189   {
190     set
191     {
192       SetDuration(value/1000);
193     }
194     get
195     {
196       int ret = (int) GetDuration() * 1000;
197       return ret;
198     }
199   }
200
201   public AlphaFunction DefaultAlphaFunction
202   {
203     set
204     {
205        SetDefaultAlphaFunction(value);
206     }
207     get
208     {
209        AlphaFunction ret = GetDefaultAlphaFunction();
210        return ret;
211     }
212   }
213
214   public Animation.State Status
215   {
216     get
217     {
218        Animation.State ret = GetState();
219        return ret;
220     }
221   }
222
223   public int LoopCount
224   {
225     set
226     {
227       SetLoopCount(value);
228     }
229     get
230     {
231       int ret = GetLoopCount();
232       return ret;
233     }
234   }
235
236   public bool Looping
237   {
238     set
239     {
240       SetLooping(value);
241     }
242     get
243     {
244       bool ret = IsLooping();
245       return ret;
246     }
247   }
248
249   public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue)
250   {
251         dynamic var = (object)(propertyIndex);
252         dynamic obj = (object)(relativeValue);
253         AnimateBy(new Property(target, var), new Property.Value(obj));
254   }
255
256   public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, AlphaFunction alpha)
257   {
258         dynamic var = (object)(propertyIndex);
259         dynamic obj = (object)(relativeValue);
260         AnimateBy(new Property(target, var), new Property.Value(obj),  alpha);
261   }
262
263   public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, TimePeriod period)
264   {
265         dynamic var = (object)(propertyIndex);
266         dynamic obj = (object)(relativeValue);
267         AnimateBy(new Property(target, var), new Property.Value(obj), period);
268   }
269
270   public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, AlphaFunction alpha, TimePeriod period)
271   {
272         dynamic var = (object)(propertyIndex);
273         dynamic obj = (object)(relativeValue);
274         AnimateBy(new Property(target, var), new Property.Value(obj), alpha, period);
275   }
276
277   public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue)
278   {
279         dynamic var = (object)(propertyIndex);
280         dynamic obj = (object)(destinationValue);
281         AnimateTo(new Property(target, var), new Property.Value(obj));
282   }
283
284   public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, AlphaFunction alpha)
285   {
286         dynamic var = (object)(propertyIndex);
287         dynamic obj = (object)(destinationValue);
288         AnimateTo(new Property(target, var), new Property.Value(obj), alpha);
289   }
290
291   public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, TimePeriod period)
292   {
293         dynamic var = (object)(propertyIndex);
294         dynamic obj = (object)(destinationValue);
295         AnimateTo(new Property(target, var), new Property.Value(obj), period);
296   }
297
298   public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, AlphaFunction alpha, TimePeriod period)
299   {
300         dynamic var = (object)(propertyIndex);
301         dynamic obj = (object)(destinationValue);
302         AnimateTo(new Property(target, var), new Property.Value(obj), alpha, period);
303   }
304
305   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames)
306   {
307         dynamic var = (object)(propertyIndex);
308         AnimateBetween(new Property(target, var), keyFrames);
309   }
310
311   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, Animation.Interpolation interpolation)
312   {
313         dynamic var = (object)(propertyIndex);
314         AnimateBetween(new Property(target, var), keyFrames, interpolation);
315   }
316
317   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha)
318   {
319         dynamic var = (object)(propertyIndex);
320         AnimateBetween(new Property(target, var), keyFrames, alpha);
321   }
322
323   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
324   {
325         dynamic var = (object)(propertyIndex);
326         AnimateBetween(new Property(target, var), keyFrames, alpha, interpolation);
327   }
328
329   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, TimePeriod period)
330   {
331         dynamic var = (object)(propertyIndex);
332         AnimateBetween(new Property(target, var), keyFrames, period);
333   }
334
335   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, TimePeriod period, Animation.Interpolation interpolation)
336   {
337         dynamic var = (object)(propertyIndex);
338         AnimateBetween(new Property(target, var), keyFrames,  period, interpolation);
339   }
340
341   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
342   {
343         dynamic var = (object)(propertyIndex);
344         AnimateBetween(new Property(target, var), keyFrames, alpha, period);
345   }
346
347   public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
348   {
349         dynamic var = (object)(propertyIndex);
350         AnimateBetween(new Property(target, var), keyFrames, alpha, period, interpolation);
351   }
352
353   public void Stop(Animation.EndAction action) {
354     SetEndAction(action);
355     NDalicPINVOKE.Animation_Stop(swigCPtr);
356     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357   }
358
359   /**
360    * @brief Create an initialized Animation.
361    *
362    * The animation will not loop.
363    * The default end action is "Bake".
364    * The default Alpha function is linear.
365    * @since 1.0.0
366    * @param [in] durationmSeconds The duration in milli seconds (int).
367    * @return A handle to a newly allocated Dali resource.
368    * @pre DurationmSeconds must be greater than zero.
369    */
370   public Animation (int durationmSeconds) : this (NDalicPINVOKE.Animation_New((float)durationmSeconds/1000.0f), true) {
371     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372   }
373 %}
374
375 %enddef
376
377
378 %define DALI_animation_EVENTHANDLER_PARAM( NameSpace, ClassName)
379   Animation_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
380   Animation_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
381   %enddef
382
383   namespace Dali
384 {
385   DALI_animation_EVENTHANDLER_PARAM( Dali, Animation);
386 }