2 # include "elementary_config.h"
5 #include <Elementary.h>
9 #define ELM_TRANSIT_CHECK_OR_RETURN(transit, ...) \
12 CRI("Elm_Transit " # transit " is NULL!"); \
15 if (!EINA_MAGIC_CHECK(transit, ELM_TRANSIT_MAGIC)) { \
16 EINA_MAGIC_FAIL(transit, ELM_TRANSIT_MAGIC); \
19 if (transit->deleted){ \
20 ERR("Elm_Transit " # transit " has already been deleted!"); \
25 #define _TRANSIT_FOCAL 2000
29 #define ELM_TRANSIT_MAGIC 0xd27f190a
32 Ecore_Animator *animator;
34 Eina_Inlist *effect_list;
36 Elm_Transit *prev_chain_transit;
37 Eina_List *next_chain_transits;
38 Elm_Transit_Tween_Mode tween_mode;
41 Elm_Transit_Del_Cb func;
59 unsigned int effects_pending_del;
62 Eina_Bool auto_reverse : 1;
63 Eina_Bool event_enabled : 1;
64 Eina_Bool deleted : 1;
65 Eina_Bool state_keep : 1;
66 Eina_Bool finished : 1;
70 struct _Elm_Transit_Effect_Module
73 Elm_Transit_Effect_Transition_Cb transition_cb;
74 Elm_Transit_Effect_End_Cb end_cb;
75 Elm_Transit_Effect *effect;
76 Eina_Bool deleted : 1;
79 struct _Elm_Transit_Obj_Data
82 Evas_Coord x, y, w, h;
85 Eina_Bool map_enabled : 1;
86 Eina_Bool visible : 1;
87 Eina_Bool freeze_events : 1;
92 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
93 typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data;
95 static void _transit_obj_data_save(Evas_Object *obj);
96 static void _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj);
97 static void _transit_obj_remove_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
98 static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
99 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
100 static void _transit_remove_dead_effects(Elm_Transit *transit);
101 static void _transit_chain_go(Elm_Transit *transit);
102 static void _transit_del(Elm_Transit *transit);
103 static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress);
104 static Eina_Bool _transit_animate_cb(void *data);
106 static char *_transit_key= "_elm_transit_key";
109 _transit_obj_data_save(Evas_Object *obj)
111 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
119 obj_data = ELM_NEW(Elm_Transit_Obj_Data);
122 ERR("Failed to allocate memory");
126 evas_object_geometry_get(obj, &obj_data->state.x, &obj_data->state.y,
127 &obj_data->state.w, &obj_data->state.h);
128 evas_object_color_get(obj, &obj_data->state.r, &obj_data->state.g,
129 &obj_data->state.b, &obj_data->state.a);
130 obj_data->state.visible = evas_object_visible_get(obj);
131 obj_data->state.freeze_events = evas_object_freeze_events_get(obj);
132 obj_data->state.map_enabled = evas_object_map_enable_get(obj);
134 ELM_SAFE_FREE(obj_data->state.map, evas_map_free);
136 if (evas_object_map_get(obj))
137 obj_data->state.map = evas_map_dup(evas_object_map_get(obj));
141 evas_object_data_set(obj, _transit_key, obj_data);
145 _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
147 //Remove duplicated objects
148 //TODO: Need to consider about optimizing here
151 if (!eina_list_data_find_list(transit->objs, obj))
153 transit->objs = eina_list_remove(transit->objs, obj);
154 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
155 _transit_obj_remove_cb,
161 _transit_obj_remove_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
163 Elm_Transit *transit = data;
164 Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
168 if (obj_data->ref == 0)
171 evas_object_data_del(obj, _transit_key);
174 _remove_obj_from_list(transit, obj);
175 if (!transit->objs && !transit->deleted) elm_transit_del(transit);
179 _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
181 Elm_Transit_Obj_Data *obj_data;
183 obj_data = evas_object_data_get(obj, _transit_key);
184 if (!obj_data) return;
188 //recover the states of the object.
189 if (!transit->state_keep)
191 evas_object_move(obj, obj_data->state.x, obj_data->state.y);
192 evas_object_resize(obj, obj_data->state.w, obj_data->state.h);
193 evas_object_color_set(obj, obj_data->state.r, obj_data->state.g,
194 obj_data->state.b, obj_data->state.a);
195 if (obj_data->state.visible) evas_object_show(obj);
196 else evas_object_hide(obj);
197 evas_object_map_enable_set(obj, obj_data->state.map_enabled);
198 evas_object_map_set(obj, obj_data->state.map);
201 if (obj_data->ref == 0)
203 ELM_SAFE_FREE(obj_data->state.map, evas_map_free);
204 evas_object_data_del(obj, _transit_key);
205 evas_object_freeze_events_set(obj, obj_data->state.freeze_events);
211 _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj)
213 _remove_obj_from_list(transit, obj);
214 _transit_obj_data_recover(transit, obj);
218 _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module)
220 if (effect_module->end_cb)
221 effect_module->end_cb(effect_module->effect, transit);
226 _transit_remove_dead_effects(Elm_Transit *transit)
228 Elm_Transit_Effect_Module *effect_module = NULL;
231 EINA_INLIST_FOREACH_SAFE(transit->effect_list, ll, effect_module)
233 if (effect_module->deleted)
235 _transit_effect_del(transit, effect_module);
236 transit->effects_pending_del--;
237 if (!transit->effects_pending_del) return;
243 _transit_chain_go(Elm_Transit *transit)
245 ELM_TRANSIT_CHECK_OR_RETURN(transit);
246 elm_transit_go(transit);
250 _transit_del(Elm_Transit *transit)
252 Elm_Transit_Effect_Module *effect_module;
253 Elm_Transit *chain_transit;
254 Eina_List *elist, *elist_next;
256 transit->deleted = EINA_TRUE;
258 ELM_SAFE_FREE(transit->animator, ecore_animator_del);
261 while (transit->effect_list)
263 effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module);
264 transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list);
265 _transit_effect_del(transit, effect_module);
269 while (transit->objs)
270 _transit_obj_remove(transit, eina_list_data_get(transit->objs));
272 if (transit->del_data.func)
273 transit->del_data.func(transit->del_data.arg, transit);
275 ecore_timer_del(transit->timer);
277 //cut off the chain transit relationship
278 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
279 chain_transit->prev_chain_transit = NULL;
281 if (transit->prev_chain_transit)
282 transit->prev_chain_transit->next_chain_transits =
283 eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
285 // run chain transits
286 if (transit->finished && transit->next_chain_transits)
288 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
289 _transit_chain_go(chain_transit);
292 eina_list_free(transit->next_chain_transits);
294 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
298 //If the transit is deleted then EINA_FALSE is retruned.
300 _transit_animate_op(Elm_Transit *transit, double progress)
302 Elm_Transit_Effect_Module *effect_module;
305 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
307 if (transit->deleted) break;
308 if (!effect_module->deleted)
309 effect_module->transition_cb(effect_module->effect, transit, progress);
313 if (transit->walking) return EINA_TRUE;
315 if (transit->deleted)
317 _transit_del(transit);
321 else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
327 _transit_animate_cb(void *data)
329 Elm_Transit *transit = data;
330 double elapsed_time, duration;
332 transit->time.current = ecore_loop_time_get();
333 elapsed_time = transit->time.current - transit->time.begin;
334 duration = transit->time.duration + transit->time.delayed;
336 if (elapsed_time > duration)
337 elapsed_time = duration;
339 transit->progress = elapsed_time / duration;
340 switch (transit->tween_mode)
342 case ELM_TRANSIT_TWEEN_MODE_LINEAR:
343 transit->progress = ecore_animator_pos_map(transit->progress,
344 ECORE_POS_MAP_LINEAR,
347 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
349 ecore_animator_pos_map(transit->progress,
350 ECORE_POS_MAP_ACCELERATE_FACTOR,
353 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
355 ecore_animator_pos_map(transit->progress,
356 ECORE_POS_MAP_DECELERATE_FACTOR,
359 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
361 ecore_animator_pos_map(transit->progress,
362 ECORE_POS_MAP_SINUSOIDAL_FACTOR,
365 case ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP:
366 transit->progress = ecore_animator_pos_map(transit->progress,
367 ECORE_POS_MAP_DIVISOR_INTERP,
368 transit->v[0], transit->v[1]);
370 case ELM_TRANSIT_TWEEN_MODE_BOUNCE:
371 transit->progress = ecore_animator_pos_map(transit->progress,
372 ECORE_POS_MAP_BOUNCE,
373 transit->v[0], transit->v[1]);
375 case ELM_TRANSIT_TWEEN_MODE_SPRING:
376 transit->progress = ecore_animator_pos_map(transit->progress,
377 ECORE_POS_MAP_SPRING,
378 transit->v[0], transit->v[1]);
380 case ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE:
381 transit->progress = ecore_animator_pos_map_n(transit->progress,
382 ECORE_POS_MAP_CUBIC_BEZIER,
390 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
392 if (transit->time.duration > 0)
394 if (!_transit_animate_op(transit, transit->progress))
395 return ECORE_CALLBACK_CANCEL;
398 /* Not end. Keep going. */
399 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
401 /* Repeat and reverse and time done! */
402 if ((transit->repeat.count >= 0) &&
403 (transit->repeat.current == transit->repeat.count) &&
404 ((!transit->auto_reverse) || transit->repeat.reverse))
406 transit->finished = EINA_TRUE;
407 elm_transit_del(transit);
408 return ECORE_CALLBACK_CANCEL;
412 if (!transit->auto_reverse || transit->repeat.reverse)
414 transit->repeat.current++;
415 transit->repeat.reverse = EINA_FALSE;
417 else transit->repeat.reverse = EINA_TRUE;
419 transit->time.begin = ecore_loop_time_get();
421 return ECORE_CALLBACK_RENEW;
425 _recover_image_uv_by_y(Evas_Map *map, int iw, int ih)
427 evas_map_point_image_uv_set(map, 0, iw, 0);
428 evas_map_point_image_uv_set(map, 1, 0, 0);
429 evas_map_point_image_uv_set(map, 2, 0, ih);
430 evas_map_point_image_uv_set(map, 3, iw, ih);
434 _recover_image_uv_by_x(Evas_Map *map, int iw, int ih)
436 evas_map_point_image_uv_set(map, 0, 0, ih);
437 evas_map_point_image_uv_set(map, 1, iw, ih);
438 evas_map_point_image_uv_set(map, 2, iw, 0);
439 evas_map_point_image_uv_set(map, 3, 0, 0);
443 _recover_image_uv(Evas_Object *obj, Evas_Map *map, Eina_Bool revert, Eina_Bool by_x)
445 //Since the map is not proper for all types of objects,
446 //Need to handle uvs only for image objects
448 const char *type = evas_object_type_get(obj);
449 if ((!type) || (strcmp(type, "image"))) return EINA_FALSE;
450 if (evas_object_image_source_get(obj)) return EINA_FALSE;
452 evas_object_image_size_get(obj, &iw, &ih);
457 _recover_image_uv_by_x(map, iw, ih);
459 _recover_image_uv_by_y(map, iw, ih);
463 evas_map_point_image_uv_set(map, 0, 0, 0);
464 evas_map_point_image_uv_set(map, 1, iw, 0);
465 evas_map_point_image_uv_set(map, 2, iw, ih);
466 evas_map_point_image_uv_set(map, 3, 0, ih);
472 _transit_go_in_cb(void *data)
474 Elm_Transit *transit = data;
476 transit->timer = NULL;
477 elm_transit_go(transit);
479 return ECORE_CALLBACK_CANCEL;
483 elm_transit_add(void)
485 Elm_Transit *transit = ELM_NEW(Elm_Transit);
488 ERR("Failed to allocate a elm_transit object!");
492 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
494 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
498 transit->smooth = EINA_TRUE;
504 elm_transit_del(Elm_Transit *transit)
506 if (!transit) return;
508 ELM_TRANSIT_CHECK_OR_RETURN(transit);
510 transit->deleted = EINA_TRUE;
511 if (transit->walking) return;
512 _transit_del(transit);
516 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)
518 ELM_TRANSIT_CHECK_OR_RETURN(transit);
519 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
520 Elm_Transit_Effect_Module *effect_module;
522 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
523 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
525 WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit);
529 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
532 ERR("Failed to allocate a new effect!: transit=%p", transit);
536 effect_module->end_cb = end_cb;
537 effect_module->transition_cb = transition_cb;
538 effect_module->effect = effect;
540 transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module);
544 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
546 ELM_TRANSIT_CHECK_OR_RETURN(transit);
547 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
548 Elm_Transit_Effect_Module *effect_module;
550 EINA_INLIST_FOREACH(transit->effect_list, effect_module)
552 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
554 if (transit->walking)
556 effect_module->deleted = EINA_TRUE;
557 transit->effects_pending_del++;
561 _transit_effect_del(transit, effect_module);
562 if (!transit->effect_list) elm_transit_del(transit);
570 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
572 ELM_TRANSIT_CHECK_OR_RETURN(transit);
573 EINA_SAFETY_ON_NULL_RETURN(obj);
575 if (transit->animator)
577 if (!evas_object_data_get(obj, _transit_key))
579 _transit_obj_data_save(obj);
580 evas_object_freeze_events_set(obj, EINA_TRUE);
584 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
585 _transit_obj_remove_cb,
588 transit->objs = eina_list_append(transit->objs, obj);
592 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
594 ELM_TRANSIT_CHECK_OR_RETURN(transit);
595 EINA_SAFETY_ON_NULL_RETURN(obj);
597 _transit_obj_remove(transit, obj);
598 if (!transit->objs) elm_transit_del(transit);
601 EAPI const Eina_List *
602 elm_transit_objects_get(const Elm_Transit *transit)
604 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
605 return transit->objs;
609 elm_transit_smooth_set(Elm_Transit *transit, Eina_Bool smooth)
611 ELM_TRANSIT_CHECK_OR_RETURN(transit);
612 transit->smooth = !!smooth;
616 elm_transit_smooth_get(const Elm_Transit *transit)
618 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
619 return transit->smooth;
623 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
625 ELM_TRANSIT_CHECK_OR_RETURN(transit);
630 if (transit->event_enabled == enabled) return;
631 transit->event_enabled = !!enabled;
632 if (!transit->animator) return;
634 EINA_LIST_FOREACH(transit->objs, list, obj)
635 evas_object_freeze_events_set(obj, enabled);
639 elm_transit_event_enabled_get(const Elm_Transit *transit)
641 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
642 return transit->event_enabled;
646 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
648 ELM_TRANSIT_CHECK_OR_RETURN(transit);
649 transit->del_data.func = cb;
650 transit->del_data.arg = data;
654 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
656 ELM_TRANSIT_CHECK_OR_RETURN(transit);
657 transit->auto_reverse = reverse;
661 elm_transit_auto_reverse_get(const Elm_Transit *transit)
663 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
664 return transit->auto_reverse;
668 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
670 ELM_TRANSIT_CHECK_OR_RETURN(transit);
671 transit->repeat.count = repeat;
672 transit->repeat.current = 0;
676 elm_transit_repeat_times_get(const Elm_Transit *transit)
678 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
679 return transit->repeat.count;
683 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
685 ELM_TRANSIT_CHECK_OR_RETURN(transit);
686 transit->tween_mode = tween_mode;
689 EAPI Elm_Transit_Tween_Mode
690 elm_transit_tween_mode_get(const Elm_Transit *transit)
692 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
693 return transit->tween_mode;
697 elm_transit_tween_mode_factor_set(Elm_Transit *transit, double v1, double v2)
699 ELM_TRANSIT_CHECK_OR_RETURN(transit);
705 elm_transit_tween_mode_factor_get(const Elm_Transit *transit, double *v1, double *v2)
707 ELM_TRANSIT_CHECK_OR_RETURN(transit);
708 if (v1) *v1 = transit->v[0];
709 if (v2) *v2 = transit->v[1];
713 elm_transit_tween_mode_factor_n_set(Elm_Transit *transit, unsigned int v_size, double *v)
716 ELM_TRANSIT_CHECK_OR_RETURN(transit);
717 if (v_size > 4) v_size = 4;
718 for (i = 0; i < v_size; i++)
719 transit->v[i] = v[i];
723 elm_transit_duration_set(Elm_Transit *transit, double duration)
725 ELM_TRANSIT_CHECK_OR_RETURN(transit);
726 if (transit->animator)
728 WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit);
731 transit->time.duration = duration;
735 elm_transit_duration_get(const Elm_Transit *transit)
737 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
738 return transit->time.duration;
742 elm_transit_go(Elm_Transit *transit)
744 ELM_TRANSIT_CHECK_OR_RETURN(transit);
746 ELM_SAFE_FREE(transit->timer, ecore_timer_del);
751 ELM_SAFE_FREE(transit->animator, ecore_animator_del);
753 EINA_LIST_FOREACH(transit->objs, elist, obj)
754 _transit_obj_data_save(obj);
756 if (!transit->event_enabled)
758 EINA_LIST_FOREACH(transit->objs, elist, obj)
759 evas_object_freeze_events_set(obj, EINA_TRUE);
762 transit->time.paused = 0;
763 transit->time.delayed = 0;
764 transit->time.begin = ecore_loop_time_get();
765 transit->animator = ecore_animator_add(_transit_animate_cb, transit);
767 _transit_animate_cb(transit);
771 elm_transit_go_in(Elm_Transit *transit, double in)
773 ELM_TRANSIT_CHECK_OR_RETURN(transit);
775 if (transit->timer) ecore_timer_del(transit->timer);
776 transit->timer = ecore_timer_add(in, _transit_go_in_cb, transit);
780 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
782 ELM_TRANSIT_CHECK_OR_RETURN(transit);
784 if (!transit->animator) return;
788 if (transit->time.paused > 0)
790 ecore_animator_freeze(transit->animator);
791 transit->time.paused = ecore_loop_time_get();
795 if (transit->time.paused == 0)
797 ecore_animator_thaw(transit->animator);
798 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
799 transit->time.paused = 0;
804 elm_transit_paused_get(const Elm_Transit *transit)
806 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
808 if (transit->time.paused == 0)
815 elm_transit_progress_value_get(const Elm_Transit *transit)
817 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
819 return transit->progress;
823 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
825 ELM_TRANSIT_CHECK_OR_RETURN(transit);
827 if (transit->state_keep == state_keep) return;
828 if (transit->animator)
830 WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit);
833 transit->state_keep = !!state_keep;
837 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
839 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
840 return transit->state_keep;
844 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
846 ELM_TRANSIT_CHECK_OR_RETURN(transit);
847 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
849 if (transit == chain_transit)
851 WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit);
854 if (transit == chain_transit->prev_chain_transit)
857 if (chain_transit->prev_chain_transit)
858 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
860 chain_transit->prev_chain_transit = transit;
861 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
865 elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
867 ELM_TRANSIT_CHECK_OR_RETURN(transit);
868 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
870 if (chain_transit->prev_chain_transit != transit)
872 WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
876 chain_transit->prev_chain_transit = NULL;
877 transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
881 elm_transit_chain_transits_get(const Elm_Transit * transit)
883 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
884 return transit->next_chain_transits;
887 ///////////////////////////////////////////////////////////////////////////
889 ///////////////////////////////////////////////////////////////////////////
890 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
892 struct _Elm_Transit_Effect_Resizing
900 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
902 Elm_Transit_Effect_Resizing *resizing = effect;
907 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
909 EINA_SAFETY_ON_NULL_RETURN(effect);
910 EINA_SAFETY_ON_NULL_RETURN(transit);
914 Elm_Transit_Effect_Resizing *resizing = effect;
916 w = resizing->from.w + (resizing->to.w * progress);
917 h = resizing->from.h + (resizing->to.h * progress);
919 EINA_LIST_FOREACH(transit->objs, elist, obj)
920 evas_object_resize(obj, w, h);
923 static Elm_Transit_Effect *
924 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
926 Elm_Transit_Effect_Resizing *resizing;
928 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
929 if (!resizing) return NULL;
931 resizing->from.w = from_w;
932 resizing->from.h = from_h;
933 resizing->to.w = to_w - from_w;
934 resizing->to.h = to_h - from_h;
939 EAPI Elm_Transit_Effect *
940 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
942 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
943 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
947 ERR("Failed to allocate resizing effect! : transit=%p", transit);
950 elm_transit_effect_add(transit,
951 _transit_effect_resizing_op, effect,
952 _transit_effect_resizing_context_free);
956 ///////////////////////////////////////////////////////////////////////////
958 ///////////////////////////////////////////////////////////////////////////
959 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
960 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
962 struct _Elm_Transit_Effect_Translation_Node
968 struct _Elm_Transit_Effect_Translation
970 struct _position_variation {
977 _translation_object_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
979 Elm_Transit_Effect_Translation *translation = data;
981 Elm_Transit_Effect_Translation_Node *translation_node;
983 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
985 if (translation_node->obj != obj) continue;
986 translation->nodes = eina_list_remove_list(translation->nodes, elist);
987 free(translation_node);
993 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
995 Elm_Transit_Effect_Translation_Node *translation_node;
996 const Eina_List *elist;
998 Eina_List *data_list = NULL;
999 const Eina_List *objs = elm_transit_objects_get(transit);
1001 EINA_LIST_FOREACH(objs, elist, obj)
1003 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1004 if (!translation_node)
1006 eina_list_free(data_list);
1009 translation_node->obj = obj;
1010 evas_object_geometry_get(obj, &(translation_node->x),
1011 &(translation_node->y), NULL, NULL);
1012 data_list = eina_list_append(data_list, translation_node);
1013 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1014 _translation_object_del_cb, translation);
1020 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
1022 EINA_SAFETY_ON_NULL_RETURN(effect);
1023 Elm_Transit_Effect_Translation *translation = effect;
1024 Eina_List *elist, *elist_next;
1025 Elm_Transit_Effect_Translation_Node *translation_node;
1027 EINA_LIST_FOREACH_SAFE(translation->nodes,
1028 elist, elist_next, translation_node)
1030 evas_object_event_callback_del(translation_node->obj,
1031 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1032 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1033 free(translation_node);
1039 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress EINA_UNUSED)
1041 EINA_SAFETY_ON_NULL_RETURN(effect);
1042 EINA_SAFETY_ON_NULL_RETURN(transit);
1044 Elm_Transit_Effect_Translation *translation = effect;
1045 Elm_Transit_Effect_Translation_Node *translation_node;
1048 if (!translation->nodes)
1049 translation->nodes = _translation_nodes_build(transit, translation);
1051 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1053 x = translation_node->x + translation->from.dx
1054 + (translation->to.dx * progress);
1055 y = translation_node->y + translation->from.dy
1056 + (translation->to.dy * progress);
1057 evas_object_move(translation_node->obj, x, y);
1061 static Elm_Transit_Effect *
1062 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1064 Elm_Transit_Effect_Translation *translation;
1066 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1067 if (!translation) return NULL;
1069 translation->from.dx = from_dx;
1070 translation->from.dy = from_dy;
1071 translation->to.dx = to_dx - from_dx;
1072 translation->to.dy = to_dy - from_dy;
1077 EAPI Elm_Transit_Effect *
1078 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1080 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1081 Elm_Transit_Effect *effect = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1085 ERR("Failed to allocate translation effect! : transit=%p", transit);
1088 elm_transit_effect_add(transit,
1089 _transit_effect_translation_op, effect,
1090 _transit_effect_translation_context_free);
1094 ///////////////////////////////////////////////////////////////////////////
1096 ///////////////////////////////////////////////////////////////////////////
1097 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1099 struct _Elm_Transit_Effect_Zoom
1105 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
1107 Elm_Transit_Effect_Zoom *zoom = effect;
1112 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1114 EINA_SAFETY_ON_NULL_RETURN(effect);
1115 EINA_SAFETY_ON_NULL_RETURN(transit);
1118 Elm_Transit_Effect_Zoom *zoom = effect;
1119 Elm_Transit_Obj_Data *obj_data;
1120 Evas_Map *map, *base_map;
1121 Evas_Coord x, y, w, h;
1122 double zoom_rate = (zoom->from * (1.0 - progress)) + (zoom->to * progress);
1124 EINA_LIST_FOREACH(transit->objs, elist, obj)
1126 obj_data = evas_object_data_get(obj, _transit_key);
1127 if (obj_data && obj_data->state.map_enabled)
1129 base_map = obj_data->state.map;
1130 if (!base_map) return;
1131 map = evas_map_dup(base_map);
1136 map = evas_map_new(4);
1138 evas_map_util_points_populate_from_object_full(map, obj, 0);
1140 evas_map_util_object_move_sync_set(map, EINA_TRUE);
1142 evas_object_geometry_get(obj, &x, &y, &w, &h);
1143 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1144 evas_map_util_zoom(map, zoom_rate, zoom_rate, x + (w / 2), y + (h / 2));
1145 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1146 evas_object_map_set(obj, map);
1147 evas_object_map_enable_set(obj, EINA_TRUE);
1153 static Elm_Transit_Effect *
1154 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1156 Elm_Transit_Effect_Zoom *zoom;
1158 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1159 if (!zoom) return NULL;
1161 zoom->from = from_rate;
1167 EAPI Elm_Transit_Effect *
1168 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1170 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1171 Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate,
1175 ERR("Failed to allocate zoom effect! : transit=%p", transit);
1178 elm_transit_effect_add(transit,
1179 _transit_effect_zoom_op, effect,
1180 _transit_effect_zoom_context_free);
1184 ///////////////////////////////////////////////////////////////////////////
1186 ///////////////////////////////////////////////////////////////////////////
1187 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1189 struct _Elm_Transit_Effect_Flip
1191 Elm_Transit_Effect_Flip_Axis axis;
1196 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1198 EINA_SAFETY_ON_NULL_RETURN(effect);
1199 EINA_SAFETY_ON_NULL_RETURN(transit);
1200 Elm_Transit_Effect_Flip *flip = effect;
1201 Evas_Object *front, *back;
1203 int count = eina_list_count(transit->objs);
1205 for (i = 0; i < (count - 1); i += 2)
1207 front = eina_list_nth(transit->objs, i);
1208 back = eina_list_nth(transit->objs, i+1);
1209 evas_object_map_enable_set(front, EINA_FALSE);
1210 evas_object_map_enable_set(back, EINA_FALSE);
1216 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1218 EINA_SAFETY_ON_NULL_RETURN(effect);
1219 EINA_SAFETY_ON_NULL_RETURN(transit);
1220 Evas_Object *obj, *front, *back;
1222 Elm_Transit_Effect_Flip *flip = effect;
1225 Evas_Coord x, y, w, h;
1227 map = evas_map_new(4);
1230 evas_map_util_object_move_sync_set(map, EINA_TRUE);
1232 if (flip->cw) degree = (float)(progress * 180);
1233 else degree = (float)(progress * -180);
1235 count = eina_list_count(transit->objs);
1237 for (i = 0; i < (count - 1); i += 2)
1239 Evas_Coord half_w, half_h;
1241 front = eina_list_nth(transit->objs, i);
1242 back = eina_list_nth(transit->objs, i+1);
1244 if ((degree < 90) && (degree > -90))
1249 evas_object_hide(back);
1250 evas_object_show(front);
1258 evas_object_hide(front);
1259 evas_object_show(back);
1263 evas_map_util_points_populate_from_object_full(map, obj, 0);
1264 evas_object_geometry_get(obj, &x, &y, &w, &h);
1268 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1270 if ((degree >= 90) || (degree <= -90))
1272 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
1274 evas_map_point_image_uv_set(map, 0, w, 0);
1275 evas_map_point_image_uv_set(map, 1, 0, 0);
1276 evas_map_point_image_uv_set(map, 2, 0, h);
1277 evas_map_point_image_uv_set(map, 3, w, h);
1281 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1282 evas_map_util_3d_rotate(map, 0, degree,
1283 0, x + half_w, y + half_h, 0);
1287 if ((degree >= 90) || (degree <= -90))
1289 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
1291 evas_map_point_image_uv_set(map, 0, 0, h);
1292 evas_map_point_image_uv_set(map, 1, w, h);
1293 evas_map_point_image_uv_set(map, 2, w, 0);
1294 evas_map_point_image_uv_set(map, 3, 0, 0);
1298 _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
1299 evas_map_util_3d_rotate(map, degree,
1300 0, 0, x + half_w, y + half_h, 0);
1302 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
1303 evas_object_map_enable_set(front, EINA_TRUE);
1304 evas_object_map_enable_set(back, EINA_TRUE);
1305 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1306 evas_object_map_set(obj, map);
1311 static Elm_Transit_Effect *
1312 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1314 Elm_Transit_Effect_Flip *flip;
1316 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1317 if (!flip) return NULL;
1325 EAPI Elm_Transit_Effect *
1326 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1328 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1329 Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw);
1333 ERR("Failed to allocate flip effect! : transit=%p", transit);
1336 elm_transit_effect_add(transit,
1337 _transit_effect_flip_op, effect,
1338 _transit_effect_flip_context_free);
1342 ///////////////////////////////////////////////////////////////////////////
1343 //ResizableFlip Effect
1344 ///////////////////////////////////////////////////////////////////////////
1345 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1346 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1348 struct _Elm_Transit_Effect_Resizable_Flip_Node
1354 } from_pos, from_size, to_pos, to_size;
1357 struct _Elm_Transit_Effect_Resizable_Flip
1361 Elm_Transit_Effect_Flip_Axis axis;
1365 _resizable_flip_object_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
1367 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1369 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1371 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1373 if (resizable_flip_node->front == obj)
1374 evas_object_event_callback_del(resizable_flip_node->back,
1375 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1376 else if (resizable_flip_node->back == obj)
1377 evas_object_event_callback_del(resizable_flip_node->front,
1378 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1381 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1383 free(resizable_flip_node);
1389 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1391 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1392 Eina_List *data_list = NULL;
1393 Evas_Coord front_x, front_y, front_w, front_h;
1394 Evas_Coord back_x, back_y, back_w, back_h;
1397 count = eina_list_count(transit->objs);
1398 for (i = 0; i < (count - 1); i += 2)
1400 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1401 if (!resizable_flip_node)
1403 eina_list_free(data_list);
1407 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1408 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1410 evas_object_geometry_get(resizable_flip_node->front,
1411 &front_x, &front_y, &front_w, &front_h);
1412 evas_object_geometry_get(resizable_flip_node->back,
1413 &back_x, &back_y, &back_w, &back_h);
1415 resizable_flip_node->from_pos.x = front_x;
1416 resizable_flip_node->from_pos.y = front_y;
1417 resizable_flip_node->to_pos.x = back_x - front_x;
1418 resizable_flip_node->to_pos.y = back_y - front_y;
1420 resizable_flip_node->from_size.x = front_w;
1421 resizable_flip_node->from_size.y = front_h;
1422 resizable_flip_node->to_size.x = back_w - front_w;
1423 resizable_flip_node->to_size.y = back_h - front_h;
1425 data_list = eina_list_append(data_list, resizable_flip_node);
1427 evas_object_event_callback_add(resizable_flip_node->back,
1428 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1429 evas_object_event_callback_add(resizable_flip_node->front,
1430 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1437 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
1441 evas_map_point_image_uv_set(map, 0,
1442 (flip->from_size.x * 2) + flip->to_size.x,
1444 evas_map_point_image_uv_set(map, 1, 0, 0);
1445 evas_map_point_image_uv_set(map, 2, 0,
1446 (flip->from_size.y * 2) + flip->to_size.y);
1447 evas_map_point_image_uv_set(map, 3,
1448 (flip->from_size.x * 2) + flip->to_size.x,
1449 (flip->from_size.y * 2) + flip->to_size.y);
1453 evas_map_point_image_uv_set(map, 0, 0, 0);
1454 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1455 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1457 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1462 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
1466 evas_map_point_image_uv_set(map, 0, 0,
1467 (flip->from_size.y * 2) + flip->to_size.y);
1468 evas_map_point_image_uv_set(map, 1,
1469 (flip->from_size.x * 2) + flip->to_size.x,
1470 (flip->from_size.y * 2) + flip->to_size.y);
1471 evas_map_point_image_uv_set(map, 2,
1472 (flip->from_size.x * 2) + flip->to_size.x,
1474 evas_map_point_image_uv_set(map, 3, 0, 0);
1478 evas_map_point_image_uv_set(map, 0, 0, 0);
1479 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1480 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1482 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1487 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
1489 EINA_SAFETY_ON_NULL_RETURN(effect);
1491 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1492 Eina_List *elist, *elist_next;
1493 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1495 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1496 elist, elist_next, resizable_flip_node)
1498 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1499 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1501 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1504 evas_object_event_callback_del(resizable_flip_node->back,
1505 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1506 evas_object_event_callback_del(resizable_flip_node->front,
1507 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1508 free(resizable_flip_node);
1510 free(resizable_flip);
1514 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED, double progress)
1516 EINA_SAFETY_ON_NULL_RETURN(effect);
1521 Evas_Coord half_w, half_h;
1522 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1523 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1526 map = evas_map_new(4);
1529 evas_map_util_object_move_sync_set(map, EINA_TRUE);
1531 if (resizable_flip->cw) degree = (float)(progress * 180);
1532 else degree = (float)(progress * -180);
1534 if (!resizable_flip->nodes)
1535 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1538 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1540 if ((degree < 90) && (degree > -90))
1542 obj = resizable_flip_node->front;
1543 if (resizable_flip_node->front != resizable_flip_node->back)
1545 evas_object_hide(resizable_flip_node->back);
1546 evas_object_show(resizable_flip_node->front);
1551 obj = resizable_flip_node->back;
1552 if (resizable_flip_node->front != resizable_flip_node->back)
1554 evas_object_hide(resizable_flip_node->front);
1555 evas_object_show(resizable_flip_node->back);
1559 x = resizable_flip_node->from_pos.x +
1560 (resizable_flip_node->to_pos.x * progress);
1561 y = resizable_flip_node->from_pos.y +
1562 (resizable_flip_node->to_pos.y * progress);
1563 w = resizable_flip_node->from_size.x +
1564 (resizable_flip_node->to_size.x * progress);
1565 h = resizable_flip_node->from_size.y +
1566 (resizable_flip_node->to_size.y * progress);
1567 evas_map_point_coord_set(map, 0, x, y, 0);
1568 evas_map_point_coord_set(map, 1, x + w, y, 0);
1569 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1570 evas_map_point_coord_set(map, 3, x, y + h, 0);
1572 half_w = (Evas_Coord)(w / 2);
1573 half_h = (Evas_Coord)(h / 2);
1575 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1577 if ((degree >= 90) || (degree <= -90))
1579 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
1580 _set_image_uv_by_axis_y(map, resizable_flip_node,
1585 if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE))
1586 _set_image_uv_by_axis_y(map, resizable_flip_node,
1589 evas_map_util_3d_rotate(map, 0, degree,
1590 0, x + half_w, y + half_h, 0);
1594 if ((degree >= 90) || (degree <= -90))
1596 if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
1597 _set_image_uv_by_axis_x(map, resizable_flip_node,
1602 if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_TRUE))
1603 _set_image_uv_by_axis_x(map, resizable_flip_node,
1606 evas_map_util_3d_rotate(map, degree, 0,
1607 0, x + half_w, y + half_h, 0);
1610 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0,
1612 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1613 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1614 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1615 evas_object_map_set(obj, map);
1620 static Elm_Transit_Effect *
1621 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1623 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1625 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1626 if (!resizable_flip) return NULL;
1628 resizable_flip->cw = cw;
1629 resizable_flip->axis = axis;
1631 return resizable_flip;
1634 EAPI Elm_Transit_Effect *
1635 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1637 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1638 Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw);
1642 ERR("Failed to allocate resizable_flip effect! : transit=%p", transit);
1645 elm_transit_effect_add(transit,
1646 _transit_effect_resizable_flip_op, effect,
1647 _transit_effect_resizable_flip_context_free);
1651 ///////////////////////////////////////////////////////////////////////////
1653 ///////////////////////////////////////////////////////////////////////////
1654 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1656 struct _Elm_Transit_Effect_Wipe
1658 Elm_Transit_Effect_Wipe_Type type;
1659 Elm_Transit_Effect_Wipe_Dir dir;
1663 _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)
1669 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1670 w2 = w - (w * progress);
1672 evas_map_point_image_uv_set(map, 0, 0, 0);
1673 evas_map_point_image_uv_set(map, 1, w2, 0);
1674 evas_map_point_image_uv_set(map, 2, w2, h);
1675 evas_map_point_image_uv_set(map, 3, 0, h);
1676 evas_map_point_coord_set(map, 0, x, y, 0);
1677 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1678 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1679 evas_map_point_coord_set(map, 3, x, h2, 0);
1681 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1682 w2 = (w * progress);
1684 evas_map_point_image_uv_set(map, 0, w2, 0);
1685 evas_map_point_image_uv_set(map, 1, w, 0);
1686 evas_map_point_image_uv_set(map, 2, w, h);
1687 evas_map_point_image_uv_set(map, 3, w2, h);
1688 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1689 evas_map_point_coord_set(map, 1, x + w, y, 0);
1690 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1691 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1693 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1695 h2 = h - (h * progress);
1696 evas_map_point_image_uv_set(map, 0, 0, 0);
1697 evas_map_point_image_uv_set(map, 1, w, 0);
1698 evas_map_point_image_uv_set(map, 2, w, h2);
1699 evas_map_point_image_uv_set(map, 3, 0, h2);
1700 evas_map_point_coord_set(map, 0, x, y, 0);
1701 evas_map_point_coord_set(map, 1, w2, y, 0);
1702 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1703 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1705 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1707 h2 = (h * progress);
1708 evas_map_point_image_uv_set(map, 0, 0, h2);
1709 evas_map_point_image_uv_set(map, 1, w, h2);
1710 evas_map_point_image_uv_set(map, 2, w, h);
1711 evas_map_point_image_uv_set(map, 3, 0, h);
1712 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1713 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1714 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1715 evas_map_point_coord_set(map, 3, x, y + h, 0);
1720 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1724 _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)
1730 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1731 w2 = (w - (w * progress));
1733 evas_map_point_image_uv_set(map, 0, w2, 0);
1734 evas_map_point_image_uv_set(map, 1, w, 0);
1735 evas_map_point_image_uv_set(map, 2, w, h);
1736 evas_map_point_image_uv_set(map, 3, w2, h);
1737 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1738 evas_map_point_coord_set(map, 1, w, y, 0);
1739 evas_map_point_coord_set(map, 2, w, h2, 0);
1740 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1742 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1743 w2 = (w * progress);
1745 evas_map_point_image_uv_set(map, 0, 0, 0);
1746 evas_map_point_image_uv_set(map, 1, w2, 0);
1747 evas_map_point_image_uv_set(map, 2, w2, h);
1748 evas_map_point_image_uv_set(map, 3, 0, h);
1749 evas_map_point_coord_set(map, 0, x, y, 0);
1750 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1751 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1752 evas_map_point_coord_set(map, 3, x, h2, 0);
1754 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1756 h2 = (h - (h * progress));
1757 evas_map_point_image_uv_set(map, 0, 0, h2);
1758 evas_map_point_image_uv_set(map, 1, w, h2);
1759 evas_map_point_image_uv_set(map, 2, w, h);
1760 evas_map_point_image_uv_set(map, 3, 0, h);
1761 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1762 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1763 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1764 evas_map_point_coord_set(map, 3, x, y + h, 0);
1766 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1768 h2 = (h * progress);
1769 evas_map_point_image_uv_set(map, 0, 0, 0);
1770 evas_map_point_image_uv_set(map, 1, w, 0);
1771 evas_map_point_image_uv_set(map, 2, w, h2);
1772 evas_map_point_image_uv_set(map, 3, 0, h2);
1773 evas_map_point_coord_set(map, 0, x, y, 0);
1774 evas_map_point_coord_set(map, 1, w2, y, 0);
1775 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1776 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1781 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
1785 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1787 EINA_SAFETY_ON_NULL_RETURN(effect);
1788 EINA_SAFETY_ON_NULL_RETURN(transit);
1791 Elm_Transit_Effect_Wipe *wipe = effect;
1792 Eina_Bool reverse = transit->auto_reverse;
1794 EINA_LIST_FOREACH(transit->objs, elist, obj)
1796 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1797 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1798 evas_object_show(obj);
1799 else evas_object_hide(obj);
1800 evas_object_map_enable_set(obj, EINA_FALSE);
1807 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1809 EINA_SAFETY_ON_NULL_RETURN(effect);
1810 EINA_SAFETY_ON_NULL_RETURN(transit);
1811 Elm_Transit_Effect_Wipe *wipe = effect;
1813 Evas_Coord _x, _y, _w, _h;
1818 map = evas_map_new(4);
1821 evas_map_util_object_move_sync_set(map, EINA_TRUE);
1823 EINA_LIST_FOREACH(transit->objs, elist, obj)
1825 type = evas_object_type_get(obj);
1826 if ((!type) || (strcmp(type, "image")) ||
1827 evas_object_image_source_get(obj))
1828 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1831 evas_object_image_size_get(obj, &_w, &_h);
1835 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1836 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1838 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1839 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
1840 evas_object_map_enable_set(obj, EINA_TRUE);
1841 evas_object_map_set(obj, map);
1846 static Elm_Transit_Effect *
1847 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1849 Elm_Transit_Effect_Wipe *wipe;
1851 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1852 if (!wipe) return NULL;
1861 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1863 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1864 void *effect = _transit_effect_wipe_context_new(type, dir);
1868 ERR("Failed to allocate wipe effect! : transit=%p", transit);
1871 elm_transit_effect_add(transit,
1872 _transit_effect_wipe_op, effect,
1873 _transit_effect_wipe_context_free);
1877 ///////////////////////////////////////////////////////////////////////////
1879 ///////////////////////////////////////////////////////////////////////////
1880 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1882 struct _Elm_Transit_Effect_Color
1884 struct _unsigned_color {
1885 unsigned int r, g, b, a;
1887 struct _signed_color {
1893 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
1895 Elm_Transit_Effect_Color *color = effect;
1900 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1902 EINA_SAFETY_ON_NULL_RETURN(effect);
1903 EINA_SAFETY_ON_NULL_RETURN(transit);
1904 Elm_Transit_Effect_Color *color = effect;
1907 unsigned int r, g, b, a;
1909 r = (color->from.r + (int)((float)color->to.r * progress));
1910 g = (color->from.g + (int)((float)color->to.g * progress));
1911 b = (color->from.b + (int)((float)color->to.b * progress));
1912 a = (color->from.a + (int)((float)color->to.a * progress));
1914 EINA_LIST_FOREACH(transit->objs, elist, obj)
1915 evas_object_color_set(obj, r, g, b, a);
1918 static Elm_Transit_Effect *
1919 _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)
1921 Elm_Transit_Effect_Color *color;
1923 color = ELM_NEW(Elm_Transit_Effect_Color);
1924 if (!color) return NULL;
1926 color->from.r = from_r;
1927 color->from.g = from_g;
1928 color->from.b = from_b;
1929 color->from.a = from_a;
1930 color->to.r = to_r - from_r;
1931 color->to.g = to_g - from_g;
1932 color->to.b = to_b - from_b;
1933 color->to.a = to_a - from_a;
1938 EAPI Elm_Transit_Effect *
1939 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)
1941 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1942 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);
1946 ERR("Failed to allocate color effect! : transit=%p", transit);
1949 elm_transit_effect_add(transit,
1950 _transit_effect_color_op, effect,
1951 _transit_effect_color_context_free);
1955 ///////////////////////////////////////////////////////////////////////////
1957 ///////////////////////////////////////////////////////////////////////////
1958 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
1959 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
1961 struct _Elm_Transit_Effect_Fade_Node
1963 Evas_Object *before;
1965 struct _signed_color before_color, after_color;
1968 Eina_Bool inversed : 1;
1971 struct _Elm_Transit_Effect_Fade
1977 _fade_object_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
1979 Elm_Transit_Effect_Fade *fade = data;
1981 Elm_Transit_Effect_Fade_Node *fade_node;
1983 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
1985 if (fade_node->before == obj)
1986 evas_object_event_callback_del(fade_node->after,
1987 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1988 else if (fade_node->after == obj)
1989 evas_object_event_callback_del(fade_node->before,
1990 EVAS_CALLBACK_DEL, _fade_object_del_cb);
1993 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2000 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2002 Elm_Transit_Effect_Fade_Node *fade;
2003 Eina_List *data_list = NULL;
2006 count = eina_list_count(transit->objs);
2007 for (i = 0; i < count; i += 2)
2009 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2012 eina_list_free(data_list);
2016 fade->before = eina_list_nth(transit->objs, i);
2017 fade->after = eina_list_nth(transit->objs, i+1);
2019 evas_object_color_get(fade->before,
2020 &fade->before_color.r, &fade->before_color.g,
2021 &fade->before_color.b, &fade->before_color.a);
2022 evas_object_color_get(fade->after,
2023 &fade->after_color.r, &fade->after_color.g,
2024 &fade->after_color.b, &fade->after_color.a);
2026 fade->before_alpha = (255 - fade->before_color.a);
2027 fade->after_alpha = (255 - fade->after_color.a);
2029 data_list = eina_list_append(data_list, fade);
2031 evas_object_event_callback_add(fade->before,
2032 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2033 evas_object_event_callback_add(fade->after,
2034 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2040 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
2042 EINA_SAFETY_ON_NULL_RETURN(effect);
2043 Elm_Transit_Effect_Fade *fade = effect;
2044 Elm_Transit_Effect_Fade_Node *fade_node;
2045 Eina_List *elist, *elist_next;
2047 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2049 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2050 fade_node->before_color.g,
2051 fade_node->before_color.b,
2052 fade_node->before_color.a);
2053 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2054 fade_node->after_color.g,
2055 fade_node->after_color.b,
2056 fade_node->after_color.a);
2058 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2059 evas_object_event_callback_del(fade_node->before,
2060 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2061 evas_object_event_callback_del(fade_node->after,
2062 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2070 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED, double progress)
2072 EINA_SAFETY_ON_NULL_RETURN(effect);
2073 Elm_Transit_Effect_Fade *fade = effect;
2075 Elm_Transit_Effect_Fade_Node *fade_node;
2079 fade->nodes = _fade_nodes_build(transit, fade);
2081 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2085 if (!fade_node->inversed)
2087 evas_object_hide(fade_node->after);
2088 evas_object_show(fade_node->before);
2089 fade_node->inversed = EINA_TRUE;
2092 _progress = (1 - (progress * 2));
2094 evas_object_color_set(fade_node->before,
2095 fade_node->before_color.r * _progress,
2096 fade_node->before_color.g * _progress,
2097 fade_node->before_color.b * _progress,
2098 fade_node->before_color.a +
2099 fade_node->before_alpha * (1 - _progress));
2103 if (fade_node->inversed)
2105 evas_object_hide(fade_node->before);
2106 evas_object_show(fade_node->after);
2107 fade_node->inversed = EINA_FALSE;
2110 _progress = ((progress - 0.5) * 2);
2112 evas_object_color_set(fade_node->after,
2113 fade_node->after_color.r * _progress,
2114 fade_node->after_color.g * _progress,
2115 fade_node->after_color.b * _progress,
2116 fade_node->after_color.a +
2117 fade_node->after_alpha * (1 - _progress));
2122 static Elm_Transit_Effect *
2123 _transit_effect_fade_context_new(void)
2125 Elm_Transit_Effect_Fade *fade;
2126 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2127 if (!fade) return NULL;
2131 EAPI Elm_Transit_Effect *
2132 elm_transit_effect_fade_add(Elm_Transit *transit)
2134 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2136 Elm_Transit_Effect *effect = _transit_effect_fade_context_new();
2140 ERR("Failed to allocate fade effect! : transit=%p", transit);
2143 elm_transit_effect_add(transit,
2144 _transit_effect_fade_op, effect,
2145 _transit_effect_fade_context_free);
2149 ///////////////////////////////////////////////////////////////////////////
2151 ///////////////////////////////////////////////////////////////////////////
2152 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2153 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2155 struct _Elm_Transit_Effect_Blend_Node
2157 Evas_Object *before;
2159 struct _signed_color from, to;
2162 struct _Elm_Transit_Effect_Blend
2168 _blend_object_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
2170 Elm_Transit_Effect_Blend *blend = data;
2172 Elm_Transit_Effect_Blend_Node *blend_node;
2174 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2176 if (blend_node->after == obj)
2177 evas_object_event_callback_del(blend_node->before,
2178 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2179 else if (blend_node->before == obj)
2180 evas_object_event_callback_del(blend_node->after,
2181 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2184 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2191 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2193 Elm_Transit_Effect_Blend_Node *blend_node;
2194 Eina_List *data_list = NULL;
2197 count = eina_list_count(transit->objs);
2198 for (i = 0; i < (count - 1); i += 2)
2200 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2203 eina_list_free(data_list);
2207 blend_node->before = eina_list_nth(transit->objs, i);
2208 blend_node->after = eina_list_nth(transit->objs, i + 1);
2209 evas_object_show(blend_node->before);
2210 evas_object_show(blend_node->after);
2212 evas_object_color_get(blend_node->before, &blend_node->from.r,
2213 &blend_node->from.g, &blend_node->from.b,
2214 &blend_node->from.a);
2215 evas_object_color_get(blend_node->after, &blend_node->to.r,
2216 &blend_node->to.g, &blend_node->to.b,
2219 data_list = eina_list_append(data_list, blend_node);
2221 evas_object_event_callback_add(blend_node->before,
2222 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2223 evas_object_event_callback_add(blend_node->after,
2224 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2230 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
2232 EINA_SAFETY_ON_NULL_RETURN(effect);
2233 Elm_Transit_Effect_Blend *blend = effect;
2234 Elm_Transit_Effect_Blend_Node *blend_node;
2235 Eina_List *elist, *elist_next;
2237 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2239 evas_object_color_set(blend_node->before,
2240 blend_node->from.r, blend_node->from.g,
2241 blend_node->from.b, blend_node->from.a);
2242 evas_object_color_set(blend_node->after, blend_node->to.r,
2243 blend_node->to.g, blend_node->to.b,
2246 if (transit->auto_reverse)
2247 evas_object_hide(blend_node->after);
2249 evas_object_hide(blend_node->before);
2251 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2253 evas_object_event_callback_del(blend_node->before,
2254 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2255 evas_object_event_callback_del(blend_node->after,
2256 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2263 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2265 EINA_SAFETY_ON_NULL_RETURN(effect);
2266 EINA_SAFETY_ON_NULL_RETURN(transit);
2267 Elm_Transit_Effect_Blend *blend = effect;
2268 Elm_Transit_Effect_Blend_Node *blend_node;
2271 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2273 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2275 evas_object_color_set(blend_node->before,
2276 (int)(blend_node->from.r * (1 - progress)),
2277 (int)(blend_node->from.g * (1 - progress)),
2278 (int)(blend_node->from.b * (1 - progress)),
2279 (int)(blend_node->from.a * (1 - progress)));
2280 evas_object_color_set(blend_node->after,
2281 (int)(blend_node->to.r * progress),
2282 (int)(blend_node->to.g * progress),
2283 (int)(blend_node->to.b * progress),
2284 (int)(blend_node->to.a * progress));
2288 static Elm_Transit_Effect *
2289 _transit_effect_blend_context_new(void)
2291 Elm_Transit_Effect_Blend *blend;
2293 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2294 if (!blend) return NULL;
2298 EAPI Elm_Transit_Effect *
2299 elm_transit_effect_blend_add(Elm_Transit *transit)
2301 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2302 Elm_Transit_Effect *effect = _transit_effect_blend_context_new();
2306 ERR("Failed to allocate blend effect! : transit=%p", transit);
2309 elm_transit_effect_add(transit,
2310 _transit_effect_blend_op, effect,
2311 _transit_effect_blend_context_free);
2315 ///////////////////////////////////////////////////////////////////////////
2317 ///////////////////////////////////////////////////////////////////////////
2318 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2320 struct _Elm_Transit_Effect_Rotation
2326 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
2328 Elm_Transit_Effect_Rotation *rotation = effect;
2333 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2335 EINA_SAFETY_ON_NULL_RETURN(effect);
2336 EINA_SAFETY_ON_NULL_RETURN(transit);
2337 Elm_Transit_Effect_Rotation *rotation = effect;
2338 Elm_Transit_Obj_Data *obj_data;
2339 Evas_Map *map, *base_map;
2340 Evas_Coord x, y, w, h;
2342 float half_w, half_h;
2346 EINA_LIST_FOREACH(transit->objs, elist, obj)
2348 obj_data = evas_object_data_get(obj, _transit_key);
2349 if (obj_data && obj_data->state.map_enabled)
2351 base_map = obj_data->state.map;
2352 if (!base_map) return;
2353 map = evas_map_dup(base_map);
2358 map = evas_map_new(4);
2360 evas_map_util_points_populate_from_object_full(map, obj, 0);
2362 evas_map_util_object_move_sync_set(map, EINA_TRUE);
2364 degree = rotation->from + (float)(progress * rotation->to);
2366 evas_object_geometry_get(obj, &x, &y, &w, &h);
2368 half_w = (float)w * 0.5;
2369 half_h = (float)h * 0.5;
2371 evas_map_util_rotate(map, degree, x + half_w, y + half_h);
2372 if (!transit->smooth) evas_map_smooth_set(map, EINA_FALSE);
2373 evas_object_map_enable_set(obj, EINA_TRUE);
2374 evas_object_map_set(obj, map);
2380 static Elm_Transit_Effect *
2381 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2383 Elm_Transit_Effect_Rotation *rotation;
2385 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2386 if (!rotation) return NULL;
2388 rotation->from = from_degree;
2389 rotation->to = to_degree - from_degree;
2394 EAPI Elm_Transit_Effect *
2395 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2397 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2398 Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree);
2402 ERR("Failed to allocate rotation effect! : transit=%p", transit);
2405 elm_transit_effect_add(transit,
2406 _transit_effect_rotation_op, effect,
2407 _transit_effect_rotation_context_free);
2411 ///////////////////////////////////////////////////////////////////////////
2412 //ImageAnimation Effect
2413 ///////////////////////////////////////////////////////////////////////////
2414 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2416 struct _Elm_Transit_Effect_Image_Animation
2419 unsigned int prev_idx;
2423 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
2425 EINA_SAFETY_ON_NULL_RETURN(effect);
2426 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2428 Eina_List *elist, *elist_next;
2430 //FIXME: Reset the image to first one.
2432 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2434 image_animation->images =
2435 eina_list_remove_list(image_animation->images, elist);
2436 eina_stringshare_del(image);
2439 free(image_animation);
2443 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2445 EINA_SAFETY_ON_NULL_RETURN(effect);
2446 EINA_SAFETY_ON_NULL_RETURN(transit);
2449 const char *type, *type_deprecated;
2450 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2451 unsigned int idx = 0;
2454 len = eina_list_count(image_animation->images);
2455 if (len <= 0) return;
2457 idx = floor(progress * len);
2458 if ((int)idx >= len) return;
2460 if (image_animation->prev_idx == idx) return;
2462 type = eina_stringshare_add("elm_image");
2463 //FIXME: Remove later when elm_icon is cleared.
2464 type_deprecated = eina_stringshare_add("elm_icon");
2466 EINA_LIST_FOREACH(transit->objs, elist, obj)
2468 if (elm_widget_type_check(obj, type, __func__) ||
2469 elm_widget_type_check(obj, type_deprecated, __func__))
2471 const char *file = eina_list_nth(image_animation->images,
2474 elm_image_file_set(obj, file, NULL);
2475 elm_image_preload_disabled_set(obj, EINA_TRUE);
2479 eina_stringshare_del(type);
2480 eina_stringshare_del(type_deprecated);
2482 image_animation->prev_idx = idx;
2485 static Elm_Transit_Effect *
2486 _transit_effect_image_animation_context_new(Eina_List *images)
2488 Elm_Transit_Effect_Image_Animation *image_animation;
2489 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2491 if (!image_animation) return NULL;
2492 image_animation->images = images;
2493 image_animation->prev_idx = -1;
2494 return image_animation;
2497 EAPI Elm_Transit_Effect *
2498 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2500 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2501 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2505 ERR("Failed to allocate image_animation effect! : transit=%p", transit);
2508 elm_transit_effect_add(transit,
2509 _transit_effect_image_animation_op, effect,
2510 _transit_effect_image_animation_context_free);