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!"); \
22 * @defgroup Transit Transit
25 * Transit (see Warning below) is designed to set the various effects for the
26 * Evas_Object such like translation, rotation, etc. For using Effects, Create
27 * transit and insert effects which are interesting.
28 * Once effects are inserted into transit, transit will manage those effects.
33 * Elm_Transit *trans = elm_transit_add();
34 * elm_transit_object_add(trans, obj);
35 * void *effect_context = elm_transit_effect_translation_context_new(0.0, 0.0,
37 * elm_transit_effect_add(transit,
38 * elm_transit_effect_translation_op, effect_context,
39 * elm_transit_effect_translation_context_free);
40 * elm_transit_duration_set(transit, 5);
41 * elm_transit_auto_reverse_set(transit, EINA_TRUE);
42 * elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
43 * elm_transit_repeat_times_set(transit, -1);
46 * @warning We strongly recomend to use elm_transit just when edje can not do
47 * the trick. Edje has more advantage than Elm_Transit, it has more flexibility and
48 * animations can be manipulated inside the theme.
51 static const char _transit_key[] = "_elm_transit";
57 #define ELM_TRANSIT_MAGIC 0xd27f190a
60 Ecore_Animator *animator;
61 Eina_List *effect_list;
63 Elm_Transit_Tween_Mode tween_mode;
65 void (*func) (void *data, Elm_Transit *transit);
81 unsigned int effects_pending_del;
83 Eina_Bool auto_reverse : 1;
84 Eina_Bool event_enabled : 1;
85 Eina_Bool deleted : 1;
86 Eina_Bool state_keep : 1;
89 struct _Elm_Transit_Effect_Module
91 void (*animation_op) (void *data, Elm_Transit *transit, double progress);
92 void (*user_data_free) (void *data, Elm_Transit *transit);
94 Eina_Bool deleted : 1;
99 Evas_Coord x, y, w, h;
102 Eina_Bool map_enabled : 1;
103 Eina_Bool visible : 1;
108 Elm_Transit *transit;
109 struct _Elm_Obj_State *state;
110 Eina_Bool pass_events : 1;
113 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
114 typedef struct _Elm_Obj_Data Elm_Obj_Data;
115 typedef struct _Elm_Obj_State Elm_Obj_State;
118 _elm_transit_obj_states_save(Evas_Object *obj)
120 Elm_Obj_Data *obj_data;
121 Elm_Obj_State *state;
123 obj_data = evas_object_data_get(obj, _transit_key);
124 if ((!obj_data) || (obj_data->state)) return;
125 state = calloc(1, sizeof(Elm_Obj_State));
127 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
128 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
129 state->visible = evas_object_visible_get(obj);
130 state->map_enabled = evas_object_map_enable_get(obj);
131 if (evas_object_map_get(obj))
132 state->map = evas_map_dup(evas_object_map_get(obj));
133 obj_data->state = state;
137 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
139 Elm_Transit *transit = data;
140 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
141 evas_object_pass_events_set(obj, obj_data->pass_events);
143 free(obj_data->state);
145 transit->objs = eina_list_remove(transit->objs, obj);
146 if (!transit->objs) elm_transit_del(transit);
150 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
152 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
153 Elm_Obj_State *state = obj_data->state;
155 evas_object_pass_events_set(obj, obj_data->pass_events);
159 //recover the states of the object.
160 if (!transit->state_keep)
162 evas_object_move(obj, state->x, state->y);
163 evas_object_resize(obj, state->w, state->h);
164 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
165 if (state->visible) evas_object_show(obj);
166 else evas_object_hide(obj);
167 if (state->map_enabled)
168 evas_object_map_enable_set(obj, EINA_TRUE);
170 evas_object_map_enable_set(obj, EINA_FALSE);
172 evas_object_map_set(obj, state->map);
179 //remove duplicated objects
180 //TODO: Need to consider about optimizing here
183 if (!eina_list_data_find_list(transit->objs, obj))
185 transit->objs = eina_list_remove(transit->objs, obj);
188 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
189 _elm_transit_object_remove_cb);
193 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module, Eina_List *elist)
195 if (effect_module->user_data_free)
196 effect_module->user_data_free(effect_module->user_data, transit);
198 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
203 _remove_dead_effects(Elm_Transit *transit)
205 Eina_List *elist, *elist_next;
206 Elm_Transit_Effect_Module *effect_module;
208 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
210 if (effect_module->deleted)
212 _elm_transit_effect_del(transit, effect_module, elist);
213 transit->effects_pending_del--;
214 if (!transit->effects_pending_del) return;
220 _elm_transit_del(Elm_Transit *transit)
222 Eina_List *elist, *elist_next;
223 Elm_Transit_Effect_Module *effect_module;
225 if (transit->animator)
226 ecore_animator_del(transit->animator);
228 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
229 _elm_transit_effect_del(transit, effect_module, elist);
231 while (transit->objs)
232 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
234 if (transit->del_data.func)
235 transit->del_data.func(transit->del_data.arg, transit);
237 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
242 _transit_animate_op(Elm_Transit *transit, double progress)
245 Elm_Transit_Effect_Module *effect_module;
248 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
250 if (transit->deleted) break;
251 if (!effect_module->deleted)
252 effect_module->animation_op(effect_module->user_data, transit, progress);
256 if (transit->walking) return;
258 if (transit->deleted) _elm_transit_del(transit);
259 else if (transit->effects_pending_del) _remove_dead_effects(transit);
263 _animator_animate_cb(void *data)
265 Elm_Transit *transit = data;
266 double elapsed_time, duration;
268 transit->time.current = ecore_loop_time_get();
269 elapsed_time = transit->time.current - transit->time.begin;
270 duration = transit->time.duration + transit->time.delayed;
272 if (elapsed_time > duration)
273 elapsed_time = duration;
275 transit->progress = elapsed_time / duration;
276 switch (transit->tween_mode)
278 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
279 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
281 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
282 transit->progress = sin(transit->progress * ELM_PI / 2.0);
284 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
285 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
292 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
294 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
296 /* Not end. Keep going. */
297 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
299 /* Repeat and reverse and time done! */
300 if ((transit->repeat.count >= 0) &&
301 (transit->repeat.current == transit->repeat.count) &&
302 ((!transit->auto_reverse) || transit->repeat.reverse))
304 elm_transit_del(transit);
305 return ECORE_CALLBACK_CANCEL;
309 if (!transit->auto_reverse || transit->repeat.reverse)
311 transit->repeat.current++;
312 transit->repeat.reverse = EINA_FALSE;
314 else transit->repeat.reverse = EINA_TRUE;
316 transit->time.begin = ecore_loop_time_get();
318 return ECORE_CALLBACK_RENEW;
324 * @note Is not necessary to delete the transit object, it will be deleted at
325 * the end of its operation.
326 * @note The transit will start playing when the program enter in the main loop, is not
327 * necessary to give a start to the transit.
329 * @param duration The duration of the transit in seconds. When transit starts
330 * to run, it will last a @p duration time.
331 * @return The transit object.
336 elm_transit_add(void)
338 Elm_Transit *transit = ELM_NEW(Elm_Transit);
339 if (!transit) return NULL;
341 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
343 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
348 * Stops the animation and delete the @p transit object.
350 * Call this function if you wants to stop the animation before the duration
351 * time. Make sure the @p transit object is still alive with
352 * elm_transit_del_cb_set() function.
353 * All added effects will be deleted, calling its repective data_free_cb
354 * functions. The function setted by elm_tansit_del_cb_set() will be called.
356 * @see elm_transit_del_cb_set()
358 * @param transit The transit object to be deleted.
361 * @warning Just call this function if you are sure the transit is alive.
364 elm_transit_del(Elm_Transit *transit)
366 ELM_TRANSIT_CHECK_OR_RETURN(transit);
368 if (transit->walking) transit->deleted = EINA_TRUE;
369 else _elm_transit_del(transit);
373 * Add a new effect to the transit.
375 * @note The cb function and the data are the key to the effect. If you try to
376 * add an already added effect, nothing is done.
377 * @note After the first addition of an effect in @p transit, if its
378 * effect list become empty again, the @p transit will be killed by
379 * elm_transit_del(transit) function.
383 * Elm_Transit *transit = elm_transit_add();
384 * elm_transit_effect_add(transit,
385 * elm_transit_effect_blend_op,
386 * elm_transit_effect_blend_context_new(),
387 * elm_transit_effect_blend_context_free);
390 * @param transit The transit object.
391 * @param cb The operation function. It is called when the animation begins,
392 * it is the function that actually performs the animation. It is called with
393 * the @p data, @p transit and the time progression of the animation (a double
394 * value between 0.0 and 1.0).
395 * @param data The context data of the effect.
396 * @param data_free_cb The function to free the context data, it will be called
397 * at the end of the effect, it must finalize the animation and free the
401 * @warning The transit free the context data at the and of the transition with
402 * the data_free_cb function, do not use the context data in another transit.
405 elm_transit_effect_add(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data, void (*data_free_cb)(void *data, Elm_Transit *transit))
407 ELM_TRANSIT_CHECK_OR_RETURN(transit);
408 EINA_SAFETY_ON_NULL_RETURN(cb);
409 Elm_Transit_Effect_Module *effect_module;
412 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
413 if ((effect_module->animation_op == cb) && (effect_module->user_data == data)) return;
415 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
416 if (!effect_module) return;
418 effect_module->user_data_free = data_free_cb;
419 effect_module->animation_op = cb;
420 effect_module->user_data = data;
422 transit->effect_list = eina_list_append(transit->effect_list, effect_module);
426 * Delete an added effect.
428 * This function will remove the effect from the @p transit, calling the
429 * data_free_cb to free the @p data.
431 * @see elm_transit_effect_add()
433 * @note If the effect is not found, nothing is done.
434 * @note If the effect list become empty, this function will call
435 * elm_transit_del(transit), that is, it will kill the @p transit.
437 * @param transit The transit object.
438 * @param cb The operation function.
439 * @param data The context data of the effect.
444 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
446 ELM_TRANSIT_CHECK_OR_RETURN(transit);
447 EINA_SAFETY_ON_NULL_RETURN(cb);
448 Eina_List *elist, *elist_next;
449 Elm_Transit_Effect_Module *effect_module;
451 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
453 if ((effect_module->animation_op == cb) && (effect_module->user_data == data))
455 if (transit->walking)
457 effect_module->deleted = EINA_TRUE;
458 transit->effects_pending_del++;
462 _elm_transit_effect_del(transit, effect_module, elist);
463 if (!transit->effect_list) elm_transit_del(transit);
471 * Add new object to apply the effects.
473 * @note After the first addition of an object in @p transit, if its
474 * object list become empty again, the @p transit will be killed by
475 * elm_transit_del(transit) function.
476 * @note If the @p obj belongs to another transit, the @p obj will be
477 * removed from it and it will only belong to the @p transit. If the old
478 * transit stays without objects, it will die.
479 * @note When you add an object into the @p transit, its state from
480 * evas_object_pass_events_get(obj) is saved, and it is applied when the
481 * transit ends, if you change this state whith evas_object_pass_events_set()
482 * after add the object, this state will change again when @p transit stops to
485 * @param transit The transit object.
486 * @param obj Object to be animated.
489 * @warning It is not allowed to add a new object after transit begins to go.
492 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
494 ELM_TRANSIT_CHECK_OR_RETURN(transit);
495 EINA_SAFETY_ON_NULL_RETURN(obj);
496 Elm_Obj_Data *obj_data;
498 obj_data = evas_object_data_get(obj, _transit_key);
500 if ((obj_data) && (obj_data->transit != transit))
501 elm_transit_object_remove(obj_data->transit, obj);
503 if ((!obj_data) || (obj_data->transit != transit))
505 obj_data = ELM_NEW(Elm_Obj_Data);
506 obj_data->pass_events = evas_object_pass_events_get(obj);
507 obj_data->transit = transit;
508 evas_object_data_set(obj, _transit_key, obj_data);
509 if (!transit->event_enabled)
510 evas_object_pass_events_set(obj, EINA_TRUE);
512 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
513 _elm_transit_object_remove_cb,
517 transit->objs = eina_list_append(transit->objs, obj);
519 if (!transit->state_keep)
520 _elm_transit_obj_states_save(obj);
525 * Removes an added object from the transit.
527 * @note If the @p obj is not in the @p transit, nothing is done.
528 * @note If the list become empty, this function will call
529 * elm_transit_del(transit), that is, it will kill the @p transit.
531 * @param transit The transit object.
532 * @param obj Object to be removed from @p transit.
535 * @warning It is not allowed to remove objects after transit begins to go.
538 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
540 ELM_TRANSIT_CHECK_OR_RETURN(transit);
541 EINA_SAFETY_ON_NULL_RETURN(obj);
542 Elm_Obj_Data *obj_data;
544 obj_data = evas_object_data_get(obj, _transit_key);
546 if ((!obj_data) || (obj_data->transit != transit)) return;
548 _elm_transit_object_remove(transit, obj);
549 if (!transit->objs) elm_transit_del(transit);
553 * Get the objects of the transit.
555 * @param transit The transit object.
556 * @return a Eina_List with the objects from the transit.
560 EAPI const Eina_List *
561 elm_transit_objects_get(const Elm_Transit *transit)
563 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
564 return transit->objs;
568 * Set the event enabled when transit is operating.
570 * If @p enabled is EINA_TRUE, the objects of the transit will receives
571 * events from mouse and keyboard during the animation.
572 * @note When you add an object with elm_transit_object_add(), its state from
573 * evas_object_pass_events_get(obj) is saved, and it is applied when the
574 * transit ends, if you change this state with evas_object_pass_events_set()
575 * after adding the object, this state will change again when @p transit stops
578 * @param transit The transit object.
579 * @param enabled Disable or enable.
584 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
586 ELM_TRANSIT_CHECK_OR_RETURN(transit);
589 Elm_Obj_Data *obj_data;
591 if (transit->event_enabled == enabled) return;
593 transit->event_enabled = !!enabled;
597 EINA_LIST_FOREACH(transit->objs, elist, obj)
599 obj_data = evas_object_data_get(obj, _transit_key);
600 evas_object_pass_events_set(obj, obj_data->pass_events);
605 EINA_LIST_FOREACH(transit->objs, elist, obj)
606 evas_object_pass_events_set(obj, EINA_TRUE);
611 * Get the value of event enabled status.
613 * @see elm_transit_event_enabled_set()
615 * @param transit The Transit object
616 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
617 * EINA_FALSE is returned
622 elm_transit_event_enabled_get(const Elm_Transit *transit)
624 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
625 return transit->event_enabled;
630 * Set the event enabled when transit is operating.
632 * If @p disabled is EINA_TRUE, the objects of the transit will receives
633 * events from mouse and keyboard during the animation.
634 * @note When you add an object with elm_transit_object_add(), its state from
635 * evas_object_pass_events_get(obj) is saved, and it is applied when the
636 * transit ends, if you change this state with evas_object_pass_events_set()
637 * after add the object, this state will change again when @p transit stops to
640 * @see elm_transit_event_enabled_set()
642 * @param transit The transit object.
643 * @param disabled Disable or enable.
647 EINA_DEPRECATED EAPI void
648 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
650 elm_transit_event_enabled_set(transit, disabled);
655 * Get the value of event block enabled status.
657 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
659 * @param transit The Transit object
660 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
661 * EINA_FALSE is returned
665 EINA_DEPRECATED EAPI Eina_Bool
666 elm_transit_event_block_get(const Elm_Transit *transit)
668 return !elm_transit_event_enabled_get(transit);
672 * Set the user-callback function when the transit is deleted.
674 * @note Using this function twice will overwrite the first function setted.
675 * @note the @p transit object will be deleted after call @p cb function.
677 * @param transit The transit object.
678 * @param cb Callback function pointer. This function will be called before
679 * the deletion of the transit.
680 * @param data Callback funtion user data. It is the @p op parameter.
685 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
687 ELM_TRANSIT_CHECK_OR_RETURN(transit);
688 transit->del_data.func = cb;
689 transit->del_data.arg = data;
693 * Set reverse effect automatically.
695 * If auto reverse is setted, after running the effects with the progress
696 * parameter from 0 to 1, it will call the effecs again with the progress
697 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
698 * where the duration was setted with the function elm_transit_add and
699 * the repeat with the function elm_transit_repeat_times_set().
701 * @param transit The transit object.
702 * @param reverse EINA_TRUE means the auto_reverse is on.
707 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
709 ELM_TRANSIT_CHECK_OR_RETURN(transit);
710 transit->auto_reverse = reverse;
714 * Get if the auto reverse is on.
716 * @see elm_transit_auto_reverse_set()
718 * @param transit The transit object.
719 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
720 * EINA_FALSE is returned
725 elm_transit_auto_reverse_get(const Elm_Transit *transit)
727 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
728 return transit->auto_reverse;
732 * Set the transit repeat count. Effect will be repeated by repeat count.
734 * This function sets the number of repetition the transit will run after
735 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
736 * If the @p repeat is a negative number, it will repeat infinite times.
738 * @note If this function is called during the transit execution, the transit
739 * will run @p repeat times, ignoring the times it already performed.
741 * @param transit The transit object
742 * @param repeat Repeat count
747 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
749 ELM_TRANSIT_CHECK_OR_RETURN(transit);
750 transit->repeat.count = repeat;
751 transit->repeat.current = 0;
755 * Get the transit repeat count.
757 * @see elm_transit_repeat_times_set()
759 * @param transit The Transit object.
760 * @return The repeat count. If @p transit is NULL
766 elm_transit_repeat_times_get(const Elm_Transit *transit)
768 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
769 return transit->repeat.count;
773 * Set the transit animation acceleration type.
775 * This function sets the tween mode of the transit that can be:
776 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
777 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
778 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
779 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
781 * @param transit The transit object.
782 * @param tween_mode The tween type.
787 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
789 ELM_TRANSIT_CHECK_OR_RETURN(transit);
790 transit->tween_mode = tween_mode;
794 * Get the transit animation acceleration type.
796 * @note @p transit can not be NULL
798 * @param transit The transit object.
799 * @return The tween type. If @p transit is NULL
800 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
804 EAPI Elm_Transit_Tween_Mode
805 elm_transit_tween_mode_get(const Elm_Transit *transit)
807 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
808 return transit->tween_mode;
812 * Set the transit animation time
814 * @note @p transit can not be NULL
816 * @param transit The transit object.
817 * @param duration The animation time.
822 elm_transit_duration_set(Elm_Transit *transit, double duration)
824 ELM_TRANSIT_CHECK_OR_RETURN(transit);
825 if (transit->animator) return;
826 transit->time.duration = duration;
830 * Get the transit animation time
832 * @note @p transit can not be NULL
834 * @param transit The transit object.
836 * @return The transit animation time.
841 elm_transit_duration_get(const Elm_Transit *transit)
843 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
844 return transit->time.duration;
848 * Starts the transition.
849 * Once this API is called, the transit begins to measure the time.
851 * @note @p transit can not be NULL
853 * @param transit The transit object.
858 elm_transit_go(Elm_Transit *transit)
860 ELM_TRANSIT_CHECK_OR_RETURN(transit);
862 if (transit->animator)
863 ecore_animator_del(transit->animator);
865 transit->time.paused = 0;
866 transit->time.delayed = 0;
867 transit->time.begin = ecore_loop_time_get();
868 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
872 * Pause/Resume the transition.
873 * If you call elm_transit_go again, paused states will affect no anymore.
875 * @note @p transit can not be NULL
877 * @param transit The transit object.
882 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
884 ELM_TRANSIT_CHECK_OR_RETURN(transit);
886 if (!transit->animator) return;
890 if (transit->time.paused > 0)
892 ecore_animator_freeze(transit->animator);
893 transit->time.paused = ecore_loop_time_get();
897 if (transit->time.paused == 0)
899 ecore_animator_thaw(transit->animator);
900 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
901 transit->time.paused = 0;
906 * Get the value of paused status.
908 * @see elm_transit_paused_set()
910 * @note @p transit can not be NULL
912 * @param transit The transit object.
913 * @return EINA_TRUE means transition is paused. If @p transit is NULL
914 * EINA_FALSE is returned
919 elm_transit_paused_get(const Elm_Transit *transit)
921 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
923 if (transit->time.paused == 0)
930 * Get the time progression of the animation (a double value between 0.0 and 1.0).
932 * @note @p transit can not be NULL
934 * @param transit The transit object.
936 * @return The time progression value. If @p transit is NULL
942 elm_transit_progress_value_get(const Elm_Transit *transit)
944 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
945 return transit->progress;
949 * Enable/disable keeping up the objects states.
950 * If it is not kept, the objects states will be reset when transition ends.
952 * @note @p transit can not be NULL.
953 * @note One state includes geometry, color, map data.
955 * @param transit The transit object.
956 * @param state_keep Keeping or Non Keeping.
961 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
966 ELM_TRANSIT_CHECK_OR_RETURN(transit);
967 if (transit->state_keep == state_keep) return;
968 if (transit->animator) return;
969 transit->state_keep = !!state_keep;
972 EINA_LIST_FOREACH(transit->objs, list, obj)
973 _elm_transit_obj_states_save(obj);
978 * Get a value whether the objects states will be reset or not.
980 * @note @p transit can not be NULL
982 * @see elm_transit_objects_final_state_keep_set()
984 * @param transit The transit object.
985 * @return EINA_TRUE means the states of the objects will be reset.
986 * If @p transit is NULL, EINA_FALSE is returned
991 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
993 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
994 return transit->state_keep;
997 ///////////////////////////////////////////////////////////////////////////////
999 ///////////////////////////////////////////////////////////////////////////////
1000 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1002 struct _Elm_Transit_Effect_Resizing
1010 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
1016 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
1018 EINA_SAFETY_ON_NULL_RETURN(data);
1019 EINA_SAFETY_ON_NULL_RETURN(transit);
1023 Elm_Transit_Effect_Resizing *resizing = data;
1025 w = resizing->from.w + (resizing->to.w * progress);
1026 h = resizing->from.h + (resizing->to.h * progress);
1028 EINA_LIST_FOREACH(transit->objs, elist, obj)
1029 evas_object_resize(obj, w, h);
1033 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1035 Elm_Transit_Effect_Resizing *resizing;
1037 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1038 if (!resizing) return NULL;
1040 resizing->from.w = from_w;
1041 resizing->from.h = from_h;
1042 resizing->to.w = to_w - from_w;
1043 resizing->to.h = to_h - from_h;
1049 * Add the Resizing Effect to Elm_Transit.
1051 * @note This API is one of the facades. It creates resizing effect context
1052 * and add it's required APIs to elm_transit_effect_add.
1054 * @see elm_transit_effect_add()
1056 * @param transit Transit object.
1057 * @param from_w Object width size when effect begins.
1058 * @param from_h Object height size when effect begins.
1059 * @param to_w Object width size when effect ends.
1060 * @param to_h Object height size when effect ends.
1061 * @return Resizing effect context data.
1066 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1068 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1069 void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1071 if (!effect_context) return NULL;
1072 elm_transit_effect_add(transit,
1073 _transit_effect_resizing_op, effect_context,
1074 _transit_effect_resizing_context_free);
1075 return effect_context;
1078 ///////////////////////////////////////////////////////////////////////////////
1079 //Translation Effect
1080 ///////////////////////////////////////////////////////////////////////////////
1081 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1082 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1084 struct _Elm_Transit_Effect_Translation_Node
1090 struct _Elm_Transit_Effect_Translation
1092 struct _position_variation {
1099 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1101 Elm_Transit_Effect_Translation *translation = data;
1103 Elm_Transit_Effect_Translation_Node *translation_node;
1105 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1107 if (translation_node->obj != obj) continue;
1108 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1109 free(translation_node);
1115 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1117 Elm_Transit_Effect_Translation_Node *translation_node;
1118 const Eina_List *elist;
1120 Eina_List *data_list = NULL;
1121 const Eina_List *objs = elm_transit_objects_get(transit);
1123 EINA_LIST_FOREACH(objs, elist, obj)
1125 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1126 if (!translation_node)
1128 eina_list_free(data_list);
1131 translation_node->obj = obj;
1132 evas_object_geometry_get(obj, &(translation_node->x),
1133 &(translation_node->y), NULL, NULL);
1134 data_list = eina_list_append(data_list, translation_node);
1135 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1136 _translation_object_del_cb, translation);
1142 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1144 EINA_SAFETY_ON_NULL_RETURN(data);
1145 Elm_Transit_Effect_Translation *translation = data;
1146 Eina_List *elist, *elist_next;
1147 Elm_Transit_Effect_Translation_Node *translation_node;
1149 EINA_LIST_FOREACH_SAFE(translation->nodes,
1150 elist, elist_next, translation_node)
1152 evas_object_event_callback_del(translation_node->obj,
1153 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1154 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1155 free(translation_node);
1161 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1163 EINA_SAFETY_ON_NULL_RETURN(data);
1164 EINA_SAFETY_ON_NULL_RETURN(transit);
1166 Elm_Transit_Effect_Translation *translation = data;
1167 Elm_Transit_Effect_Translation_Node *translation_node;
1170 if (!translation->nodes)
1171 translation->nodes = _translation_nodes_build(transit, translation);
1173 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1175 x = translation_node->x + translation->from.dx
1176 + (translation->to.dx * progress);
1177 y = translation_node->y + translation->from.dy
1178 + (translation->to.dy * progress);
1179 evas_object_move(translation_node->obj, x, y);
1184 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1186 Elm_Transit_Effect_Translation *translation;
1188 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1189 if (!translation) return NULL;
1191 translation->from.dx = from_dx;
1192 translation->from.dy = from_dy;
1193 translation->to.dx = to_dx - from_dx;
1194 translation->to.dy = to_dy - from_dy;
1200 * Add the Translation Effect to Elm_Transit.
1202 * @note This API is one of the facades. It creates translation effect context
1203 * and add it's required APIs to elm_transit_effect_add.
1205 * @see elm_transit_effect_add()
1207 * @param transit Transit object.
1208 * @param from_dx X Position variation when effect begins.
1209 * @param from_dy Y Position variation when effect begins.
1210 * @param to_dx X Position variation when effect ends.
1211 * @param to_dy Y Position variation when effect ends.
1212 * @return Translation effect context data.
1215 * @warning Is higher recommended just create a transit with this effect when
1216 * the window that the objects of the transit belongs has already been created.
1217 * This is because this effect needs the geometry information about the objects,
1218 * and if the window was not created yet, it can get a wrong information.
1221 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1223 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1224 void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1226 if (!effect_context) return NULL;
1227 elm_transit_effect_add(transit,
1228 _transit_effect_translation_op, effect_context,
1229 _transit_effect_translation_context_free);
1230 return effect_context;
1234 ///////////////////////////////////////////////////////////////////////////////
1236 ///////////////////////////////////////////////////////////////////////////////
1237 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1239 struct _Elm_Transit_Effect_Zoom
1245 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1251 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1253 EINA_SAFETY_ON_NULL_RETURN(data);
1254 EINA_SAFETY_ON_NULL_RETURN(transit);
1257 Elm_Transit_Effect_Zoom *zoom = data;
1259 Evas_Coord x, y, w, h;
1261 map = evas_map_new(4);
1264 EINA_LIST_FOREACH(transit->objs, elist, obj)
1266 evas_object_geometry_get(obj, &x, &y, &w, &h);
1267 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1268 (progress * zoom->to));
1269 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1270 evas_object_map_set(obj, map);
1271 evas_object_map_enable_set(obj, EINA_TRUE);
1277 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1279 Elm_Transit_Effect_Zoom *zoom;
1281 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1282 if (!zoom) return NULL;
1284 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1285 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1291 * Add the Zoom Effect to Elm_Transit.
1293 * @note This API is one of the facades. It creates zoom effect context
1294 * and add it's required APIs to elm_transit_effect_add.
1296 * @see elm_transit_effect_add()
1298 * @param transit Transit object.
1299 * @param from_rate Scale rate when effect begins (1 is current rate).
1300 * @param to_rate Scale rate when effect ends.
1301 * @return Zoom effect context data.
1304 * @warning Is higher recommended just create a transit with this effect when
1305 * the window that the objects of the transit belongs has already been created.
1306 * This is because this effect needs the geometry information about the objects,
1307 * and if the window was not created yet, it can get a wrong information.
1310 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1312 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1313 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1315 if (!effect_context) return NULL;
1316 elm_transit_effect_add(transit,
1317 _transit_effect_zoom_op, effect_context,
1318 _transit_effect_zoom_context_free);
1319 return effect_context;
1323 ///////////////////////////////////////////////////////////////////////////////
1325 ///////////////////////////////////////////////////////////////////////////////
1326 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1328 struct _Elm_Transit_Effect_Flip
1330 Elm_Transit_Effect_Flip_Axis axis;
1335 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1337 EINA_SAFETY_ON_NULL_RETURN(data);
1338 EINA_SAFETY_ON_NULL_RETURN(transit);
1339 Evas_Object *front, *back;
1341 int count = eina_list_count(transit->objs);
1343 for (i = 0; i < (count - 1); i += 2)
1345 front = eina_list_nth(transit->objs, i);
1346 back = eina_list_nth(transit->objs, i+1);
1347 evas_object_map_enable_set(front, EINA_FALSE);
1348 evas_object_map_enable_set(back, EINA_FALSE);
1354 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1356 EINA_SAFETY_ON_NULL_RETURN(data);
1357 EINA_SAFETY_ON_NULL_RETURN(transit);
1358 Evas_Object *obj, *front, *back;
1360 Elm_Transit_Effect_Flip *flip = data;
1363 Evas_Coord x, y, w, h;
1365 map = evas_map_new(4);
1368 if (flip->cw) degree = (float)(progress * 180);
1369 else degree = (float)(progress * -180);
1371 count = eina_list_count(transit->objs);
1372 for (i = 0; i < (count - 1); i += 2)
1374 Evas_Coord half_w, half_h;
1376 front = eina_list_nth(transit->objs, i);
1377 back = eina_list_nth(transit->objs, i+1);
1379 if ((degree < 90) && (degree > -90))
1384 evas_object_hide(back);
1385 evas_object_show(front);
1393 evas_object_hide(front);
1394 evas_object_show(back);
1398 evas_map_util_points_populate_from_object_full(map, obj, 0);
1399 evas_object_geometry_get(obj, &x, &y, &w, &h);
1403 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1405 if ((degree >= 90) || (degree <= -90))
1407 evas_map_point_image_uv_set(map, 0, w, 0);
1408 evas_map_point_image_uv_set(map, 1, 0, 0);
1409 evas_map_point_image_uv_set(map, 2, 0, h);
1410 evas_map_point_image_uv_set(map, 3, w, h);
1412 evas_map_util_3d_rotate(map, 0, degree,
1413 0, x + half_w, y + half_h, 0);
1417 if ((degree >= 90) || (degree <= -90))
1419 evas_map_point_image_uv_set(map, 0, 0, h);
1420 evas_map_point_image_uv_set(map, 1, w, h);
1421 evas_map_point_image_uv_set(map, 2, w, 0);
1422 evas_map_point_image_uv_set(map, 3, 0, 0);
1424 evas_map_util_3d_rotate(map, degree,
1425 0, 0, x + half_w, y + half_h, 0);
1427 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1428 evas_object_map_enable_set(front, EINA_TRUE);
1429 evas_object_map_enable_set(back, EINA_TRUE);
1430 evas_object_map_set(obj, map);
1436 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1438 Elm_Transit_Effect_Flip *flip;
1440 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1441 if (!flip) return NULL;
1450 * Add the Flip Effect to Elm_Transit.
1452 * @note This API is one of the facades. It creates flip effect context
1453 * and add it's required APIs to elm_transit_effect_add.
1454 * @note This effect is applied to each pair of objects in the order they are listed
1455 * in the transit list of objects. The first object in the pair will be the
1456 * "front" object and the second will be the "back" object.
1458 * @see elm_transit_effect_add()
1460 * @param transit Transit object.
1461 * @param axis Flipping Axis(X or Y).
1462 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1463 * @return Flip effect context data.
1466 * @warning Is higher recommended just create a transit with this effect when
1467 * the window that the objects of the transit belongs has already been created.
1468 * This is because this effect needs the geometry information about the objects,
1469 * and if the window was not created yet, it can get a wrong information.
1472 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1474 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1475 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1477 if (!effect_context) return NULL;
1478 elm_transit_effect_add(transit,
1479 _transit_effect_flip_op, effect_context,
1480 _transit_effect_flip_context_free);
1481 return effect_context;
1484 ///////////////////////////////////////////////////////////////////////////////
1485 //ResizableFlip Effect
1486 ///////////////////////////////////////////////////////////////////////////////
1487 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1488 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1490 struct _Elm_Transit_Effect_Resizable_Flip_Node
1496 } from_pos, from_size, to_pos, to_size;
1499 struct _Elm_Transit_Effect_Resizable_Flip
1503 Elm_Transit_Effect_Flip_Axis axis;
1507 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1509 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1511 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1513 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1515 if (resizable_flip_node->front == obj)
1516 evas_object_event_callback_del(resizable_flip_node->back,
1517 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1518 else if (resizable_flip_node->back == obj)
1519 evas_object_event_callback_del(resizable_flip_node->front,
1520 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1523 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1525 free(resizable_flip_node);
1531 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1533 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1534 Eina_List *data_list = NULL;
1535 Evas_Coord front_x, front_y, front_w, front_h;
1536 Evas_Coord back_x, back_y, back_w, back_h;
1539 count = eina_list_count(transit->objs);
1540 for (i = 0; i < (count - 1); i += 2)
1542 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1543 if (!resizable_flip_node)
1545 eina_list_free(data_list);
1549 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1550 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1552 evas_object_geometry_get(resizable_flip_node->front,
1553 &front_x, &front_y, &front_w, &front_h);
1554 evas_object_geometry_get(resizable_flip_node->back,
1555 &back_x, &back_y, &back_w, &back_h);
1557 resizable_flip_node->from_pos.x = front_x;
1558 resizable_flip_node->from_pos.y = front_y;
1559 resizable_flip_node->to_pos.x = back_x - front_x;
1560 resizable_flip_node->to_pos.y = back_y - front_y;
1562 resizable_flip_node->from_size.x = front_w;
1563 resizable_flip_node->from_size.y = front_h;
1564 resizable_flip_node->to_size.x = back_w - front_w;
1565 resizable_flip_node->to_size.y = back_h - front_h;
1567 data_list = eina_list_append(data_list, resizable_flip_node);
1569 evas_object_event_callback_add(resizable_flip_node->back,
1570 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1571 evas_object_event_callback_add(resizable_flip_node->front,
1572 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1579 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1581 if ((degree >= 90) || (degree <= -90))
1583 evas_map_point_image_uv_set(map, 0,
1584 (flip->from_size.x * 2) + flip->to_size.x,
1586 evas_map_point_image_uv_set(map, 1, 0, 0);
1587 evas_map_point_image_uv_set(map, 2, 0,
1588 (flip->from_size.y * 2) + flip->to_size.y);
1589 evas_map_point_image_uv_set(map, 3,
1590 (flip->from_size.x * 2) + flip->to_size.x,
1591 (flip->from_size.y * 2) + flip->to_size.y);
1595 evas_map_point_image_uv_set(map, 0, 0, 0);
1596 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1597 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1599 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1604 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1606 if ((degree >= 90) || (degree <= -90))
1608 evas_map_point_image_uv_set(map, 0, 0,
1609 (flip->from_size.y * 2) + flip->to_size.y);
1610 evas_map_point_image_uv_set(map, 1,
1611 (flip->from_size.x * 2) + flip->to_size.x,
1612 (flip->from_size.y * 2) + flip->to_size.y);
1613 evas_map_point_image_uv_set(map, 2,
1614 (flip->from_size.x * 2) + flip->to_size.x,
1616 evas_map_point_image_uv_set(map, 3, 0, 0);
1620 evas_map_point_image_uv_set(map, 0, 0, 0);
1621 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1622 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1624 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1629 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1631 EINA_SAFETY_ON_NULL_RETURN(data);
1633 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1634 Eina_List *elist, *elist_next;
1635 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1637 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1638 elist, elist_next, resizable_flip_node)
1640 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1641 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1643 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1646 evas_object_event_callback_del(resizable_flip_node->back,
1647 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1648 evas_object_event_callback_del(resizable_flip_node->front,
1649 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1650 free(resizable_flip_node);
1652 free(resizable_flip);
1656 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1658 EINA_SAFETY_ON_NULL_RETURN(data);
1663 Evas_Coord half_w, half_h;
1664 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1665 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1668 map = evas_map_new(4);
1671 if (resizable_flip->cw) degree = (float)(progress * 180);
1672 else degree = (float)(progress * -180);
1674 if (!resizable_flip->nodes)
1675 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1678 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1680 if ((degree < 90) && (degree > -90))
1682 obj = resizable_flip_node->front;
1683 if (resizable_flip_node->front != resizable_flip_node->back)
1685 evas_object_hide(resizable_flip_node->back);
1686 evas_object_show(resizable_flip_node->front);
1691 obj = resizable_flip_node->back;
1692 if (resizable_flip_node->front != resizable_flip_node->back)
1694 evas_object_hide(resizable_flip_node->front);
1695 evas_object_show(resizable_flip_node->back);
1699 x = resizable_flip_node->from_pos.x +
1700 (resizable_flip_node->to_pos.x * progress);
1701 y = resizable_flip_node->from_pos.y +
1702 (resizable_flip_node->to_pos.y * progress);
1703 w = resizable_flip_node->from_size.x +
1704 (resizable_flip_node->to_size.x * progress);
1705 h = resizable_flip_node->from_size.y +
1706 (resizable_flip_node->to_size.y * progress);
1707 evas_map_point_coord_set(map, 0, x, y, 0);
1708 evas_map_point_coord_set(map, 1, x + w, y, 0);
1709 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1710 evas_map_point_coord_set(map, 3, x, y + h, 0);
1712 half_w = (Evas_Coord)(w / 2);
1713 half_h = (Evas_Coord)(h / 2);
1715 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1717 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1718 evas_map_util_3d_rotate(map, 0, degree,
1719 0, x + half_w, y + half_h, 0);
1723 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1724 evas_map_util_3d_rotate(map, degree, 0,
1725 0, x + half_w, y + half_h, 0);
1728 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1729 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1730 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1731 evas_object_map_set(obj, map);
1737 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1739 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1741 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1742 if (!resizable_flip) return NULL;
1744 resizable_flip->cw = cw;
1745 resizable_flip->axis = axis;
1747 return resizable_flip;
1751 * Add the Resizable Flip Effect to Elm_Transit.
1753 * @note This API is one of the facades. It creates resizable flip effect context
1754 * and add it's required APIs to elm_transit_effect_add.
1755 * @note This effect is applied to each pair of objects in the order they are listed
1756 * in the transit list of objects. The first object in the pair will be the
1757 * "front" object and the second will be the "back" object.
1759 * @see elm_transit_effect_add()
1761 * @param transit Transit object.
1762 * @param axis Flipping Axis(X or Y).
1763 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1764 * @return Resizable flip effect context data.
1767 * @warning Is higher recommended just create a transit with this effect when
1768 * the window that the objects of the transit belongs has already been created.
1769 * This is because this effect needs the geometry information about the objects,
1770 * and if the window was not created yet, it can get a wrong information.
1773 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1775 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1776 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1778 if (!effect_context) return NULL;
1779 elm_transit_effect_add(transit,
1780 _transit_effect_resizable_flip_op, effect_context,
1781 _transit_effect_resizable_flip_context_free);
1782 return effect_context;
1786 ///////////////////////////////////////////////////////////////////////////////
1788 ///////////////////////////////////////////////////////////////////////////////
1789 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1791 struct _Elm_Transit_Effect_Wipe
1793 Elm_Transit_Effect_Wipe_Type type;
1794 Elm_Transit_Effect_Wipe_Dir dir;
1798 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1804 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1805 w2 = w - (w * progress);
1807 evas_map_point_image_uv_set(map, 0, 0, 0);
1808 evas_map_point_image_uv_set(map, 1, w2, 0);
1809 evas_map_point_image_uv_set(map, 2, w2, h);
1810 evas_map_point_image_uv_set(map, 3, 0, h);
1811 evas_map_point_coord_set(map, 0, x, y, 0);
1812 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1813 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1814 evas_map_point_coord_set(map, 3, x, h2, 0);
1816 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1817 w2 = (w * progress);
1819 evas_map_point_image_uv_set(map, 0, w2, 0);
1820 evas_map_point_image_uv_set(map, 1, w, 0);
1821 evas_map_point_image_uv_set(map, 2, w, h);
1822 evas_map_point_image_uv_set(map, 3, w2, h);
1823 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1824 evas_map_point_coord_set(map, 1, x + w, y, 0);
1825 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1826 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1828 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1830 h2 = h - (h * progress);
1831 evas_map_point_image_uv_set(map, 0, 0, 0);
1832 evas_map_point_image_uv_set(map, 1, w, 0);
1833 evas_map_point_image_uv_set(map, 2, w, h2);
1834 evas_map_point_image_uv_set(map, 3, 0, h2);
1835 evas_map_point_coord_set(map, 0, x, y, 0);
1836 evas_map_point_coord_set(map, 1, w2, y, 0);
1837 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1838 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1840 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1842 h2 = (h * progress);
1843 evas_map_point_image_uv_set(map, 0, 0, h2);
1844 evas_map_point_image_uv_set(map, 1, w, h2);
1845 evas_map_point_image_uv_set(map, 2, w, h);
1846 evas_map_point_image_uv_set(map, 3, 0, h);
1847 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1848 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1849 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1850 evas_map_point_coord_set(map, 3, x, y + h, 0);
1855 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1859 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1865 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1866 w2 = (w - (w * progress));
1868 evas_map_point_image_uv_set(map, 0, w2, 0);
1869 evas_map_point_image_uv_set(map, 1, w, 0);
1870 evas_map_point_image_uv_set(map, 2, w, h);
1871 evas_map_point_image_uv_set(map, 3, w2, h);
1872 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1873 evas_map_point_coord_set(map, 1, w, y, 0);
1874 evas_map_point_coord_set(map, 2, w, h2, 0);
1875 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1877 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1878 w2 = (w * progress);
1880 evas_map_point_image_uv_set(map, 0, 0, 0);
1881 evas_map_point_image_uv_set(map, 1, w2, 0);
1882 evas_map_point_image_uv_set(map, 2, w2, h);
1883 evas_map_point_image_uv_set(map, 3, 0, h);
1884 evas_map_point_coord_set(map, 0, x, y, 0);
1885 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1886 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1887 evas_map_point_coord_set(map, 3, x, h2, 0);
1889 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1891 h2 = (h - (h * progress));
1892 evas_map_point_image_uv_set(map, 0, 0, h2);
1893 evas_map_point_image_uv_set(map, 1, w, h2);
1894 evas_map_point_image_uv_set(map, 2, w, h);
1895 evas_map_point_image_uv_set(map, 3, 0, h);
1896 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1897 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1898 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1899 evas_map_point_coord_set(map, 3, x, y + h, 0);
1901 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1903 h2 = (h * progress);
1904 evas_map_point_image_uv_set(map, 0, 0, 0);
1905 evas_map_point_image_uv_set(map, 1, w, 0);
1906 evas_map_point_image_uv_set(map, 2, w, h2);
1907 evas_map_point_image_uv_set(map, 3, 0, h2);
1908 evas_map_point_coord_set(map, 0, x, y, 0);
1909 evas_map_point_coord_set(map, 1, w2, y, 0);
1910 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1911 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1916 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1920 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1922 EINA_SAFETY_ON_NULL_RETURN(data);
1923 EINA_SAFETY_ON_NULL_RETURN(transit);
1926 Elm_Transit_Effect_Wipe *wipe = data;
1927 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1929 EINA_LIST_FOREACH(transit->objs, elist, obj)
1931 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1932 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1933 evas_object_show(obj);
1934 else evas_object_hide(obj);
1935 evas_object_map_enable_set(obj, EINA_FALSE);
1942 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1944 EINA_SAFETY_ON_NULL_RETURN(data);
1945 EINA_SAFETY_ON_NULL_RETURN(transit);
1946 Elm_Transit_Effect_Wipe *wipe = data;
1948 Evas_Coord _x, _y, _w, _h;
1952 map = evas_map_new(4);
1955 EINA_LIST_FOREACH(transit->objs, elist, obj)
1957 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1959 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1960 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1962 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1964 evas_object_map_enable_set(obj, EINA_TRUE);
1965 evas_object_map_set(obj, map);
1971 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1973 Elm_Transit_Effect_Wipe *wipe;
1975 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1976 if (!wipe) return NULL;
1985 * Add the Wipe Effect to Elm_Transit.
1987 * @note This API is one of the facades. It creates wipe effect context
1988 * and add it's required APIs to elm_transit_effect_add.
1990 * @see elm_transit_effect_add()
1992 * @param transit Transit object.
1993 * @param type Wipe type. Hide or show.
1994 * @param dir Wipe Direction.
1995 * @return Wipe effect context data.
1998 * @warning Is higher recommended just create a transit with this effect when
1999 * the window that the objects of the transit belongs has already been created.
2000 * This is because this effect needs the geometry information about the objects,
2001 * and if the window was not created yet, it can get a wrong information.
2004 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2006 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2007 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2009 if (!effect_context) return NULL;
2010 elm_transit_effect_add(transit,
2011 _transit_effect_wipe_op, effect_context,
2012 _transit_effect_wipe_context_free);
2013 return effect_context;
2017 ///////////////////////////////////////////////////////////////////////////////
2019 ///////////////////////////////////////////////////////////////////////////////
2020 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2022 struct _Elm_Transit_Effect_Color
2024 struct _unsigned_color {
2025 unsigned int r, g, b, a;
2027 struct _signed_color {
2033 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
2039 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
2041 EINA_SAFETY_ON_NULL_RETURN(data);
2042 EINA_SAFETY_ON_NULL_RETURN(transit);
2043 Elm_Transit_Effect_Color *color = data;
2046 unsigned int r, g, b, a;
2048 r = (color->from.r + (int)((float)color->to.r * progress));
2049 g = (color->from.g + (int)((float)color->to.g * progress));
2050 b = (color->from.b + (int)((float)color->to.b * progress));
2051 a = (color->from.a + (int)((float)color->to.a * progress));
2053 EINA_LIST_FOREACH(transit->objs, elist, obj)
2054 evas_object_color_set(obj, r, g, b, a);
2058 _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)
2060 Elm_Transit_Effect_Color *color;
2062 color = ELM_NEW(Elm_Transit_Effect_Color);
2063 if (!color) return NULL;
2065 color->from.r = from_r;
2066 color->from.g = from_g;
2067 color->from.b = from_b;
2068 color->from.a = from_a;
2069 color->to.r = to_r - from_r;
2070 color->to.g = to_g - from_g;
2071 color->to.b = to_b - from_b;
2072 color->to.a = to_a - from_a;
2078 * Add the Color Effect to Elm_Transit.
2080 * @note This API is one of the facades. It creates color effect context
2081 * and add it's required APIs to elm_transit_effect_add.
2083 * @see elm_transit_effect_add()
2085 * @param transit Transit object.
2086 * @param from_r RGB R when effect begins.
2087 * @param from_g RGB G when effect begins.
2088 * @param from_b RGB B when effect begins.
2089 * @param from_a RGB A when effect begins.
2090 * @param to_r RGB R when effect ends.
2091 * @param to_g RGB G when effect ends.
2092 * @param to_b RGB B when effect ends.
2093 * @param to_a RGB A when effect ends.
2094 * @return Color effect context data.
2099 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)
2101 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2102 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2104 if (!effect_context) return NULL;
2105 elm_transit_effect_add(transit,
2106 _transit_effect_color_op, effect_context,
2107 _transit_effect_color_context_free);
2108 return effect_context;
2111 ///////////////////////////////////////////////////////////////////////////////
2113 ///////////////////////////////////////////////////////////////////////////////
2114 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2115 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2117 struct _Elm_Transit_Effect_Fade_Node
2119 Evas_Object *before;
2121 struct _signed_color before_color, after_color;
2124 Eina_Bool inversed : 1;
2127 struct _Elm_Transit_Effect_Fade
2133 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2135 Elm_Transit_Effect_Fade *fade = data;
2137 Elm_Transit_Effect_Fade_Node *fade_node;
2139 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2141 if (fade_node->before == obj)
2142 evas_object_event_callback_del(fade_node->after,
2143 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2144 else if (fade_node->after == obj)
2145 evas_object_event_callback_del(fade_node->before,
2146 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2149 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2156 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2158 Elm_Transit_Effect_Fade_Node *fade;
2159 Eina_List *data_list = NULL;
2162 count = eina_list_count(transit->objs);
2163 for (i = 0; i < count; i += 2)
2165 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2168 eina_list_free(data_list);
2172 fade->before = eina_list_nth(transit->objs, i);
2173 fade->after = eina_list_nth(transit->objs, i+1);
2175 evas_object_color_get(fade->before,
2176 &fade->before_color.r, &fade->before_color.g,
2177 &fade->before_color.b, &fade->before_color.a);
2178 evas_object_color_get(fade->after,
2179 &fade->after_color.r, &fade->after_color.g,
2180 &fade->after_color.b, &fade->after_color.a);
2182 fade->before_alpha = (255 - fade->before_color.a);
2183 fade->after_alpha = (255 - fade->after_color.a);
2185 data_list = eina_list_append(data_list, fade);
2187 evas_object_event_callback_add(fade->before,
2188 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2189 evas_object_event_callback_add(fade->after,
2190 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2196 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2198 EINA_SAFETY_ON_NULL_RETURN(data);
2199 Elm_Transit_Effect_Fade *fade = data;
2200 Elm_Transit_Effect_Fade_Node *fade_node;
2201 Eina_List *elist, *elist_next;
2203 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2205 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2206 fade_node->before_color.g,
2207 fade_node->before_color.b,
2208 fade_node->before_color.a);
2209 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2210 fade_node->after_color.g,
2211 fade_node->after_color.b,
2212 fade_node->after_color.a);
2214 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2215 evas_object_event_callback_del(fade_node->before,
2216 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2217 evas_object_event_callback_del(fade_node->after,
2218 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2226 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2228 EINA_SAFETY_ON_NULL_RETURN(data);
2229 Elm_Transit_Effect_Fade *fade = data;
2231 Elm_Transit_Effect_Fade_Node *fade_node;
2235 fade->nodes = _fade_nodes_build(transit, fade);
2237 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2241 if (!fade_node->inversed)
2243 evas_object_hide(fade_node->after);
2244 evas_object_show(fade_node->before);
2245 fade_node->inversed = EINA_TRUE;
2248 _progress = (1 - (progress * 2));
2250 evas_object_color_set(fade_node->before,
2251 fade_node->before_color.r * _progress,
2252 fade_node->before_color.g * _progress,
2253 fade_node->before_color.b * _progress,
2254 fade_node->before_color.a +
2255 fade_node->before_alpha * (1 - _progress));
2259 if (fade_node->inversed)
2261 evas_object_hide(fade_node->before);
2262 evas_object_show(fade_node->after);
2263 fade_node->inversed = EINA_FALSE;
2266 _progress = ((progress - 0.5) * 2);
2268 evas_object_color_set(fade_node->after,
2269 fade_node->after_color.r * _progress,
2270 fade_node->after_color.g * _progress,
2271 fade_node->after_color.b * _progress,
2272 fade_node->after_color.a +
2273 fade_node->after_alpha * (1 - _progress));
2279 _transit_effect_fade_context_new(void)
2281 Elm_Transit_Effect_Fade *fade;
2282 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2283 if (!fade) return NULL;
2288 * Add the Fade Effect to Elm_Transit.
2290 * @note This API is one of the facades. It creates fade effect context
2291 * and add it's required APIs to elm_transit_effect_add.
2292 * @note This effect is applied to each pair of objects in the order they are listed
2293 * in the transit list of objects. The first object in the pair will be the
2294 * "before" object and the second will be the "after" object.
2296 * @see elm_transit_effect_add()
2298 * @param transit Transit object.
2299 * @return Fade effect context data.
2302 * @warning Is higher recommended just create a transit with this effect when
2303 * the window that the objects of the transit belongs has already been created.
2304 * This is because this effect needs the color information about the objects,
2305 * and if the window was not created yet, it can get a wrong information.
2308 elm_transit_effect_fade_add(Elm_Transit *transit)
2310 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2312 void *effect_context = _transit_effect_fade_context_new();
2313 if (!effect_context) return NULL;
2314 elm_transit_effect_add(transit,
2315 _transit_effect_fade_op, effect_context,
2316 _transit_effect_fade_context_free);
2317 return effect_context;
2321 ///////////////////////////////////////////////////////////////////////////////
2323 ///////////////////////////////////////////////////////////////////////////////
2324 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2325 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2327 struct _Elm_Transit_Effect_Blend_Node
2329 Evas_Object *before;
2331 struct _signed_color from, to;
2334 struct _Elm_Transit_Effect_Blend
2340 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2342 Elm_Transit_Effect_Blend *blend = data;
2344 Elm_Transit_Effect_Blend_Node *blend_node;
2346 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2348 if (blend_node->after == obj)
2349 evas_object_event_callback_del(blend_node->before,
2350 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2351 else if (blend_node->before == obj)
2352 evas_object_event_callback_del(blend_node->after,
2353 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2356 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2363 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2365 Elm_Transit_Effect_Blend_Node *blend_node;
2366 Eina_List *data_list = NULL;
2369 count = eina_list_count(transit->objs);
2370 for (i = 0; i < (count - 1); i += 2)
2372 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2375 eina_list_free(data_list);
2379 blend_node->before = eina_list_nth(transit->objs, i);
2380 blend_node->after = eina_list_nth(transit->objs, i + 1);
2381 evas_object_show(blend_node->before);
2382 evas_object_show(blend_node->after);
2384 evas_object_color_get(blend_node->before, &blend_node->from.r,
2385 &blend_node->from.g, &blend_node->from.b,
2386 &blend_node->from.a);
2387 evas_object_color_get(blend_node->after, &blend_node->to.r,
2388 &blend_node->to.g, &blend_node->to.b,
2391 data_list = eina_list_append(data_list, blend_node);
2393 evas_object_event_callback_add(blend_node->before,
2394 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2395 evas_object_event_callback_add(blend_node->after,
2396 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2402 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2404 EINA_SAFETY_ON_NULL_RETURN(data);
2405 Elm_Transit_Effect_Blend *blend = data;
2406 Elm_Transit_Effect_Blend_Node *blend_node;
2407 Eina_List *elist, *elist_next;
2409 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2411 evas_object_color_set(blend_node->before,
2412 blend_node->from.r, blend_node->from.g,
2413 blend_node->from.b, blend_node->from.a);
2414 evas_object_color_set(blend_node->after, blend_node->to.r,
2415 blend_node->to.g, blend_node->to.b,
2418 if (elm_transit_auto_reverse_get(transit))
2419 evas_object_hide(blend_node->after);
2421 evas_object_hide(blend_node->before);
2423 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2425 evas_object_event_callback_del(blend_node->before,
2426 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2427 evas_object_event_callback_del(blend_node->after,
2428 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2435 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2437 EINA_SAFETY_ON_NULL_RETURN(data);
2438 EINA_SAFETY_ON_NULL_RETURN(transit);
2439 Elm_Transit_Effect_Blend *blend = data;
2440 Elm_Transit_Effect_Blend_Node *blend_node;
2443 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2445 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2447 evas_object_color_set(blend_node->before,
2448 (int)(blend_node->from.r * (1 - progress)),
2449 (int)(blend_node->from.g * (1 - progress)),
2450 (int)(blend_node->from.b * (1 - progress)),
2451 (int)(blend_node->from.a * (1 - progress)));
2452 evas_object_color_set(blend_node->after,
2453 (int)(blend_node->to.r * progress),
2454 (int)(blend_node->to.g * progress),
2455 (int)(blend_node->to.b * progress),
2456 (int)(blend_node->to.a * progress));
2461 _transit_effect_blend_context_new(void)
2463 Elm_Transit_Effect_Blend *blend;
2465 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2466 if (!blend) return NULL;
2471 * Add the Blend Effect to Elm_Transit.
2473 * @note This API is one of the facades. It creates blend effect context
2474 * and add it's required APIs to elm_transit_effect_add.
2475 * @note This effect is applied to each pair of objects in the order they are listed
2476 * in the transit list of objects. The first object in the pair will be the
2477 * "before" object and the second will be the "after" object.
2479 * @see elm_transit_effect_add()
2481 * @param transit Transit object.
2482 * @return Blend effect context data.
2485 * @warning Is higher recommended just create a transit with this effect when
2486 * the window that the objects of the transit belongs has already been created.
2487 * This is because this effect needs the color information about the objects,
2488 * and if the window was not created yet, it can get a wrong information.
2491 elm_transit_effect_blend_add(Elm_Transit *transit)
2493 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2494 void *effect_context = _transit_effect_blend_context_new();
2496 if (!effect_context) return NULL;
2497 elm_transit_effect_add(transit,
2498 _transit_effect_blend_op, effect_context,
2499 _transit_effect_blend_context_free);
2500 return effect_context;
2504 ///////////////////////////////////////////////////////////////////////////////
2506 ///////////////////////////////////////////////////////////////////////////////
2507 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2509 struct _Elm_Transit_Effect_Rotation
2515 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2521 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2523 EINA_SAFETY_ON_NULL_RETURN(data);
2524 EINA_SAFETY_ON_NULL_RETURN(transit);
2525 Elm_Transit_Effect_Rotation *rotation = data;
2527 Evas_Coord x, y, w, h;
2529 float half_w, half_h;
2533 map = evas_map_new(4);
2536 EINA_LIST_FOREACH(transit->objs, elist, obj)
2538 evas_map_util_points_populate_from_object_full(map, obj, 0);
2539 degree = rotation->from + (float)(progress * rotation->to);
2541 evas_object_geometry_get(obj, &x, &y, &w, &h);
2543 half_w = (float)w * 0.5;
2544 half_h = (float)h * 0.5;
2546 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2547 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2548 evas_object_map_enable_set(obj, EINA_TRUE);
2549 evas_object_map_set(obj, map);
2555 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2557 Elm_Transit_Effect_Rotation *rotation;
2559 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2560 if (!rotation) return NULL;
2562 rotation->from = from_degree;
2563 rotation->to = to_degree - from_degree;
2569 * Add the Rotation Effect to Elm_Transit.
2571 * @note This API is one of the facades. It creates rotation effect context
2572 * and add it's required APIs to elm_transit_effect_add.
2574 * @see elm_transit_effect_add()
2576 * @param transit Transit object.
2577 * @param from_degree Degree when effect begins.
2578 * @param to_degree Degree when effect is ends.
2579 * @return Rotation effect context data.
2582 * @warning Is higher recommended just create a transit with this effect when
2583 * the window that the objects of the transit belongs has already been created.
2584 * This is because this effect needs the geometry information about the objects,
2585 * and if the window was not created yet, it can get a wrong information.
2588 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2590 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2591 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2593 if (!effect_context) return NULL;
2594 elm_transit_effect_add(transit,
2595 _transit_effect_rotation_op, effect_context,
2596 _transit_effect_rotation_context_free);
2597 return effect_context;
2601 ///////////////////////////////////////////////////////////////////////////////
2602 //ImageAnimation Effect
2603 ///////////////////////////////////////////////////////////////////////////////
2604 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2606 struct _Elm_Transit_Effect_Image_Animation
2612 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2614 EINA_SAFETY_ON_NULL_RETURN(data);
2615 Elm_Transit_Effect_Image_Animation *image_animation = data;
2617 Eina_List *elist, *elist_next;
2619 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2621 image_animation->images =
2622 eina_list_remove_list(image_animation->images, elist);
2623 eina_stringshare_del(image);
2630 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2632 EINA_SAFETY_ON_NULL_RETURN(data);
2633 EINA_SAFETY_ON_NULL_RETURN(transit);
2637 Elm_Transit_Effect_Image_Animation *image_animation = data;
2638 unsigned int count = 0;
2641 type = eina_stringshare_add("icon");
2642 len = eina_list_count(image_animation->images);
2644 if (!len) count = floor(progress * len);
2645 else count = floor(progress * (len - 1));
2647 EINA_LIST_FOREACH(transit->objs, elist, obj)
2649 if (elm_widget_type_check(obj, type))
2650 elm_icon_file_set(obj,
2651 eina_list_nth(image_animation->images, count), NULL);
2654 eina_stringshare_del(type);
2658 _transit_effect_image_animation_context_new(Eina_List *images)
2660 Elm_Transit_Effect_Image_Animation *image_animation;
2661 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2663 if (!image_animation) return NULL;
2664 image_animation->images = images;
2665 return image_animation;
2669 * Add the ImageAnimation Effect to Elm_Transit.
2671 * @note This API is one of the facades. It creates image animation effect context
2672 * and add it's required APIs to elm_transit_effect_add.
2673 * The @p images parameter is a list images paths. This list and
2674 * its contents will be deleted at the end of the effect by
2675 * elm_transit_effect_image_animation_context_free() function.
2679 * char buf[PATH_MAX];
2680 * Eina_List *images = NULL;
2681 * Elm_Transit *transi = elm_transit_add();
2683 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2684 * images = eina_list_append(images, eina_stringshare_add(buf));
2686 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2687 * images = eina_list_append(images, eina_stringshare_add(buf));
2688 * elm_transit_effect_image_animation_add(transi, images);
2692 * @see elm_transit_effect_add()
2694 * @param transit Transit object.
2695 * @param images Eina_List of images file paths. This list and
2696 * its contents will be deleted at the end of the effect by
2697 * elm_transit_effect_image_animation_context_free() function.
2698 * @return Image Animation effect context data.
2703 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2705 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2706 void *effect_context = _transit_effect_image_animation_context_new(images);
2708 if (!effect_context) return NULL;
2709 elm_transit_effect_add(transit,
2710 _transit_effect_image_animation_op, effect_context,
2711 _transit_effect_image_animation_context_free);
2712 return effect_context;