Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / TransitEffect.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18 using System.Collections.Generic;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// The axis along which flip effect should be applied.
24     /// </summary>
25     public enum FlipAxis
26     {
27         /// <summary>
28         /// Flip on X axis
29         /// </summary>
30         X,
31
32         /// <summary>
33         /// Flip on Y axis
34         /// </summary>
35         Y,
36     }
37
38     /// <summary>
39     /// The direction in which the wipe effect should occur.
40     /// </summary>
41     public enum WipeDirection
42     {
43         /// <summary>
44         /// Wipe to the left
45         /// </summary>
46         Left,
47
48         /// <summary>
49         /// Wipe to the right
50         /// </summary>
51         Right,
52
53         /// <summary>
54         /// Wipe to the up
55         /// </summary>
56         Up,
57
58         /// <summary>
59         /// Wipe to the down
60         /// </summary>
61         Down,
62     }
63
64     /// <summary>
65     /// Whether the wipe effect should show or hide the object.
66     /// </summary>
67     public enum WipeType
68     {
69         /// <summary>
70         /// Hide the object during the animation
71         /// </summary>
72         Hide,
73
74         /// <summary>
75         /// Show the object during the animation
76         /// </summary>
77         Show,
78     }
79
80     /// <summary>
81     /// The type of acceleration used in the transition.
82     /// </summary>
83     public enum TweenMode
84     {
85         /// <summary>
86         /// Constant speed
87         /// </summary>
88         Linear,
89
90         /// <summary>
91         /// Starts slow, increase speed over time, then decrease again and stop slowly, v1 being a power factor
92         /// </summary>
93         Sinusoidal,
94
95         /// <summary>
96         /// Starts fast and decrease speed over time, v1 being a power factor
97         /// </summary>
98         Decelerate,
99
100         /// <summary>
101         /// Starts slow and increase speed over time, v1 being a power factor
102         /// </summary>
103         Accelerate,
104
105         /// <summary>
106         /// Start at gradient v1, interpolated via power of v2 curve
107         /// </summary>
108         DivisorInterpolate,
109
110         /// <summary>
111         /// Start at 0.0 then "drop" like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1
112         /// </summary>
113         Bounce,
114
115         /// <summary>
116         /// Start at 0.0 then "wobble" like a spring rest position 1.0, and wobble v2 times, with decay factor of v1
117         /// </summary>
118         Spring,
119
120         /// <summary>
121         /// Follow the cubic-bezier curve calculated with the control points (x1, y1), (x2, y2)
122         /// </summary>
123         BezierCurve,
124     }
125
126     /// <summary>
127     /// Blend effect class.
128     /// </summary>
129     public class BlendEffect : EffectBase
130     {
131         /// <summary>
132         /// Creates and initializes a new instance of BlendEffect class.
133         /// </summary>
134         public BlendEffect()
135         {
136         }
137
138         internal override IntPtr CreateEffect(IntPtr transit)
139         {
140             return Interop.Elementary.elm_transit_effect_blend_add(transit);
141         }
142     }
143
144     /// <summary>
145     /// Color effect class.
146     /// </summary>
147     public class ColorEffect : EffectBase
148     {
149         Color _begin;
150         Color _end;
151
152         /// <summary>
153         /// Creates and initializes a new instance of ColorEffect class.
154         /// </summary>
155         /// <param name="beginColor">The begin color of the effect</param>
156         /// <param name="endColor">The end color of the effect</param>
157         public ColorEffect(Color beginColor, Color endColor)
158         {
159             _begin = beginColor;
160             _end = endColor;
161         }
162
163         /// <summary>
164         /// The begin color of the effect
165         /// </summary>
166         public Color BeginColor
167         {
168             get { return _begin; }
169         }
170
171         /// <summary>
172         /// The end color of the effect
173         /// </summary>
174         public Color EndColor
175         {
176             get { return _end; }
177         }
178
179         internal override IntPtr CreateEffect(IntPtr transit)
180         {
181             return Interop.Elementary.elm_transit_effect_color_add(transit, _begin.R, _begin.G, _begin.B, _begin.A, _end.R, _end.G, _end.B, _end.A);
182         }
183     }
184
185     /// <summary>
186     /// Fade effect class.
187     /// </summary>
188     public class FadeEffect : EffectBase
189     {
190         /// <summary>
191         /// Creates and initializes a new instance of FadeEffect class.
192         /// </summary>
193         public FadeEffect()
194         {
195         }
196
197         internal override IntPtr CreateEffect(IntPtr transit)
198         {
199             return Interop.Elementary.elm_transit_effect_fade_add(transit);
200         }
201     }
202
203     /// <summary>
204     /// Flip effect class.
205     /// </summary>
206     public class FlipEffect : EffectBase
207     {
208         FlipAxis _axis;
209         bool _clockWise;
210         bool _resizable;
211
212         /// <summary>
213         /// Creates and initializes a new instance of FlipEffect class.
214         /// </summary>
215         /// <param name="axis">Flipping Axis(X or Y).</param>
216         /// <param name="clockWise">Flipping Direction. True is clock-wise.</param>
217         /// <param name="resizable">Resizable effect with FlipEffect</param>
218         public FlipEffect(FlipAxis axis, bool clockWise, bool resizable = false)
219         {
220             _axis = axis;
221             _clockWise = clockWise;
222             _resizable = resizable;
223         }
224
225         /// <summary>
226         /// Flipping Axis(X or Y).
227         /// </summary>
228         public FlipAxis Axis
229         {
230             get { return _axis; }
231         }
232
233         /// <summary>
234         /// Flipping Direction. True is clock-wise.
235         /// </summary>
236         public bool ClockWise
237         {
238             get { return _clockWise; }
239         }
240
241         /// <summary>
242         /// Resizable FlipEffect.
243         /// </summary>
244         public bool Resizable
245         {
246             get { return _resizable; }
247         }
248
249         internal override IntPtr CreateEffect(IntPtr transit)
250         {
251             if (_resizable)
252                 return Interop.Elementary.elm_transit_effect_resizable_flip_add(transit, (int)_axis, _clockWise);
253             return Interop.Elementary.elm_transit_effect_flip_add(transit, (int)_axis, _clockWise);
254         }
255     }
256
257     /// <summary>
258     /// Resizing effect class.
259     /// </summary>
260     public class ResizingEffect : EffectBase
261     {
262         Size _begin;
263         Size _end;
264
265         /// <summary>
266         /// Creates and initializes a new instance of FlipEffect class.
267         /// </summary>
268         /// <param name="beginSize">The begin Size of the effect</param>
269         /// <param name="endSize">The end Size of the effect</param>
270         public ResizingEffect(Size beginSize, Size endSize)
271         {
272             _begin = beginSize;
273             _end = endSize;
274         }
275
276         /// <summary>
277         /// The begin Size of the effect
278         /// </summary>
279         public Size BeginSize
280         {
281             get { return _begin; }
282         }
283
284         /// <summary>
285         /// The end Size of the effect
286         /// </summary>
287         public Size EndSize
288         {
289             get { return _end; }
290         }
291
292         internal override IntPtr CreateEffect(IntPtr transit)
293         {
294             return Interop.Elementary.elm_transit_effect_resizing_add(transit, _begin.Width, _begin.Height, _end.Width, _end.Height);
295         }
296     }
297
298     /// <summary>
299     /// Rotation effect class.
300     /// </summary>
301     public class RotationEffect : EffectBase
302     {
303         float _begin;
304         float _end;
305
306         /// <summary>
307         /// Creates and initializes a new instance of RotationEffect class.
308         /// </summary>
309         /// <param name="beginDegree">The begin degree of the effect</param>
310         /// <param name="endDegree">The end degree of the effect</param>
311         public RotationEffect(float beginDegree, float endDegree)
312         {
313             _begin = beginDegree;
314             _end = endDegree;
315         }
316
317         /// <summary>
318         /// The begin degree of the effect
319         /// </summary>
320         public float BeginDegree
321         {
322             get { return _begin; }
323         }
324
325         /// <summary>
326         /// The end degree of the effect
327         /// </summary>
328         public float EndDegree
329         {
330             get { return _end; }
331         }
332
333         internal override IntPtr CreateEffect(IntPtr transit)
334         {
335             return Interop.Elementary.elm_transit_effect_rotation_add(transit, _begin, _end);
336         }
337     }
338
339     /// <summary>
340     /// Translation effect class.
341     /// </summary>
342     public class TranslationEffect : EffectBase
343     {
344         Point _begin;
345         Point _end;
346
347         /// <summary>
348         /// Creates and initializes a new instance of FlipEffect class.
349         /// </summary>
350         /// <param name="beginPoint">The begin Point of the effect</param>
351         /// <param name="endPoint">The end Point of the effect</param>
352         public TranslationEffect(Point beginPoint, Point endPoint)
353         {
354             _begin = beginPoint;
355             _end = endPoint;
356         }
357
358         /// <summary>
359         /// The begin Point of the effect
360         /// </summary>
361         public Point BeginPoint
362         {
363             get { return _begin; }
364         }
365
366         /// <summary>
367         /// The end Point of the effect
368         /// </summary>
369         public Point EndPoint
370         {
371             get { return _end; }
372         }
373
374         internal override IntPtr CreateEffect(IntPtr transit)
375         {
376             return Interop.Elementary.elm_transit_effect_translation_add(transit, _begin.X, _begin.Y, _end.X, _end.Y);
377         }
378     }
379
380     /// <summary>
381     /// Wipe effect class.
382     /// </summary>
383     public class WipeEffect : EffectBase
384     {
385         WipeType _type;
386         WipeDirection _direction;
387
388         /// <summary>
389         /// Creates and initializes a new instance of WipeEffect class.
390         /// </summary>
391         /// <param name="type">Wipe type. Hide or show.</param>
392         /// <param name="direction">Wipe Direction.</param>
393         public WipeEffect(WipeType type, WipeDirection direction)
394         {
395             _type = type;
396             _direction = direction;
397         }
398
399         /// <summary>
400         /// Wipe type. Hide or show.
401         /// </summary>
402         public WipeType Type
403         {
404             get { return _type; }
405         }
406
407         /// <summary>
408         /// Wipe Direction.
409         /// </summary>
410         public WipeDirection Direction
411         {
412             get { return _direction; }
413         }
414
415         internal override IntPtr CreateEffect(IntPtr transit)
416         {
417             return Interop.Elementary.elm_transit_effect_wipe_add(transit, (int)_type, (int)_direction);
418         }
419     }
420
421     /// <summary>
422     /// Zoom effect class.
423     /// </summary>
424     public class ZoomEffect : EffectBase
425     {
426         float _begin;
427         float _end;
428
429         /// <summary>
430         /// Creates and initializes a new instance of ZoomEffect class.
431         /// </summary>
432         /// <param name="beginRate">The begin rate of the effect</param>
433         /// <param name="endRate">The end rate of the effect</param>
434         public ZoomEffect(float beginRate, float endRate)
435         {
436             _begin = beginRate;
437             _end = endRate;
438         }
439
440         /// <summary>
441         /// The begin rate of the effect
442         /// </summary>
443         public float BeginRate
444         {
445             get { return _begin; }
446         }
447
448         /// <summary>
449         /// The end rate of the effect
450         /// </summary>
451         public float EndRate
452         {
453             get { return _end; }
454         }
455
456         internal override IntPtr CreateEffect(IntPtr transit)
457         {
458             return Interop.Elementary.elm_transit_effect_zoom_add(transit, _begin, _end);
459         }
460     }
461 }