summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_object_main.c
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-13 20:40:01 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-13 22:56:33 +0900
commit4dae43e4d13ca43b9fef41f180ee7315b49dd3be (patch)
tree7a01582c60b717a82acdadf79bc9cd5b6deceac1 /src/lib/evas/canvas/evas_object_main.c
parent5699466dbabc8a1b2bd6b46a49cb268c5db415e1 (diff)
efl_animation: Fix to set Efl_Event_Description for event animation
Any event represented by Efl_Event_Description can be registered for event animation. (e.g. EFL_GFX_EVENT_SHOW, EFL_GFX_EVENT_HIDE, etc.)
Diffstat (limited to '')
-rw-r--r--src/lib/evas/canvas/evas_object_main.c445
1 files changed, 214 insertions, 231 deletions
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c
index a6f9471eeb..464f657487 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -48,16 +48,16 @@ Eina_Cow *evas_object_events_cow = NULL;
48 48
49typedef struct _Event_Animation 49typedef struct _Event_Animation
50{ 50{
51 Efl_Animation *anim; 51 EINA_INLIST;
52 Efl_Animation_Object *anim_obj;
53} Event_Animation;
54 52
55typedef struct _Hide_Anim_Data 53 const Efl_Event_Description *desc;
56{ 54
57 Efl_Canvas_Object *target; 55 Efl_Animation *anim;
58 Eina_Bool anim_started; 56 Efl_Animation_Object *anim_obj;
59 Eina_Bool anim_ended; 57
60} Hide_Anim_Data; 58 Eina_Bool hide_anim_started : 1;
59 Eina_Bool hide_anim_ended : 1;
60} Event_Animation;
61 61
62static Eina_Bool 62static Eina_Bool
63_init_cow(void) 63_init_cow(void)
@@ -177,31 +177,82 @@ _evas_object_pointer_data_get(Evas_Pointer_Data *evas_pdata,
177 return pdata; 177 return pdata;
178} 178}
179 179
180static void _animation_intercept_hide(void *data, Evas_Object *eo_obj);
181
182static void
183_animation_hide_end_cb(void *data, const Efl_Event *event EINA_UNUSED)
184{
185 Event_Animation *event_anim = data;
186
187 event_anim->hide_anim_ended = EINA_TRUE;
188
189 //Animation Object is automatically deleted when animation is ended.
190 event_anim->anim_obj = NULL;
191
192 Evas_Object *target = efl_animation_target_get(event_anim->anim);
193 _animation_intercept_hide(event_anim, target);
194
195 event_anim->hide_anim_started = EINA_FALSE;
196 event_anim->hide_anim_ended = EINA_FALSE;
197}
198
199static void _all_animation_objects_cancel(Evas_Object_Protected_Data *obj);
200
180static void 201static void
181_init_event_anims(Evas_Object_Protected_Data *obj) 202_animation_intercept_hide(void *data, Evas_Object *eo_obj)
182{ 203{
183 obj->event_anims = eina_array_new(EFL_ANIMATION_EVENT_TYPE_COUNT); 204 Event_Animation *event_anim = data;
205 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
184 206
185 int i; 207 if (event_anim->anim &&
186 for (i = 0; i < EFL_ANIMATION_EVENT_TYPE_COUNT; i++) 208 !event_anim->hide_anim_started && !event_anim->hide_anim_ended)
187 { 209 {
188 Event_Animation *event_anims = calloc(1, sizeof(Event_Animation)); 210 event_anim->hide_anim_started = EINA_TRUE;
189 eina_array_push(obj->event_anims, event_anims); 211
212 _all_animation_objects_cancel(obj);
213
214 //Create animation object to start animation
215 event_anim->anim_obj = efl_animation_object_create(event_anim->anim);
216
217 efl_event_callback_add(event_anim->anim_obj,
218 EFL_ANIMATION_OBJECT_EVENT_ENDED,
219 _animation_hide_end_cb,
220 event_anim);
221
222 //Start animation
223 efl_animation_object_start(event_anim->anim_obj);
190 } 224 }
225 else
226 efl_gfx_visible_set(eo_obj, EINA_FALSE);
191} 227}
192 228
193static void 229static void
194_free_event_anims(Evas_Object_Protected_Data *obj) 230_event_anim_free(Event_Animation *event_anim)
195{ 231{
196 int i; 232 if (event_anim->anim)
197 for (i = 0; i < EFL_ANIMATION_EVENT_TYPE_COUNT; i++)
198 { 233 {
199 Event_Animation *event_anims = eina_array_pop(obj->event_anims); 234 //Deallocate memory and Unset callbacks for Hide event
200 if (event_anims) free(event_anims); 235 if (event_anim->desc == EFL_GFX_EVENT_HIDE)
236 {
237 Efl_Canvas_Object *target =
238 efl_animation_target_get(event_anim->anim);
239
240 evas_object_intercept_hide_callback_del(target,
241 _animation_intercept_hide);
242
243 if (event_anim->hide_anim_started &&
244 !event_anim->hide_anim_ended)
245 efl_gfx_visible_set(target, EINA_FALSE);
246 }
201 } 247 }
202 248
203 eina_array_free(obj->event_anims); 249 if (event_anim->anim_obj)
204 obj->event_anims = NULL; 250 {
251 efl_del(event_anim->anim_obj);
252 event_anim->anim_obj = NULL;
253 }
254
255 free(event_anim);
205} 256}
206 257
207EOLIAN static Eo * 258EOLIAN static Eo *
@@ -232,7 +283,7 @@ _efl_canvas_object_efl_object_constructor(Eo *eo_obj, Evas_Object_Protected_Data
232 obj->data_3d = eina_cow_alloc(evas_object_3d_cow); 283 obj->data_3d = eina_cow_alloc(evas_object_3d_cow);
233 obj->mask = eina_cow_alloc(evas_object_mask_cow); 284 obj->mask = eina_cow_alloc(evas_object_mask_cow);
234 obj->events = eina_cow_alloc(evas_object_events_cow); 285 obj->events = eina_cow_alloc(evas_object_events_cow);
235 _init_event_anims(obj); 286 obj->event_anims = NULL;
236 287
237 evas_object_inject(eo_obj, obj, evas); 288 evas_object_inject(eo_obj, obj, evas);
238 evas_object_callback_init(eo_obj, obj); 289 evas_object_callback_init(eo_obj, obj);
@@ -543,7 +594,19 @@ evas_object_free(Evas_Object *eo_obj, Eina_Bool clean_layer)
543 eina_cow_free(evas_object_3d_cow, (const Eina_Cow_Data**) &obj->data_3d); 594 eina_cow_free(evas_object_3d_cow, (const Eina_Cow_Data**) &obj->data_3d);
544 eina_cow_free(evas_object_mask_cow, (const Eina_Cow_Data**) &obj->mask); 595 eina_cow_free(evas_object_mask_cow, (const Eina_Cow_Data**) &obj->mask);
545 eina_cow_free(evas_object_events_cow, (const Eina_Cow_Data**) &obj->events); 596 eina_cow_free(evas_object_events_cow, (const Eina_Cow_Data**) &obj->events);
546 _free_event_anims(obj); 597
598 //Free event animations
599 while (obj->event_anims)
600 {
601 Event_Animation *event_anim =
602 EINA_INLIST_CONTAINER_GET(obj->event_anims, Event_Animation);
603
604 obj->event_anims =
605 eina_inlist_remove(obj->event_anims, obj->event_anims);
606
607 _event_anim_free(event_anim);
608 }
609
547 efl_data_unref(eo_obj, obj->private_data); 610 efl_data_unref(eo_obj, obj->private_data);
548 obj->private_data = NULL; 611 obj->private_data = NULL;
549 612
@@ -1071,60 +1134,34 @@ _is_event_blocked(Eo *eo_obj, const Efl_Event_Description *desc,
1071} 1134}
1072 1135
1073static Eina_Bool 1136static Eina_Bool
1074_efl_animation_event_type_is_inform_call(Efl_Animation_Event_Type event) 1137_efl_animation_event_type_is_inform_call(const Efl_Event_Description *desc)
1075{ 1138{
1076 if ((event == EFL_ANIMATION_EVENT_TYPE_SHOW) || 1139 if ((desc == EFL_GFX_EVENT_SHOW) || (desc == EFL_GFX_EVENT_HIDE) ||
1077 (event == EFL_ANIMATION_EVENT_TYPE_HIDE)) 1140 (desc == EFL_GFX_EVENT_MOVE) || (desc == EFL_GFX_EVENT_RESIZE) ||
1141 (desc == EFL_GFX_EVENT_CHANGE_SIZE_HINTS))
1078 return EINA_TRUE; 1142 return EINA_TRUE;
1079 1143
1080 return EINA_FALSE; 1144 return EINA_FALSE;
1081} 1145}
1082 1146
1083//These macros are matched to Efl_Animation_Event_Type enum values. 1147static Event_Animation *
1084#define EFL_ANIMATION_EVENT_TYPE_SHOW_STR "show" 1148_event_animation_find(Evas_Object_Protected_Data *obj,
1085#define EFL_ANIMATION_EVENT_TYPE_HIDE_STR "hide" 1149 const Efl_Event_Description *desc)
1086#define EFL_ANIMATION_EVENT_TYPE_CLICKED_STR "clicked"
1087
1088static Efl_Animation_Event_Type
1089_efl_animation_event_type_get(const char *event_str)
1090{ 1150{
1091 if (!event_str) return -1; 1151 Event_Animation *event_anim;
1092 1152 EINA_INLIST_FOREACH(obj->event_anims, event_anim)
1093 if (!strncmp(event_str, EFL_ANIMATION_EVENT_TYPE_SHOW_STR, 1153 {
1094 strlen(EFL_ANIMATION_EVENT_TYPE_SHOW_STR))) 1154 if (event_anim->desc == desc)
1095 return EFL_ANIMATION_EVENT_TYPE_SHOW; 1155 return event_anim;
1096 1156 }
1097 else if (!strncmp(event_str, EFL_ANIMATION_EVENT_TYPE_HIDE_STR, 1157 return NULL;
1098 strlen(EFL_ANIMATION_EVENT_TYPE_HIDE_STR)))
1099 return EFL_ANIMATION_EVENT_TYPE_HIDE;
1100
1101 else if (!strncmp(event_str, EFL_ANIMATION_EVENT_TYPE_CLICKED_STR,
1102 strlen(EFL_ANIMATION_EVENT_TYPE_CLICKED_STR)))
1103 return EFL_ANIMATION_EVENT_TYPE_CLICKED;
1104
1105 return -1;
1106}
1107
1108static Eina_Bool
1109_efl_animation_event_type_is_valid(Efl_Animation_Event_Type event)
1110{
1111 if ((event < 0) || (event >= EFL_ANIMATION_EVENT_TYPE_COUNT))
1112 return EINA_FALSE;
1113
1114 return EINA_TRUE;
1115} 1158}
1116 1159
1117static Efl_Animation_Object * 1160static Efl_Animation_Object *
1118_event_animation_object_get(Eo *eo_obj, Efl_Animation_Event_Type event_type) 1161_event_animation_object_get(Evas_Object_Protected_Data *obj,
1162 const Efl_Event_Description *desc)
1119{ 1163{
1120 Evas_Object_Protected_Data *pd = efl_data_scope_get(eo_obj, MY_CLASS); 1164 Event_Animation *event_anim = _event_animation_find(obj, desc);
1121 if (!pd) return NULL;
1122
1123 if (!_efl_animation_event_type_is_valid(event_type))
1124 return NULL;
1125
1126 Event_Animation *event_anim = eina_array_data_get(pd->event_anims,
1127 event_type);
1128 if (event_anim && event_anim->anim_obj) 1165 if (event_anim && event_anim->anim_obj)
1129 return event_anim->anim_obj; 1166 return event_anim->anim_obj;
1130 1167
@@ -1132,41 +1169,60 @@ _event_animation_object_get(Eo *eo_obj, Efl_Animation_Event_Type event_type)
1132} 1169}
1133 1170
1134static void 1171static void
1135_all_animation_objects_cancel(Eo *eo_obj) 1172_all_animation_objects_cancel(Evas_Object_Protected_Data *obj)
1136{ 1173{
1137 Efl_Animation_Event_Type event_type; 1174 if (obj->event_anims)
1138 for (event_type = EFL_ANIMATION_EVENT_TYPE_SHOW;
1139 event_type < EFL_ANIMATION_EVENT_TYPE_COUNT; event_type++)
1140 { 1175 {
1141 Efl_Animation_Object *anim_obj = 1176 Event_Animation *event_anim;
1142 _event_animation_object_get(eo_obj, event_type); 1177 EINA_INLIST_FOREACH(obj->event_anims, event_anim)
1143 if (anim_obj) 1178 {
1144 efl_animation_object_cancel(anim_obj); 1179 if (event_anim && event_anim->anim_obj)
1180 {
1181 efl_animation_object_cancel(event_anim->anim_obj);
1182 event_anim->anim_obj = NULL;
1183 }
1184 }
1145 } 1185 }
1146} 1186}
1147 1187
1188static void
1189_animation_end_cb(void *data, const Efl_Event *event EINA_UNUSED)
1190{
1191 Event_Animation *event_anim = data;
1192
1193 //Animation Object is automatically deleted when animation is ended.
1194 event_anim->anim_obj = NULL;
1195}
1196
1148EOLIAN static Eina_Bool 1197EOLIAN static Eina_Bool
1149_efl_canvas_object_efl_object_event_callback_call(Eo *eo_obj, 1198_efl_canvas_object_efl_object_event_callback_call(Eo *eo_obj,
1150 Evas_Object_Protected_Data *obj EINA_UNUSED, 1199 Evas_Object_Protected_Data *obj,
1151 const Efl_Event_Description *desc, 1200 const Efl_Event_Description *desc,
1152 void *event_info) 1201 void *event_info)
1153{ 1202{
1154 if (_is_event_blocked(eo_obj, desc, event_info)) return EINA_FALSE; 1203 if (_is_event_blocked(eo_obj, desc, event_info)) return EINA_FALSE;
1155 1204
1156 //Start animation corresponding to the current event 1205 //Start animation corresponding to the current event
1157 if (desc && desc->name) 1206 if (desc)
1158 { 1207 {
1159 Efl_Animation_Event_Type event_type = 1208 if (!_efl_animation_event_type_is_inform_call(desc))
1160 _efl_animation_event_type_get(desc->name);
1161
1162 if (!_efl_animation_event_type_is_inform_call(event_type))
1163 { 1209 {
1164 Efl_Animation_Object *anim_obj = 1210 Event_Animation *event_anim = _event_animation_find(obj, desc);
1165 _event_animation_object_get(eo_obj, event_type); 1211 if (event_anim)
1166 if (anim_obj)
1167 { 1212 {
1168 _all_animation_objects_cancel(eo_obj); 1213 _all_animation_objects_cancel(obj);
1169 efl_animation_object_start(anim_obj); 1214
1215 //Create animation object to start animation
1216 event_anim->anim_obj =
1217 efl_animation_object_create(event_anim->anim);
1218
1219 efl_event_callback_add(event_anim->anim_obj,
1220 EFL_ANIMATION_OBJECT_EVENT_ENDED,
1221 _animation_end_cb,
1222 event_anim);
1223
1224 //Start animation
1225 efl_animation_object_start(event_anim->anim_obj);
1170 } 1226 }
1171 } 1227 }
1172 } 1228 }
@@ -1177,26 +1233,33 @@ _efl_canvas_object_efl_object_event_callback_call(Eo *eo_obj,
1177 1233
1178EOLIAN static Eina_Bool 1234EOLIAN static Eina_Bool
1179_efl_canvas_object_efl_object_event_callback_legacy_call(Eo *eo_obj, 1235_efl_canvas_object_efl_object_event_callback_legacy_call(Eo *eo_obj,
1180 Evas_Object_Protected_Data *obj EINA_UNUSED, 1236 Evas_Object_Protected_Data *obj,
1181 const Efl_Event_Description *desc, 1237 const Efl_Event_Description *desc,
1182 void *event_info) 1238 void *event_info)
1183{ 1239{
1184 if (_is_event_blocked(eo_obj, desc, event_info)) return EINA_FALSE; 1240 if (_is_event_blocked(eo_obj, desc, event_info)) return EINA_FALSE;
1185 1241
1186 //Start animation corresponding to the current event 1242 //Start animation corresponding to the current event
1187 if (desc && desc->name) 1243 if (desc)
1188 { 1244 {
1189 Efl_Animation_Event_Type event_type = 1245 if (!_efl_animation_event_type_is_inform_call(desc))
1190 _efl_animation_event_type_get(desc->name);
1191
1192 if (!_efl_animation_event_type_is_inform_call(event_type))
1193 { 1246 {
1194 Efl_Animation_Object *anim_obj = 1247 Event_Animation *event_anim = _event_animation_find(obj, desc);
1195 _event_animation_object_get(eo_obj, event_type); 1248 if (event_anim)
1196 if (anim_obj)
1197 { 1249 {
1198 _all_animation_objects_cancel(eo_obj); 1250 _all_animation_objects_cancel(obj);
1199 efl_animation_object_start(anim_obj); 1251
1252 //Create animation object to start animation
1253 event_anim->anim_obj =
1254 efl_animation_object_create(event_anim->anim);
1255
1256 efl_event_callback_add(event_anim->anim_obj,
1257 EFL_ANIMATION_OBJECT_EVENT_ENDED,
1258 _animation_end_cb,
1259 event_anim);
1260
1261 //Start animation
1262 efl_animation_object_start(event_anim->anim_obj);
1200 } 1263 }
1201 } 1264 }
1202 } 1265 }
@@ -1221,14 +1284,6 @@ _efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data
1221 1284
1222 edata = efl_data_scope_get(evas_object_evas_get(eo_obj), EVAS_CANVAS_CLASS); 1285 edata = efl_data_scope_get(evas_object_evas_get(eo_obj), EVAS_CANVAS_CLASS);
1223 1286
1224 //Unset event animations
1225 efl_canvas_object_event_animation_set(eo_obj, EFL_ANIMATION_EVENT_TYPE_SHOW,
1226 NULL);
1227 efl_canvas_object_event_animation_set(eo_obj, EFL_ANIMATION_EVENT_TYPE_HIDE,
1228 NULL);
1229 efl_canvas_object_event_animation_set(eo_obj,
1230 EFL_ANIMATION_EVENT_TYPE_CLICKED,
1231 NULL);
1232 evas_object_hide(eo_obj); 1287 evas_object_hide(eo_obj);
1233 1288
1234 if (obj->events) EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events) 1289 if (obj->events) EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
@@ -1853,39 +1908,6 @@ evas_object_hide(Evas_Object *eo_obj)
1853 efl_gfx_visible_set(eo_obj, EINA_FALSE); 1908 efl_gfx_visible_set(eo_obj, EINA_FALSE);
1854} 1909}
1855 1910
1856static void _animation_intercept_hide(void *data, Evas_Object *eo_obj);
1857
1858static void
1859_animation_hide_end_cb(void *data, const Efl_Event *event EINA_UNUSED)
1860{
1861 Hide_Anim_Data *hide_anim_data = data;
1862
1863 hide_anim_data->anim_ended = EINA_TRUE;
1864
1865 _animation_intercept_hide(hide_anim_data, hide_anim_data->target);
1866
1867 hide_anim_data->anim_started = EINA_FALSE;
1868 hide_anim_data->anim_ended = EINA_FALSE;
1869}
1870
1871static void
1872_animation_intercept_hide(void *data, Evas_Object *eo_obj)
1873{
1874 Hide_Anim_Data *hide_anim_data = data;
1875
1876 Efl_Animation_Object *anim_obj =
1877 _event_animation_object_get(eo_obj, EFL_ANIMATION_EVENT_TYPE_HIDE);
1878 if (anim_obj && !hide_anim_data->anim_started && !hide_anim_data->anim_ended)
1879 {
1880 hide_anim_data->anim_started = EINA_TRUE;
1881
1882 _all_animation_objects_cancel(eo_obj);
1883 efl_animation_object_start(anim_obj);
1884 }
1885 else
1886 efl_gfx_visible_set(eo_obj, EINA_FALSE);
1887}
1888
1889EAPI Eina_Bool 1911EAPI Eina_Bool
1890evas_object_visible_get(const Evas_Object *obj) 1912evas_object_visible_get(const Evas_Object *obj)
1891{ 1913{
@@ -1928,13 +1950,22 @@ _show(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
1928 evas_object_update_bounding_box(eo_obj, obj, NULL); 1950 evas_object_update_bounding_box(eo_obj, obj, NULL);
1929 evas_object_inform_call_show(eo_obj); 1951 evas_object_inform_call_show(eo_obj);
1930 1952
1931 //Start animation 1953 Event_Animation *event_anim = _event_animation_find(obj, EFL_GFX_EVENT_SHOW);
1932 Efl_Animation_Object *anim_obj = 1954 if (event_anim)
1933 _event_animation_object_get(eo_obj, EFL_ANIMATION_EVENT_TYPE_SHOW);
1934 if (anim_obj)
1935 { 1955 {
1936 _all_animation_objects_cancel(eo_obj); 1956 _all_animation_objects_cancel(obj);
1937 efl_animation_object_start(anim_obj); 1957
1958 //Create animation object to start animation
1959 event_anim->anim_obj =
1960 efl_animation_object_create(event_anim->anim);
1961
1962 efl_event_callback_add(event_anim->anim_obj,
1963 EFL_ANIMATION_OBJECT_EVENT_ENDED,
1964 _animation_end_cb,
1965 event_anim);
1966
1967 //Start animation
1968 efl_animation_object_start(event_anim->anim_obj);
1938 } 1969 }
1939} 1970}
1940 1971
@@ -2733,110 +2764,58 @@ _efl_canvas_object_legacy_ctor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
2733EOLIAN void 2764EOLIAN void
2734_efl_canvas_object_event_animation_set(Eo *eo_obj, 2765_efl_canvas_object_event_animation_set(Eo *eo_obj,
2735 Evas_Object_Protected_Data *pd, 2766 Evas_Object_Protected_Data *pd,
2736 Efl_Animation_Event_Type event_type, 2767 const Efl_Event_Description *desc,
2737 Efl_Animation *animation) 2768 Efl_Animation *animation)
2738{ 2769{
2739 if (!_efl_animation_event_type_is_valid(event_type)) 2770 Event_Animation *event_anim = _event_animation_find(pd, desc);
2740 return;
2741
2742 // This may happen if the object never was fully created.
2743 if (!pd->event_anims) return;
2744 2771
2745 Event_Animation *event_anim = 2772 if (event_anim)
2746 eina_array_data_get(pd->event_anims, event_type);
2747 if (!event_anim) return;
2748
2749 Efl_Animation *cur_anim = event_anim->anim;
2750 Efl_Animation_Object *cur_anim_obj = event_anim->anim_obj;
2751
2752 //Unset for current event animation
2753 if (cur_anim)
2754 { 2773 {
2755 Efl_Canvas_Object *prev_target = efl_animation_target_get(cur_anim); 2774 if (event_anim->anim == animation)
2756 2775 return;
2757 //Deallocate memory and Unset callbacks for Hide event
2758 if (event_type == EFL_ANIMATION_EVENT_TYPE_HIDE)
2759 {
2760 Hide_Anim_Data *hide_anim_data
2761 = evas_object_intercept_hide_callback_del(prev_target,
2762 _animation_intercept_hide);
2763 if (hide_anim_data)
2764 {
2765 efl_event_callback_del(cur_anim_obj,
2766 EFL_ANIMATION_OBJECT_EVENT_ENDED,
2767 _animation_hide_end_cb,
2768 hide_anim_data);
2769 2776
2770 if (hide_anim_data->anim_started && 2777 pd->event_anims =
2771 !hide_anim_data->anim_ended) 2778 eina_inlist_remove(pd->event_anims, EINA_INLIST_GET(event_anim));
2772 efl_gfx_visible_set(prev_target, EINA_FALSE);
2773 2779
2774 free(hide_anim_data); 2780 _event_anim_free(event_anim);
2775 }
2776 }
2777
2778 //Stop animation
2779 efl_animation_object_cancel(cur_anim_obj);
2780
2781 /* Delete current animation object because animation object is
2782 * created in efl_canvas_object_event_animation_set(). */
2783 efl_del(cur_anim_obj);
2784 } 2781 }
2785 2782
2786 Efl_Animation *new_anim = animation; 2783 if (!animation) return;
2787 Efl_Animation_Object *new_anim_obj = NULL;
2788
2789 //Set for new event animation
2790 if (new_anim)
2791 {
2792 //Set target object for the given animation
2793 Efl_Canvas_Object *target = efl_animation_target_get(new_anim);
2794 if (!target)
2795 target = eo_obj;
2796 efl_animation_target_set(new_anim, target);
2797 2784
2798 new_anim_obj = efl_animation_object_create(new_anim); 2785 event_anim = calloc(1, sizeof(Event_Animation));
2799 2786
2800 /* Event animation object should not be deleted after animation is 2787 //Set target object for the given animation
2801 * cancelled or finished */ 2788 Efl_Canvas_Object *target = efl_animation_target_get(animation);
2802 efl_animation_object_auto_del_set(new_anim_obj, EINA_FALSE); 2789 if (!target)
2790 target = eo_obj;
2791 efl_animation_target_set(animation, target);
2803 2792
2804 //Allocate memory and Set callbacks for Hide event 2793 //Set callback for Hide event
2805 if (event_type == EFL_ANIMATION_EVENT_TYPE_HIDE) 2794 if (desc == EFL_GFX_EVENT_HIDE)
2806 { 2795 {
2807 Hide_Anim_Data *hide_anim_data = calloc(1, sizeof(Hide_Anim_Data)); 2796 evas_object_intercept_hide_callback_add(target,
2808 hide_anim_data->target = target; 2797 _animation_intercept_hide,
2809 hide_anim_data->anim_started = EINA_FALSE; 2798 event_anim);
2810 hide_anim_data->anim_ended = EINA_FALSE;
2811
2812 evas_object_intercept_hide_callback_add(target,
2813 _animation_intercept_hide,
2814 hide_anim_data);
2815
2816 efl_event_callback_add(new_anim_obj,
2817 EFL_ANIMATION_OBJECT_EVENT_ENDED,
2818 _animation_hide_end_cb,
2819 hide_anim_data);
2820 }
2821 } 2799 }
2822 2800
2823 //Replace current event animation with new event animation 2801 event_anim->desc = desc;
2824 event_anim->anim = new_anim; 2802 event_anim->anim = animation;
2825 event_anim->anim_obj = new_anim_obj; 2803 event_anim->anim_obj = NULL;
2804 event_anim->hide_anim_started = EINA_FALSE;
2805 event_anim->hide_anim_ended = EINA_FALSE;
2806
2807 pd->event_anims =
2808 eina_inlist_append(pd->event_anims, EINA_INLIST_GET(event_anim));
2826} 2809}
2827 2810
2828EOLIAN Efl_Animation * 2811EOLIAN Efl_Animation *
2829_efl_canvas_object_event_animation_get(Eo *eo_obj EINA_UNUSED, 2812_efl_canvas_object_event_animation_get(Eo *eo_obj EINA_UNUSED,
2830 Evas_Object_Protected_Data *pd, 2813 Evas_Object_Protected_Data *pd,
2831 Efl_Animation_Event_Type event_type) 2814 const Efl_Event_Description *desc)
2832{ 2815{
2833 if (!_efl_animation_event_type_is_valid(event_type)) 2816 Event_Animation *event_anim = _event_animation_find(pd, desc);
2834 return NULL;
2835
2836 Event_Animation *event_anim = eina_array_data_get(pd->event_anims,
2837 event_type);
2838 if (event_anim && event_anim->anim) 2817 if (event_anim && event_anim->anim)
2839 return event_anim->anim; 2818 return event_anim->anim_obj;
2840 2819
2841 return NULL; 2820 return NULL;
2842} 2821}
@@ -2846,9 +2825,11 @@ _efl_canvas_object_event_animation_get(Eo *eo_obj EINA_UNUSED,
2846 * animation is cancelled and show operation is proceeded. */ 2825 * animation is cancelled and show operation is proceeded. */
2847Eina_Bool 2826Eina_Bool
2848_efl_canvas_object_event_animation_is_running(Eo *eo_obj, 2827_efl_canvas_object_event_animation_is_running(Eo *eo_obj,
2849 Efl_Animation_Event_Type event) 2828 const Efl_Event_Description *desc)
2850{ 2829{
2851 if (_event_animation_object_get(eo_obj, event)) 2830 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
2831
2832 if (_event_animation_object_get(obj, desc))
2852 return EINA_TRUE; 2833 return EINA_TRUE;
2853 2834
2854 return EINA_FALSE; 2835 return EINA_FALSE;
@@ -2857,7 +2838,9 @@ _efl_canvas_object_event_animation_is_running(Eo *eo_obj,
2857void 2838void
2858_efl_canvas_object_event_animation_cancel(Eo *eo_obj) 2839_efl_canvas_object_event_animation_cancel(Eo *eo_obj)
2859{ 2840{
2860 _all_animation_objects_cancel(eo_obj); 2841 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
2842
2843 _all_animation_objects_cancel(obj);
2861} 2844}
2862 2845
2863 2846