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) (Elm_Transit_Effect *effect, Elm_Transit *transit, double progress);
92 void (*user_effect_free) (Elm_Transit_Effect *effect, Elm_Transit *transit);
93 Elm_Transit_Effect *user_effect;
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_effect_free)
196 effect_module->user_effect_free(effect_module->user_effect, 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_effect, 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)(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress), Elm_Transit_Effect *effect, void (*effect_free_cb)(Elm_Transit_Effect *effect, 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_effect == effect)) return;
415 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
416 if (!effect_module) return;
418 effect_module->user_effect_free = effect_free_cb;
419 effect_module->animation_op = cb;
420 effect_module->user_effect = effect;
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)(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress), Elm_Transit_Effect *effect)
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_effect == effect))
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(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1012 Elm_Transit_Effect_Resizing *resizing = effect;
1017 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1019 EINA_SAFETY_ON_NULL_RETURN(effect);
1020 EINA_SAFETY_ON_NULL_RETURN(transit);
1024 Elm_Transit_Effect_Resizing *resizing = effect;
1026 w = resizing->from.w + (resizing->to.w * progress);
1027 h = resizing->from.h + (resizing->to.h * progress);
1029 EINA_LIST_FOREACH(transit->objs, elist, obj)
1030 evas_object_resize(obj, w, h);
1033 static Elm_Transit_Effect *
1034 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1036 Elm_Transit_Effect_Resizing *resizing;
1038 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1039 if (!resizing) return NULL;
1041 resizing->from.w = from_w;
1042 resizing->from.h = from_h;
1043 resizing->to.w = to_w - from_w;
1044 resizing->to.h = to_h - from_h;
1050 * Add the Resizing Effect to Elm_Transit.
1052 * @note This API is one of the facades. It creates resizing effect context
1053 * and add it's required APIs to elm_transit_effect_add.
1055 * @see elm_transit_effect_add()
1057 * @param transit Transit object.
1058 * @param from_w Object width size when effect begins.
1059 * @param from_h Object height size when effect begins.
1060 * @param to_w Object width size when effect ends.
1061 * @param to_h Object height size when effect ends.
1062 * @return Resizing effect context data.
1066 EAPI Elm_Transit_Effect *
1067 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1069 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1070 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1072 if (!effect) return NULL;
1073 elm_transit_effect_add(transit,
1074 _transit_effect_resizing_op, effect,
1075 _transit_effect_resizing_context_free);
1079 ///////////////////////////////////////////////////////////////////////////////
1080 //Translation Effect
1081 ///////////////////////////////////////////////////////////////////////////////
1082 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1083 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1085 struct _Elm_Transit_Effect_Translation_Node
1091 struct _Elm_Transit_Effect_Translation
1093 struct _position_variation {
1100 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1102 Elm_Transit_Effect_Translation *translation = data;
1104 Elm_Transit_Effect_Translation_Node *translation_node;
1106 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1108 if (translation_node->obj != obj) continue;
1109 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1110 free(translation_node);
1116 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1118 Elm_Transit_Effect_Translation_Node *translation_node;
1119 const Eina_List *elist;
1121 Eina_List *data_list = NULL;
1122 const Eina_List *objs = elm_transit_objects_get(transit);
1124 EINA_LIST_FOREACH(objs, elist, obj)
1126 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1127 if (!translation_node)
1129 eina_list_free(data_list);
1132 translation_node->obj = obj;
1133 evas_object_geometry_get(obj, &(translation_node->x),
1134 &(translation_node->y), NULL, NULL);
1135 data_list = eina_list_append(data_list, translation_node);
1136 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1137 _translation_object_del_cb, translation);
1143 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1145 EINA_SAFETY_ON_NULL_RETURN(effect);
1146 Elm_Transit_Effect_Translation *translation = effect;
1147 Eina_List *elist, *elist_next;
1148 Elm_Transit_Effect_Translation_Node *translation_node;
1150 EINA_LIST_FOREACH_SAFE(translation->nodes,
1151 elist, elist_next, translation_node)
1153 evas_object_event_callback_del(translation_node->obj,
1154 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1155 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1156 free(translation_node);
1162 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1164 EINA_SAFETY_ON_NULL_RETURN(effect);
1165 EINA_SAFETY_ON_NULL_RETURN(transit);
1167 Elm_Transit_Effect_Translation *translation = effect;
1168 Elm_Transit_Effect_Translation_Node *translation_node;
1171 if (!translation->nodes)
1172 translation->nodes = _translation_nodes_build(transit, translation);
1174 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1176 x = translation_node->x + translation->from.dx
1177 + (translation->to.dx * progress);
1178 y = translation_node->y + translation->from.dy
1179 + (translation->to.dy * progress);
1180 evas_object_move(translation_node->obj, x, y);
1184 static Elm_Transit_Effect *
1185 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1187 Elm_Transit_Effect_Translation *translation;
1189 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1190 if (!translation) return NULL;
1192 translation->from.dx = from_dx;
1193 translation->from.dy = from_dy;
1194 translation->to.dx = to_dx - from_dx;
1195 translation->to.dy = to_dy - from_dy;
1201 * Add the Translation Effect to Elm_Transit.
1203 * @note This API is one of the facades. It creates translation effect context
1204 * and add it's required APIs to elm_transit_effect_add.
1206 * @see elm_transit_effect_add()
1208 * @param transit Transit object.
1209 * @param from_dx X Position variation when effect begins.
1210 * @param from_dy Y Position variation when effect begins.
1211 * @param to_dx X Position variation when effect ends.
1212 * @param to_dy Y Position variation when effect ends.
1213 * @return Translation effect context data.
1216 * @warning Is higher recommended just create a transit with this effect when
1217 * the window that the objects of the transit belongs has already been created.
1218 * This is because this effect needs the geometry information about the objects,
1219 * and if the window was not created yet, it can get a wrong information.
1221 EAPI Elm_Transit_Effect *
1222 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1224 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1225 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1227 if (!effect_context) return NULL;
1228 elm_transit_effect_add(transit,
1229 _transit_effect_translation_op, effect_context,
1230 _transit_effect_translation_context_free);
1231 return effect_context;
1235 ///////////////////////////////////////////////////////////////////////////////
1237 ///////////////////////////////////////////////////////////////////////////////
1238 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1240 struct _Elm_Transit_Effect_Zoom
1246 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1248 Elm_Transit_Effect_Zoom *zoom = effect;
1253 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1255 EINA_SAFETY_ON_NULL_RETURN(effect);
1256 EINA_SAFETY_ON_NULL_RETURN(transit);
1259 Elm_Transit_Effect_Zoom *zoom = effect;
1261 Evas_Coord x, y, w, h;
1263 map = evas_map_new(4);
1266 EINA_LIST_FOREACH(transit->objs, elist, obj)
1268 evas_object_geometry_get(obj, &x, &y, &w, &h);
1269 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1270 (progress * zoom->to));
1271 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1272 evas_object_map_set(obj, map);
1273 evas_object_map_enable_set(obj, EINA_TRUE);
1278 static Elm_Transit_Effect *
1279 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1281 Elm_Transit_Effect_Zoom *zoom;
1283 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1284 if (!zoom) return NULL;
1286 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1287 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1293 * Add the Zoom Effect to Elm_Transit.
1295 * @note This API is one of the facades. It creates zoom effect context
1296 * and add it's required APIs to elm_transit_effect_add.
1298 * @see elm_transit_effect_add()
1300 * @param transit Transit object.
1301 * @param from_rate Scale rate when effect begins (1 is current rate).
1302 * @param to_rate Scale rate when effect ends.
1303 * @return Zoom effect context data.
1306 * @warning Is higher recommended just create a transit with this effect when
1307 * the window that the objects of the transit belongs has already been created.
1308 * This is because this effect needs the geometry information about the objects,
1309 * and if the window was not created yet, it can get a wrong information.
1311 EAPI Elm_Transit_Effect *
1312 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1314 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1315 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1317 if (!effect_context) return NULL;
1318 elm_transit_effect_add(transit,
1319 _transit_effect_zoom_op, effect_context,
1320 _transit_effect_zoom_context_free);
1321 return effect_context;
1325 ///////////////////////////////////////////////////////////////////////////////
1327 ///////////////////////////////////////////////////////////////////////////////
1328 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1330 struct _Elm_Transit_Effect_Flip
1332 Elm_Transit_Effect_Flip_Axis axis;
1337 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1339 EINA_SAFETY_ON_NULL_RETURN(effect);
1340 EINA_SAFETY_ON_NULL_RETURN(transit);
1341 Elm_Transit_Effect_Flip *flip = effect;
1342 Evas_Object *front, *back;
1344 int count = eina_list_count(transit->objs);
1346 for (i = 0; i < (count - 1); i += 2)
1348 front = eina_list_nth(transit->objs, i);
1349 back = eina_list_nth(transit->objs, i+1);
1350 evas_object_map_enable_set(front, EINA_FALSE);
1351 evas_object_map_enable_set(back, EINA_FALSE);
1357 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1359 EINA_SAFETY_ON_NULL_RETURN(effect);
1360 EINA_SAFETY_ON_NULL_RETURN(transit);
1361 Evas_Object *obj, *front, *back;
1363 Elm_Transit_Effect_Flip *flip = effect;
1366 Evas_Coord x, y, w, h;
1368 map = evas_map_new(4);
1371 if (flip->cw) degree = (float)(progress * 180);
1372 else degree = (float)(progress * -180);
1374 count = eina_list_count(transit->objs);
1375 for (i = 0; i < (count - 1); i += 2)
1377 Evas_Coord half_w, half_h;
1379 front = eina_list_nth(transit->objs, i);
1380 back = eina_list_nth(transit->objs, i+1);
1382 if ((degree < 90) && (degree > -90))
1387 evas_object_hide(back);
1388 evas_object_show(front);
1396 evas_object_hide(front);
1397 evas_object_show(back);
1401 evas_map_util_points_populate_from_object_full(map, obj, 0);
1402 evas_object_geometry_get(obj, &x, &y, &w, &h);
1406 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1408 if ((degree >= 90) || (degree <= -90))
1410 evas_map_point_image_uv_set(map, 0, w, 0);
1411 evas_map_point_image_uv_set(map, 1, 0, 0);
1412 evas_map_point_image_uv_set(map, 2, 0, h);
1413 evas_map_point_image_uv_set(map, 3, w, h);
1415 evas_map_util_3d_rotate(map, 0, degree,
1416 0, x + half_w, y + half_h, 0);
1420 if ((degree >= 90) || (degree <= -90))
1422 evas_map_point_image_uv_set(map, 0, 0, h);
1423 evas_map_point_image_uv_set(map, 1, w, h);
1424 evas_map_point_image_uv_set(map, 2, w, 0);
1425 evas_map_point_image_uv_set(map, 3, 0, 0);
1427 evas_map_util_3d_rotate(map, degree,
1428 0, 0, x + half_w, y + half_h, 0);
1430 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1431 evas_object_map_enable_set(front, EINA_TRUE);
1432 evas_object_map_enable_set(back, EINA_TRUE);
1433 evas_object_map_set(obj, map);
1438 static Elm_Transit_Effect *
1439 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1441 Elm_Transit_Effect_Flip *flip;
1443 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1444 if (!flip) return NULL;
1453 * Add the Flip Effect to Elm_Transit.
1455 * @note This API is one of the facades. It creates flip effect context
1456 * and add it's required APIs to elm_transit_effect_add.
1457 * @note This effect is applied to each pair of objects in the order they are listed
1458 * in the transit list of objects. The first object in the pair will be the
1459 * "front" object and the second will be the "back" object.
1461 * @see elm_transit_effect_add()
1463 * @param transit Transit object.
1464 * @param axis Flipping Axis(X or Y).
1465 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1466 * @return Flip effect context data.
1469 * @warning Is higher recommended just create a transit with this effect when
1470 * the window that the objects of the transit belongs has already been created.
1471 * This is because this effect needs the geometry information about the objects,
1472 * and if the window was not created yet, it can get a wrong information.
1474 EAPI Elm_Transit_Effect *
1475 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1477 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1478 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1480 if (!effect_context) return NULL;
1481 elm_transit_effect_add(transit,
1482 _transit_effect_flip_op, effect_context,
1483 _transit_effect_flip_context_free);
1484 return effect_context;
1487 ///////////////////////////////////////////////////////////////////////////////
1488 //ResizableFlip Effect
1489 ///////////////////////////////////////////////////////////////////////////////
1490 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1491 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1493 struct _Elm_Transit_Effect_Resizable_Flip_Node
1499 } from_pos, from_size, to_pos, to_size;
1502 struct _Elm_Transit_Effect_Resizable_Flip
1506 Elm_Transit_Effect_Flip_Axis axis;
1510 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1512 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1514 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1516 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1518 if (resizable_flip_node->front == obj)
1519 evas_object_event_callback_del(resizable_flip_node->back,
1520 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1521 else if (resizable_flip_node->back == obj)
1522 evas_object_event_callback_del(resizable_flip_node->front,
1523 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1526 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1528 free(resizable_flip_node);
1534 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1536 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1537 Eina_List *data_list = NULL;
1538 Evas_Coord front_x, front_y, front_w, front_h;
1539 Evas_Coord back_x, back_y, back_w, back_h;
1542 count = eina_list_count(transit->objs);
1543 for (i = 0; i < (count - 1); i += 2)
1545 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1546 if (!resizable_flip_node)
1548 eina_list_free(data_list);
1552 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1553 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1555 evas_object_geometry_get(resizable_flip_node->front,
1556 &front_x, &front_y, &front_w, &front_h);
1557 evas_object_geometry_get(resizable_flip_node->back,
1558 &back_x, &back_y, &back_w, &back_h);
1560 resizable_flip_node->from_pos.x = front_x;
1561 resizable_flip_node->from_pos.y = front_y;
1562 resizable_flip_node->to_pos.x = back_x - front_x;
1563 resizable_flip_node->to_pos.y = back_y - front_y;
1565 resizable_flip_node->from_size.x = front_w;
1566 resizable_flip_node->from_size.y = front_h;
1567 resizable_flip_node->to_size.x = back_w - front_w;
1568 resizable_flip_node->to_size.y = back_h - front_h;
1570 data_list = eina_list_append(data_list, resizable_flip_node);
1572 evas_object_event_callback_add(resizable_flip_node->back,
1573 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1574 evas_object_event_callback_add(resizable_flip_node->front,
1575 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1582 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1584 if ((degree >= 90) || (degree <= -90))
1586 evas_map_point_image_uv_set(map, 0,
1587 (flip->from_size.x * 2) + flip->to_size.x,
1589 evas_map_point_image_uv_set(map, 1, 0, 0);
1590 evas_map_point_image_uv_set(map, 2, 0,
1591 (flip->from_size.y * 2) + flip->to_size.y);
1592 evas_map_point_image_uv_set(map, 3,
1593 (flip->from_size.x * 2) + flip->to_size.x,
1594 (flip->from_size.y * 2) + flip->to_size.y);
1598 evas_map_point_image_uv_set(map, 0, 0, 0);
1599 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1600 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1602 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1607 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1609 if ((degree >= 90) || (degree <= -90))
1611 evas_map_point_image_uv_set(map, 0, 0,
1612 (flip->from_size.y * 2) + flip->to_size.y);
1613 evas_map_point_image_uv_set(map, 1,
1614 (flip->from_size.x * 2) + flip->to_size.x,
1615 (flip->from_size.y * 2) + flip->to_size.y);
1616 evas_map_point_image_uv_set(map, 2,
1617 (flip->from_size.x * 2) + flip->to_size.x,
1619 evas_map_point_image_uv_set(map, 3, 0, 0);
1623 evas_map_point_image_uv_set(map, 0, 0, 0);
1624 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1625 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1627 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1632 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1634 EINA_SAFETY_ON_NULL_RETURN(effect);
1636 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1637 Eina_List *elist, *elist_next;
1638 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1640 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1641 elist, elist_next, resizable_flip_node)
1643 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1644 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1646 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1649 evas_object_event_callback_del(resizable_flip_node->back,
1650 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1651 evas_object_event_callback_del(resizable_flip_node->front,
1652 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1653 free(resizable_flip_node);
1655 free(resizable_flip);
1659 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1661 EINA_SAFETY_ON_NULL_RETURN(effect);
1666 Evas_Coord half_w, half_h;
1667 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1668 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1671 map = evas_map_new(4);
1674 if (resizable_flip->cw) degree = (float)(progress * 180);
1675 else degree = (float)(progress * -180);
1677 if (!resizable_flip->nodes)
1678 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1681 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1683 if ((degree < 90) && (degree > -90))
1685 obj = resizable_flip_node->front;
1686 if (resizable_flip_node->front != resizable_flip_node->back)
1688 evas_object_hide(resizable_flip_node->back);
1689 evas_object_show(resizable_flip_node->front);
1694 obj = resizable_flip_node->back;
1695 if (resizable_flip_node->front != resizable_flip_node->back)
1697 evas_object_hide(resizable_flip_node->front);
1698 evas_object_show(resizable_flip_node->back);
1702 x = resizable_flip_node->from_pos.x +
1703 (resizable_flip_node->to_pos.x * progress);
1704 y = resizable_flip_node->from_pos.y +
1705 (resizable_flip_node->to_pos.y * progress);
1706 w = resizable_flip_node->from_size.x +
1707 (resizable_flip_node->to_size.x * progress);
1708 h = resizable_flip_node->from_size.y +
1709 (resizable_flip_node->to_size.y * progress);
1710 evas_map_point_coord_set(map, 0, x, y, 0);
1711 evas_map_point_coord_set(map, 1, x + w, y, 0);
1712 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1713 evas_map_point_coord_set(map, 3, x, y + h, 0);
1715 half_w = (Evas_Coord)(w / 2);
1716 half_h = (Evas_Coord)(h / 2);
1718 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1720 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1721 evas_map_util_3d_rotate(map, 0, degree,
1722 0, x + half_w, y + half_h, 0);
1726 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1727 evas_map_util_3d_rotate(map, degree, 0,
1728 0, x + half_w, y + half_h, 0);
1731 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1732 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1733 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1734 evas_object_map_set(obj, map);
1739 static Elm_Transit_Effect *
1740 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1742 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1744 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1745 if (!resizable_flip) return NULL;
1747 resizable_flip->cw = cw;
1748 resizable_flip->axis = axis;
1750 return resizable_flip;
1754 * Add the Resizable Flip Effect to Elm_Transit.
1756 * @note This API is one of the facades. It creates resizable flip effect context
1757 * and add it's required APIs to elm_transit_effect_add.
1758 * @note This effect is applied to each pair of objects in the order they are listed
1759 * in the transit list of objects. The first object in the pair will be the
1760 * "front" object and the second will be the "back" object.
1762 * @see elm_transit_effect_add()
1764 * @param transit Transit object.
1765 * @param axis Flipping Axis(X or Y).
1766 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1767 * @return Resizable flip effect context data.
1770 * @warning Is higher recommended just create a transit with this effect when
1771 * the window that the objects of the transit belongs has already been created.
1772 * This is because this effect needs the geometry information about the objects,
1773 * and if the window was not created yet, it can get a wrong information.
1775 EAPI Elm_Transit_Effect *
1776 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1778 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1779 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1781 if (!effect_context) return NULL;
1782 elm_transit_effect_add(transit,
1783 _transit_effect_resizable_flip_op, effect_context,
1784 _transit_effect_resizable_flip_context_free);
1785 return effect_context;
1789 ///////////////////////////////////////////////////////////////////////////////
1791 ///////////////////////////////////////////////////////////////////////////////
1792 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1794 struct _Elm_Transit_Effect_Wipe
1796 Elm_Transit_Effect_Wipe_Type type;
1797 Elm_Transit_Effect_Wipe_Dir dir;
1801 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1807 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1808 w2 = w - (w * progress);
1810 evas_map_point_image_uv_set(map, 0, 0, 0);
1811 evas_map_point_image_uv_set(map, 1, w2, 0);
1812 evas_map_point_image_uv_set(map, 2, w2, h);
1813 evas_map_point_image_uv_set(map, 3, 0, h);
1814 evas_map_point_coord_set(map, 0, x, y, 0);
1815 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1816 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1817 evas_map_point_coord_set(map, 3, x, h2, 0);
1819 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1820 w2 = (w * progress);
1822 evas_map_point_image_uv_set(map, 0, w2, 0);
1823 evas_map_point_image_uv_set(map, 1, w, 0);
1824 evas_map_point_image_uv_set(map, 2, w, h);
1825 evas_map_point_image_uv_set(map, 3, w2, h);
1826 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1827 evas_map_point_coord_set(map, 1, x + w, y, 0);
1828 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1829 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1831 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1833 h2 = h - (h * progress);
1834 evas_map_point_image_uv_set(map, 0, 0, 0);
1835 evas_map_point_image_uv_set(map, 1, w, 0);
1836 evas_map_point_image_uv_set(map, 2, w, h2);
1837 evas_map_point_image_uv_set(map, 3, 0, h2);
1838 evas_map_point_coord_set(map, 0, x, y, 0);
1839 evas_map_point_coord_set(map, 1, w2, y, 0);
1840 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1841 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1843 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1845 h2 = (h * progress);
1846 evas_map_point_image_uv_set(map, 0, 0, h2);
1847 evas_map_point_image_uv_set(map, 1, w, h2);
1848 evas_map_point_image_uv_set(map, 2, w, h);
1849 evas_map_point_image_uv_set(map, 3, 0, h);
1850 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1851 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1852 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1853 evas_map_point_coord_set(map, 3, x, y + h, 0);
1858 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1862 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1868 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1869 w2 = (w - (w * progress));
1871 evas_map_point_image_uv_set(map, 0, w2, 0);
1872 evas_map_point_image_uv_set(map, 1, w, 0);
1873 evas_map_point_image_uv_set(map, 2, w, h);
1874 evas_map_point_image_uv_set(map, 3, w2, h);
1875 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1876 evas_map_point_coord_set(map, 1, w, y, 0);
1877 evas_map_point_coord_set(map, 2, w, h2, 0);
1878 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1880 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1881 w2 = (w * progress);
1883 evas_map_point_image_uv_set(map, 0, 0, 0);
1884 evas_map_point_image_uv_set(map, 1, w2, 0);
1885 evas_map_point_image_uv_set(map, 2, w2, h);
1886 evas_map_point_image_uv_set(map, 3, 0, h);
1887 evas_map_point_coord_set(map, 0, x, y, 0);
1888 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1889 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1890 evas_map_point_coord_set(map, 3, x, h2, 0);
1892 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1894 h2 = (h - (h * progress));
1895 evas_map_point_image_uv_set(map, 0, 0, h2);
1896 evas_map_point_image_uv_set(map, 1, w, h2);
1897 evas_map_point_image_uv_set(map, 2, w, h);
1898 evas_map_point_image_uv_set(map, 3, 0, h);
1899 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1900 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1901 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1902 evas_map_point_coord_set(map, 3, x, y + h, 0);
1904 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1906 h2 = (h * progress);
1907 evas_map_point_image_uv_set(map, 0, 0, 0);
1908 evas_map_point_image_uv_set(map, 1, w, 0);
1909 evas_map_point_image_uv_set(map, 2, w, h2);
1910 evas_map_point_image_uv_set(map, 3, 0, h2);
1911 evas_map_point_coord_set(map, 0, x, y, 0);
1912 evas_map_point_coord_set(map, 1, w2, y, 0);
1913 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1914 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1919 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1923 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1925 EINA_SAFETY_ON_NULL_RETURN(effect);
1926 EINA_SAFETY_ON_NULL_RETURN(transit);
1929 Elm_Transit_Effect_Wipe *wipe = effect;
1930 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1932 EINA_LIST_FOREACH(transit->objs, elist, obj)
1934 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1935 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1936 evas_object_show(obj);
1937 else evas_object_hide(obj);
1938 evas_object_map_enable_set(obj, EINA_FALSE);
1945 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1947 EINA_SAFETY_ON_NULL_RETURN(effect);
1948 EINA_SAFETY_ON_NULL_RETURN(transit);
1949 Elm_Transit_Effect_Wipe *wipe = effect;
1951 Evas_Coord _x, _y, _w, _h;
1955 map = evas_map_new(4);
1958 EINA_LIST_FOREACH(transit->objs, elist, obj)
1960 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1962 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1963 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1965 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1967 evas_object_map_enable_set(obj, EINA_TRUE);
1968 evas_object_map_set(obj, map);
1973 static Elm_Transit_Effect *
1974 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1976 Elm_Transit_Effect_Wipe *wipe;
1978 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1979 if (!wipe) return NULL;
1988 * Add the Wipe Effect to Elm_Transit.
1990 * @note This API is one of the facades. It creates wipe effect context
1991 * and add it's required APIs to elm_transit_effect_add.
1993 * @see elm_transit_effect_add()
1995 * @param transit Transit object.
1996 * @param type Wipe type. Hide or show.
1997 * @param dir Wipe Direction.
1998 * @return Wipe effect context data.
2001 * @warning Is higher recommended just create a transit with this effect when
2002 * the window that the objects of the transit belongs has already been created.
2003 * This is because this effect needs the geometry information about the objects,
2004 * and if the window was not created yet, it can get a wrong information.
2007 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2009 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2010 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2012 if (!effect_context) return NULL;
2013 elm_transit_effect_add(transit,
2014 _transit_effect_wipe_op, effect_context,
2015 _transit_effect_wipe_context_free);
2016 return effect_context;
2020 ///////////////////////////////////////////////////////////////////////////////
2022 ///////////////////////////////////////////////////////////////////////////////
2023 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2025 struct _Elm_Transit_Effect_Color
2027 struct _unsigned_color {
2028 unsigned int r, g, b, a;
2030 struct _signed_color {
2036 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2038 Elm_Transit_Effect_Color *color = effect;
2043 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2045 EINA_SAFETY_ON_NULL_RETURN(effect);
2046 EINA_SAFETY_ON_NULL_RETURN(transit);
2047 Elm_Transit_Effect_Color *color = effect;
2050 unsigned int r, g, b, a;
2052 r = (color->from.r + (int)((float)color->to.r * progress));
2053 g = (color->from.g + (int)((float)color->to.g * progress));
2054 b = (color->from.b + (int)((float)color->to.b * progress));
2055 a = (color->from.a + (int)((float)color->to.a * progress));
2057 EINA_LIST_FOREACH(transit->objs, elist, obj)
2058 evas_object_color_set(obj, r, g, b, a);
2061 static Elm_Transit_Effect *
2062 _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)
2064 Elm_Transit_Effect_Color *color;
2066 color = ELM_NEW(Elm_Transit_Effect_Color);
2067 if (!color) return NULL;
2069 color->from.r = from_r;
2070 color->from.g = from_g;
2071 color->from.b = from_b;
2072 color->from.a = from_a;
2073 color->to.r = to_r - from_r;
2074 color->to.g = to_g - from_g;
2075 color->to.b = to_b - from_b;
2076 color->to.a = to_a - from_a;
2082 * Add the Color Effect to Elm_Transit.
2084 * @note This API is one of the facades. It creates color effect context
2085 * and add it's required APIs to elm_transit_effect_add.
2087 * @see elm_transit_effect_add()
2089 * @param transit Transit object.
2090 * @param from_r RGB R when effect begins.
2091 * @param from_g RGB G when effect begins.
2092 * @param from_b RGB B when effect begins.
2093 * @param from_a RGB A when effect begins.
2094 * @param to_r RGB R when effect ends.
2095 * @param to_g RGB G when effect ends.
2096 * @param to_b RGB B when effect ends.
2097 * @param to_a RGB A when effect ends.
2098 * @return Color effect context data.
2102 EAPI Elm_Transit_Effect *
2103 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)
2105 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2106 Elm_Transit_Effect *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2108 if (!effect_context) return NULL;
2109 elm_transit_effect_add(transit,
2110 _transit_effect_color_op, effect_context,
2111 _transit_effect_color_context_free);
2112 return effect_context;
2115 ///////////////////////////////////////////////////////////////////////////////
2117 ///////////////////////////////////////////////////////////////////////////////
2118 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2119 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2121 struct _Elm_Transit_Effect_Fade_Node
2123 Evas_Object *before;
2125 struct _signed_color before_color, after_color;
2128 Eina_Bool inversed : 1;
2131 struct _Elm_Transit_Effect_Fade
2137 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2139 Elm_Transit_Effect_Fade *fade = data;
2141 Elm_Transit_Effect_Fade_Node *fade_node;
2143 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2145 if (fade_node->before == obj)
2146 evas_object_event_callback_del(fade_node->after,
2147 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2148 else if (fade_node->after == obj)
2149 evas_object_event_callback_del(fade_node->before,
2150 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2153 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2160 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2162 Elm_Transit_Effect_Fade_Node *fade;
2163 Eina_List *data_list = NULL;
2166 count = eina_list_count(transit->objs);
2167 for (i = 0; i < count; i += 2)
2169 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2172 eina_list_free(data_list);
2176 fade->before = eina_list_nth(transit->objs, i);
2177 fade->after = eina_list_nth(transit->objs, i+1);
2179 evas_object_color_get(fade->before,
2180 &fade->before_color.r, &fade->before_color.g,
2181 &fade->before_color.b, &fade->before_color.a);
2182 evas_object_color_get(fade->after,
2183 &fade->after_color.r, &fade->after_color.g,
2184 &fade->after_color.b, &fade->after_color.a);
2186 fade->before_alpha = (255 - fade->before_color.a);
2187 fade->after_alpha = (255 - fade->after_color.a);
2189 data_list = eina_list_append(data_list, fade);
2191 evas_object_event_callback_add(fade->before,
2192 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2193 evas_object_event_callback_add(fade->after,
2194 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2200 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2202 EINA_SAFETY_ON_NULL_RETURN(effect);
2203 Elm_Transit_Effect_Fade *fade = effect;
2204 Elm_Transit_Effect_Fade_Node *fade_node;
2205 Eina_List *elist, *elist_next;
2207 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2209 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2210 fade_node->before_color.g,
2211 fade_node->before_color.b,
2212 fade_node->before_color.a);
2213 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2214 fade_node->after_color.g,
2215 fade_node->after_color.b,
2216 fade_node->after_color.a);
2218 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2219 evas_object_event_callback_del(fade_node->before,
2220 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2221 evas_object_event_callback_del(fade_node->after,
2222 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2230 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2232 EINA_SAFETY_ON_NULL_RETURN(effect);
2233 Elm_Transit_Effect_Fade *fade = effect;
2235 Elm_Transit_Effect_Fade_Node *fade_node;
2239 fade->nodes = _fade_nodes_build(transit, fade);
2241 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2245 if (!fade_node->inversed)
2247 evas_object_hide(fade_node->after);
2248 evas_object_show(fade_node->before);
2249 fade_node->inversed = EINA_TRUE;
2252 _progress = (1 - (progress * 2));
2254 evas_object_color_set(fade_node->before,
2255 fade_node->before_color.r * _progress,
2256 fade_node->before_color.g * _progress,
2257 fade_node->before_color.b * _progress,
2258 fade_node->before_color.a +
2259 fade_node->before_alpha * (1 - _progress));
2263 if (fade_node->inversed)
2265 evas_object_hide(fade_node->before);
2266 evas_object_show(fade_node->after);
2267 fade_node->inversed = EINA_FALSE;
2270 _progress = ((progress - 0.5) * 2);
2272 evas_object_color_set(fade_node->after,
2273 fade_node->after_color.r * _progress,
2274 fade_node->after_color.g * _progress,
2275 fade_node->after_color.b * _progress,
2276 fade_node->after_color.a +
2277 fade_node->after_alpha * (1 - _progress));
2282 static Elm_Transit_Effect *
2283 _transit_effect_fade_context_new(void)
2285 Elm_Transit_Effect_Fade *fade;
2286 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2287 if (!fade) return NULL;
2292 * Add the Fade Effect to Elm_Transit.
2294 * @note This API is one of the facades. It creates fade effect context
2295 * and add it's required APIs to elm_transit_effect_add.
2296 * @note This effect is applied to each pair of objects in the order they are listed
2297 * in the transit list of objects. The first object in the pair will be the
2298 * "before" object and the second will be the "after" object.
2300 * @see elm_transit_effect_add()
2302 * @param transit Transit object.
2303 * @return Fade effect context data.
2306 * @warning Is higher recommended just create a transit with this effect when
2307 * the window that the objects of the transit belongs has already been created.
2308 * This is because this effect needs the color information about the objects,
2309 * and if the window was not created yet, it can get a wrong information.
2311 EAPI Elm_Transit_Effect *
2312 elm_transit_effect_fade_add(Elm_Transit *transit)
2314 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2316 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2317 if (!effect_context) return NULL;
2318 elm_transit_effect_add(transit,
2319 _transit_effect_fade_op, effect_context,
2320 _transit_effect_fade_context_free);
2321 return effect_context;
2325 ///////////////////////////////////////////////////////////////////////////////
2327 ///////////////////////////////////////////////////////////////////////////////
2328 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2329 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2331 struct _Elm_Transit_Effect_Blend_Node
2333 Evas_Object *before;
2335 struct _signed_color from, to;
2338 struct _Elm_Transit_Effect_Blend
2344 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2346 Elm_Transit_Effect_Blend *blend = data;
2348 Elm_Transit_Effect_Blend_Node *blend_node;
2350 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2352 if (blend_node->after == obj)
2353 evas_object_event_callback_del(blend_node->before,
2354 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2355 else if (blend_node->before == obj)
2356 evas_object_event_callback_del(blend_node->after,
2357 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2360 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2367 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2369 Elm_Transit_Effect_Blend_Node *blend_node;
2370 Eina_List *data_list = NULL;
2373 count = eina_list_count(transit->objs);
2374 for (i = 0; i < (count - 1); i += 2)
2376 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2379 eina_list_free(data_list);
2383 blend_node->before = eina_list_nth(transit->objs, i);
2384 blend_node->after = eina_list_nth(transit->objs, i + 1);
2385 evas_object_show(blend_node->before);
2386 evas_object_show(blend_node->after);
2388 evas_object_color_get(blend_node->before, &blend_node->from.r,
2389 &blend_node->from.g, &blend_node->from.b,
2390 &blend_node->from.a);
2391 evas_object_color_get(blend_node->after, &blend_node->to.r,
2392 &blend_node->to.g, &blend_node->to.b,
2395 data_list = eina_list_append(data_list, blend_node);
2397 evas_object_event_callback_add(blend_node->before,
2398 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2399 evas_object_event_callback_add(blend_node->after,
2400 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2406 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2408 EINA_SAFETY_ON_NULL_RETURN(effect);
2409 Elm_Transit_Effect_Blend *blend = effect;
2410 Elm_Transit_Effect_Blend_Node *blend_node;
2411 Eina_List *elist, *elist_next;
2413 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2415 evas_object_color_set(blend_node->before,
2416 blend_node->from.r, blend_node->from.g,
2417 blend_node->from.b, blend_node->from.a);
2418 evas_object_color_set(blend_node->after, blend_node->to.r,
2419 blend_node->to.g, blend_node->to.b,
2422 if (elm_transit_auto_reverse_get(transit))
2423 evas_object_hide(blend_node->after);
2425 evas_object_hide(blend_node->before);
2427 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2429 evas_object_event_callback_del(blend_node->before,
2430 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2431 evas_object_event_callback_del(blend_node->after,
2432 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2439 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2441 EINA_SAFETY_ON_NULL_RETURN(effect);
2442 EINA_SAFETY_ON_NULL_RETURN(transit);
2443 Elm_Transit_Effect_Blend *blend = effect;
2444 Elm_Transit_Effect_Blend_Node *blend_node;
2447 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2449 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2451 evas_object_color_set(blend_node->before,
2452 (int)(blend_node->from.r * (1 - progress)),
2453 (int)(blend_node->from.g * (1 - progress)),
2454 (int)(blend_node->from.b * (1 - progress)),
2455 (int)(blend_node->from.a * (1 - progress)));
2456 evas_object_color_set(blend_node->after,
2457 (int)(blend_node->to.r * progress),
2458 (int)(blend_node->to.g * progress),
2459 (int)(blend_node->to.b * progress),
2460 (int)(blend_node->to.a * progress));
2464 static Elm_Transit_Effect *
2465 _transit_effect_blend_context_new(void)
2467 Elm_Transit_Effect_Blend *blend;
2469 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2470 if (!blend) return NULL;
2475 * Add the Blend Effect to Elm_Transit.
2477 * @note This API is one of the facades. It creates blend effect context
2478 * and add it's required APIs to elm_transit_effect_add.
2479 * @note This effect is applied to each pair of objects in the order they are listed
2480 * in the transit list of objects. The first object in the pair will be the
2481 * "before" object and the second will be the "after" object.
2483 * @see elm_transit_effect_add()
2485 * @param transit Transit object.
2486 * @return Blend effect context data.
2489 * @warning Is higher recommended just create a transit with this effect when
2490 * the window that the objects of the transit belongs has already been created.
2491 * This is because this effect needs the color information about the objects,
2492 * and if the window was not created yet, it can get a wrong information.
2494 EAPI Elm_Transit_Effect *
2495 elm_transit_effect_blend_add(Elm_Transit *transit)
2497 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2498 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2500 if (!effect_context) return NULL;
2501 elm_transit_effect_add(transit,
2502 _transit_effect_blend_op, effect_context,
2503 _transit_effect_blend_context_free);
2504 return effect_context;
2508 ///////////////////////////////////////////////////////////////////////////////
2510 ///////////////////////////////////////////////////////////////////////////////
2511 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2513 struct _Elm_Transit_Effect_Rotation
2519 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2521 Elm_Transit_Effect_Rotation *rotation = effect;
2526 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2528 EINA_SAFETY_ON_NULL_RETURN(effect);
2529 EINA_SAFETY_ON_NULL_RETURN(transit);
2530 Elm_Transit_Effect_Rotation *rotation = effect;
2532 Evas_Coord x, y, w, h;
2534 float half_w, half_h;
2538 map = evas_map_new(4);
2541 EINA_LIST_FOREACH(transit->objs, elist, obj)
2543 evas_map_util_points_populate_from_object_full(map, obj, 0);
2544 degree = rotation->from + (float)(progress * rotation->to);
2546 evas_object_geometry_get(obj, &x, &y, &w, &h);
2548 half_w = (float)w * 0.5;
2549 half_h = (float)h * 0.5;
2551 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2552 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2553 evas_object_map_enable_set(obj, EINA_TRUE);
2554 evas_object_map_set(obj, map);
2559 static Elm_Transit_Effect *
2560 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2562 Elm_Transit_Effect_Rotation *rotation;
2564 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2565 if (!rotation) return NULL;
2567 rotation->from = from_degree;
2568 rotation->to = to_degree - from_degree;
2574 * Add the Rotation Effect to Elm_Transit.
2576 * @note This API is one of the facades. It creates rotation effect context
2577 * and add it's required APIs to elm_transit_effect_add.
2579 * @see elm_transit_effect_add()
2581 * @param transit Transit object.
2582 * @param from_degree Degree when effect begins.
2583 * @param to_degree Degree when effect is ends.
2584 * @return Rotation effect context data.
2587 * @warning Is higher recommended just create a transit with this effect when
2588 * the window that the objects of the transit belongs has already been created.
2589 * This is because this effect needs the geometry information about the objects,
2590 * and if the window was not created yet, it can get a wrong information.
2592 EAPI Elm_Transit_Effect *
2593 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2595 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2596 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2598 if (!effect_context) return NULL;
2599 elm_transit_effect_add(transit,
2600 _transit_effect_rotation_op, effect_context,
2601 _transit_effect_rotation_context_free);
2602 return effect_context;
2606 ///////////////////////////////////////////////////////////////////////////////
2607 //ImageAnimation Effect
2608 ///////////////////////////////////////////////////////////////////////////////
2609 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2611 struct _Elm_Transit_Effect_Image_Animation
2617 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2619 EINA_SAFETY_ON_NULL_RETURN(effect);
2620 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2622 Eina_List *elist, *elist_next;
2624 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2626 image_animation->images =
2627 eina_list_remove_list(image_animation->images, elist);
2628 eina_stringshare_del(image);
2631 free(image_animation);
2635 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2637 EINA_SAFETY_ON_NULL_RETURN(effect);
2638 EINA_SAFETY_ON_NULL_RETURN(transit);
2642 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2643 unsigned int count = 0;
2646 type = eina_stringshare_add("icon");
2647 len = eina_list_count(image_animation->images);
2649 if (!len) count = floor(progress * len);
2650 else count = floor(progress * (len - 1));
2652 EINA_LIST_FOREACH(transit->objs, elist, obj)
2654 if (elm_widget_type_check(obj, type))
2655 elm_icon_file_set(obj,
2656 eina_list_nth(image_animation->images, count), NULL);
2659 eina_stringshare_del(type);
2662 static Elm_Transit_Effect *
2663 _transit_effect_image_animation_context_new(Eina_List *images)
2665 Elm_Transit_Effect_Image_Animation *image_animation;
2666 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2668 if (!image_animation) return NULL;
2669 image_animation->images = images;
2670 return image_animation;
2674 * Add the ImageAnimation Effect to Elm_Transit.
2676 * @note This API is one of the facades. It creates image animation effect context
2677 * and add it's required APIs to elm_transit_effect_add.
2678 * The @p images parameter is a list images paths. This list and
2679 * its contents will be deleted at the end of the effect by
2680 * elm_transit_effect_image_animation_context_free() function.
2684 * char buf[PATH_MAX];
2685 * Eina_List *images = NULL;
2686 * Elm_Transit *transi = elm_transit_add();
2688 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2689 * images = eina_list_append(images, eina_stringshare_add(buf));
2691 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2692 * images = eina_list_append(images, eina_stringshare_add(buf));
2693 * elm_transit_effect_image_animation_add(transi, images);
2697 * @see elm_transit_effect_add()
2699 * @param transit Transit object.
2700 * @param images Eina_List of images file paths. This list and
2701 * its contents will be deleted at the end of the effect by
2702 * elm_transit_effect_image_animation_context_free() function.
2703 * @return Image Animation effect context data.
2707 EAPI Elm_Transit_Effect *
2708 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2710 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2711 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2713 if (!effect) return NULL;
2714 elm_transit_effect_add(transit,
2715 _transit_effect_image_animation_op, effect,
2716 _transit_effect_image_animation_context_free);