diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-24 20:45:52 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-10-12 21:03:49 +0900 |
commit | 5038223b61526419e7b3d0c2c8b996666a2fb1c6 (patch) | |
tree | a5643a263dc86367574854c14b99e1d746db3bfe /src/lib/evas | |
parent | 72f1fbf4f1eddbc1cde4455081be4f3a9b8a1a44 (diff) |
efl_animation: Add efl_animation
Efl.Animation is a class which contains basic properties of animation
for Efl.Canvas.Object.
Diffstat (limited to 'src/lib/evas')
-rw-r--r-- | src/lib/evas/Evas_Common.h | 7 | ||||
-rw-r--r-- | src/lib/evas/Evas_Eo.h | 5 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation.c | 107 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation.eo | 43 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_private.h | 31 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_types.eot | 2 |
6 files changed, 195 insertions, 0 deletions
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 72ec2b9dfc..d97b856208 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h | |||
@@ -3330,6 +3330,13 @@ EAPI const Eina_List *evas_font_path_global_list(void) EINA_WARN_UNUSED_R | |||
3330 | */ | 3330 | */ |
3331 | EAPI void evas_font_reinit(void); | 3331 | EAPI void evas_font_reinit(void); |
3332 | 3332 | ||
3333 | #ifndef _EFL_ANIMATION_EO_CLASS_TYPE | ||
3334 | #define _EFL_ANIMATION_EO_CLASS_TYPE | ||
3335 | |||
3336 | typedef Eo Efl_Animation; | ||
3337 | |||
3338 | #endif | ||
3339 | |||
3333 | /** | 3340 | /** |
3334 | * @} | 3341 | * @} |
3335 | */ | 3342 | */ |
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 24a4047eb8..b81a6ad6fa 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h | |||
@@ -51,7 +51,12 @@ | |||
51 | * @} | 51 | * @} |
52 | */ | 52 | */ |
53 | 53 | ||
54 | #include "canvas/efl_animation_types.eot.h" | ||
55 | |||
54 | #include "canvas/efl_canvas_object.eo.h" | 56 | #include "canvas/efl_canvas_object.eo.h" |
57 | |||
58 | #include "canvas/efl_animation.eo.h" | ||
59 | |||
55 | #endif /* EFL_EO_API_SUPPORT */ | 60 | #endif /* EFL_EO_API_SUPPORT */ |
56 | 61 | ||
57 | #if defined(EFL_BETA_API_SUPPORT) && defined(EFL_EO_API_SUPPORT) | 62 | #if defined(EFL_BETA_API_SUPPORT) && defined(EFL_EO_API_SUPPORT) |
diff --git a/src/lib/evas/canvas/efl_animation.c b/src/lib/evas/canvas/efl_animation.c new file mode 100644 index 0000000000..92bef8feee --- /dev/null +++ b/src/lib/evas/canvas/efl_animation.c | |||
@@ -0,0 +1,107 @@ | |||
1 | #include "efl_animation_private.h" | ||
2 | |||
3 | static void | ||
4 | _target_del_cb(void *data, const Efl_Event *event EINA_UNUSED) | ||
5 | { | ||
6 | Eo *eo_obj = data; | ||
7 | |||
8 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); | ||
9 | EFL_ANIMATION_DATA_GET(eo_obj, pd); | ||
10 | |||
11 | pd->target = NULL; | ||
12 | } | ||
13 | |||
14 | EOLIAN static void | ||
15 | _efl_animation_target_set(Eo *eo_obj, | ||
16 | Efl_Animation_Data *pd, | ||
17 | Efl_Canvas_Object *target) | ||
18 | { | ||
19 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); | ||
20 | |||
21 | efl_event_callback_add(target, EFL_EVENT_DEL, _target_del_cb, eo_obj); | ||
22 | |||
23 | pd->target = target; | ||
24 | } | ||
25 | |||
26 | EOLIAN static Efl_Canvas_Object * | ||
27 | _efl_animation_target_get(Eo *eo_obj, Efl_Animation_Data *pd) | ||
28 | { | ||
29 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, NULL); | ||
30 | |||
31 | return pd->target; | ||
32 | } | ||
33 | |||
34 | EOLIAN static void | ||
35 | _efl_animation_duration_set(Eo *eo_obj, | ||
36 | Efl_Animation_Data *pd, | ||
37 | double duration) | ||
38 | { | ||
39 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); | ||
40 | |||
41 | pd->duration = duration; | ||
42 | } | ||
43 | |||
44 | EOLIAN static double | ||
45 | _efl_animation_duration_get(Eo *eo_obj, Efl_Animation_Data *pd) | ||
46 | { | ||
47 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, 0.0); | ||
48 | |||
49 | return pd->duration; | ||
50 | } | ||
51 | |||
52 | EOLIAN static Eina_Bool | ||
53 | _efl_animation_is_deleted(Eo *eo_obj, Efl_Animation_Data *pd) | ||
54 | { | ||
55 | EINA_SAFETY_ON_NULL_RETURN_VAL(eo_obj, EINA_TRUE); | ||
56 | |||
57 | return pd->is_deleted; | ||
58 | } | ||
59 | |||
60 | EOLIAN static void | ||
61 | _efl_animation_final_state_keep_set(Eo *eo_obj, | ||
62 | Efl_Animation_Data *pd, | ||
63 | Eina_Bool keep_final_state) | ||
64 | { | ||
65 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); | ||
66 | |||
67 | if (pd->keep_final_state == keep_final_state) return; | ||
68 | |||
69 | pd->keep_final_state = !!keep_final_state; | ||
70 | } | ||
71 | |||
72 | EOLIAN static Eina_Bool | ||
73 | _efl_animation_final_state_keep_get(Eo *eo_obj, Efl_Animation_Data *pd) | ||
74 | { | ||
75 | EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, EINA_FALSE); | ||
76 | |||
77 | return pd->keep_final_state; | ||
78 | } | ||
79 | |||
80 | EOLIAN static Efl_Object * | ||
81 | _efl_animation_efl_object_constructor(Eo *eo_obj, | ||
82 | Efl_Animation_Data *pd) | ||
83 | { | ||
84 | eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); | ||
85 | |||
86 | pd->target = NULL; | ||
87 | |||
88 | pd->duration = 0.0; | ||
89 | |||
90 | pd->is_deleted = EINA_FALSE; | ||
91 | pd->keep_final_state = EINA_FALSE; | ||
92 | |||
93 | return eo_obj; | ||
94 | } | ||
95 | |||
96 | EOLIAN static void | ||
97 | _efl_animation_efl_object_destructor(Eo *eo_obj, Efl_Animation_Data *pd) | ||
98 | { | ||
99 | pd->is_deleted = EINA_TRUE; | ||
100 | |||
101 | if (pd->target) | ||
102 | efl_event_callback_del(pd->target, EFL_EVENT_DEL, _target_del_cb, eo_obj); | ||
103 | |||
104 | efl_destructor(efl_super(eo_obj, MY_CLASS)); | ||
105 | } | ||
106 | |||
107 | #include "efl_animation.eo.c" | ||
diff --git a/src/lib/evas/canvas/efl_animation.eo b/src/lib/evas/canvas/efl_animation.eo new file mode 100644 index 0000000000..67da77c0f9 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation.eo | |||
@@ -0,0 +1,43 @@ | |||
1 | import efl_animation_types; | ||
2 | |||
3 | class Efl.Animation (Efl.Object) | ||
4 | { | ||
5 | [[Efl animation class]] | ||
6 | data: Efl_Animation_Data; | ||
7 | methods { | ||
8 | @property target { | ||
9 | set { | ||
10 | } | ||
11 | get { | ||
12 | } | ||
13 | values { | ||
14 | target: Efl.Canvas.Object; [[Target object which is applied animation.]] | ||
15 | } | ||
16 | } | ||
17 | @property final_state_keep { | ||
18 | set { | ||
19 | } | ||
20 | get { | ||
21 | } | ||
22 | values { | ||
23 | keep_final_state: bool; [[$true to keep final state, $false otherwise.]] | ||
24 | } | ||
25 | } | ||
26 | @property duration { | ||
27 | set { | ||
28 | } | ||
29 | get { | ||
30 | } | ||
31 | values { | ||
32 | duration: double; [[Duration value.]] | ||
33 | } | ||
34 | } | ||
35 | is_deleted @protected { | ||
36 | return: bool; [[$true if animation is deleted, $false otherwise.]] | ||
37 | } | ||
38 | } | ||
39 | implements { | ||
40 | Efl.Object.constructor; | ||
41 | Efl.Object.destructor; | ||
42 | } | ||
43 | } | ||
diff --git a/src/lib/evas/canvas/efl_animation_private.h b/src/lib/evas/canvas/efl_animation_private.h new file mode 100644 index 0000000000..44c48a0b88 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_private.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #define EFL_ANIMATION_PROTECTED | ||
2 | |||
3 | #include "evas_common_private.h" | ||
4 | |||
5 | #define MY_CLASS EFL_ANIMATION_CLASS | ||
6 | #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) | ||
7 | |||
8 | typedef struct _Efl_Animation_Data | ||
9 | { | ||
10 | Efl_Canvas_Object *target; | ||
11 | |||
12 | double duration; | ||
13 | |||
14 | Eina_Bool is_deleted : 1; | ||
15 | Eina_Bool keep_final_state : 1; | ||
16 | } Efl_Animation_Data; | ||
17 | |||
18 | #define EFL_ANIMATION_CHECK_OR_RETURN(anim, ...) \ | ||
19 | do { \ | ||
20 | if (!anim) { \ | ||
21 | CRI("Efl_Animation " # anim " is NULL!"); \ | ||
22 | return __VA_ARGS__; \ | ||
23 | } \ | ||
24 | if (efl_animation_is_deleted(anim)) { \ | ||
25 | ERR("Efl_Animation " # anim " has already been deleted!"); \ | ||
26 | return __VA_ARGS__; \ | ||
27 | } \ | ||
28 | } while (0) | ||
29 | |||
30 | #define EFL_ANIMATION_DATA_GET(o, pd) \ | ||
31 | Efl_Animation_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_CLASS) | ||
diff --git a/src/lib/evas/canvas/efl_animation_types.eot b/src/lib/evas/canvas/efl_animation_types.eot new file mode 100644 index 0000000000..f9047e3061 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_types.eot | |||
@@ -0,0 +1,2 @@ | |||
1 | // ---------------------------------------------------------------------------- | ||
2 | // All the below types are for Efl Animation | ||