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 *prev_chain_transit;
64 Eina_List *next_chain_transits;
65 Elm_Transit_Tween_Mode tween_mode;
67 Elm_Transit_Effect_End_Cb func;
83 unsigned int effects_pending_del;
85 Eina_Bool auto_reverse : 1;
86 Eina_Bool event_enabled : 1;
87 Eina_Bool deleted : 1;
88 Eina_Bool state_keep : 1;
91 struct _Elm_Transit_Effect_Module
93 Elm_Transit_Effect_Transition_Cb transition_cb;
94 Elm_Transit_Effect_End_Cb end_cb;
95 Elm_Transit_Effect *effect;
96 Eina_Bool deleted : 1;
101 Evas_Coord x, y, w, h;
104 Eina_Bool map_enabled : 1;
105 Eina_Bool visible : 1;
110 Elm_Transit *transit;
111 struct _Elm_Obj_State *state;
112 Eina_Bool pass_events : 1;
115 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
116 typedef struct _Elm_Obj_Data Elm_Obj_Data;
117 typedef struct _Elm_Obj_State Elm_Obj_State;
120 _elm_transit_obj_states_save(Evas_Object *obj)
122 Elm_Obj_Data *obj_data;
123 Elm_Obj_State *state;
125 obj_data = evas_object_data_get(obj, _transit_key);
126 if ((!obj_data) || (obj_data->state)) return;
127 state = calloc(1, sizeof(Elm_Obj_State));
129 evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
130 evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a);
131 state->visible = evas_object_visible_get(obj);
132 state->map_enabled = evas_object_map_enable_get(obj);
133 if (evas_object_map_get(obj))
134 state->map = evas_map_dup(evas_object_map_get(obj));
135 obj_data->state = state;
139 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
141 Elm_Transit *transit = data;
142 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
143 evas_object_pass_events_set(obj, obj_data->pass_events);
145 free(obj_data->state);
147 transit->objs = eina_list_remove(transit->objs, obj);
148 if (!transit->objs) elm_transit_del(transit);
152 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
154 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
155 Elm_Obj_State *state = obj_data->state;
157 evas_object_pass_events_set(obj, obj_data->pass_events);
161 //recover the states of the object.
162 if (!transit->state_keep)
164 evas_object_move(obj, state->x, state->y);
165 evas_object_resize(obj, state->w, state->h);
166 evas_object_color_set(obj, state->r, state->g, state->b, state->a);
167 if (state->visible) evas_object_show(obj);
168 else evas_object_hide(obj);
169 if (state->map_enabled)
170 evas_object_map_enable_set(obj, EINA_TRUE);
172 evas_object_map_enable_set(obj, EINA_FALSE);
174 evas_object_map_set(obj, state->map);
181 //remove duplicated objects
182 //TODO: Need to consider about optimizing here
185 if (!eina_list_data_find_list(transit->objs, obj))
187 transit->objs = eina_list_remove(transit->objs, obj);
190 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
191 _elm_transit_object_remove_cb);
195 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module, Eina_List *elist)
197 if (effect_module->end_cb)
198 effect_module->end_cb(effect_module->effect, transit);
200 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
205 _remove_dead_effects(Elm_Transit *transit)
207 Eina_List *elist, *elist_next;
208 Elm_Transit_Effect_Module *effect_module;
210 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
212 if (effect_module->deleted)
214 _elm_transit_effect_del(transit, effect_module, elist);
215 transit->effects_pending_del--;
216 if (!transit->effects_pending_del) return;
222 _elm_transit_del(Elm_Transit *transit)
224 Eina_List *elist, *elist_next;
225 Elm_Transit_Effect_Module *effect_module;
226 Elm_Transit *chain_transit;
228 transit->deleted = EINA_TRUE;
230 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
232 if (transit->prev_chain_transit)
233 transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit);
234 chain_transit->prev_chain_transit = NULL;
237 eina_list_free(transit->next_chain_transits);
239 if (transit->animator)
240 ecore_animator_del(transit->animator);
242 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
243 _elm_transit_effect_del(transit, effect_module, elist);
245 while (transit->objs)
246 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
248 if (transit->del_data.func)
249 transit->del_data.func(transit->del_data.arg, transit);
251 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
256 _chain_transits_go(Elm_Transit *transit)
258 Eina_List *elist, *elist_next;
259 Elm_Transit *chain_transit;
261 EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
262 elm_transit_go(chain_transit);
266 _transit_animate_op(Elm_Transit *transit, double progress)
269 Elm_Transit_Effect_Module *effect_module;
272 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
274 if (transit->deleted) break;
275 if (!effect_module->deleted)
276 effect_module->transition_cb(effect_module->effect, transit, progress);
280 if (transit->walking) return;
282 if (transit->deleted) _elm_transit_del(transit);
283 else if (transit->effects_pending_del) _remove_dead_effects(transit);
287 _animator_animate_cb(void *data)
289 Elm_Transit *transit = data;
290 double elapsed_time, duration;
292 transit->time.current = ecore_loop_time_get();
293 elapsed_time = transit->time.current - transit->time.begin;
294 duration = transit->time.duration + transit->time.delayed;
296 if (elapsed_time > duration)
297 elapsed_time = duration;
299 transit->progress = elapsed_time / duration;
300 switch (transit->tween_mode)
302 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
303 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
305 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
306 transit->progress = sin(transit->progress * ELM_PI / 2.0);
308 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
309 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
316 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
318 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
320 /* Not end. Keep going. */
321 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
323 /* Repeat and reverse and time done! */
324 if ((transit->repeat.count >= 0) &&
325 (transit->repeat.current == transit->repeat.count) &&
326 ((!transit->auto_reverse) || transit->repeat.reverse))
328 /* run chain transit */
329 if (transit->next_chain_transits)
330 _chain_transits_go(transit);
332 elm_transit_del(transit);
333 return ECORE_CALLBACK_CANCEL;
337 if (!transit->auto_reverse || transit->repeat.reverse)
339 transit->repeat.current++;
340 transit->repeat.reverse = EINA_FALSE;
342 else transit->repeat.reverse = EINA_TRUE;
344 transit->time.begin = ecore_loop_time_get();
346 return ECORE_CALLBACK_RENEW;
352 * @note Is not necessary to delete the transit object, it will be deleted at
353 * the end of its operation.
354 * @note The transit will start playing when the program enter in the main loop, is not
355 * necessary to give a start to the transit.
357 * @param duration The duration of the transit in seconds. When transit starts
358 * to run, it will last a @p duration time.
359 * @return The transit object.
364 elm_transit_add(void)
366 Elm_Transit *transit = ELM_NEW(Elm_Transit);
367 if (!transit) return NULL;
369 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
371 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
376 * Stops the animation and delete the @p transit object.
378 * Call this function if you wants to stop the animation before the duration
379 * time. Make sure the @p transit object is still alive with
380 * elm_transit_del_cb_set() function.
381 * All added effects will be deleted, calling its repective data_free_cb
382 * functions. The function setted by elm_transit_del_cb_set() will be called.
384 * @see elm_transit_del_cb_set()
386 * @param transit The transit object to be deleted.
389 * @warning Just call this function if you are sure the transit is alive.
392 elm_transit_del(Elm_Transit *transit)
394 ELM_TRANSIT_CHECK_OR_RETURN(transit);
396 if (transit->walking) transit->deleted = EINA_TRUE;
397 else _elm_transit_del(transit);
401 * Add a new effect to the transit.
403 * @note The cb function and the data are the key to the effect. If you try to
404 * add an already added effect, nothing is done.
405 * @note After the first addition of an effect in @p transit, if its
406 * effect list become empty again, the @p transit will be killed by
407 * elm_transit_del(transit) function.
411 * Elm_Transit *transit = elm_transit_add();
412 * elm_transit_effect_add(transit,
413 * elm_transit_effect_blend_op,
414 * elm_transit_effect_blend_context_new(),
415 * elm_transit_effect_blend_context_free);
418 * @param transit The transit object.
419 * @param cb The operation function. It is called when the animation begins,
420 * it is the function that actually performs the animation. It is called with
421 * the @p data, @p transit and the time progression of the animation (a double
422 * value between 0.0 and 1.0).
423 * @param data The context data of the effect.
424 * @param data_free_cb The function to free the context data, it will be called
425 * at the end of the effect, it must finalize the animation and free the
429 * @warning The transit free the context data at the and of the transition with
430 * the data_free_cb function, do not use the context data in another transit.
433 elm_transit_effect_add(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect, Elm_Transit_Effect_End_Cb end_cb)
435 ELM_TRANSIT_CHECK_OR_RETURN(transit);
436 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
437 Elm_Transit_Effect_Module *effect_module;
440 EINA_LIST_FOREACH(transit->effect_list, elist, effect_module)
441 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) return;
443 effect_module = ELM_NEW(Elm_Transit_Effect_Module);
444 if (!effect_module) return;
446 effect_module->end_cb = end_cb;
447 effect_module->transition_cb = transition_cb;
448 effect_module->effect = effect;
450 transit->effect_list = eina_list_append(transit->effect_list, effect_module);
454 * Delete an added effect.
456 * This function will remove the effect from the @p transit, calling the
457 * data_free_cb to free the @p data.
459 * @see elm_transit_effect_add()
461 * @note If the effect is not found, nothing is done.
462 * @note If the effect list become empty, this function will call
463 * elm_transit_del(transit), that is, it will kill the @p transit.
465 * @param transit The transit object.
466 * @param cb The operation function.
467 * @param data The context data of the effect.
472 elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect)
474 ELM_TRANSIT_CHECK_OR_RETURN(transit);
475 EINA_SAFETY_ON_NULL_RETURN(transition_cb);
476 Eina_List *elist, *elist_next;
477 Elm_Transit_Effect_Module *effect_module;
479 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect_module)
481 if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect))
483 if (transit->walking)
485 effect_module->deleted = EINA_TRUE;
486 transit->effects_pending_del++;
490 _elm_transit_effect_del(transit, effect_module, elist);
491 if (!transit->effect_list) elm_transit_del(transit);
499 * Add new object to apply the effects.
501 * @note After the first addition of an object in @p transit, if its
502 * object list become empty again, the @p transit will be killed by
503 * elm_transit_del(transit) function.
504 * @note If the @p obj belongs to another transit, the @p obj will be
505 * removed from it and it will only belong to the @p transit. If the old
506 * transit stays without objects, it will die.
507 * @note When you add an object into the @p transit, its state from
508 * evas_object_pass_events_get(obj) is saved, and it is applied when the
509 * transit ends, if you change this state whith evas_object_pass_events_set()
510 * after add the object, this state will change again when @p transit stops to
513 * @param transit The transit object.
514 * @param obj Object to be animated.
517 * @warning It is not allowed to add a new object after transit begins to go.
520 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
522 ELM_TRANSIT_CHECK_OR_RETURN(transit);
523 EINA_SAFETY_ON_NULL_RETURN(obj);
524 Elm_Obj_Data *obj_data;
526 obj_data = evas_object_data_get(obj, _transit_key);
528 if ((obj_data) && (obj_data->transit != transit))
529 elm_transit_object_remove(obj_data->transit, obj);
531 if ((!obj_data) || (obj_data->transit != transit))
533 obj_data = ELM_NEW(Elm_Obj_Data);
534 obj_data->pass_events = evas_object_pass_events_get(obj);
535 obj_data->transit = transit;
536 evas_object_data_set(obj, _transit_key, obj_data);
537 if (!transit->event_enabled)
538 evas_object_pass_events_set(obj, EINA_TRUE);
540 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
541 _elm_transit_object_remove_cb,
545 transit->objs = eina_list_append(transit->objs, obj);
547 if (!transit->state_keep)
548 _elm_transit_obj_states_save(obj);
553 * Removes an added object from the transit.
555 * @note If the @p obj is not in the @p transit, nothing is done.
556 * @note If the list become empty, this function will call
557 * elm_transit_del(transit), that is, it will kill the @p transit.
559 * @param transit The transit object.
560 * @param obj Object to be removed from @p transit.
563 * @warning It is not allowed to remove objects after transit begins to go.
566 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
568 ELM_TRANSIT_CHECK_OR_RETURN(transit);
569 EINA_SAFETY_ON_NULL_RETURN(obj);
570 Elm_Obj_Data *obj_data;
572 obj_data = evas_object_data_get(obj, _transit_key);
574 if ((!obj_data) || (obj_data->transit != transit)) return;
576 _elm_transit_object_remove(transit, obj);
577 if (!transit->objs) elm_transit_del(transit);
581 * Get the objects of the transit.
583 * @param transit The transit object.
584 * @return a Eina_List with the objects from the transit.
588 EAPI const Eina_List *
589 elm_transit_objects_get(const Elm_Transit *transit)
591 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
592 return transit->objs;
596 * Set the event enabled when transit is operating.
598 * If @p enabled is EINA_TRUE, the objects of the transit will receives
599 * events from mouse and keyboard during the animation.
600 * @note When you add an object with elm_transit_object_add(), its state from
601 * evas_object_pass_events_get(obj) is saved, and it is applied when the
602 * transit ends, if you change this state with evas_object_pass_events_set()
603 * after adding the object, this state will change again when @p transit stops
606 * @param transit The transit object.
607 * @param enabled Disable or enable.
612 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
614 ELM_TRANSIT_CHECK_OR_RETURN(transit);
617 Elm_Obj_Data *obj_data;
619 if (transit->event_enabled == enabled) return;
621 transit->event_enabled = !!enabled;
625 EINA_LIST_FOREACH(transit->objs, elist, obj)
627 obj_data = evas_object_data_get(obj, _transit_key);
628 evas_object_pass_events_set(obj, obj_data->pass_events);
633 EINA_LIST_FOREACH(transit->objs, elist, obj)
634 evas_object_pass_events_set(obj, EINA_TRUE);
639 * Get the value of event enabled status.
641 * @see elm_transit_event_enabled_set()
643 * @param transit The Transit object
644 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
645 * EINA_FALSE is returned
650 elm_transit_event_enabled_get(const Elm_Transit *transit)
652 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
653 return transit->event_enabled;
658 * Set the event enabled when transit is operating.
660 * If @p disabled is EINA_TRUE, the objects of the transit will receives
661 * events from mouse and keyboard during the animation.
662 * @note When you add an object with elm_transit_object_add(), its state from
663 * evas_object_pass_events_get(obj) is saved, and it is applied when the
664 * transit ends, if you change this state with evas_object_pass_events_set()
665 * after add the object, this state will change again when @p transit stops to
668 * @see elm_transit_event_enabled_set()
670 * @param transit The transit object.
671 * @param disabled Disable or enable.
675 EINA_DEPRECATED EAPI void
676 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
678 elm_transit_event_enabled_set(transit, disabled);
683 * Get the value of event block enabled status.
685 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
687 * @param transit The Transit object
688 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
689 * EINA_FALSE is returned
693 EINA_DEPRECATED EAPI Eina_Bool
694 elm_transit_event_block_get(const Elm_Transit *transit)
696 return !elm_transit_event_enabled_get(transit);
700 * Set the user-callback function when the transit is deleted.
702 * @note Using this function twice will overwrite the first function setted.
703 * @note the @p transit object will be deleted after call @p cb function.
705 * @param transit The transit object.
706 * @param cb Callback function pointer. This function will be called before
707 * the deletion of the transit.
708 * @param data Callback funtion user data. It is the @p op parameter.
713 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
715 ELM_TRANSIT_CHECK_OR_RETURN(transit);
716 transit->del_data.func = cb;
717 transit->del_data.arg = data;
721 * Set reverse effect automatically.
723 * If auto reverse is setted, after running the effects with the progress
724 * parameter from 0 to 1, it will call the effecs again with the progress
725 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
726 * where the duration was setted with the function elm_transit_add and
727 * the repeat with the function elm_transit_repeat_times_set().
729 * @param transit The transit object.
730 * @param reverse EINA_TRUE means the auto_reverse is on.
735 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
737 ELM_TRANSIT_CHECK_OR_RETURN(transit);
738 transit->auto_reverse = reverse;
742 * Get if the auto reverse is on.
744 * @see elm_transit_auto_reverse_set()
746 * @param transit The transit object.
747 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
748 * EINA_FALSE is returned
753 elm_transit_auto_reverse_get(const Elm_Transit *transit)
755 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
756 return transit->auto_reverse;
760 * Set the transit repeat count. Effect will be repeated by repeat count.
762 * This function sets the number of repetition the transit will run after
763 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
764 * If the @p repeat is a negative number, it will repeat infinite times.
766 * @note If this function is called during the transit execution, the transit
767 * will run @p repeat times, ignoring the times it already performed.
769 * @param transit The transit object
770 * @param repeat Repeat count
775 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
777 ELM_TRANSIT_CHECK_OR_RETURN(transit);
778 transit->repeat.count = repeat;
779 transit->repeat.current = 0;
783 * Get the transit repeat count.
785 * @see elm_transit_repeat_times_set()
787 * @param transit The Transit object.
788 * @return The repeat count. If @p transit is NULL
794 elm_transit_repeat_times_get(const Elm_Transit *transit)
796 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
797 return transit->repeat.count;
801 * Set the transit animation acceleration type.
803 * This function sets the tween mode of the transit that can be:
804 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
805 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
806 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
807 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
809 * @param transit The transit object.
810 * @param tween_mode The tween type.
815 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
817 ELM_TRANSIT_CHECK_OR_RETURN(transit);
818 transit->tween_mode = tween_mode;
822 * Get the transit animation acceleration type.
824 * @note @p transit can not be NULL
826 * @param transit The transit object.
827 * @return The tween type. If @p transit is NULL
828 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
832 EAPI Elm_Transit_Tween_Mode
833 elm_transit_tween_mode_get(const Elm_Transit *transit)
835 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
836 return transit->tween_mode;
840 * Set the transit animation time
842 * @note @p transit can not be NULL
844 * @param transit The transit object.
845 * @param duration The animation time.
850 elm_transit_duration_set(Elm_Transit *transit, double duration)
852 ELM_TRANSIT_CHECK_OR_RETURN(transit);
853 if (transit->animator) return;
854 transit->time.duration = duration;
858 * Get the transit animation time
860 * @note @p transit can not be NULL
862 * @param transit The transit object.
864 * @return The transit animation time.
869 elm_transit_duration_get(const Elm_Transit *transit)
871 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
872 return transit->time.duration;
876 * Starts the transition.
877 * Once this API is called, the transit begins to measure the time.
879 * @note @p transit can not be NULL
881 * @param transit The transit object.
886 elm_transit_go(Elm_Transit *transit)
888 ELM_TRANSIT_CHECK_OR_RETURN(transit);
890 if (transit->animator)
891 ecore_animator_del(transit->animator);
893 transit->time.paused = 0;
894 transit->time.delayed = 0;
895 transit->time.begin = ecore_loop_time_get();
896 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
900 * Pause/Resume the transition.
901 * If you call elm_transit_go again, paused states will affect no anymore.
903 * @note @p transit can not be NULL
905 * @param transit The transit object.
910 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
912 ELM_TRANSIT_CHECK_OR_RETURN(transit);
914 if (!transit->animator) return;
918 if (transit->time.paused > 0)
920 ecore_animator_freeze(transit->animator);
921 transit->time.paused = ecore_loop_time_get();
925 if (transit->time.paused == 0)
927 ecore_animator_thaw(transit->animator);
928 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
929 transit->time.paused = 0;
934 * Get the value of paused status.
936 * @see elm_transit_paused_set()
938 * @note @p transit can not be NULL
940 * @param transit The transit object.
941 * @return EINA_TRUE means transition is paused. If @p transit is NULL
942 * EINA_FALSE is returned
947 elm_transit_paused_get(const Elm_Transit *transit)
949 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
951 if (transit->time.paused == 0)
958 * Get the time progression of the animation (a double value between 0.0 and 1.0).
960 * @note @p transit can not be NULL
962 * @param transit The transit object.
964 * @return The time progression value. If @p transit is NULL
970 elm_transit_progress_value_get(const Elm_Transit *transit)
972 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
973 return transit->progress;
977 * Enable/disable keeping up the objects states.
978 * If it is not kept, the objects states will be reset when transition ends.
980 * @note @p transit can not be NULL.
981 * @note One state includes geometry, color, map data.
983 * @param transit The transit object.
984 * @param state_keep Keeping or Non Keeping.
989 elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep)
994 ELM_TRANSIT_CHECK_OR_RETURN(transit);
995 if (transit->state_keep == state_keep) return;
996 if (transit->animator) return;
997 transit->state_keep = !!state_keep;
1000 EINA_LIST_FOREACH(transit->objs, list, obj)
1001 _elm_transit_obj_states_save(obj);
1006 * Get a value whether the objects states will be reset or not.
1008 * @note @p transit can not be NULL
1010 * @see elm_transit_objects_final_state_keep_set()
1012 * @param transit The transit object.
1013 * @return EINA_TRUE means the states of the objects will be reset.
1014 * If @p transit is NULL, EINA_FALSE is returned
1019 elm_transit_objects_final_state_keep_get(const Elm_Transit *transit)
1021 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
1022 return transit->state_keep;
1026 * Makes the chain relationship between two transits.
1028 * @note @p transit can not be NULL. Transit would have multiple chain transits.
1029 * @note @p chain_transit can not be NULL. Chain transits could be chained to the only one transit.
1031 * @param transit The transit object.
1032 * @param chain_transit The chain transit object. This transit will be operated * after transit is done.
1037 elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit)
1039 ELM_TRANSIT_CHECK_OR_RETURN(transit);
1040 ELM_TRANSIT_CHECK_OR_RETURN(chain_transit);
1042 if (transit == chain_transit) return;
1043 if (transit == chain_transit->prev_chain_transit) return;
1045 if (chain_transit->prev_chain_transit)
1046 chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit);
1048 chain_transit->prev_chain_transit = transit;
1049 transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit);
1053 * Get the current chain transit list.
1055 * @note @p transit can not be NULL.
1057 * @param transit The transit object.
1058 * @return chain transit list.
1063 elm_transit_chain_transits_get(const Elm_Transit * transit)
1065 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1066 return transit->next_chain_transits;
1069 ///////////////////////////////////////////////////////////////////////////////
1071 ///////////////////////////////////////////////////////////////////////////////
1072 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
1074 struct _Elm_Transit_Effect_Resizing
1082 _transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1084 Elm_Transit_Effect_Resizing *resizing = effect;
1089 _transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1091 EINA_SAFETY_ON_NULL_RETURN(effect);
1092 EINA_SAFETY_ON_NULL_RETURN(transit);
1096 Elm_Transit_Effect_Resizing *resizing = effect;
1098 w = resizing->from.w + (resizing->to.w * progress);
1099 h = resizing->from.h + (resizing->to.h * progress);
1101 EINA_LIST_FOREACH(transit->objs, elist, obj)
1102 evas_object_resize(obj, w, h);
1105 static Elm_Transit_Effect *
1106 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1108 Elm_Transit_Effect_Resizing *resizing;
1110 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
1111 if (!resizing) return NULL;
1113 resizing->from.w = from_w;
1114 resizing->from.h = from_h;
1115 resizing->to.w = to_w - from_w;
1116 resizing->to.h = to_h - from_h;
1122 * Add the Resizing Effect to Elm_Transit.
1124 * @note This API is one of the facades. It creates resizing effect context
1125 * and add it's required APIs to elm_transit_effect_add.
1127 * @see elm_transit_effect_add()
1129 * @param transit Transit object.
1130 * @param from_w Object width size when effect begins.
1131 * @param from_h Object height size when effect begins.
1132 * @param to_w Object width size when effect ends.
1133 * @param to_h Object height size when effect ends.
1134 * @return Resizing effect context data.
1138 EAPI Elm_Transit_Effect *
1139 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
1141 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1142 Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
1144 if (!effect) return NULL;
1145 elm_transit_effect_add(transit,
1146 _transit_effect_resizing_op, effect,
1147 _transit_effect_resizing_context_free);
1151 ///////////////////////////////////////////////////////////////////////////////
1152 //Translation Effect
1153 ///////////////////////////////////////////////////////////////////////////////
1154 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
1155 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
1157 struct _Elm_Transit_Effect_Translation_Node
1163 struct _Elm_Transit_Effect_Translation
1165 struct _position_variation {
1172 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1174 Elm_Transit_Effect_Translation *translation = data;
1176 Elm_Transit_Effect_Translation_Node *translation_node;
1178 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1180 if (translation_node->obj != obj) continue;
1181 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1182 free(translation_node);
1188 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1190 Elm_Transit_Effect_Translation_Node *translation_node;
1191 const Eina_List *elist;
1193 Eina_List *data_list = NULL;
1194 const Eina_List *objs = elm_transit_objects_get(transit);
1196 EINA_LIST_FOREACH(objs, elist, obj)
1198 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1199 if (!translation_node)
1201 eina_list_free(data_list);
1204 translation_node->obj = obj;
1205 evas_object_geometry_get(obj, &(translation_node->x),
1206 &(translation_node->y), NULL, NULL);
1207 data_list = eina_list_append(data_list, translation_node);
1208 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1209 _translation_object_del_cb, translation);
1215 _transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1217 EINA_SAFETY_ON_NULL_RETURN(effect);
1218 Elm_Transit_Effect_Translation *translation = effect;
1219 Eina_List *elist, *elist_next;
1220 Elm_Transit_Effect_Translation_Node *translation_node;
1222 EINA_LIST_FOREACH_SAFE(translation->nodes,
1223 elist, elist_next, translation_node)
1225 evas_object_event_callback_del(translation_node->obj,
1226 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1227 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1228 free(translation_node);
1234 _transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__)
1236 EINA_SAFETY_ON_NULL_RETURN(effect);
1237 EINA_SAFETY_ON_NULL_RETURN(transit);
1239 Elm_Transit_Effect_Translation *translation = effect;
1240 Elm_Transit_Effect_Translation_Node *translation_node;
1243 if (!translation->nodes)
1244 translation->nodes = _translation_nodes_build(transit, translation);
1246 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1248 x = translation_node->x + translation->from.dx
1249 + (translation->to.dx * progress);
1250 y = translation_node->y + translation->from.dy
1251 + (translation->to.dy * progress);
1252 evas_object_move(translation_node->obj, x, y);
1256 static Elm_Transit_Effect *
1257 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1259 Elm_Transit_Effect_Translation *translation;
1261 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1262 if (!translation) return NULL;
1264 translation->from.dx = from_dx;
1265 translation->from.dy = from_dy;
1266 translation->to.dx = to_dx - from_dx;
1267 translation->to.dy = to_dy - from_dy;
1273 * Add the Translation Effect to Elm_Transit.
1275 * @note This API is one of the facades. It creates translation effect context
1276 * and add it's required APIs to elm_transit_effect_add.
1278 * @see elm_transit_effect_add()
1280 * @param transit Transit object.
1281 * @param from_dx X Position variation when effect begins.
1282 * @param from_dy Y Position variation when effect begins.
1283 * @param to_dx X Position variation when effect ends.
1284 * @param to_dy Y Position variation when effect ends.
1285 * @return Translation effect context data.
1288 * @warning Is higher recommended just create a transit with this effect when
1289 * the window that the objects of the transit belongs has already been created.
1290 * This is because this effect needs the geometry information about the objects,
1291 * and if the window was not created yet, it can get a wrong information.
1293 EAPI Elm_Transit_Effect *
1294 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1296 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1297 Elm_Transit_Effect *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1299 if (!effect_context) return NULL;
1300 elm_transit_effect_add(transit,
1301 _transit_effect_translation_op, effect_context,
1302 _transit_effect_translation_context_free);
1303 return effect_context;
1307 ///////////////////////////////////////////////////////////////////////////////
1309 ///////////////////////////////////////////////////////////////////////////////
1310 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1312 struct _Elm_Transit_Effect_Zoom
1318 _transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1320 Elm_Transit_Effect_Zoom *zoom = effect;
1325 _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress)
1327 EINA_SAFETY_ON_NULL_RETURN(effect);
1328 EINA_SAFETY_ON_NULL_RETURN(transit);
1331 Elm_Transit_Effect_Zoom *zoom = effect;
1333 Evas_Coord x, y, w, h;
1335 map = evas_map_new(4);
1338 EINA_LIST_FOREACH(transit->objs, elist, obj)
1340 evas_object_geometry_get(obj, &x, &y, &w, &h);
1341 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1342 (progress * zoom->to));
1343 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1344 evas_object_map_set(obj, map);
1345 evas_object_map_enable_set(obj, EINA_TRUE);
1350 static Elm_Transit_Effect *
1351 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1353 Elm_Transit_Effect_Zoom *zoom;
1355 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1356 if (!zoom) return NULL;
1358 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1359 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1365 * Add the Zoom Effect to Elm_Transit.
1367 * @note This API is one of the facades. It creates zoom effect context
1368 * and add it's required APIs to elm_transit_effect_add.
1370 * @see elm_transit_effect_add()
1372 * @param transit Transit object.
1373 * @param from_rate Scale rate when effect begins (1 is current rate).
1374 * @param to_rate Scale rate when effect ends.
1375 * @return Zoom effect context data.
1378 * @warning Is higher recommended just create a transit with this effect when
1379 * the window that the objects of the transit belongs has already been created.
1380 * This is because this effect needs the geometry information about the objects,
1381 * and if the window was not created yet, it can get a wrong information.
1383 EAPI Elm_Transit_Effect *
1384 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1386 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1387 Elm_Transit_Effect *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1389 if (!effect_context) return NULL;
1390 elm_transit_effect_add(transit,
1391 _transit_effect_zoom_op, effect_context,
1392 _transit_effect_zoom_context_free);
1393 return effect_context;
1397 ///////////////////////////////////////////////////////////////////////////////
1399 ///////////////////////////////////////////////////////////////////////////////
1400 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1402 struct _Elm_Transit_Effect_Flip
1404 Elm_Transit_Effect_Flip_Axis axis;
1409 _transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1411 EINA_SAFETY_ON_NULL_RETURN(effect);
1412 EINA_SAFETY_ON_NULL_RETURN(transit);
1413 Elm_Transit_Effect_Flip *flip = effect;
1414 Evas_Object *front, *back;
1416 int count = eina_list_count(transit->objs);
1418 for (i = 0; i < (count - 1); i += 2)
1420 front = eina_list_nth(transit->objs, i);
1421 back = eina_list_nth(transit->objs, i+1);
1422 evas_object_map_enable_set(front, EINA_FALSE);
1423 evas_object_map_enable_set(back, EINA_FALSE);
1429 _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
1431 EINA_SAFETY_ON_NULL_RETURN(effect);
1432 EINA_SAFETY_ON_NULL_RETURN(transit);
1433 Evas_Object *obj, *front, *back;
1435 Elm_Transit_Effect_Flip *flip = effect;
1438 Evas_Coord x, y, w, h;
1440 map = evas_map_new(4);
1443 if (flip->cw) degree = (float)(progress * 180);
1444 else degree = (float)(progress * -180);
1446 count = eina_list_count(transit->objs);
1447 for (i = 0; i < (count - 1); i += 2)
1449 Evas_Coord half_w, half_h;
1451 front = eina_list_nth(transit->objs, i);
1452 back = eina_list_nth(transit->objs, i+1);
1454 if ((degree < 90) && (degree > -90))
1459 evas_object_hide(back);
1460 evas_object_show(front);
1468 evas_object_hide(front);
1469 evas_object_show(back);
1473 evas_map_util_points_populate_from_object_full(map, obj, 0);
1474 evas_object_geometry_get(obj, &x, &y, &w, &h);
1478 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1480 if ((degree >= 90) || (degree <= -90))
1482 evas_map_point_image_uv_set(map, 0, w, 0);
1483 evas_map_point_image_uv_set(map, 1, 0, 0);
1484 evas_map_point_image_uv_set(map, 2, 0, h);
1485 evas_map_point_image_uv_set(map, 3, w, h);
1487 evas_map_util_3d_rotate(map, 0, degree,
1488 0, x + half_w, y + half_h, 0);
1492 if ((degree >= 90) || (degree <= -90))
1494 evas_map_point_image_uv_set(map, 0, 0, h);
1495 evas_map_point_image_uv_set(map, 1, w, h);
1496 evas_map_point_image_uv_set(map, 2, w, 0);
1497 evas_map_point_image_uv_set(map, 3, 0, 0);
1499 evas_map_util_3d_rotate(map, degree,
1500 0, 0, x + half_w, y + half_h, 0);
1502 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1503 evas_object_map_enable_set(front, EINA_TRUE);
1504 evas_object_map_enable_set(back, EINA_TRUE);
1505 evas_object_map_set(obj, map);
1510 static Elm_Transit_Effect *
1511 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1513 Elm_Transit_Effect_Flip *flip;
1515 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1516 if (!flip) return NULL;
1525 * Add the Flip Effect to Elm_Transit.
1527 * @note This API is one of the facades. It creates flip effect context
1528 * and add it's required APIs to elm_transit_effect_add.
1529 * @note This effect is applied to each pair of objects in the order they are listed
1530 * in the transit list of objects. The first object in the pair will be the
1531 * "front" object and the second will be the "back" object.
1533 * @see elm_transit_effect_add()
1535 * @param transit Transit object.
1536 * @param axis Flipping Axis(X or Y).
1537 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1538 * @return Flip effect context data.
1541 * @warning Is higher recommended just create a transit with this effect when
1542 * the window that the objects of the transit belongs has already been created.
1543 * This is because this effect needs the geometry information about the objects,
1544 * and if the window was not created yet, it can get a wrong information.
1546 EAPI Elm_Transit_Effect *
1547 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1549 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1550 Elm_Transit_Effect *effect_context = _transit_effect_flip_context_new(axis, cw);
1552 if (!effect_context) return NULL;
1553 elm_transit_effect_add(transit,
1554 _transit_effect_flip_op, effect_context,
1555 _transit_effect_flip_context_free);
1556 return effect_context;
1559 ///////////////////////////////////////////////////////////////////////////////
1560 //ResizableFlip Effect
1561 ///////////////////////////////////////////////////////////////////////////////
1562 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1563 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1565 struct _Elm_Transit_Effect_Resizable_Flip_Node
1571 } from_pos, from_size, to_pos, to_size;
1574 struct _Elm_Transit_Effect_Resizable_Flip
1578 Elm_Transit_Effect_Flip_Axis axis;
1582 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1584 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1586 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1588 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1590 if (resizable_flip_node->front == obj)
1591 evas_object_event_callback_del(resizable_flip_node->back,
1592 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1593 else if (resizable_flip_node->back == obj)
1594 evas_object_event_callback_del(resizable_flip_node->front,
1595 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1598 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1600 free(resizable_flip_node);
1606 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1608 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1609 Eina_List *data_list = NULL;
1610 Evas_Coord front_x, front_y, front_w, front_h;
1611 Evas_Coord back_x, back_y, back_w, back_h;
1614 count = eina_list_count(transit->objs);
1615 for (i = 0; i < (count - 1); i += 2)
1617 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1618 if (!resizable_flip_node)
1620 eina_list_free(data_list);
1624 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1625 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1627 evas_object_geometry_get(resizable_flip_node->front,
1628 &front_x, &front_y, &front_w, &front_h);
1629 evas_object_geometry_get(resizable_flip_node->back,
1630 &back_x, &back_y, &back_w, &back_h);
1632 resizable_flip_node->from_pos.x = front_x;
1633 resizable_flip_node->from_pos.y = front_y;
1634 resizable_flip_node->to_pos.x = back_x - front_x;
1635 resizable_flip_node->to_pos.y = back_y - front_y;
1637 resizable_flip_node->from_size.x = front_w;
1638 resizable_flip_node->from_size.y = front_h;
1639 resizable_flip_node->to_size.x = back_w - front_w;
1640 resizable_flip_node->to_size.y = back_h - front_h;
1642 data_list = eina_list_append(data_list, resizable_flip_node);
1644 evas_object_event_callback_add(resizable_flip_node->back,
1645 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1646 evas_object_event_callback_add(resizable_flip_node->front,
1647 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1654 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1656 if ((degree >= 90) || (degree <= -90))
1658 evas_map_point_image_uv_set(map, 0,
1659 (flip->from_size.x * 2) + flip->to_size.x,
1661 evas_map_point_image_uv_set(map, 1, 0, 0);
1662 evas_map_point_image_uv_set(map, 2, 0,
1663 (flip->from_size.y * 2) + flip->to_size.y);
1664 evas_map_point_image_uv_set(map, 3,
1665 (flip->from_size.x * 2) + flip->to_size.x,
1666 (flip->from_size.y * 2) + flip->to_size.y);
1670 evas_map_point_image_uv_set(map, 0, 0, 0);
1671 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1672 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1674 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1679 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1681 if ((degree >= 90) || (degree <= -90))
1683 evas_map_point_image_uv_set(map, 0, 0,
1684 (flip->from_size.y * 2) + flip->to_size.y);
1685 evas_map_point_image_uv_set(map, 1,
1686 (flip->from_size.x * 2) + flip->to_size.x,
1687 (flip->from_size.y * 2) + flip->to_size.y);
1688 evas_map_point_image_uv_set(map, 2,
1689 (flip->from_size.x * 2) + flip->to_size.x,
1691 evas_map_point_image_uv_set(map, 3, 0, 0);
1695 evas_map_point_image_uv_set(map, 0, 0, 0);
1696 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1697 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1699 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1704 _transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
1706 EINA_SAFETY_ON_NULL_RETURN(effect);
1708 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1709 Eina_List *elist, *elist_next;
1710 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1712 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1713 elist, elist_next, resizable_flip_node)
1715 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1716 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1718 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1721 evas_object_event_callback_del(resizable_flip_node->back,
1722 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1723 evas_object_event_callback_del(resizable_flip_node->front,
1724 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1725 free(resizable_flip_node);
1727 free(resizable_flip);
1731 _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
1733 EINA_SAFETY_ON_NULL_RETURN(effect);
1738 Evas_Coord half_w, half_h;
1739 Elm_Transit_Effect_ResizableFlip *resizable_flip = effect;
1740 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1743 map = evas_map_new(4);
1746 if (resizable_flip->cw) degree = (float)(progress * 180);
1747 else degree = (float)(progress * -180);
1749 if (!resizable_flip->nodes)
1750 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1753 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1755 if ((degree < 90) && (degree > -90))
1757 obj = resizable_flip_node->front;
1758 if (resizable_flip_node->front != resizable_flip_node->back)
1760 evas_object_hide(resizable_flip_node->back);
1761 evas_object_show(resizable_flip_node->front);
1766 obj = resizable_flip_node->back;
1767 if (resizable_flip_node->front != resizable_flip_node->back)
1769 evas_object_hide(resizable_flip_node->front);
1770 evas_object_show(resizable_flip_node->back);
1774 x = resizable_flip_node->from_pos.x +
1775 (resizable_flip_node->to_pos.x * progress);
1776 y = resizable_flip_node->from_pos.y +
1777 (resizable_flip_node->to_pos.y * progress);
1778 w = resizable_flip_node->from_size.x +
1779 (resizable_flip_node->to_size.x * progress);
1780 h = resizable_flip_node->from_size.y +
1781 (resizable_flip_node->to_size.y * progress);
1782 evas_map_point_coord_set(map, 0, x, y, 0);
1783 evas_map_point_coord_set(map, 1, x + w, y, 0);
1784 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1785 evas_map_point_coord_set(map, 3, x, y + h, 0);
1787 half_w = (Evas_Coord)(w / 2);
1788 half_h = (Evas_Coord)(h / 2);
1790 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1792 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1793 evas_map_util_3d_rotate(map, 0, degree,
1794 0, x + half_w, y + half_h, 0);
1798 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1799 evas_map_util_3d_rotate(map, degree, 0,
1800 0, x + half_w, y + half_h, 0);
1803 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1804 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1805 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1806 evas_object_map_set(obj, map);
1811 static Elm_Transit_Effect *
1812 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1814 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1816 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1817 if (!resizable_flip) return NULL;
1819 resizable_flip->cw = cw;
1820 resizable_flip->axis = axis;
1822 return resizable_flip;
1826 * Add the Resizable Flip Effect to Elm_Transit.
1828 * @note This API is one of the facades. It creates resizable flip effect context
1829 * and add it's required APIs to elm_transit_effect_add.
1830 * @note This effect is applied to each pair of objects in the order they are listed
1831 * in the transit list of objects. The first object in the pair will be the
1832 * "front" object and the second will be the "back" object.
1834 * @see elm_transit_effect_add()
1836 * @param transit Transit object.
1837 * @param axis Flipping Axis(X or Y).
1838 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1839 * @return Resizable flip effect context data.
1842 * @warning Is higher recommended just create a transit with this effect when
1843 * the window that the objects of the transit belongs has already been created.
1844 * This is because this effect needs the geometry information about the objects,
1845 * and if the window was not created yet, it can get a wrong information.
1847 EAPI Elm_Transit_Effect *
1848 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1850 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1851 Elm_Transit_Effect *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1853 if (!effect_context) return NULL;
1854 elm_transit_effect_add(transit,
1855 _transit_effect_resizable_flip_op, effect_context,
1856 _transit_effect_resizable_flip_context_free);
1857 return effect_context;
1861 ///////////////////////////////////////////////////////////////////////////////
1863 ///////////////////////////////////////////////////////////////////////////////
1864 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1866 struct _Elm_Transit_Effect_Wipe
1868 Elm_Transit_Effect_Wipe_Type type;
1869 Elm_Transit_Effect_Wipe_Dir dir;
1873 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1879 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1880 w2 = w - (w * progress);
1882 evas_map_point_image_uv_set(map, 0, 0, 0);
1883 evas_map_point_image_uv_set(map, 1, w2, 0);
1884 evas_map_point_image_uv_set(map, 2, w2, h);
1885 evas_map_point_image_uv_set(map, 3, 0, h);
1886 evas_map_point_coord_set(map, 0, x, y, 0);
1887 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1888 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1889 evas_map_point_coord_set(map, 3, x, h2, 0);
1891 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1892 w2 = (w * progress);
1894 evas_map_point_image_uv_set(map, 0, w2, 0);
1895 evas_map_point_image_uv_set(map, 1, w, 0);
1896 evas_map_point_image_uv_set(map, 2, w, h);
1897 evas_map_point_image_uv_set(map, 3, w2, h);
1898 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1899 evas_map_point_coord_set(map, 1, x + w, y, 0);
1900 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1901 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1903 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1905 h2 = h - (h * progress);
1906 evas_map_point_image_uv_set(map, 0, 0, 0);
1907 evas_map_point_image_uv_set(map, 1, w, 0);
1908 evas_map_point_image_uv_set(map, 2, w, h2);
1909 evas_map_point_image_uv_set(map, 3, 0, h2);
1910 evas_map_point_coord_set(map, 0, x, y, 0);
1911 evas_map_point_coord_set(map, 1, w2, y, 0);
1912 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1913 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1915 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1917 h2 = (h * progress);
1918 evas_map_point_image_uv_set(map, 0, 0, h2);
1919 evas_map_point_image_uv_set(map, 1, w, h2);
1920 evas_map_point_image_uv_set(map, 2, w, h);
1921 evas_map_point_image_uv_set(map, 3, 0, h);
1922 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1923 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1924 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1925 evas_map_point_coord_set(map, 3, x, y + h, 0);
1930 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1934 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1940 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1941 w2 = (w - (w * progress));
1943 evas_map_point_image_uv_set(map, 0, w2, 0);
1944 evas_map_point_image_uv_set(map, 1, w, 0);
1945 evas_map_point_image_uv_set(map, 2, w, h);
1946 evas_map_point_image_uv_set(map, 3, w2, h);
1947 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1948 evas_map_point_coord_set(map, 1, w, y, 0);
1949 evas_map_point_coord_set(map, 2, w, h2, 0);
1950 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1952 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1953 w2 = (w * progress);
1955 evas_map_point_image_uv_set(map, 0, 0, 0);
1956 evas_map_point_image_uv_set(map, 1, w2, 0);
1957 evas_map_point_image_uv_set(map, 2, w2, h);
1958 evas_map_point_image_uv_set(map, 3, 0, h);
1959 evas_map_point_coord_set(map, 0, x, y, 0);
1960 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1961 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1962 evas_map_point_coord_set(map, 3, x, h2, 0);
1964 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1966 h2 = (h - (h * progress));
1967 evas_map_point_image_uv_set(map, 0, 0, h2);
1968 evas_map_point_image_uv_set(map, 1, w, h2);
1969 evas_map_point_image_uv_set(map, 2, w, h);
1970 evas_map_point_image_uv_set(map, 3, 0, h);
1971 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1972 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1973 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1974 evas_map_point_coord_set(map, 3, x, y + h, 0);
1976 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1978 h2 = (h * progress);
1979 evas_map_point_image_uv_set(map, 0, 0, 0);
1980 evas_map_point_image_uv_set(map, 1, w, 0);
1981 evas_map_point_image_uv_set(map, 2, w, h2);
1982 evas_map_point_image_uv_set(map, 3, 0, h2);
1983 evas_map_point_coord_set(map, 0, x, y, 0);
1984 evas_map_point_coord_set(map, 1, w2, y, 0);
1985 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1986 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1991 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1995 _transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit)
1997 EINA_SAFETY_ON_NULL_RETURN(effect);
1998 EINA_SAFETY_ON_NULL_RETURN(transit);
2001 Elm_Transit_Effect_Wipe *wipe = effect;
2002 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
2004 EINA_LIST_FOREACH(transit->objs, elist, obj)
2006 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
2007 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
2008 evas_object_show(obj);
2009 else evas_object_hide(obj);
2010 evas_object_map_enable_set(obj, EINA_FALSE);
2017 _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2019 EINA_SAFETY_ON_NULL_RETURN(effect);
2020 EINA_SAFETY_ON_NULL_RETURN(transit);
2021 Elm_Transit_Effect_Wipe *wipe = effect;
2023 Evas_Coord _x, _y, _w, _h;
2027 map = evas_map_new(4);
2030 EINA_LIST_FOREACH(transit->objs, elist, obj)
2032 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
2034 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
2035 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2037 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
2039 evas_object_map_enable_set(obj, EINA_TRUE);
2040 evas_object_map_set(obj, map);
2045 static Elm_Transit_Effect *
2046 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2048 Elm_Transit_Effect_Wipe *wipe;
2050 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
2051 if (!wipe) return NULL;
2060 * Add the Wipe Effect to Elm_Transit.
2062 * @note This API is one of the facades. It creates wipe effect context
2063 * and add it's required APIs to elm_transit_effect_add.
2065 * @see elm_transit_effect_add()
2067 * @param transit Transit object.
2068 * @param type Wipe type. Hide or show.
2069 * @param dir Wipe Direction.
2070 * @return Wipe effect context data.
2073 * @warning Is higher recommended just create a transit with this effect when
2074 * the window that the objects of the transit belongs has already been created.
2075 * This is because this effect needs the geometry information about the objects,
2076 * and if the window was not created yet, it can get a wrong information.
2079 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
2081 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2082 void *effect_context = _transit_effect_wipe_context_new(type, dir);
2084 if (!effect_context) return NULL;
2085 elm_transit_effect_add(transit,
2086 _transit_effect_wipe_op, effect_context,
2087 _transit_effect_wipe_context_free);
2088 return effect_context;
2092 ///////////////////////////////////////////////////////////////////////////////
2094 ///////////////////////////////////////////////////////////////////////////////
2095 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
2097 struct _Elm_Transit_Effect_Color
2099 struct _unsigned_color {
2100 unsigned int r, g, b, a;
2102 struct _signed_color {
2108 _transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2110 Elm_Transit_Effect_Color *color = effect;
2115 _transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2117 EINA_SAFETY_ON_NULL_RETURN(effect);
2118 EINA_SAFETY_ON_NULL_RETURN(transit);
2119 Elm_Transit_Effect_Color *color = effect;
2122 unsigned int r, g, b, a;
2124 r = (color->from.r + (int)((float)color->to.r * progress));
2125 g = (color->from.g + (int)((float)color->to.g * progress));
2126 b = (color->from.b + (int)((float)color->to.b * progress));
2127 a = (color->from.a + (int)((float)color->to.a * progress));
2129 EINA_LIST_FOREACH(transit->objs, elist, obj)
2130 evas_object_color_set(obj, r, g, b, a);
2133 static Elm_Transit_Effect *
2134 _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)
2136 Elm_Transit_Effect_Color *color;
2138 color = ELM_NEW(Elm_Transit_Effect_Color);
2139 if (!color) return NULL;
2141 color->from.r = from_r;
2142 color->from.g = from_g;
2143 color->from.b = from_b;
2144 color->from.a = from_a;
2145 color->to.r = to_r - from_r;
2146 color->to.g = to_g - from_g;
2147 color->to.b = to_b - from_b;
2148 color->to.a = to_a - from_a;
2154 * Add the Color Effect to Elm_Transit.
2156 * @note This API is one of the facades. It creates color effect context
2157 * and add it's required APIs to elm_transit_effect_add.
2159 * @see elm_transit_effect_add()
2161 * @param transit Transit object.
2162 * @param from_r RGB R when effect begins.
2163 * @param from_g RGB G when effect begins.
2164 * @param from_b RGB B when effect begins.
2165 * @param from_a RGB A when effect begins.
2166 * @param to_r RGB R when effect ends.
2167 * @param to_g RGB G when effect ends.
2168 * @param to_b RGB B when effect ends.
2169 * @param to_a RGB A when effect ends.
2170 * @return Color effect context data.
2174 EAPI Elm_Transit_Effect *
2175 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)
2177 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2178 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);
2180 if (!effect_context) return NULL;
2181 elm_transit_effect_add(transit,
2182 _transit_effect_color_op, effect_context,
2183 _transit_effect_color_context_free);
2184 return effect_context;
2187 ///////////////////////////////////////////////////////////////////////////////
2189 ///////////////////////////////////////////////////////////////////////////////
2190 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2191 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2193 struct _Elm_Transit_Effect_Fade_Node
2195 Evas_Object *before;
2197 struct _signed_color before_color, after_color;
2200 Eina_Bool inversed : 1;
2203 struct _Elm_Transit_Effect_Fade
2209 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2211 Elm_Transit_Effect_Fade *fade = data;
2213 Elm_Transit_Effect_Fade_Node *fade_node;
2215 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2217 if (fade_node->before == obj)
2218 evas_object_event_callback_del(fade_node->after,
2219 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2220 else if (fade_node->after == obj)
2221 evas_object_event_callback_del(fade_node->before,
2222 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2225 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2232 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2234 Elm_Transit_Effect_Fade_Node *fade;
2235 Eina_List *data_list = NULL;
2238 count = eina_list_count(transit->objs);
2239 for (i = 0; i < count; i += 2)
2241 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2244 eina_list_free(data_list);
2248 fade->before = eina_list_nth(transit->objs, i);
2249 fade->after = eina_list_nth(transit->objs, i+1);
2251 evas_object_color_get(fade->before,
2252 &fade->before_color.r, &fade->before_color.g,
2253 &fade->before_color.b, &fade->before_color.a);
2254 evas_object_color_get(fade->after,
2255 &fade->after_color.r, &fade->after_color.g,
2256 &fade->after_color.b, &fade->after_color.a);
2258 fade->before_alpha = (255 - fade->before_color.a);
2259 fade->after_alpha = (255 - fade->after_color.a);
2261 data_list = eina_list_append(data_list, fade);
2263 evas_object_event_callback_add(fade->before,
2264 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2265 evas_object_event_callback_add(fade->after,
2266 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2272 _transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2274 EINA_SAFETY_ON_NULL_RETURN(effect);
2275 Elm_Transit_Effect_Fade *fade = effect;
2276 Elm_Transit_Effect_Fade_Node *fade_node;
2277 Eina_List *elist, *elist_next;
2279 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2281 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2282 fade_node->before_color.g,
2283 fade_node->before_color.b,
2284 fade_node->before_color.a);
2285 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2286 fade_node->after_color.g,
2287 fade_node->after_color.b,
2288 fade_node->after_color.a);
2290 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2291 evas_object_event_callback_del(fade_node->before,
2292 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2293 evas_object_event_callback_del(fade_node->after,
2294 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2302 _transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress)
2304 EINA_SAFETY_ON_NULL_RETURN(effect);
2305 Elm_Transit_Effect_Fade *fade = effect;
2307 Elm_Transit_Effect_Fade_Node *fade_node;
2311 fade->nodes = _fade_nodes_build(transit, fade);
2313 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2317 if (!fade_node->inversed)
2319 evas_object_hide(fade_node->after);
2320 evas_object_show(fade_node->before);
2321 fade_node->inversed = EINA_TRUE;
2324 _progress = (1 - (progress * 2));
2326 evas_object_color_set(fade_node->before,
2327 fade_node->before_color.r * _progress,
2328 fade_node->before_color.g * _progress,
2329 fade_node->before_color.b * _progress,
2330 fade_node->before_color.a +
2331 fade_node->before_alpha * (1 - _progress));
2335 if (fade_node->inversed)
2337 evas_object_hide(fade_node->before);
2338 evas_object_show(fade_node->after);
2339 fade_node->inversed = EINA_FALSE;
2342 _progress = ((progress - 0.5) * 2);
2344 evas_object_color_set(fade_node->after,
2345 fade_node->after_color.r * _progress,
2346 fade_node->after_color.g * _progress,
2347 fade_node->after_color.b * _progress,
2348 fade_node->after_color.a +
2349 fade_node->after_alpha * (1 - _progress));
2354 static Elm_Transit_Effect *
2355 _transit_effect_fade_context_new(void)
2357 Elm_Transit_Effect_Fade *fade;
2358 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2359 if (!fade) return NULL;
2364 * Add the Fade Effect to Elm_Transit.
2366 * @note This API is one of the facades. It creates fade effect context
2367 * and add it's required APIs to elm_transit_effect_add.
2368 * @note This effect is applied to each pair of objects in the order they are listed
2369 * in the transit list of objects. The first object in the pair will be the
2370 * "before" object and the second will be the "after" object.
2372 * @see elm_transit_effect_add()
2374 * @param transit Transit object.
2375 * @return Fade effect context data.
2378 * @warning Is higher recommended just create a transit with this effect when
2379 * the window that the objects of the transit belongs has already been created.
2380 * This is because this effect needs the color information about the objects,
2381 * and if the window was not created yet, it can get a wrong information.
2383 EAPI Elm_Transit_Effect *
2384 elm_transit_effect_fade_add(Elm_Transit *transit)
2386 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2388 Elm_Transit_Effect *effect_context = _transit_effect_fade_context_new();
2389 if (!effect_context) return NULL;
2390 elm_transit_effect_add(transit,
2391 _transit_effect_fade_op, effect_context,
2392 _transit_effect_fade_context_free);
2393 return effect_context;
2397 ///////////////////////////////////////////////////////////////////////////////
2399 ///////////////////////////////////////////////////////////////////////////////
2400 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2401 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2403 struct _Elm_Transit_Effect_Blend_Node
2405 Evas_Object *before;
2407 struct _signed_color from, to;
2410 struct _Elm_Transit_Effect_Blend
2416 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2418 Elm_Transit_Effect_Blend *blend = data;
2420 Elm_Transit_Effect_Blend_Node *blend_node;
2422 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2424 if (blend_node->after == obj)
2425 evas_object_event_callback_del(blend_node->before,
2426 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2427 else if (blend_node->before == obj)
2428 evas_object_event_callback_del(blend_node->after,
2429 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2432 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2439 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2441 Elm_Transit_Effect_Blend_Node *blend_node;
2442 Eina_List *data_list = NULL;
2445 count = eina_list_count(transit->objs);
2446 for (i = 0; i < (count - 1); i += 2)
2448 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2451 eina_list_free(data_list);
2455 blend_node->before = eina_list_nth(transit->objs, i);
2456 blend_node->after = eina_list_nth(transit->objs, i + 1);
2457 evas_object_show(blend_node->before);
2458 evas_object_show(blend_node->after);
2460 evas_object_color_get(blend_node->before, &blend_node->from.r,
2461 &blend_node->from.g, &blend_node->from.b,
2462 &blend_node->from.a);
2463 evas_object_color_get(blend_node->after, &blend_node->to.r,
2464 &blend_node->to.g, &blend_node->to.b,
2467 data_list = eina_list_append(data_list, blend_node);
2469 evas_object_event_callback_add(blend_node->before,
2470 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2471 evas_object_event_callback_add(blend_node->after,
2472 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2478 _transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2480 EINA_SAFETY_ON_NULL_RETURN(effect);
2481 Elm_Transit_Effect_Blend *blend = effect;
2482 Elm_Transit_Effect_Blend_Node *blend_node;
2483 Eina_List *elist, *elist_next;
2485 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2487 evas_object_color_set(blend_node->before,
2488 blend_node->from.r, blend_node->from.g,
2489 blend_node->from.b, blend_node->from.a);
2490 evas_object_color_set(blend_node->after, blend_node->to.r,
2491 blend_node->to.g, blend_node->to.b,
2494 if (elm_transit_auto_reverse_get(transit))
2495 evas_object_hide(blend_node->after);
2497 evas_object_hide(blend_node->before);
2499 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2501 evas_object_event_callback_del(blend_node->before,
2502 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2503 evas_object_event_callback_del(blend_node->after,
2504 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2511 _transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2513 EINA_SAFETY_ON_NULL_RETURN(effect);
2514 EINA_SAFETY_ON_NULL_RETURN(transit);
2515 Elm_Transit_Effect_Blend *blend = effect;
2516 Elm_Transit_Effect_Blend_Node *blend_node;
2519 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2521 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2523 evas_object_color_set(blend_node->before,
2524 (int)(blend_node->from.r * (1 - progress)),
2525 (int)(blend_node->from.g * (1 - progress)),
2526 (int)(blend_node->from.b * (1 - progress)),
2527 (int)(blend_node->from.a * (1 - progress)));
2528 evas_object_color_set(blend_node->after,
2529 (int)(blend_node->to.r * progress),
2530 (int)(blend_node->to.g * progress),
2531 (int)(blend_node->to.b * progress),
2532 (int)(blend_node->to.a * progress));
2536 static Elm_Transit_Effect *
2537 _transit_effect_blend_context_new(void)
2539 Elm_Transit_Effect_Blend *blend;
2541 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2542 if (!blend) return NULL;
2547 * Add the Blend Effect to Elm_Transit.
2549 * @note This API is one of the facades. It creates blend effect context
2550 * and add it's required APIs to elm_transit_effect_add.
2551 * @note This effect is applied to each pair of objects in the order they are listed
2552 * in the transit list of objects. The first object in the pair will be the
2553 * "before" object and the second will be the "after" object.
2555 * @see elm_transit_effect_add()
2557 * @param transit Transit object.
2558 * @return Blend effect context data.
2561 * @warning Is higher recommended just create a transit with this effect when
2562 * the window that the objects of the transit belongs has already been created.
2563 * This is because this effect needs the color information about the objects,
2564 * and if the window was not created yet, it can get a wrong information.
2566 EAPI Elm_Transit_Effect *
2567 elm_transit_effect_blend_add(Elm_Transit *transit)
2569 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2570 Elm_Transit_Effect *effect_context = _transit_effect_blend_context_new();
2572 if (!effect_context) return NULL;
2573 elm_transit_effect_add(transit,
2574 _transit_effect_blend_op, effect_context,
2575 _transit_effect_blend_context_free);
2576 return effect_context;
2580 ///////////////////////////////////////////////////////////////////////////////
2582 ///////////////////////////////////////////////////////////////////////////////
2583 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2585 struct _Elm_Transit_Effect_Rotation
2591 _transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2593 Elm_Transit_Effect_Rotation *rotation = effect;
2598 _transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2600 EINA_SAFETY_ON_NULL_RETURN(effect);
2601 EINA_SAFETY_ON_NULL_RETURN(transit);
2602 Elm_Transit_Effect_Rotation *rotation = effect;
2604 Evas_Coord x, y, w, h;
2606 float half_w, half_h;
2610 map = evas_map_new(4);
2613 EINA_LIST_FOREACH(transit->objs, elist, obj)
2615 evas_map_util_points_populate_from_object_full(map, obj, 0);
2616 degree = rotation->from + (float)(progress * rotation->to);
2618 evas_object_geometry_get(obj, &x, &y, &w, &h);
2620 half_w = (float)w * 0.5;
2621 half_h = (float)h * 0.5;
2623 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2624 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2625 evas_object_map_enable_set(obj, EINA_TRUE);
2626 evas_object_map_set(obj, map);
2631 static Elm_Transit_Effect *
2632 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2634 Elm_Transit_Effect_Rotation *rotation;
2636 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2637 if (!rotation) return NULL;
2639 rotation->from = from_degree;
2640 rotation->to = to_degree - from_degree;
2646 * Add the Rotation Effect to Elm_Transit.
2648 * @note This API is one of the facades. It creates rotation effect context
2649 * and add it's required APIs to elm_transit_effect_add.
2651 * @see elm_transit_effect_add()
2653 * @param transit Transit object.
2654 * @param from_degree Degree when effect begins.
2655 * @param to_degree Degree when effect is ends.
2656 * @return Rotation effect context data.
2659 * @warning Is higher recommended just create a transit with this effect when
2660 * the window that the objects of the transit belongs has already been created.
2661 * This is because this effect needs the geometry information about the objects,
2662 * and if the window was not created yet, it can get a wrong information.
2664 EAPI Elm_Transit_Effect *
2665 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2667 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2668 Elm_Transit_Effect *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2670 if (!effect_context) return NULL;
2671 elm_transit_effect_add(transit,
2672 _transit_effect_rotation_op, effect_context,
2673 _transit_effect_rotation_context_free);
2674 return effect_context;
2678 ///////////////////////////////////////////////////////////////////////////////
2679 //ImageAnimation Effect
2680 ///////////////////////////////////////////////////////////////////////////////
2681 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2683 struct _Elm_Transit_Effect_Image_Animation
2689 _transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
2691 EINA_SAFETY_ON_NULL_RETURN(effect);
2692 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2694 Eina_List *elist, *elist_next;
2696 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2698 image_animation->images =
2699 eina_list_remove_list(image_animation->images, elist);
2700 eina_stringshare_del(image);
2703 free(image_animation);
2707 _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
2709 EINA_SAFETY_ON_NULL_RETURN(effect);
2710 EINA_SAFETY_ON_NULL_RETURN(transit);
2714 Elm_Transit_Effect_Image_Animation *image_animation = effect;
2715 unsigned int count = 0;
2718 type = eina_stringshare_add("icon");
2719 len = eina_list_count(image_animation->images);
2721 if (!len) count = floor(progress * len);
2722 else count = floor(progress * (len - 1));
2724 EINA_LIST_FOREACH(transit->objs, elist, obj)
2726 if (elm_widget_type_check(obj, type))
2727 elm_icon_file_set(obj,
2728 eina_list_nth(image_animation->images, count), NULL);
2731 eina_stringshare_del(type);
2734 static Elm_Transit_Effect *
2735 _transit_effect_image_animation_context_new(Eina_List *images)
2737 Elm_Transit_Effect_Image_Animation *image_animation;
2738 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2740 if (!image_animation) return NULL;
2741 image_animation->images = images;
2742 return image_animation;
2746 * Add the ImageAnimation Effect to Elm_Transit.
2748 * @note This API is one of the facades. It creates image animation effect context
2749 * and add it's required APIs to elm_transit_effect_add.
2750 * The @p images parameter is a list images paths. This list and
2751 * its contents will be deleted at the end of the effect by
2752 * elm_transit_effect_image_animation_context_free() function.
2756 * char buf[PATH_MAX];
2757 * Eina_List *images = NULL;
2758 * Elm_Transit *transi = elm_transit_add();
2760 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2761 * images = eina_list_append(images, eina_stringshare_add(buf));
2763 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2764 * images = eina_list_append(images, eina_stringshare_add(buf));
2765 * elm_transit_effect_image_animation_add(transi, images);
2769 * @see elm_transit_effect_add()
2771 * @param transit Transit object.
2772 * @param images Eina_List of images file paths. This list and
2773 * its contents will be deleted at the end of the effect by
2774 * elm_transit_effect_image_animation_context_free() function.
2775 * @return Image Animation effect context data.
2779 EAPI Elm_Transit_Effect *
2780 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2782 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2783 Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images);
2785 if (!effect) return NULL;
2786 elm_transit_effect_add(transit,
2787 _transit_effect_image_animation_op, effect,
2788 _transit_effect_image_animation_context_free);