summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 17:17:24 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-12 21:03:49 +0900
commit861a90415c6b41c02a2599f4b2deb50f254dba02 (patch)
tree17f7aae6e1545494c90e9f765c33e927b80911c7 /src
parente1a73fffb9a8e3ededcf4a06c47b034536c33e9c (diff)
efl_animation: Add group animation object
Diffstat (limited to '')
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/lib/evas/Evas_Common.h8
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/Evas_Internal.h7
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group.c188
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group.eo13
-rw-r--r--src/lib/evas/canvas/efl_animation_object_group_private.h26
7 files changed, 247 insertions, 1 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 68c1b1817a..96f133e0c2 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -55,6 +55,7 @@ evas_eolian_pub_files = \
55 lib/evas/canvas/efl_animation_object_rotate.eo \ 55 lib/evas/canvas/efl_animation_object_rotate.eo \
56 lib/evas/canvas/efl_animation_object_scale.eo \ 56 lib/evas/canvas/efl_animation_object_scale.eo \
57 lib/evas/canvas/efl_animation_object_translate.eo \ 57 lib/evas/canvas/efl_animation_object_translate.eo \
58 lib/evas/canvas/efl_animation_object_group.eo \
58 $(NULL) 59 $(NULL)
59 60
60evas_eolian_legacy_files = \ 61evas_eolian_legacy_files = \
@@ -143,7 +144,8 @@ lib/evas/canvas/efl_animation_object_private.h \
143lib/evas/canvas/efl_animation_object_alpha_private.h \ 144lib/evas/canvas/efl_animation_object_alpha_private.h \
144lib/evas/canvas/efl_animation_object_rotate_private.h \ 145lib/evas/canvas/efl_animation_object_rotate_private.h \
145lib/evas/canvas/efl_animation_object_scale_private.h \ 146lib/evas/canvas/efl_animation_object_scale_private.h \
146lib/evas/canvas/efl_animation_object_translate_private.h 147lib/evas/canvas/efl_animation_object_translate_private.h \
148lib/evas/canvas/efl_animation_object_group_private.h
147 149
148# Linebreak 150# Linebreak
149 151
@@ -240,6 +242,7 @@ lib/evas/canvas/efl_animation_object_alpha.c \
240lib/evas/canvas/efl_animation_object_rotate.c \ 242lib/evas/canvas/efl_animation_object_rotate.c \
241lib/evas/canvas/efl_animation_object_scale.c \ 243lib/evas/canvas/efl_animation_object_scale.c \
242lib/evas/canvas/efl_animation_object_translate.c \ 244lib/evas/canvas/efl_animation_object_translate.c \
245lib/evas/canvas/efl_animation_object_group.c \
243$(NULL) 246$(NULL)
244 247
245EXTRA_DIST2 += \ 248EXTRA_DIST2 += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 7c39fb21df..79f2f4c08a 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3407,12 +3407,20 @@ typedef Eo Efl_Animation_Object_Translate;
3407 3407
3408#endif 3408#endif
3409 3409
3410#ifndef _EFL_ANIMATION_OBJECT_GROUP_EO_CLASS_TYPE
3411#define _EFL_ANIMATION_OBJECT_GROUP_EO_CLASS_TYPE
3412
3413typedef Eo Efl_Animation_Object_Group;
3414
3415#endif
3416
3410struct _Efl_Animation_Object_Running_Event_Info 3417struct _Efl_Animation_Object_Running_Event_Info
3411{ 3418{
3412 double progress; 3419 double progress;
3413}; 3420};
3414 3421
3415#define EFL_ANIMATION_GROUP_DURATION_NONE -1 3422#define EFL_ANIMATION_GROUP_DURATION_NONE -1
3423#define EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE -1
3416 3424
3417/** 3425/**
3418 * @} 3426 * @}
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 6f52e0c809..b0a2d25924 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -66,6 +66,7 @@
66#include "canvas/efl_animation_object_rotate.eo.h" 66#include "canvas/efl_animation_object_rotate.eo.h"
67#include "canvas/efl_animation_object_scale.eo.h" 67#include "canvas/efl_animation_object_scale.eo.h"
68#include "canvas/efl_animation_object_translate.eo.h" 68#include "canvas/efl_animation_object_translate.eo.h"
69#include "canvas/efl_animation_object_group.eo.h"
69 70
70#endif /* EFL_EO_API_SUPPORT */ 71#endif /* EFL_EO_API_SUPPORT */
71 72
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index a406abc5e7..721eba618d 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -131,6 +131,13 @@ EOAPI void efl_animation_object_translate_absolute_set(Eo *obj, int from_x, int
131EOAPI void efl_animation_object_translate_absolute_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y); 131EOAPI void efl_animation_object_translate_absolute_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y);
132/* Efl.Animation.Object.Translate END */ 132/* Efl.Animation.Object.Translate END */
133 133
134/* Efl.Animation.Object.Group */
135EOAPI void efl_animation_object_group_object_add(Eo *obj, Efl_Animation_Object *anim_obj);
136EOAPI void efl_animation_object_group_object_del(Eo *obj, Efl_Animation_Object *anim_obj);
137
138EOAPI Eina_List *efl_animation_object_group_objects_get(Eo *obj);
139/* Efl.Animation.Object.Group END */
140
134#ifdef __cplusplus 141#ifdef __cplusplus
135} 142}
136#endif 143#endif
diff --git a/src/lib/evas/canvas/efl_animation_object_group.c b/src/lib/evas/canvas/efl_animation_object_group.c
new file mode 100644
index 0000000000..d3799b40ca
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group.c
@@ -0,0 +1,188 @@
1#include "efl_animation_object_group_private.h"
2
3EOLIAN static void
4_efl_animation_object_group_object_add(Eo *eo_obj,
5 Efl_Animation_Object_Group_Data *pd,
6 Efl_Animation_Object *anim_obj)
7{
8 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
9
10 if (!anim_obj) return;
11
12 Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
13 if (target)
14 efl_animation_object_target_set(anim_obj, target);
15
16 double duration = efl_animation_object_duration_get(eo_obj);
17 /* if group animation object duration is available value, then the duration
18 * is propagated to its child. */
19 if (duration != EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE)
20 efl_animation_object_duration_set(anim_obj, duration);
21
22 Eina_Bool state_keep = efl_animation_object_final_state_keep_get(eo_obj);
23 efl_animation_object_final_state_keep_set(anim_obj, state_keep);
24
25 pd->anim_objs = eina_list_append(pd->anim_objs, anim_obj);
26}
27
28EOLIAN static void
29_efl_animation_object_group_object_del(Eo *eo_obj,
30 Efl_Animation_Object_Group_Data *pd,
31 Efl_Animation_Object *anim_obj)
32{
33 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
34
35 if (!anim_obj) return;
36
37 pd->anim_objs = eina_list_remove(pd->anim_objs, anim_obj);
38}
39
40EOLIAN static Eina_List *
41_efl_animation_object_group_objects_get(Eo *eo_obj,
42 Efl_Animation_Object_Group_Data *pd)
43{
44 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj, NULL);
45
46 return pd->anim_objs;
47}
48
49EOLIAN static void
50_efl_animation_object_group_efl_animation_object_target_set(Eo *eo_obj,
51 Efl_Animation_Object_Group_Data *pd,
52 Efl_Canvas_Object *target)
53{
54 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
55
56 Eina_List *l;
57 Efl_Animation_Object *anim_obj;
58
59 EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
60 {
61 efl_animation_object_target_set(anim_obj, target);
62 }
63
64 efl_animation_object_target_set(efl_super(eo_obj, MY_CLASS), target);
65}
66
67EOLIAN static void
68_efl_animation_object_group_efl_animation_object_duration_set(Eo *eo_obj,
69 Efl_Animation_Object_Group_Data *pd,
70 double duration)
71{
72 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
73
74 if (duration == EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE) goto end;
75
76 if (duration < 0.0) return;
77
78 Eina_List *l;
79 Efl_Animation_Object *anim_obj;
80
81 EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
82 {
83 efl_animation_object_duration_set(anim_obj, duration);
84 }
85
86end:
87 efl_animation_object_duration_only_set(efl_super(eo_obj, MY_CLASS),
88 duration);
89
90 /* efl_animation_object_total_duration_get() should calculate the new total
91 * duration. */
92 double total_duration = efl_animation_object_total_duration_get(eo_obj);
93 efl_animation_object_total_duration_set(eo_obj, total_duration);
94}
95
96EOLIAN static void
97_efl_animation_object_group_efl_animation_object_final_state_keep_set(Eo *eo_obj,
98 Efl_Animation_Object_Group_Data *pd,
99 Eina_Bool state_keep)
100{
101 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
102
103 Eina_List *l;
104 Efl_Animation_Object *anim_obj;
105
106 EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
107 {
108 efl_animation_object_final_state_keep_set(anim_obj, state_keep);
109 }
110
111 efl_animation_object_final_state_keep_set(efl_super(eo_obj, MY_CLASS),
112 state_keep);
113}
114
115EOLIAN static Efl_Object *
116_efl_animation_object_group_efl_object_constructor(Eo *eo_obj,
117 Efl_Animation_Object_Group_Data *pd)
118{
119 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
120
121 pd->anim_objs = NULL;
122
123 //group animation object does not affect its child duration by default.
124 efl_animation_object_duration_only_set(efl_super(eo_obj, MY_CLASS),
125 EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE);
126
127 return eo_obj;
128}
129
130EOLIAN static void
131_efl_animation_object_group_efl_object_destructor(Eo *eo_obj,
132 Efl_Animation_Object_Group_Data *pd)
133{
134 Efl_Animation_Object *anim_obj;
135
136 EINA_LIST_FREE(pd->anim_objs, anim_obj)
137 efl_del(anim_obj);
138
139 efl_destructor(efl_super(eo_obj, MY_CLASS));
140}
141
142EOLIAN static void
143_efl_animation_object_group_efl_animation_object_target_state_save(Eo *eo_obj,
144 Efl_Animation_Object_Group_Data *pd)
145{
146 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
147
148 Eina_List *l;
149 Efl_Animation_Object *anim_obj;
150
151 EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
152 {
153 efl_animation_object_target_state_save(anim_obj);
154 }
155}
156
157EOLIAN static void
158_efl_animation_object_group_efl_animation_object_target_state_reset(Eo *eo_obj,
159 Efl_Animation_Object_Group_Data *pd)
160{
161 EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj);
162
163 Eina_List *l;
164 Efl_Animation_Object *anim_obj;
165
166 EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
167 {
168 efl_animation_object_target_state_reset(anim_obj);
169 }
170}
171
172/* Internal EO APIs */
173
174EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_add, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);
175
176EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_del, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);
177
178EOAPI EFL_FUNC_BODY(efl_animation_object_group_objects_get, Eina_List *, NULL);
179
180#define EFL_ANIMATION_OBJECT_GROUP_EXTRA_OPS \
181 EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_add, _efl_animation_object_group_object_add), \
182 EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_del, _efl_animation_object_group_object_del), \
183 EFL_OBJECT_OP_FUNC(efl_animation_object_group_objects_get, _efl_animation_object_group_objects_get), \
184 EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_group_efl_animation_object_target_set), \
185 EFL_OBJECT_OP_FUNC(efl_animation_object_duration_set, _efl_animation_object_group_efl_animation_object_duration_set), \
186 EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_group_efl_animation_object_final_state_keep_set)
187
188#include "efl_animation_object_group.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_object_group.eo b/src/lib/evas/canvas/efl_animation_object_group.eo
new file mode 100644
index 0000000000..cdde1ec78b
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group.eo
@@ -0,0 +1,13 @@
1import efl_animation_types;
2
3abstract Efl.Animation.Object.Group (Efl.Animation.Object)
4{
5 [[Efl group animation object abstract class]]
6 data: Efl_Animation_Object_Group_Data;
7 implements {
8 Efl.Object.constructor;
9 Efl.Object.destructor;
10 Efl.Animation.Object.target_state_save;
11 Efl.Animation.Object.target_state_reset;
12 }
13}
diff --git a/src/lib/evas/canvas/efl_animation_object_group_private.h b/src/lib/evas/canvas/efl_animation_object_group_private.h
new file mode 100644
index 0000000000..a710b462e7
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_object_group_private.h
@@ -0,0 +1,26 @@
1#define EFL_ANIMATION_OBJECT_PROTECTED
2
3#include "evas_common_private.h"
4
5#define MY_CLASS EFL_ANIMATION_OBJECT_GROUP_CLASS
6#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
7
8#define EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(anim_obj, ...) \
9 do { \
10 if (!anim_obj) { \
11 CRI("Efl_Animation_Object " # anim_obj " is NULL!"); \
12 return __VA_ARGS__; \
13 } \
14 if (efl_animation_object_is_deleted(anim_obj)) { \
15 ERR("Efl_Animation_Object " # anim_obj " has already been deleted!"); \
16 return __VA_ARGS__; \
17 } \
18 } while (0)
19
20#define EFL_ANIMATION_OBJECT_GROUP_DATA_GET(o, pd) \
21 Efl_Animation_Object_Group_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_GROUP_CLASS)
22
23typedef struct _Efl_Animation_Object_Group_Data
24{
25 Eina_List *anim_objs;
26} Efl_Animation_Object_Group_Data;