1 #include <Elementary.h>
4 #define ELM_TRANSIT_CHECK_OR_RETURN(transit, ...) \
7 CRITICAL("Elm_Transit " # transit " is NULL!"); \
10 if (!EINA_MAGIC_CHECK(transit, ELM_TRANSIT_MAGIC)) { \
11 EINA_MAGIC_FAIL(transit, ELM_TRANSIT_MAGIC); \
14 if (transit->deleted){ \
15 ERR("Elm_Transit " # transit " has already been deleted!"); \
21 #define _TRANSIT_FOCAL 2000
25 #define ELM_TRANSIT_MAGIC 0xd27f190a
28 Ecore_Animator *animator;
29 Eina_Inlist *effect_list;
31 Elm_Transit *prev_chain_transit;
32 Eina_List *next_chain_transits;
33 Elm_Transit_Tween_Mode tween_mode;
36 Elm_Transit_Del_Cb func;
54 unsigned int effects_pending_del;
57 Eina_Bool auto_reverse : 1;
58 Eina_Bool event_enabled : 1;
59 Eina_Bool deleted : 1;
60 Eina_Bool state_keep : 1;
61 Eina_Bool finished : 1;
65 struct _Elm_Transit_Effect_Module
68 Elm_Transit_Effect_Transition_Cb transition_cb;
69 Elm_Transit_Effect_End_Cb end_cb;
70 Elm_Transit_Effect *effect;
71 Eina_Bool deleted : 1;
74 struct _Elm_Transit_Obj_State
76 Evas_Coord x, y, w, h;
79 Eina_Bool map_enabled : 1;
80 Eina_Bool visible : 1;
83 struct _Elm_Transit_Obj_Data
85 struct _Elm_Transit_Obj_State *state;
86 Eina_Bool freeze_events : 1;
89 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
90 typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data;
91 typedef struct _Elm_Transit_Obj_State Elm_Transit_Obj_State;
93 static void _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj);
94 static void _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj);
95 static void _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data);
96 static void _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
97 static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
98 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
99 static void _transit_remove_dead_effects(Elm_Transit *transit);
100 static void _transit_chain_go(Elm_Transit *transit);
101 static void _transit_del(Elm_Transit *transit);
102 static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress);
103 static Eina_Bool _transit_animate_cb(void *data);
105 static char *_transit_key= "_elm_transit_key";
108 _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
110 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
113 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
115 obj_data->freeze_events = evas_object_freeze_events_get(obj);
117 if ((!transit->state_keep) && (obj_data->state))
119 free(obj_data->state);
120 obj_data->state = NULL;
124 _transit_obj_states_save(obj, obj_data);
127 evas_object_data_set(obj, _transit_key, obj_data);
131 _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data)
133 Elm_Transit_Obj_State *state = obj_data->state;
136 state = calloc(1, sizeof(Elm_Transit_Obj_State));
139 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
140 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
141 state->visible = evas_object_visible_get(obj);
142 state->map_enabled = evas_object_map_enable_get(obj);
143 if (evas_object_map_get(obj))
144 state->map = evas_map_dup(evas_object_map_get(obj));
145 obj_data->state = state;
149 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
151 //Remove duplicated objects
152 //TODO: Need to consider about optimizing here
155 if (!eina_list_data_find_list(transit->objs, obj))
157 transit->objs = eina_list_remove(transit->objs, obj);
158 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
159 _transit_obj_remove_cb,
165 _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
167 Elm_Transit *transit = data;
168 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
172 free(obj_data->state);
175 _remove_obj_from_list(transit, obj);
176 if (!transit->objs && !transit->deleted) elm_transit_del(transit);
180 _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
182 Elm_Transit_Obj_Data *obj_data;
183 Elm_Transit_Obj_State *state;
185 obj_data = evas_object_data_get(obj, _transit_key);
186 if (!obj_data) return;
187 evas_object_data_del(obj, _transit_key);
188 evas_object_freeze_events_set(obj, obj_data->freeze_events);
189 state = obj_data->state;
192 //recover the states of the object.
193 if (!transit->state_keep)
195 evas_object_move(obj, state->x, state->y);
196 evas_object_resize(obj, state->w, state->h);
197 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
198 if (state->visible) evas_object_show(obj);
199 else evas_object_hide(obj);
200 evas_object_map_enable_set(obj, state->map_enabled);
201 evas_object_map_set(obj, state->map);
209 _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
211 _remove_obj_from_list(transit, obj);
212 _transit_obj_data_recover(transit, obj);
216 _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
218 if (effect_module->end_cb)
219 effect_module->end_cb(effect_module->effect, transit);
224 _transit_remove_dead_effects(Elm_Transit *transit)
226 Elm_Transit_Effect_Module *effect_module = NULL;
229 EINA_INLIST_FOREACH_SAFE(transit->effect_list, ll, effect_module)
231 if (effect_module->deleted)
233 _transit_effect_del(transit, effect_module);
234 transit->effects_pending_del--;
235 if (!transit->effects_pending_del) return;
241 _transit_chain_go(Elm_Transit *transit)
243 ELM_TRANSIT_CHECK_OR_RETURN(transit);
244 elm_transit_go(transit);
248 _transit_del(Elm_Transit *transit)
250 Elm_Transit_Effect_Module *effect_module;
251 Elm_Transit *chain_transit;
252 Eina_List *elist, *elist_next;
254 transit->deleted = EINA_TRUE;
256 if (transit->animator)
257 ecore_animator_del(transit->animator);
260 while (transit->effect_list)
262 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
263 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
264 _transit_effect_del(transit, effect_module);
268 while (transit->objs)
269 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
271 if (transit->del_data.func)
272 transit->del_data.func(transit->del_data.arg, transit);
274 //cut off the chain transit relationship
275 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
276 chain_transit->prev_chain_transit = NULL;
278 if (transit->prev_chain_transit)
279 transit->prev_chain_transit->next_chain_transits =
280 eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
282 // run chain transits
283 if (transit->finished && transit->next_chain_transits)
285 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
286 _transit_chain_go(chain_transit);
289 eina_list_free(transit->next_chain_transits);
291 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
295 //If the transit is deleted then EINA_FALSE is retruned.
297 _transit_animate_op(Elm_Transit *transit, double progress)
299 Elm_Transit_Effect_Module *effect_module;
302 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
304 if (transit->deleted) break;
305 if (!effect_module->deleted)
306 effect_module->transition_cb(effect_module->effect, transit, progress);
310 if (transit->walking) return EINA_TRUE;
312 if (transit->deleted)
314 _transit_del(transit);
318 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
324 _transit_animate_cb(void *data)
326 Elm_Transit *transit = data;
327 double elapsed_time, duration;
329 transit->time.current = ecore_loop_time_get();
330 elapsed_time = transit->time.current - transit->time.begin;
331 duration = transit->time.duration + transit->time.delayed;
333 if (elapsed_time > duration)
334 elapsed_time = duration;
336 transit->progress = elapsed_time / duration;
337 switch (transit->tween_mode)
339 case ELM_TRANSIT_TWEEN_MODE_LINEAR:
340 transit->progress = ecore_animator_pos_map(transit->progress,
341 ECORE_POS_MAP_LINEAR,
344 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
345 transit->progress = ecore_animator_pos_map(transit->progress,
346 ECORE_POS_MAP_ACCELERATE,
349 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
350 transit->progress = ecore_animator_pos_map(transit->progress,
351 ECORE_POS_MAP_DECELERATE,
354 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
355 transit->progress = ecore_animator_pos_map(transit->progress,
356 ECORE_POS_MAP_SINUSOIDAL,
359 case ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP:
360 transit->progress = ecore_animator_pos_map(transit->progress,
361 ECORE_POS_MAP_DIVISOR_INTERP,
362 transit->v1, transit->v2);
364 case ELM_TRANSIT_TWEEN_MODE_BOUNCE:
365 transit->progress = ecore_animator_pos_map(transit->progress,
366 ECORE_POS_MAP_BOUNCE,
367 transit->v1, transit->v2);
369 case ELM_TRANSIT_TWEEN_MODE_SPRING:
370 transit->progress = ecore_animator_pos_map(transit->progress,
371 ECORE_POS_MAP_SPRING,
372 transit->v1, transit->v2);
379 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
381 if (transit->time.duration > 0)
383 if (!_transit_animate_op(transit, transit->progress))
384 return ECORE_CALLBACK_CANCEL;
387 /* Not end. Keep going. */
388 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
390 /* Repeat and reverse and time done! */
391 if ((transit->repeat.count >= 0) &&
392 (transit->repeat.current == transit->repeat.count) &&
393 ((!transit->auto_reverse) || transit->repeat.reverse))
395 transit->finished = EINA_TRUE;
396 elm_transit_del(transit);
397 return ECORE_CALLBACK_CANCEL;
401 if (!transit->auto_reverse || transit->repeat.reverse)
403 transit->repeat.current++;
404 transit->repeat.reverse = EINA_FALSE;
406 else transit->repeat.reverse = EINA_TRUE;
408 transit->time.begin = ecore_loop_time_get();
410 return ECORE_CALLBACK_RENEW;
414 _recover_image_uv_by_y(Evas_Map *map, int iw, int ih)
416 evas_map_point_image_uv_set(map, 0, iw, 0);
417 evas_map_point_image_uv_set(map, 1, 0, 0);
418 evas_map_point_image_uv_set(map, 2, 0, ih);
419 evas_map_point_image_uv_set(map, 3, iw, ih);
423 _recover_image_uv_by_x(Evas_Map *map, int iw, int ih)
425 evas_map_point_image_uv_set(map, 0, 0, ih);
426 evas_map_point_image_uv_set(map, 1, iw, ih);
427 evas_map_point_image_uv_set(map, 2, iw, 0);
428 evas_map_point_image_uv_set(map, 3, 0, 0);
432 _recover_image_uv(Evas_Object *obj, Evas_Map *map, Eina_Bool revert, Eina_Bool by_x)
434 //Since the map is not proper for all types of objects,
435 //Need to handle uvs only for image objects
437 const char *type = evas_object_type_get(obj);
438 if ((!type) || (strcmp(type, "image"))) return EINA_FALSE;
439 if (evas_object_image_source_get(obj)) return EINA_FALSE;
441 evas_object_image_size_get(obj, &iw, &ih);
446 _recover_image_uv_by_x(map, iw, ih);
448 _recover_image_uv_by_y(map, iw, ih);
452 evas_map_point_image_uv_set(map, 0, 0, 0);
453 evas_map_point_image_uv_set(map, 1, iw, 0);
454 evas_map_point_image_uv_set(map, 2, iw, ih);
455 evas_map_point_image_uv_set(map, 3, 0, ih);
461 elm_transit_add(void)
463 Elm_Transit *transit = ELM_NEW(Elm_Transit);
466 ERR("Failed to allocate a elm_transit object!");
470 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
472 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
476 transit->smooth = EINA_TRUE;
482 elm_transit_del(Elm_Transit *transit)
484 ELM_TRANSIT_CHECK_OR_RETURN(transit);
486 transit->deleted = EINA_TRUE;
487 if (transit->walking) return;
488 _transit_del(transit);
492 elm_transit_effect_add(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect, Elm_Transit_Effect_End_Cb end_cb)
494 ELM_TRANSIT_CHECK_OR_RETURN(transit);
495 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
496 Elm_Transit_Effect_Module *effect_module;
498 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
499 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
501 WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit);
505 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
508 ERR("Failed to allocate a new effect!: transit=%p", transit);
512 effect_module->end_cb = end_cb;
513 effect_module->transition_cb = transition_cb;
514 effect_module->effect = effect;
516 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
520 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
522 ELM_TRANSIT_CHECK_OR_RETURN(transit);
523 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
524 Elm_Transit_Effect_Module *effect_module;
526 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
528 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
530 if (transit->walking)
532 effect_module->deleted = EINA_TRUE;
533 transit->effects_pending_del++;
537 _transit_effect_del(transit, effect_module);
538 if (!transit->effect_list) elm_transit_del(transit);
546 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
548 ELM_TRANSIT_CHECK_OR_RETURN(transit);
549 EINA_SAFETY_ON_NULL_RETURN(obj);
551 if (transit->animator)
553 if (!evas_object_data_get(obj, _transit_key))
555 _transit_obj_data_update(transit, obj);
556 evas_object_freeze_events_set(obj, EINA_TRUE);
560 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
561 _transit_obj_remove_cb,
564 transit->objs = eina_list_append(transit->objs, obj);
568 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
570 ELM_TRANSIT_CHECK_OR_RETURN(transit);
571 EINA_SAFETY_ON_NULL_RETURN(obj);
573 _transit_obj_remove(transit, obj);
574 if (!transit->objs) elm_transit_del(transit);
577 EAPI const Eina_List *
578 elm_transit_objects_get(const Elm_Transit *transit)
580 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
581 return transit->objs;
585 elm_transit_smooth_set(Elm_Transit *transit, Eina_Bool smooth)
587 ELM_TRANSIT_CHECK_OR_RETURN(transit);
588 transit->smooth = !!smooth;
592 elm_transit_smooth_get(const Elm_Transit *transit)
594 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
595 return transit->smooth;
599 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
601 ELM_TRANSIT_CHECK_OR_RETURN(transit);
606 if (transit->event_enabled == enabled) return;
607 transit->event_enabled = !!enabled;
608 if (!transit->animator) return;
610 EINA_LIST_FOREACH(transit->objs, list, obj)
611 evas_object_freeze_events_set(obj, enabled);
615 elm_transit_event_enabled_get(const Elm_Transit *transit)
617 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
618 return transit->event_enabled;
622 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
624 ELM_TRANSIT_CHECK_OR_RETURN(transit);
625 transit->del_data.func = cb;
626 transit->del_data.arg = data;
630 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
632 ELM_TRANSIT_CHECK_OR_RETURN(transit);
633 transit->auto_reverse = reverse;
637 elm_transit_auto_reverse_get(const Elm_Transit *transit)
639 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
640 return transit->auto_reverse;
644 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
646 ELM_TRANSIT_CHECK_OR_RETURN(transit);
647 transit->repeat.count = repeat;
648 transit->repeat.current = 0;
652 elm_transit_repeat_times_get(const Elm_Transit *transit)
654 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
655 return transit->repeat.count;
659 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
661 ELM_TRANSIT_CHECK_OR_RETURN(transit);
662 transit->tween_mode = tween_mode;
665 EAPI Elm_Transit_Tween_Mode
666 elm_transit_tween_mode_get(const Elm_Transit *transit)
668 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
669 return transit->tween_mode;
673 elm_transit_tween_mode_factor_set(Elm_Transit *transit, double v1, double v2)
675 ELM_TRANSIT_CHECK_OR_RETURN(transit);
681 elm_transit_tween_mode_factor_get(const Elm_Transit *transit, double *v1, double *v2)
683 ELM_TRANSIT_CHECK_OR_RETURN(transit);
684 if (v1) *v1 = transit->v1;
685 if (v2) *v2 = transit->v2;
689 elm_transit_duration_set(Elm_Transit *transit, double duration)
691 ELM_TRANSIT_CHECK_OR_RETURN(transit);
692 if (transit->animator)
694 WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit);
697 transit->time.duration = duration;
701 elm_transit_duration_get(const Elm_Transit *transit)
703 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
704 return transit->time.duration;
708 elm_transit_go(Elm_Transit *transit)
710 ELM_TRANSIT_CHECK_OR_RETURN(transit);
715 if (transit->animator)
716 ecore_animator_del(transit->animator);
718 EINA_LIST_FOREACH(transit->objs, elist, obj)
719 _transit_obj_data_update(transit, obj);
721 if (!transit->event_enabled)
723 EINA_LIST_FOREACH(transit->objs, elist, obj)
724 evas_object_freeze_events_set(obj, EINA_TRUE);
727 transit->time.paused = 0;
728 transit->time.delayed = 0;
729 transit->time.begin = ecore_loop_time_get();
730 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
731 _transit_animate_cb(transit);
735 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
737 ELM_TRANSIT_CHECK_OR_RETURN(transit);
739 if (!transit->animator) return;
743 if (transit->time.paused > 0)
745 ecore_animator_freeze(transit->animator);
746 transit->time.paused = ecore_loop_time_get();
750 if (transit->time.paused == 0)
752 ecore_animator_thaw(transit->animator);
753 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
754 transit->time.paused = 0;
759 elm_transit_paused_get(const Elm_Transit *transit)
761 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
763 if (transit->time.paused == 0)
770 elm_transit_progress_value_get(const Elm_Transit *transit)
772 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
774 return transit->progress;
778 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
780 ELM_TRANSIT_CHECK_OR_RETURN(transit);
782 if (transit->state_keep == state_keep) return;
783 if (transit->animator)
785 WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit);
788 transit->state_keep = !!state_keep;
792 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
794 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
795 return transit->state_keep;
799 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
801 ELM_TRANSIT_CHECK_OR_RETURN(transit);
802 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
804 if (transit == chain_transit)
806 WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit);
809 if (transit == chain_transit->prev_chain_transit)
812 if (chain_transit->prev_chain_transit)
813 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
815 chain_transit->prev_chain_transit = transit;
816 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
820 elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
822 ELM_TRANSIT_CHECK_OR_RETURN(transit);
823 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
825 if (chain_transit->prev_chain_transit != transit)
827 WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
831 chain_transit->prev_chain_transit = NULL;
832 transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
836 elm_transit_chain_transits_get(const Elm_Transit * transit)
838 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
839 return transit->next_chain_transits;
842 ///////////////////////////////////////////////////////////////////////////
844 ///////////////////////////////////////////////////////////////////////////
845 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
847 struct _Elm_Transit_Effect_Resizing
855 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
857 Elm_Transit_Effect_Resizing *resizing = effect;
862 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
864 EINA_SAFETY_ON_NULL_RETURN(effect);
865 EINA_SAFETY_ON_NULL_RETURN(transit);
869 Elm_Transit_Effect_Resizing *resizing = effect;
871 w = resizing->from.w + (resizing->to.w * progress);
872 h = resizing->from.h + (resizing->to.h * progress);
874 EINA_LIST_FOREACH(transit->objs, elist, obj)
875 evas_object_resize(obj, w, h);
878 static Elm_Transit_Effect *
879 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
881 Elm_Transit_Effect_Resizing *resizing;
883 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
884 if (!resizing) return NULL;
886 resizing->from.w = from_w;
887 resizing->from.h = from_h;
888 resizing->to.w = to_w - from_w;
889 resizing->to.h = to_h - from_h;
894 EAPI Elm_Transit_Effect *
895 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
897 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
898 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
902 ERR("Failed to allocate resizing effect! : transit=%p", transit);
905 elm_transit_effect_add(transit,
906 _transit_effect_resizing_op, effect,
907 _transit_effect_resizing_context_free);
911 ///////////////////////////////////////////////////////////////////////////
913 ///////////////////////////////////////////////////////////////////////////
914 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
915 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
917 struct _Elm_Transit_Effect_Translation_Node
923 struct _Elm_Transit_Effect_Translation
925 struct _position_variation {
932 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
934 Elm_Transit_Effect_Translation *translation = data;
936 Elm_Transit_Effect_Translation_Node *translation_node;
938 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
940 if (translation_node->obj != obj) continue;
941 translation->nodes = eina_list_remove_list(translation->nodes, elist);
942 free(translation_node);
948 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
950 Elm_Transit_Effect_Translation_Node *translation_node;
951 const Eina_List *elist;
953 Eina_List *data_list = NULL;
954 const Eina_List *objs = elm_transit_objects_get(transit);
956 EINA_LIST_FOREACH(objs, elist, obj)
958 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
959 if (!translation_node)
961 eina_list_free(data_list);
964 translation_node->obj = obj;
965 evas_object_geometry_get(obj, &(translation_node->x),
966 &(translation_node->y), NULL, NULL);
967 data_list = eina_list_append(data_list, translation_node);
968 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
969 _translation_object_del_cb, translation);
975 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
977 EINA_SAFETY_ON_NULL_RETURN(effect);
978 Elm_Transit_Effect_Translation *translation = effect;
979 Eina_List *elist, *elist_next;
980 Elm_Transit_Effect_Translation_Node *translation_node;
982 EINA_LIST_FOREACH_SAFE(translation->nodes,
983 elist, elist_next, translation_node)
985 evas_object_event_callback_del(translation_node->obj,
986 EVAS_CALLBACK_DEL, _translation_object_del_cb);
987 translation->nodes = eina_list_remove_list(translation->nodes, elist);
988 free(translation_node);
994 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
996 EINA_SAFETY_ON_NULL_RETURN(effect);
997 EINA_SAFETY_ON_NULL_RETURN(transit);
999 Elm_Transit_Effect_Translation *translation = effect;
1000 Elm_Transit_Effect_Translation_Node *translation_node;
1003 if (!translation->nodes)
1004 translation->nodes = _translation_nodes_build(transit, translation);
1006 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1008 x = translation_node->x + translation->from.dx
1009 + (translation->to.dx * progress);
1010 y = translation_node->y + translation->from.dy
1011 + (translation->to.dy * progress);
1012 evas_object_move(translation_node->obj, x, y);
1016 static Elm_Transit_Effect *
1017 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1019 Elm_Transit_Effect_Translation *translation;
1021 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1022 if (!translation) return NULL;
1024 translation->from.dx = from_dx;
1025 translation->from.dy = from_dy;
1026 translation->to.dx = to_dx - from_dx;
1027 translation->to.dy = to_dy - from_dy;
1032 EAPI Elm_Transit_Effect *
1033 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1035 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1036 Elm_Transit_Effect *effect = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1040 ERR("Failed to allocate translation effect! : transit=%p", transit);
1043 elm_transit_effect_add(transit,
1044 _transit_effect_translation_op, effect,
1045 _transit_effect_translation_context_free);
1049 ///////////////////////////////////////////////////////////////////////////
1051 ///////////////////////////////////////////////////////////////////////////
1052 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1054 struct _Elm_Transit_Effect_Zoom
1060 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1062 Elm_Transit_Effect_Zoom *zoom = effect;
1067 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1069 EINA_SAFETY_ON_NULL_RETURN(effect);
1070 EINA_SAFETY_ON_NULL_RETURN(transit);
1073 Elm_Transit_Effect_Zoom *zoom = effect;
1075 Evas_Coord x, y, w, h;
1077 map = evas_map_new(4);
1080 EINA_LIST_FOREACH(transit->objs, elist, obj)
1082 evas_object_geometry_get(obj, &x, &y, &w, &h);
1083 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1084 (progress * zoom->to));
1085 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1086 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0,
1088 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1089 evas_object_map_set(obj, map);
1090 evas_object_map_enable_set(obj, EINA_TRUE);
1095 static Elm_Transit_Effect *
1096 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1098 Elm_Transit_Effect_Zoom *zoom;
1100 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1101 if (!zoom) return NULL;
1103 zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate);
1104 zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from;
1109 EAPI Elm_Transit_Effect *
1110 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1112 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1113 Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate, to_rate);
1117 ERR("Failed to allocate zoom effect! : transit=%p", transit);
1120 elm_transit_effect_add(transit,
1121 _transit_effect_zoom_op, effect,
1122 _transit_effect_zoom_context_free);
1126 ///////////////////////////////////////////////////////////////////////////
1128 ///////////////////////////////////////////////////////////////////////////
1129 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1131 struct _Elm_Transit_Effect_Flip
1133 Elm_Transit_Effect_Flip_Axis axis;
1138 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1140 EINA_SAFETY_ON_NULL_RETURN(effect);
1141 EINA_SAFETY_ON_NULL_RETURN(transit);
1142 Elm_Transit_Effect_Flip *flip = effect;
1143 Evas_Object *front, *back;
1145 int count = eina_list_count(transit->objs);
1147 for (i = 0; i < (count - 1); i += 2)
1149 front = eina_list_nth(transit->objs, i);
1150 back = eina_list_nth(transit->objs, i+1);
1151 evas_object_map_enable_set(front, EINA_FALSE);
1152 evas_object_map_enable_set(back, EINA_FALSE);
1158 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1160 EINA_SAFETY_ON_NULL_RETURN(effect);
1161 EINA_SAFETY_ON_NULL_RETURN(transit);
1162 Evas_Object *obj, *front, *back;
1164 Elm_Transit_Effect_Flip *flip = effect;
1167 Evas_Coord x, y, w, h;
1169 map = evas_map_new(4);
1172 if (flip->cw) degree = (float)(progress * 180);
1173 else degree = (float)(progress * -180);
1175 count = eina_list_count(transit->objs);
1177 for (i = 0; i < (count - 1); i += 2)
1179 Evas_Coord half_w, half_h;
1181 front = eina_list_nth(transit->objs, i);
1182 back = eina_list_nth(transit->objs, i+1);
1184 if ((degree < 90) && (degree > -90))
1189 evas_object_hide(back);
1190 evas_object_show(front);
1198 evas_object_hide(front);
1199 evas_object_show(back);
1203 evas_map_util_points_populate_from_object_full(map, obj, 0);
1204 evas_object_geometry_get(obj, &x, &y, &w, &h);
1208 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1210 if ((degree >= 90) || (degree <= -90))
1212 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
1214 evas_map_point_image_uv_set(map, 0, w, 0);
1215 evas_map_point_image_uv_set(map, 1, 0, 0);
1216 evas_map_point_image_uv_set(map, 2, 0, h);
1217 evas_map_point_image_uv_set(map, 3, w, h);
1221 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1222 evas_map_util_3d_rotate(map, 0, degree,
1223 0, x + half_w, y + half_h, 0);
1227 if ((degree >= 90) || (degree <= -90))
1229 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
1231 evas_map_point_image_uv_set(map, 0, 0, h);
1232 evas_map_point_image_uv_set(map, 1, w, h);
1233 evas_map_point_image_uv_set(map, 2, w, 0);
1234 evas_map_point_image_uv_set(map, 3, 0, 0);
1238 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1239 evas_map_util_3d_rotate(map, degree,
1240 0, 0, x + half_w, y + half_h, 0);
1242 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1243 evas_object_map_enable_set(front, EINA_TRUE);
1244 evas_object_map_enable_set(back, EINA_TRUE);
1245 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1246 evas_object_map_set(obj, map);
1251 static Elm_Transit_Effect *
1252 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1254 Elm_Transit_Effect_Flip *flip;
1256 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1257 if (!flip) return NULL;
1265 EAPI Elm_Transit_Effect *
1266 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1268 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1269 Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw);
1273 ERR("Failed to allocate flip effect! : transit=%p", transit);
1276 elm_transit_effect_add(transit,
1277 _transit_effect_flip_op, effect,
1278 _transit_effect_flip_context_free);
1282 ///////////////////////////////////////////////////////////////////////////
1283 //ResizableFlip Effect
1284 ///////////////////////////////////////////////////////////////////////////
1285 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1286 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1288 struct _Elm_Transit_Effect_Resizable_Flip_Node
1294 } from_pos, from_size, to_pos, to_size;
1297 struct _Elm_Transit_Effect_Resizable_Flip
1301 Elm_Transit_Effect_Flip_Axis axis;
1305 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1307 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1309 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1311 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1313 if (resizable_flip_node->front == obj)
1314 evas_object_event_callback_del(resizable_flip_node->back,
1315 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1316 else if (resizable_flip_node->back == obj)
1317 evas_object_event_callback_del(resizable_flip_node->front,
1318 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1321 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1323 free(resizable_flip_node);
1329 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1331 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1332 Eina_List *data_list = NULL;
1333 Evas_Coord front_x, front_y, front_w, front_h;
1334 Evas_Coord back_x, back_y, back_w, back_h;
1337 count = eina_list_count(transit->objs);
1338 for (i = 0; i < (count - 1); i += 2)
1340 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1341 if (!resizable_flip_node)
1343 eina_list_free(data_list);
1347 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1348 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1350 evas_object_geometry_get(resizable_flip_node->front,
1351 &front_x, &front_y, &front_w, &front_h);
1352 evas_object_geometry_get(resizable_flip_node->back,
1353 &back_x, &back_y, &back_w, &back_h);
1355 resizable_flip_node->from_pos.x = front_x;
1356 resizable_flip_node->from_pos.y = front_y;
1357 resizable_flip_node->to_pos.x = back_x - front_x;
1358 resizable_flip_node->to_pos.y = back_y - front_y;
1360 resizable_flip_node->from_size.x = front_w;
1361 resizable_flip_node->from_size.y = front_h;
1362 resizable_flip_node->to_size.x = back_w - front_w;
1363 resizable_flip_node->to_size.y = back_h - front_h;
1365 data_list = eina_list_append(data_list, resizable_flip_node);
1367 evas_object_event_callback_add(resizable_flip_node->back,
1368 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1369 evas_object_event_callback_add(resizable_flip_node->front,
1370 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1377 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
1381 evas_map_point_image_uv_set(map, 0,
1382 (flip->from_size.x * 2) + flip->to_size.x,
1384 evas_map_point_image_uv_set(map, 1, 0, 0);
1385 evas_map_point_image_uv_set(map, 2, 0,
1386 (flip->from_size.y * 2) + flip->to_size.y);
1387 evas_map_point_image_uv_set(map, 3,
1388 (flip->from_size.x * 2) + flip->to_size.x,
1389 (flip->from_size.y * 2) + flip->to_size.y);
1393 evas_map_point_image_uv_set(map, 0, 0, 0);
1394 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1395 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1397 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1402 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
1406 evas_map_point_image_uv_set(map, 0, 0,
1407 (flip->from_size.y * 2) + flip->to_size.y);
1408 evas_map_point_image_uv_set(map, 1,
1409 (flip->from_size.x * 2) + flip->to_size.x,
1410 (flip->from_size.y * 2) + flip->to_size.y);
1411 evas_map_point_image_uv_set(map, 2,
1412 (flip->from_size.x * 2) + flip->to_size.x,
1414 evas_map_point_image_uv_set(map, 3, 0, 0);
1418 evas_map_point_image_uv_set(map, 0, 0, 0);
1419 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1420 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1422 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1427 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1429 EINA_SAFETY_ON_NULL_RETURN(effect);
1431 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1432 Eina_List *elist, *elist_next;
1433 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1435 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1436 elist, elist_next, resizable_flip_node)
1438 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1439 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1441 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1444 evas_object_event_callback_del(resizable_flip_node->back,
1445 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1446 evas_object_event_callback_del(resizable_flip_node->front,
1447 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1448 free(resizable_flip_node);
1450 free(resizable_flip);
1454 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1456 EINA_SAFETY_ON_NULL_RETURN(effect);
1461 Evas_Coord half_w, half_h;
1462 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1463 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1466 map = evas_map_new(4);
1469 if (resizable_flip->cw) degree = (float)(progress * 180);
1470 else degree = (float)(progress * -180);
1472 if (!resizable_flip->nodes)
1473 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1476 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1478 if ((degree < 90) && (degree > -90))
1480 obj = resizable_flip_node->front;
1481 if (resizable_flip_node->front != resizable_flip_node->back)
1483 evas_object_hide(resizable_flip_node->back);
1484 evas_object_show(resizable_flip_node->front);
1489 obj = resizable_flip_node->back;
1490 if (resizable_flip_node->front != resizable_flip_node->back)
1492 evas_object_hide(resizable_flip_node->front);
1493 evas_object_show(resizable_flip_node->back);
1497 x = resizable_flip_node->from_pos.x +
1498 (resizable_flip_node->to_pos.x * progress);
1499 y = resizable_flip_node->from_pos.y +
1500 (resizable_flip_node->to_pos.y * progress);
1501 w = resizable_flip_node->from_size.x +
1502 (resizable_flip_node->to_size.x * progress);
1503 h = resizable_flip_node->from_size.y +
1504 (resizable_flip_node->to_size.y * progress);
1505 evas_map_point_coord_set(map, 0, x, y, 0);
1506 evas_map_point_coord_set(map, 1, x + w, y, 0);
1507 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1508 evas_map_point_coord_set(map, 3, x, y + h, 0);
1510 half_w = (Evas_Coord)(w / 2);
1511 half_h = (Evas_Coord)(h / 2);
1513 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1515 if ((degree >= 90) || (degree <= -90))
1517 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
1518 _set_image_uv_by_axis_y(map, resizable_flip_node,
1523 if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE))
1524 _set_image_uv_by_axis_y(map, resizable_flip_node,
1527 evas_map_util_3d_rotate(map, 0, degree,
1528 0, x + half_w, y + half_h, 0);
1532 if ((degree >= 90) || (degree <= -90))
1534 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
1535 _set_image_uv_by_axis_x(map, resizable_flip_node,
1540 if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_TRUE))
1541 _set_image_uv_by_axis_x(map, resizable_flip_node,
1544 evas_map_util_3d_rotate(map, degree, 0,
1545 0, x + half_w, y + half_h, 0);
1548 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0,
1550 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1551 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1552 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1553 evas_object_map_set(obj, map);
1558 static Elm_Transit_Effect *
1559 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1561 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1563 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1564 if (!resizable_flip) return NULL;
1566 resizable_flip->cw = cw;
1567 resizable_flip->axis = axis;
1569 return resizable_flip;
1572 EAPI Elm_Transit_Effect *
1573 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1575 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1576 Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw);
1580 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
1583 elm_transit_effect_add(transit,
1584 _transit_effect_resizable_flip_op, effect,
1585 _transit_effect_resizable_flip_context_free);
1589 ///////////////////////////////////////////////////////////////////////////
1591 ///////////////////////////////////////////////////////////////////////////
1592 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1594 struct _Elm_Transit_Effect_Wipe
1596 Elm_Transit_Effect_Wipe_Type type;
1597 Elm_Transit_Effect_Wipe_Dir dir;
1601 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, float progress)
1607 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1608 w2 = w - (w * progress);
1610 evas_map_point_image_uv_set(map, 0, 0, 0);
1611 evas_map_point_image_uv_set(map, 1, w2, 0);
1612 evas_map_point_image_uv_set(map, 2, w2, h);
1613 evas_map_point_image_uv_set(map, 3, 0, h);
1614 evas_map_point_coord_set(map, 0, x, y, 0);
1615 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1616 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1617 evas_map_point_coord_set(map, 3, x, h2, 0);
1619 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1620 w2 = (w * progress);
1622 evas_map_point_image_uv_set(map, 0, w2, 0);
1623 evas_map_point_image_uv_set(map, 1, w, 0);
1624 evas_map_point_image_uv_set(map, 2, w, h);
1625 evas_map_point_image_uv_set(map, 3, w2, h);
1626 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1627 evas_map_point_coord_set(map, 1, x + w, y, 0);
1628 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1629 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1631 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1633 h2 = h - (h * progress);
1634 evas_map_point_image_uv_set(map, 0, 0, 0);
1635 evas_map_point_image_uv_set(map, 1, w, 0);
1636 evas_map_point_image_uv_set(map, 2, w, h2);
1637 evas_map_point_image_uv_set(map, 3, 0, h2);
1638 evas_map_point_coord_set(map, 0, x, y, 0);
1639 evas_map_point_coord_set(map, 1, w2, y, 0);
1640 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1641 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1643 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1645 h2 = (h * progress);
1646 evas_map_point_image_uv_set(map, 0, 0, h2);
1647 evas_map_point_image_uv_set(map, 1, w, h2);
1648 evas_map_point_image_uv_set(map, 2, w, h);
1649 evas_map_point_image_uv_set(map, 3, 0, h);
1650 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1651 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1652 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1653 evas_map_point_coord_set(map, 3, x, y + h, 0);
1658 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1662 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, float progress)
1668 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1669 w2 = (w - (w * progress));
1671 evas_map_point_image_uv_set(map, 0, w2, 0);
1672 evas_map_point_image_uv_set(map, 1, w, 0);
1673 evas_map_point_image_uv_set(map, 2, w, h);
1674 evas_map_point_image_uv_set(map, 3, w2, h);
1675 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1676 evas_map_point_coord_set(map, 1, w, y, 0);
1677 evas_map_point_coord_set(map, 2, w, h2, 0);
1678 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1680 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1681 w2 = (w * progress);
1683 evas_map_point_image_uv_set(map, 0, 0, 0);
1684 evas_map_point_image_uv_set(map, 1, w2, 0);
1685 evas_map_point_image_uv_set(map, 2, w2, h);
1686 evas_map_point_image_uv_set(map, 3, 0, h);
1687 evas_map_point_coord_set(map, 0, x, y, 0);
1688 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1689 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1690 evas_map_point_coord_set(map, 3, x, h2, 0);
1692 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1694 h2 = (h - (h * progress));
1695 evas_map_point_image_uv_set(map, 0, 0, h2);
1696 evas_map_point_image_uv_set(map, 1, w, h2);
1697 evas_map_point_image_uv_set(map, 2, w, h);
1698 evas_map_point_image_uv_set(map, 3, 0, h);
1699 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1700 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1701 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1702 evas_map_point_coord_set(map, 3, x, y + h, 0);
1704 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1706 h2 = (h * progress);
1707 evas_map_point_image_uv_set(map, 0, 0, 0);
1708 evas_map_point_image_uv_set(map, 1, w, 0);
1709 evas_map_point_image_uv_set(map, 2, w, h2);
1710 evas_map_point_image_uv_set(map, 3, 0, h2);
1711 evas_map_point_coord_set(map, 0, x, y, 0);
1712 evas_map_point_coord_set(map, 1, w2, y, 0);
1713 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1714 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1719 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1723 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1725 EINA_SAFETY_ON_NULL_RETURN(effect);
1726 EINA_SAFETY_ON_NULL_RETURN(transit);
1729 Elm_Transit_Effect_Wipe *wipe = effect;
1730 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1732 EINA_LIST_FOREACH(transit->objs, elist, obj)
1734 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1735 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1736 evas_object_show(obj);
1737 else evas_object_hide(obj);
1738 evas_object_map_enable_set(obj, EINA_FALSE);
1745 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1747 EINA_SAFETY_ON_NULL_RETURN(effect);
1748 EINA_SAFETY_ON_NULL_RETURN(transit);
1749 Elm_Transit_Effect_Wipe *wipe = effect;
1751 Evas_Coord _x, _y, _w, _h;
1756 map = evas_map_new(4);
1759 EINA_LIST_FOREACH(transit->objs, elist, obj)
1761 type = evas_object_type_get(obj);
1762 if ((!type) || (strcmp(type, "image")) ||
1763 evas_object_image_source_get(obj))
1764 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1767 evas_object_image_size_get(obj, &_w, &_h);
1771 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1772 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1774 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1775 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1776 evas_object_map_enable_set(obj, EINA_TRUE);
1777 evas_object_map_set(obj, map);
1782 static Elm_Transit_Effect *
1783 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1785 Elm_Transit_Effect_Wipe *wipe;
1787 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1788 if (!wipe) return NULL;
1797 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1799 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1800 void *effect = _transit_effect_wipe_context_new(type, dir);
1804 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1807 elm_transit_effect_add(transit,
1808 _transit_effect_wipe_op, effect,
1809 _transit_effect_wipe_context_free);
1813 ///////////////////////////////////////////////////////////////////////////
1815 ///////////////////////////////////////////////////////////////////////////
1816 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1818 struct _Elm_Transit_Effect_Color
1820 struct _unsigned_color {
1821 unsigned int r, g, b, a;
1823 struct _signed_color {
1829 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1831 Elm_Transit_Effect_Color *color = effect;
1836 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1838 EINA_SAFETY_ON_NULL_RETURN(effect);
1839 EINA_SAFETY_ON_NULL_RETURN(transit);
1840 Elm_Transit_Effect_Color *color = effect;
1843 unsigned int r, g, b, a;
1845 r = (color->from.r + (int)((float)color->to.r * progress));
1846 g = (color->from.g + (int)((float)color->to.g * progress));
1847 b = (color->from.b + (int)((float)color->to.b * progress));
1848 a = (color->from.a + (int)((float)color->to.a * progress));
1850 EINA_LIST_FOREACH(transit->objs, elist, obj)
1851 evas_object_color_set(obj, r, g, b, a);
1854 static Elm_Transit_Effect *
1855 _transit_effect_color_context_new(unsigned int from_r, unsigned int from_g, unsigned int from_b, unsigned int from_a, unsigned int to_r, unsigned int to_g, unsigned int to_b, unsigned int to_a)
1857 Elm_Transit_Effect_Color *color;
1859 color = ELM_NEW(Elm_Transit_Effect_Color);
1860 if (!color) return NULL;
1862 color->from.r = from_r;
1863 color->from.g = from_g;
1864 color->from.b = from_b;
1865 color->from.a = from_a;
1866 color->to.r = to_r - from_r;
1867 color->to.g = to_g - from_g;
1868 color->to.b = to_b - from_b;
1869 color->to.a = to_a - from_a;
1874 EAPI Elm_Transit_Effect *
1875 elm_transit_effect_color_add(Elm_Transit *transit, unsigned int from_r, unsigned int from_g, unsigned int from_b, unsigned int from_a, unsigned int to_r, unsigned int to_g, unsigned int to_b, unsigned int to_a)
1877 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1878 Elm_Transit_Effect *effect = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
1882 ERR("Failed to allocate color effect! : transit=%p", transit);
1885 elm_transit_effect_add(transit,
1886 _transit_effect_color_op, effect,
1887 _transit_effect_color_context_free);
1891 ///////////////////////////////////////////////////////////////////////////
1893 ///////////////////////////////////////////////////////////////////////////
1894 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1895 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1897 struct _Elm_Transit_Effect_Fade_Node
1899 Evas_Object *before;
1901 struct _signed_color before_color, after_color;
1904 Eina_Bool inversed : 1;
1907 struct _Elm_Transit_Effect_Fade
1913 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1915 Elm_Transit_Effect_Fade *fade = data;
1917 Elm_Transit_Effect_Fade_Node *fade_node;
1919 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1921 if (fade_node->before == obj)
1922 evas_object_event_callback_del(fade_node->after,
1923 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1924 else if (fade_node->after == obj)
1925 evas_object_event_callback_del(fade_node->before,
1926 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1929 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1936 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
1938 Elm_Transit_Effect_Fade_Node *fade;
1939 Eina_List *data_list = NULL;
1942 count = eina_list_count(transit->objs);
1943 for (i = 0; i < count; i += 2)
1945 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
1948 eina_list_free(data_list);
1952 fade->before = eina_list_nth(transit->objs, i);
1953 fade->after = eina_list_nth(transit->objs, i+1);
1955 evas_object_color_get(fade->before,
1956 &fade->before_color.r, &fade->before_color.g,
1957 &fade->before_color.b, &fade->before_color.a);
1958 evas_object_color_get(fade->after,
1959 &fade->after_color.r, &fade->after_color.g,
1960 &fade->after_color.b, &fade->after_color.a);
1962 fade->before_alpha = (255 - fade->before_color.a);
1963 fade->after_alpha = (255 - fade->after_color.a);
1965 data_list = eina_list_append(data_list, fade);
1967 evas_object_event_callback_add(fade->before,
1968 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1969 evas_object_event_callback_add(fade->after,
1970 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
1976 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1978 EINA_SAFETY_ON_NULL_RETURN(effect);
1979 Elm_Transit_Effect_Fade *fade = effect;
1980 Elm_Transit_Effect_Fade_Node *fade_node;
1981 Eina_List *elist, *elist_next;
1983 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
1985 evas_object_color_set(fade_node->before, fade_node->before_color.r,
1986 fade_node->before_color.g,
1987 fade_node->before_color.b,
1988 fade_node->before_color.a);
1989 evas_object_color_set(fade_node->after, fade_node->after_color.r,
1990 fade_node->after_color.g,
1991 fade_node->after_color.b,
1992 fade_node->after_color.a);
1994 fade->nodes = eina_list_remove_list(fade->nodes, elist);
1995 evas_object_event_callback_del(fade_node->before,
1996 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1997 evas_object_event_callback_del(fade_node->after,
1998 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2006 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2008 EINA_SAFETY_ON_NULL_RETURN(effect);
2009 Elm_Transit_Effect_Fade *fade = effect;
2011 Elm_Transit_Effect_Fade_Node *fade_node;
2015 fade->nodes = _fade_nodes_build(transit, fade);
2017 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2021 if (!fade_node->inversed)
2023 evas_object_hide(fade_node->after);
2024 evas_object_show(fade_node->before);
2025 fade_node->inversed = EINA_TRUE;
2028 _progress = (1 - (progress * 2));
2030 evas_object_color_set(fade_node->before,
2031 fade_node->before_color.r * _progress,
2032 fade_node->before_color.g * _progress,
2033 fade_node->before_color.b * _progress,
2034 fade_node->before_color.a +
2035 fade_node->before_alpha * (1 - _progress));
2039 if (fade_node->inversed)
2041 evas_object_hide(fade_node->before);
2042 evas_object_show(fade_node->after);
2043 fade_node->inversed = EINA_FALSE;
2046 _progress = ((progress - 0.5) * 2);
2048 evas_object_color_set(fade_node->after,
2049 fade_node->after_color.r * _progress,
2050 fade_node->after_color.g * _progress,
2051 fade_node->after_color.b * _progress,
2052 fade_node->after_color.a +
2053 fade_node->after_alpha * (1 - _progress));
2058 static Elm_Transit_Effect *
2059 _transit_effect_fade_context_new(void)
2061 Elm_Transit_Effect_Fade *fade;
2062 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2063 if (!fade) return NULL;
2067 EAPI Elm_Transit_Effect *
2068 elm_transit_effect_fade_add(Elm_Transit *transit)
2070 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2072 Elm_Transit_Effect *effect = _transit_effect_fade_context_new();
2076 ERR("Failed to allocate fade effect! : transit=%p", transit);
2079 elm_transit_effect_add(transit,
2080 _transit_effect_fade_op, effect,
2081 _transit_effect_fade_context_free);
2085 ///////////////////////////////////////////////////////////////////////////
2087 ///////////////////////////////////////////////////////////////////////////
2088 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2089 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2091 struct _Elm_Transit_Effect_Blend_Node
2093 Evas_Object *before;
2095 struct _signed_color from, to;
2098 struct _Elm_Transit_Effect_Blend
2104 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2106 Elm_Transit_Effect_Blend *blend = data;
2108 Elm_Transit_Effect_Blend_Node *blend_node;
2110 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2112 if (blend_node->after == obj)
2113 evas_object_event_callback_del(blend_node->before,
2114 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2115 else if (blend_node->before == obj)
2116 evas_object_event_callback_del(blend_node->after,
2117 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2120 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2127 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2129 Elm_Transit_Effect_Blend_Node *blend_node;
2130 Eina_List *data_list = NULL;
2133 count = eina_list_count(transit->objs);
2134 for (i = 0; i < (count - 1); i += 2)
2136 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2139 eina_list_free(data_list);
2143 blend_node->before = eina_list_nth(transit->objs, i);
2144 blend_node->after = eina_list_nth(transit->objs, i + 1);
2145 evas_object_show(blend_node->before);
2146 evas_object_show(blend_node->after);
2148 evas_object_color_get(blend_node->before, &blend_node->from.r,
2149 &blend_node->from.g, &blend_node->from.b,
2150 &blend_node->from.a);
2151 evas_object_color_get(blend_node->after, &blend_node->to.r,
2152 &blend_node->to.g, &blend_node->to.b,
2155 data_list = eina_list_append(data_list, blend_node);
2157 evas_object_event_callback_add(blend_node->before,
2158 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2159 evas_object_event_callback_add(blend_node->after,
2160 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2166 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2168 EINA_SAFETY_ON_NULL_RETURN(effect);
2169 Elm_Transit_Effect_Blend *blend = effect;
2170 Elm_Transit_Effect_Blend_Node *blend_node;
2171 Eina_List *elist, *elist_next;
2173 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2175 evas_object_color_set(blend_node->before,
2176 blend_node->from.r, blend_node->from.g,
2177 blend_node->from.b, blend_node->from.a);
2178 evas_object_color_set(blend_node->after, blend_node->to.r,
2179 blend_node->to.g, blend_node->to.b,
2182 if (elm_transit_auto_reverse_get(transit))
2183 evas_object_hide(blend_node->after);
2185 evas_object_hide(blend_node->before);
2187 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2189 evas_object_event_callback_del(blend_node->before,
2190 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2191 evas_object_event_callback_del(blend_node->after,
2192 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2199 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2201 EINA_SAFETY_ON_NULL_RETURN(effect);
2202 EINA_SAFETY_ON_NULL_RETURN(transit);
2203 Elm_Transit_Effect_Blend *blend = effect;
2204 Elm_Transit_Effect_Blend_Node *blend_node;
2207 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2209 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2211 evas_object_color_set(blend_node->before,
2212 (int)(blend_node->from.r * (1 - progress)),
2213 (int)(blend_node->from.g * (1 - progress)),
2214 (int)(blend_node->from.b * (1 - progress)),
2215 (int)(blend_node->from.a * (1 - progress)));
2216 evas_object_color_set(blend_node->after,
2217 (int)(blend_node->to.r * progress),
2218 (int)(blend_node->to.g * progress),
2219 (int)(blend_node->to.b * progress),
2220 (int)(blend_node->to.a * progress));
2224 static Elm_Transit_Effect *
2225 _transit_effect_blend_context_new(void)
2227 Elm_Transit_Effect_Blend *blend;
2229 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2230 if (!blend) return NULL;
2234 EAPI Elm_Transit_Effect *
2235 elm_transit_effect_blend_add(Elm_Transit *transit)
2237 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2238 Elm_Transit_Effect *effect = _transit_effect_blend_context_new();
2242 ERR("Failed to allocate blend effect! : transit=%p", transit);
2245 elm_transit_effect_add(transit,
2246 _transit_effect_blend_op, effect,
2247 _transit_effect_blend_context_free);
2251 ///////////////////////////////////////////////////////////////////////////
2253 ///////////////////////////////////////////////////////////////////////////
2254 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2256 struct _Elm_Transit_Effect_Rotation
2262 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2264 Elm_Transit_Effect_Rotation *rotation = effect;
2269 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2271 EINA_SAFETY_ON_NULL_RETURN(effect);
2272 EINA_SAFETY_ON_NULL_RETURN(transit);
2273 Elm_Transit_Effect_Rotation *rotation = effect;
2275 Evas_Coord x, y, w, h;
2277 float half_w, half_h;
2281 map = evas_map_new(4);
2284 EINA_LIST_FOREACH(transit->objs, elist, obj)
2286 evas_map_util_points_populate_from_object_full(map, obj, 0);
2287 degree = rotation->from + (float)(progress * rotation->to);
2289 evas_object_geometry_get(obj, &x, &y, &w, &h);
2291 half_w = (float)w * 0.5;
2292 half_h = (float)h * 0.5;
2294 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2295 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
2296 evas_object_map_enable_set(obj, EINA_TRUE);
2297 evas_object_map_set(obj, map);
2302 static Elm_Transit_Effect *
2303 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2305 Elm_Transit_Effect_Rotation *rotation;
2307 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2308 if (!rotation) return NULL;
2310 rotation->from = from_degree;
2311 rotation->to = to_degree - from_degree;
2316 EAPI Elm_Transit_Effect *
2317 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2319 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2320 Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree);
2324 ERR("Failed to allocate rotation effect! : transit=%p", transit);
2327 elm_transit_effect_add(transit,
2328 _transit_effect_rotation_op, effect,
2329 _transit_effect_rotation_context_free);
2333 ///////////////////////////////////////////////////////////////////////////
2334 //ImageAnimation Effect
2335 ///////////////////////////////////////////////////////////////////////////
2336 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2338 struct _Elm_Transit_Effect_Image_Animation
2341 unsigned int prev_idx;
2345 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2347 EINA_SAFETY_ON_NULL_RETURN(effect);
2348 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2350 Eina_List *elist, *elist_next;
2352 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2354 image_animation->images =
2355 eina_list_remove_list(image_animation->images, elist);
2356 eina_stringshare_del(image);
2359 free(image_animation);
2363 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2365 EINA_SAFETY_ON_NULL_RETURN(effect);
2366 EINA_SAFETY_ON_NULL_RETURN(transit);
2369 const char *type, *type_deprecated;
2370 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2371 unsigned int idx = 0;
2374 type = eina_stringshare_add("elm_image");
2375 //FIXME: Remove later when elm_icon is cleared.
2376 type_deprecated = eina_stringshare_add("elm_icon");
2378 len = eina_list_count(image_animation->images);
2381 idx = floor(progress * len);
2382 if (image_animation->prev_idx != idx)
2384 EINA_LIST_FOREACH(transit->objs, elist, obj)
2386 if (elm_widget_type_check(obj, type, __func__) ||
2387 elm_widget_type_check(obj, type_deprecated, __func__))
2389 const char *file = eina_list_nth(image_animation->images,
2392 elm_image_file_set(obj, file, NULL);
2393 elm_image_preload_disabled_set(obj, EINA_TRUE);
2397 image_animation->prev_idx = idx;
2400 eina_stringshare_del(type);
2401 eina_stringshare_del(type_deprecated);
2404 static Elm_Transit_Effect *
2405 _transit_effect_image_animation_context_new(Eina_List *images)
2407 Elm_Transit_Effect_Image_Animation *image_animation;
2408 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2410 if (!image_animation) return NULL;
2411 image_animation->images = images;
2412 image_animation->prev_idx = -1;
2413 return image_animation;
2416 EAPI Elm_Transit_Effect *
2417 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2419 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2420 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2424 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2427 elm_transit_effect_add(transit,
2428 _transit_effect_image_animation_op, effect,
2429 _transit_effect_image_animation_context_free);