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;
88 struct _Elm_Transit_Effect
90 void (*animation_op) (void *data, Elm_Transit *transit, double progress);
91 void (*user_data_free) (void *data, Elm_Transit *transit);
93 Eina_Bool deleted : 1;
102 typedef struct _Elm_Transit_Effect Elm_Transit_Effect;
103 typedef struct _Elm_Obj_Data Elm_Obj_Data;
106 _elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
108 Elm_Transit *transit = data;
110 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
111 evas_object_pass_events_set(obj, obj_data->state);
113 transit->objs = eina_list_remove(transit->objs, obj);
114 if (!transit->objs) elm_transit_del(transit);
118 _elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
120 Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
122 evas_object_pass_events_set(obj, obj_data->state);
124 transit->objs = eina_list_remove(transit->objs, obj);
125 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
126 _elm_transit_object_remove_cb);
130 _elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect *effect, Eina_List *elist)
132 if (effect->user_data_free)
133 effect->user_data_free(effect->user_data, transit);
135 transit->effect_list = eina_list_remove_list(transit->effect_list, elist);
140 _remove_dead_effects(Elm_Transit *transit)
142 Eina_List *elist, *elist_next;
143 Elm_Transit_Effect *effect;
145 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
149 _elm_transit_effect_del(transit, effect, elist);
150 transit->effects_pending_del--;
151 if (!transit->effects_pending_del) return;
157 _elm_transit_del(Elm_Transit *transit)
159 Eina_List *elist, *elist_next;
160 Elm_Transit_Effect *effect;
162 if (transit->animator)
163 ecore_animator_del(transit->animator);
165 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
166 _elm_transit_effect_del(transit, effect, elist);
168 while (transit->objs)
169 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
171 if (transit->del_data.func)
172 transit->del_data.func(transit->del_data.arg, transit);
174 EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
179 _transit_animate_op(Elm_Transit *transit, double progress)
182 Elm_Transit_Effect *effect;
185 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
187 if (transit->deleted) break;
188 if (!effect->deleted)
189 effect->animation_op(effect->user_data, transit, progress);
193 if (transit->walking) return;
195 if (transit->deleted) _elm_transit_del(transit);
196 else if (transit->effects_pending_del) _remove_dead_effects(transit);
200 _animator_animate_cb(void *data)
202 Elm_Transit *transit = data;
203 double elapsed_time, duration;
205 transit->time.current = ecore_loop_time_get();
206 elapsed_time = transit->time.current - transit->time.begin;
207 duration = transit->time.duration + transit->time.delayed;
209 if (elapsed_time > duration)
210 elapsed_time = duration;
212 transit->progress = elapsed_time / duration;
213 switch (transit->tween_mode)
215 case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
216 transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
218 case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
219 transit->progress = sin(transit->progress * ELM_PI / 2.0);
221 case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
222 transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
229 if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
231 if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
233 /* Not end. Keep going. */
234 if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
236 /* Repeat and reverse and time done! */
237 if ((transit->repeat.current == transit->repeat.count)
238 && (!transit->auto_reverse || transit->repeat.reverse))
240 elm_transit_del(transit);
241 return ECORE_CALLBACK_CANCEL;
245 if (!transit->auto_reverse || transit->repeat.reverse)
247 transit->repeat.current++;
248 transit->repeat.reverse = EINA_FALSE;
250 else transit->repeat.reverse = EINA_TRUE;
252 transit->time.begin = ecore_loop_time_get();
254 return ECORE_CALLBACK_RENEW;
260 * @note Is not necessary to delete the transit object, it will be deleted at
261 * the end of its operation.
262 * @note The transit will start playing when the program enter in the main loop, is not
263 * necessary to give a start to the transit.
265 * @param duration The duration of the transit in seconds. When transit starts
266 * to run, it will last a @p duration time.
267 * @return The transit object.
272 elm_transit_add(void)
274 Elm_Transit *transit = ELM_NEW(Elm_Transit);
275 if (!transit) return NULL;
277 EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC);
279 elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
284 * Stops the animation and delete the @p transit object.
286 * Call this function if you wants to stop the animation before the duration
287 * time. Make sure the @p transit object is still alive with
288 * elm_transit_del_cb_set() function.
289 * All added effects will be deleted, calling its repective data_free_cb
290 * functions. The function setted by elm_tansit_del_cb_set() will be called.
292 * @see elm_transit_del_cb_set()
294 * @param transit The transit object to be deleted.
297 * @warning Just call this function if you are sure the transit is alive.
300 elm_transit_del(Elm_Transit *transit)
302 ELM_TRANSIT_CHECK_OR_RETURN(transit);
304 if (transit->walking) transit->deleted = EINA_TRUE;
305 else _elm_transit_del(transit);
309 * Add a new effect to the transit.
311 * @note The cb function and the data are the key to the effect. If you try to
312 * add an already added effect, nothing is done.
313 * @note After the first addition of an effect in @p transit, if its
314 * effect list become empty again, the @p transit will be killed by
315 * elm_transit_del(transit) function.
319 * Elm_Transit *transit = elm_transit_add();
320 * elm_transit_effect_add(transit,
321 * elm_transit_effect_blend_op,
322 * elm_transit_effect_blend_context_new(),
323 * elm_transit_effect_blend_context_free);
326 * @param transit The transit object.
327 * @param cb The operation function. It is called when the animation begins,
328 * it is the function that actually performs the animation. It is called with
329 * the @p data, @p transit and the time progression of the animation (a double
330 * value between 0.0 and 1.0).
331 * @param data The context data of the effect.
332 * @param data_free_cb The function to free the context data, it will be called
333 * at the end of the effect, it must finalize the animation and free the
337 * @warning The transit free the context data at the and of the transition with
338 * the data_free_cb function, do not use the context data in another transit.
341 elm_transit_effect_add(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data, void (*data_free_cb)(void *data, Elm_Transit *transit))
343 ELM_TRANSIT_CHECK_OR_RETURN(transit);
344 EINA_SAFETY_ON_NULL_RETURN(cb);
345 Elm_Transit_Effect *effect;
348 EINA_LIST_FOREACH(transit->effect_list, elist, effect)
350 if ((effect->animation_op == cb) && (effect->user_data == data)) return;
353 effect = ELM_NEW(Elm_Transit_Effect);
356 effect->user_data_free = data_free_cb;
357 effect->animation_op = cb;
358 effect->user_data = data;
360 transit->effect_list = eina_list_append(transit->effect_list, effect);
364 * Delete an added effect.
366 * This function will remove the effect from the @p transit, calling the
367 * data_free_cb to free the @p data.
369 * @see elm_transit_effect_add()
371 * @note If the effect is not found, nothing is done.
372 * @note If the effect list become empty, this function will call
373 * elm_transit_del(transit), that is, it will kill the @p transit.
375 * @param transit The transit object.
376 * @param cb The operation function.
377 * @param data The context data of the effect.
382 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
384 ELM_TRANSIT_CHECK_OR_RETURN(transit);
385 EINA_SAFETY_ON_NULL_RETURN(cb);
386 Eina_List *elist, *elist_next;
387 Elm_Transit_Effect *effect;
389 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
391 if ((effect->animation_op == cb) && (effect->user_data == data))
393 if (transit->walking)
395 effect->deleted = EINA_TRUE;
396 transit->effects_pending_del++;
400 _elm_transit_effect_del(transit, effect, elist);
401 if (!transit->effect_list) elm_transit_del(transit);
409 * Add new object to apply the effects.
411 * @note After the first addition of an object in @p transit, if its
412 * object list become empty again, the @p transit will be killed by
413 * elm_transit_del(transit) function.
414 * @note If the @p obj belongs to another transit, the @p obj will be
415 * removed from it and it will only belong to the @p transit. If the old
416 * transit stays without objects, it will die.
417 * @note When you add an object into the @p transit, its state from
418 * evas_object_pass_events_get(obj) is saved, and it is applied when the
419 * transit ends, if you change this state whith evas_object_pass_events_set()
420 * after add the object, this state will change again when @p transit stops to
423 * @param transit The transit object.
424 * @param obj Object to be animated.
427 * @warning See the documentation of the effect if is safe add or remove
428 * an object after @p transit begins to run.
431 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
433 ELM_TRANSIT_CHECK_OR_RETURN(transit);
434 EINA_SAFETY_ON_NULL_RETURN(obj);
435 Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
439 if (obj_data->transit == transit) return;
440 elm_transit_object_remove(obj_data->transit, obj);
443 obj_data = ELM_NEW(Elm_Obj_Data);
444 obj_data->state = evas_object_pass_events_get(obj);
445 obj_data->transit = transit;
446 evas_object_data_set(obj, _transit_key, obj_data);
448 transit->objs = eina_list_append(transit->objs, obj);
450 if (!transit->event_enabled)
451 evas_object_pass_events_set(obj, EINA_TRUE);
453 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
454 _elm_transit_object_remove_cb, transit);
458 * Removes an added object from the transit.
460 * @note If the @p obj is not in the @p transit, nothing is done.
461 * @note If the list become empty, this function will call
462 * elm_transit_del(transit), that is, it will kill the @p transit.
464 * @param transit The transit object.
465 * @param obj Object to be removed from @p transit.
468 * @warning See the documentation of the effect if is safe add or remove
469 * an object after @p transit begins to run.
472 elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
474 ELM_TRANSIT_CHECK_OR_RETURN(transit);
475 EINA_SAFETY_ON_NULL_RETURN(obj);
476 Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key);
477 if ((!obj_data) || (obj_data->transit != transit)) return;
479 _elm_transit_object_remove(transit, obj);
480 if (!transit->objs) elm_transit_del(transit);
484 * Get the objects of the transit.
486 * @param transit The transit object.
487 * @return a Eina_List with the objects from the transit.
491 EAPI const Eina_List *
492 elm_transit_objects_get(const Elm_Transit *transit)
494 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
495 return transit->objs;
499 * Set the event enabled when transit is operating.
501 * If @p enabled is EINA_TRUE, the objects of the transit will receives
502 * events from mouse and keyboard during the animation.
503 * @note When you add an object with elm_transit_object_add(), its state from
504 * evas_object_pass_events_get(obj) is saved, and it is applied when the
505 * transit ends, if you change this state with evas_object_pass_events_set()
506 * after add the object, this state will change again when @p transit stops to
509 * @param transit The transit object.
510 * @param enabled Disable or enable.
515 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
517 ELM_TRANSIT_CHECK_OR_RETURN(transit);
520 Elm_Obj_Data *obj_data;
522 if (transit->event_enabled == enabled) return;
524 transit->event_enabled = enabled;
528 EINA_LIST_FOREACH(transit->objs, elist, obj)
530 obj_data = evas_object_data_get(obj, _transit_key);
531 evas_object_pass_events_set(obj, obj_data->state);
536 EINA_LIST_FOREACH(transit->objs, elist, obj)
537 evas_object_pass_events_set(obj, EINA_TRUE);
542 * Get the value of event enabled status.
544 * @see elm_transit_event_enabled_set()
546 * @param transit The Transit object
547 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
548 * EINA_FALSE is returned
553 elm_transit_event_enabled_get(const Elm_Transit *transit)
555 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
557 return transit->event_enabled;
562 * Set the event enabled when transit is operating.
564 * If @p disabled is EINA_TRUE, the objects of the transit will receives
565 * events from mouse and keyboard during the animation.
566 * @note When you add an object with elm_transit_object_add(), its state from
567 * evas_object_pass_events_get(obj) is saved, and it is applied when the
568 * transit ends, if you change this state with evas_object_pass_events_set()
569 * after add the object, this state will change again when @p transit stops to
572 * @see elm_transit_event_enabled_set()
574 * @param transit The transit object.
575 * @param disabled Disable or enable.
579 EINA_DEPRECATED EAPI void
580 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
582 elm_transit_event_enabled_set(transit, disabled);
587 * Get the value of event block enabled status.
589 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
591 * @param transit The Transit object
592 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
593 * EINA_FALSE is returned
597 EINA_DEPRECATED EAPI Eina_Bool
598 elm_transit_event_block_get(const Elm_Transit *transit)
600 return !elm_transit_event_enabled_get(transit);
604 * Set the user-callback function when the transit is deleted.
606 * @note Using this function twice will overwrite the first function setted.
607 * @note the @p transit object will be deleted after call @p cb function.
609 * @param transit The transit object.
610 * @param cb Callback function pointer. This function will be called before
611 * the deletion of the transit.
612 * @param data Callback funtion user data. It is the @p op parameter.
617 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
619 ELM_TRANSIT_CHECK_OR_RETURN(transit);
620 transit->del_data.func = cb;
621 transit->del_data.arg = data;
625 * Set reverse effect automatically.
627 * If auto reverse is setted, after running the effects with the progress
628 * parameter from 0 to 1, it will call the effecs again with the progress
629 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
630 * where the duration was setted with the function elm_transit_add and
631 * the repeat with the function elm_transit_repeat_times_set().
633 * @param transit The transit object.
634 * @param reverse EINA_TRUE means the auto_reverse is on.
639 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
641 ELM_TRANSIT_CHECK_OR_RETURN(transit);
642 transit->auto_reverse = reverse;
646 * Get if the auto reverse is on.
648 * @see elm_transit_auto_reverse_set()
650 * @param transit The transit object.
651 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
652 * EINA_FALSE is returned
657 elm_transit_auto_reverse_get(Elm_Transit *transit)
659 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
660 return transit->auto_reverse;
664 * Set the transit repeat count. Effect will be repeated by repeat count.
666 * This function sets the number of repetition the transit will run after
667 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
668 * If the @p repeat is a negative number, it will repeat infinite times.
670 * @note If this function is called during the transit execution, the transit
671 * will run @p repeat times, ignoring the times it already performed.
673 * @param transit The transit object
674 * @param repeat Repeat count
679 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
681 ELM_TRANSIT_CHECK_OR_RETURN(transit);
682 transit->repeat.count = repeat;
683 transit->repeat.current = 0;
687 * Get the transit repeat count.
689 * @see elm_transit_repeat_times_set()
691 * @param transit The Transit object.
692 * @return The repeat count. If @p transit is NULL
698 elm_transit_repeat_times_get(Elm_Transit *transit)
700 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
701 return transit->repeat.count;
705 * Set the transit animation acceleration type.
707 * This function sets the tween mode of the transit that can be:
708 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
709 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
710 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
711 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
713 * @param transit The transit object.
714 * @param tween_mode The tween type.
719 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
721 ELM_TRANSIT_CHECK_OR_RETURN(transit);
723 transit->tween_mode = tween_mode;
727 * Get the transit animation acceleration type.
729 * @note @p transit can not be NULL
731 * @param transit The transit object.
732 * @return The tween type. If @p transit is NULL
733 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
737 EAPI Elm_Transit_Tween_Mode
738 elm_transit_tween_mode_get(const Elm_Transit *transit)
740 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
741 return transit->tween_mode;
745 * Set the transit animation time
747 * @note @p transit can not be NULL
749 * @param transit The transit object.
750 * @param duration The animation time.
755 elm_transit_duration_set(Elm_Transit *transit, double duration)
757 ELM_TRANSIT_CHECK_OR_RETURN(transit);
758 if (transit->animator) return;
759 transit->time.duration = duration;
763 * Get the transit animation time
765 * @note @p transit can not be NULL
767 * @param transit The transit object.
769 * @return The transit animation time.
774 elm_transit_duration_get(const Elm_Transit *transit)
776 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
777 return transit->time.duration;
781 * Starts the transition.
782 * Once this API is called, the transit begins to measure the time.
784 * @note @p transit can not be NULL
786 * @param transit The transit object.
791 elm_transit_go(Elm_Transit *transit)
793 ELM_TRANSIT_CHECK_OR_RETURN(transit);
795 if (transit->animator)
796 ecore_animator_del(transit->animator);
798 transit->time.paused = 0;
799 transit->time.delayed = 0;
800 transit->time.begin = ecore_loop_time_get();
801 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
805 * Pause/Resume the transition.
806 * If you call elm_transit_go again, paused states will affect no anymore.
808 * @note @p transit can not be NULL
810 * @param transit The transit object.
815 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
817 ELM_TRANSIT_CHECK_OR_RETURN(transit);
819 if (!transit->animator) return;
823 if (transit->time.paused > 0)
825 ecore_animator_freeze(transit->animator);
826 transit->time.paused = ecore_loop_time_get();
830 if (transit->time.paused == 0)
832 ecore_animator_thaw(transit->animator);
833 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
834 transit->time.paused = 0;
839 * Get the value of paused status.
841 * @see elm_transit_paused_set()
843 * @note @p transit can not be NULL
845 * @param transit The transit object.
846 * @return EINA_TRUE means transition is paused. If @p transit is NULL
847 * EINA_FALSE is returned
852 elm_transit_paused_get(const Elm_Transit *transit)
854 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
856 if (transit->time.paused == 0)
863 * Get the time progression of the animation (a double value between 0.0 and 1.0).
865 * @note @p transit can not be NULL
867 * @param transit The transit object.
869 * @return The time progression value. If @p transit is NULL
875 elm_transit_progress_value_get(const Elm_Transit *transit)
877 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
879 return transit->progress;
882 ///////////////////////////////////////////////////////////////////////////////
884 ///////////////////////////////////////////////////////////////////////////////
885 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
887 struct _Elm_Transit_Effect_Resizing
895 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
901 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
903 EINA_SAFETY_ON_NULL_RETURN(data);
904 EINA_SAFETY_ON_NULL_RETURN(transit);
908 Elm_Transit_Effect_Resizing *resizing = data;
910 w = resizing->from.w + (resizing->to.w * progress);
911 h = resizing->from.h + (resizing->to.h * progress);
913 EINA_LIST_FOREACH(transit->objs, elist, obj)
914 evas_object_resize(obj, w, h);
918 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
920 Elm_Transit_Effect_Resizing *resizing;
922 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
923 if (!resizing) return NULL;
925 resizing->from.w = from_w;
926 resizing->from.h = from_h;
927 resizing->to.w = to_w - from_w;
928 resizing->to.h = to_h - from_h;
934 * Add the Resizing Effect to Elm_Transit.
936 * @note This API is one of the facades. It creates resizing effect context
937 * and add it's required APIs to elm_transit_effect_add.
938 * @note This effect will be applied to the objects that are in the transit,
939 * @note If you change the set of objects in the transit with elm_transit_object_add()
940 * or elm_transit_object_remove(), the set of objects affected by this effect
941 * will be changed too.
943 * @see elm_transit_effect_add()
945 * @param transit Transit object.
946 * @param from_w Object width size when effect begins.
947 * @param from_h Object height size when effect begins.
948 * @param to_w Object width size when effect ends.
949 * @param to_h Object height size when effect ends.
950 * @return Resizing effect context data.
955 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
957 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
958 void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
960 if (!effect_context) return NULL;
961 elm_transit_effect_add(transit,
962 _transit_effect_resizing_op, effect_context,
963 _transit_effect_resizing_context_free);
964 return effect_context;
967 ///////////////////////////////////////////////////////////////////////////////
969 ///////////////////////////////////////////////////////////////////////////////
970 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
971 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
973 struct _Elm_Transit_Effect_Translation_Node
979 struct _Elm_Transit_Effect_Translation
981 struct _position_variation {
988 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
990 Elm_Transit_Effect_Translation *translation = data;
992 Elm_Transit_Effect_Translation_Node *translation_node;
994 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
996 if (translation_node->obj != obj) continue;
997 translation->nodes = eina_list_remove_list(translation->nodes, elist);
998 free(translation_node);
1004 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1006 Elm_Transit_Effect_Translation_Node *translation_node;
1007 const Eina_List *elist;
1009 Eina_List *data_list = NULL;
1010 const Eina_List *objs = elm_transit_objects_get(transit);
1012 EINA_LIST_FOREACH(objs, elist, obj)
1014 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1015 if (!translation_node)
1017 eina_list_free(data_list);
1020 translation_node->obj = obj;
1021 evas_object_geometry_get(obj, &(translation_node->x),
1022 &(translation_node->y), NULL, NULL);
1023 data_list = eina_list_append(data_list, translation_node);
1024 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1025 _translation_object_del_cb, translation);
1031 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1033 EINA_SAFETY_ON_NULL_RETURN(data);
1034 Elm_Transit_Effect_Translation *translation = data;
1035 Eina_List *elist, *elist_next;
1036 Elm_Transit_Effect_Translation_Node *translation_node;
1038 EINA_LIST_FOREACH_SAFE(translation->nodes,
1039 elist, elist_next, translation_node)
1041 evas_object_event_callback_del(translation_node->obj,
1042 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1043 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1044 free(translation_node);
1050 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1052 EINA_SAFETY_ON_NULL_RETURN(data);
1053 EINA_SAFETY_ON_NULL_RETURN(transit);
1055 Elm_Transit_Effect_Translation *translation = data;
1056 Elm_Transit_Effect_Translation_Node *translation_node;
1059 if (!translation->nodes)
1060 translation->nodes = _translation_nodes_build(transit, translation);
1062 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1064 x = translation_node->x + translation->from.dx
1065 + (translation->to.dx * progress);
1066 y = translation_node->y + translation->from.dy
1067 + (translation->to.dy * progress);
1068 evas_object_move(translation_node->obj, x, y);
1073 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1075 Elm_Transit_Effect_Translation *translation;
1077 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1078 if (!translation) return NULL;
1080 translation->from.dx = from_dx;
1081 translation->from.dy = from_dy;
1082 translation->to.dx = to_dx - from_dx;
1083 translation->to.dy = to_dy - from_dy;
1089 * Add the Translation Effect to Elm_Transit.
1091 * @note This API is one of the facades. It creates translation effect context
1092 * and add it's required APIs to elm_transit_effect_add.
1093 * @note When this function is called, it gets the current objects in
1094 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
1095 * will not cause any changes in the set of objects that this effect is being
1098 * @see elm_transit_effect_add()
1100 * @param transit Transit object.
1101 * @param from_dx X Position variation when effect begins.
1102 * @param from_dy Y Position variation when effect begins.
1103 * @param to_dx X Position variation when effect ends.
1104 * @param to_dy Y Position variation when effect ends.
1105 * @return Translation effect context data.
1108 * @warning Is higher recommended just create a transit with this effect when
1109 * the window that the objects of the transit belongs has already been created.
1110 * This is because this effect needs the geometry information about the objects,
1111 * and if the window was not created yet, it can get a wrong information.
1112 * @warning Is not recommended remove or add an object after the transit begins
1113 * to run, because the order of the objects will be affected.
1116 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1118 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1119 void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1121 if (!effect_context) return NULL;
1122 elm_transit_effect_add(transit,
1123 _transit_effect_translation_op, effect_context,
1124 _transit_effect_translation_context_free);
1125 return effect_context;
1129 ///////////////////////////////////////////////////////////////////////////////
1131 ///////////////////////////////////////////////////////////////////////////////
1132 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1134 struct _Elm_Transit_Effect_Zoom
1140 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1146 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1148 EINA_SAFETY_ON_NULL_RETURN(data);
1149 EINA_SAFETY_ON_NULL_RETURN(transit);
1152 Elm_Transit_Effect_Zoom *zoom = data;
1154 Evas_Coord x, y, w, h;
1156 map = evas_map_new(4);
1159 EINA_LIST_FOREACH(transit->objs, elist, obj)
1161 evas_object_geometry_get(obj, &x, &y, &w, &h);
1162 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1163 (progress * zoom->to));
1164 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1165 evas_object_map_set(obj, map);
1166 evas_object_map_enable_set(obj, EINA_TRUE);
1172 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1174 Elm_Transit_Effect_Zoom *zoom;
1176 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1177 if (!zoom) return NULL;
1179 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1180 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1186 * Add the Zoom Effect to Elm_Transit.
1188 * @note This API is one of the facades. It creates zoom effect context
1189 * and add it's required APIs to elm_transit_effect_add.
1190 * @note If you change the set of objects in the transit with elm_transit_object_add()
1191 * or elm_transit_object_remove(), the set of objects affected by this effect
1192 * will be changed too.
1194 * @see elm_transit_effect_add()
1196 * @param transit Transit object.
1197 * @param from_rate Scale rate when effect begins (1 is current rate).
1198 * @param to_rate Scale rate when effect ends.
1199 * @return Zoom effect context data.
1202 * @warning Is higher recommended just create a transit with this effect when
1203 * the window that the objects of the transit belongs has already been created.
1204 * This is because this effect needs the geometry information about the objects,
1205 * and if the window was not created yet, it can get a wrong information.
1206 * @warning Is not recommended remove or add an object after the transit begins
1207 * to run, because the order of the objects will be affected.
1210 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1212 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1213 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1215 if (!effect_context) return NULL;
1216 elm_transit_effect_add(transit,
1217 _transit_effect_zoom_op, effect_context,
1218 _transit_effect_zoom_context_free);
1219 return effect_context;
1223 ///////////////////////////////////////////////////////////////////////////////
1225 ///////////////////////////////////////////////////////////////////////////////
1226 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1228 struct _Elm_Transit_Effect_Flip
1230 Elm_Transit_Effect_Flip_Axis axis;
1235 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1237 EINA_SAFETY_ON_NULL_RETURN(data);
1238 EINA_SAFETY_ON_NULL_RETURN(transit);
1239 Evas_Object *front, *back;
1241 int count = eina_list_count(transit->objs);
1243 for (i = 0; i < (count - 1); i += 2)
1245 front = eina_list_nth(transit->objs, i);
1246 back = eina_list_nth(transit->objs, i+1);
1247 evas_object_map_enable_set(front, EINA_FALSE);
1248 evas_object_map_enable_set(back, EINA_FALSE);
1254 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1256 EINA_SAFETY_ON_NULL_RETURN(data);
1257 EINA_SAFETY_ON_NULL_RETURN(transit);
1258 Evas_Object *obj, *front, *back;
1260 Elm_Transit_Effect_Flip *flip = data;
1263 Evas_Coord x, y, w, h;
1265 map = evas_map_new(4);
1268 if (flip->cw) degree = (float)(progress * 180);
1269 else degree = (float)(progress * -180);
1271 count = eina_list_count(transit->objs);
1272 for (i = 0; i < (count - 1); i += 2)
1274 Evas_Coord half_w, half_h;
1276 front = eina_list_nth(transit->objs, i);
1277 back = eina_list_nth(transit->objs, i+1);
1279 if ((degree < 90) && (degree > -90))
1284 evas_object_hide(back);
1285 evas_object_show(front);
1293 evas_object_hide(front);
1294 evas_object_show(back);
1298 evas_map_util_points_populate_from_object_full(map, obj, 0);
1299 evas_object_geometry_get(obj, &x, &y, &w, &h);
1303 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1305 if ((degree >= 90) || (degree <= -90))
1307 evas_map_point_image_uv_set(map, 0, w, 0);
1308 evas_map_point_image_uv_set(map, 1, 0, 0);
1309 evas_map_point_image_uv_set(map, 2, 0, h);
1310 evas_map_point_image_uv_set(map, 3, w, h);
1312 evas_map_util_3d_rotate(map, 0, degree,
1313 0, x + half_w, y + half_h, 0);
1317 if ((degree >= 90) || (degree <= -90))
1319 evas_map_point_image_uv_set(map, 0, 0, h);
1320 evas_map_point_image_uv_set(map, 1, w, h);
1321 evas_map_point_image_uv_set(map, 2, w, 0);
1322 evas_map_point_image_uv_set(map, 3, 0, 0);
1324 evas_map_util_3d_rotate(map, degree,
1325 0, 0, x + half_w, y + half_h, 0);
1327 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1328 evas_object_map_enable_set(front, EINA_TRUE);
1329 evas_object_map_enable_set(back, EINA_TRUE);
1330 evas_object_map_set(obj, map);
1336 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1338 Elm_Transit_Effect_Flip *flip;
1340 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1341 if (!flip) return NULL;
1350 * Add the Flip Effect to Elm_Transit.
1352 * @note This API is one of the facades. It creates flip effect context
1353 * and add it's required APIs to elm_transit_effect_add.
1354 * @note This effect is applied to each pair of objects in the order they are listed
1355 * in the transit list of objects. The first object in the pair will be the
1356 * "front" object and the second will be the "back" object.
1357 * @note If you change the set of objects in the transit with elm_transit_object_add()
1358 * or elm_transit_object_remove(), the set of objects affected by this effect
1359 * will be changed too.
1361 * @see elm_transit_effect_add()
1363 * @param transit Transit object.
1364 * @param axis Flipping Axis(X or Y).
1365 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1366 * @return Flip effect context data.
1369 * @warning Is higher recommended just create a transit with this effect when
1370 * the window that the objects of the transit belongs has already been created.
1371 * This is because this effect needs the geometry information about the objects,
1372 * and if the window was not created yet, it can get a wrong information.
1373 * @warning Is not recommended remove or add an object after the transit begins
1374 * to run, because the order of the objects will be affected.
1377 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1379 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1380 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1382 if (!effect_context) return NULL;
1383 elm_transit_effect_add(transit,
1384 _transit_effect_flip_op, effect_context,
1385 _transit_effect_flip_context_free);
1386 return effect_context;
1389 ///////////////////////////////////////////////////////////////////////////////
1391 ///////////////////////////////////////////////////////////////////////////////
1392 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1393 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1395 struct _Elm_Transit_Effect_Resizable_Flip_Node
1401 } from_pos, from_size, to_pos, to_size;
1404 struct _Elm_Transit_Effect_Resizable_Flip
1408 Elm_Transit_Effect_Flip_Axis axis;
1412 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1414 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1416 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1418 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1420 if (resizable_flip_node->front == obj)
1421 evas_object_event_callback_del(resizable_flip_node->back,
1422 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1423 else if (resizable_flip_node->back == obj)
1424 evas_object_event_callback_del(resizable_flip_node->front,
1425 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1428 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1430 free(resizable_flip_node);
1436 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1438 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1439 Eina_List *data_list = NULL;
1440 Evas_Coord front_x, front_y, front_w, front_h;
1441 Evas_Coord back_x, back_y, back_w, back_h;
1444 count = eina_list_count(transit->objs);
1445 for (i = 0; i < (count - 1); i += 2)
1447 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1448 if (!resizable_flip_node)
1450 eina_list_free(data_list);
1454 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1455 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1457 evas_object_geometry_get(resizable_flip_node->front,
1458 &front_x, &front_y, &front_w, &front_h);
1459 evas_object_geometry_get(resizable_flip_node->back,
1460 &back_x, &back_y, &back_w, &back_h);
1462 resizable_flip_node->from_pos.x = front_x;
1463 resizable_flip_node->from_pos.y = front_y;
1464 resizable_flip_node->to_pos.x = back_x - front_x;
1465 resizable_flip_node->to_pos.y = back_y - front_y;
1467 resizable_flip_node->from_size.x = front_w;
1468 resizable_flip_node->from_size.y = front_h;
1469 resizable_flip_node->to_size.x = back_w - front_w;
1470 resizable_flip_node->to_size.y = back_h - front_h;
1472 data_list = eina_list_append(data_list, resizable_flip_node);
1474 evas_object_event_callback_add(resizable_flip_node->back,
1475 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1476 evas_object_event_callback_add(resizable_flip_node->front,
1477 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1484 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1486 if ((degree >= 90) || (degree <= -90))
1488 evas_map_point_image_uv_set(map, 0,
1489 (flip->from_size.x * 2) + flip->to_size.x,
1491 evas_map_point_image_uv_set(map, 1, 0, 0);
1492 evas_map_point_image_uv_set(map, 2, 0,
1493 (flip->from_size.y * 2) + flip->to_size.y);
1494 evas_map_point_image_uv_set(map, 3,
1495 (flip->from_size.x * 2) + flip->to_size.x,
1496 (flip->from_size.y * 2) + flip->to_size.y);
1500 evas_map_point_image_uv_set(map, 0, 0, 0);
1501 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1502 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1504 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1509 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1511 if ((degree >= 90) || (degree <= -90))
1513 evas_map_point_image_uv_set(map, 0, 0,
1514 (flip->from_size.y * 2) + flip->to_size.y);
1515 evas_map_point_image_uv_set(map, 1,
1516 (flip->from_size.x * 2) + flip->to_size.x,
1517 (flip->from_size.y * 2) + flip->to_size.y);
1518 evas_map_point_image_uv_set(map, 2,
1519 (flip->from_size.x * 2) + flip->to_size.x,
1521 evas_map_point_image_uv_set(map, 3, 0, 0);
1525 evas_map_point_image_uv_set(map, 0, 0, 0);
1526 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1527 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1529 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1534 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1536 EINA_SAFETY_ON_NULL_RETURN(data);
1538 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1539 Eina_List *elist, *elist_next;
1540 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1542 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1543 elist, elist_next, resizable_flip_node)
1545 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1546 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1548 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1551 evas_object_event_callback_del(resizable_flip_node->back,
1552 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1553 evas_object_event_callback_del(resizable_flip_node->front,
1554 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1555 free(resizable_flip_node);
1557 free(resizable_flip);
1561 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1563 EINA_SAFETY_ON_NULL_RETURN(data);
1568 Evas_Coord half_w, half_h;
1569 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1570 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1573 map = evas_map_new(4);
1576 if (resizable_flip->cw) degree = (float)(progress * 180);
1577 else degree = (float)(progress * -180);
1579 if (!resizable_flip->nodes)
1580 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1583 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1585 if ((degree < 90) && (degree > -90))
1587 obj = resizable_flip_node->front;
1588 if (resizable_flip_node->front != resizable_flip_node->back)
1590 evas_object_hide(resizable_flip_node->back);
1591 evas_object_show(resizable_flip_node->front);
1596 obj = resizable_flip_node->back;
1597 if (resizable_flip_node->front != resizable_flip_node->back)
1599 evas_object_hide(resizable_flip_node->front);
1600 evas_object_show(resizable_flip_node->back);
1604 x = resizable_flip_node->from_pos.x +
1605 (resizable_flip_node->to_pos.x * progress);
1606 y = resizable_flip_node->from_pos.y +
1607 (resizable_flip_node->to_pos.y * progress);
1608 w = resizable_flip_node->from_size.x +
1609 (resizable_flip_node->to_size.x * progress);
1610 h = resizable_flip_node->from_size.y +
1611 (resizable_flip_node->to_size.y * progress);
1612 evas_map_point_coord_set(map, 0, x, y, 0);
1613 evas_map_point_coord_set(map, 1, x + w, y, 0);
1614 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1615 evas_map_point_coord_set(map, 3, x, y + h, 0);
1617 half_w = (Evas_Coord)(w / 2);
1618 half_h = (Evas_Coord)(h / 2);
1620 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1622 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1623 evas_map_util_3d_rotate(map, 0, degree,
1624 0, x + half_w, y + half_h, 0);
1628 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1629 evas_map_util_3d_rotate(map, degree, 0,
1630 0, x + half_w, y + half_h, 0);
1633 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1634 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1635 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1636 evas_object_map_set(obj, map);
1642 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1644 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1646 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1647 if (!resizable_flip) return NULL;
1649 resizable_flip->cw = cw;
1650 resizable_flip->axis = axis;
1652 return resizable_flip;
1656 * Add the Resizable Flip Effect to Elm_Transit.
1658 * @note This API is one of the facades. It creates resizable flip effect context
1659 * and add it's required APIs to elm_transit_effect_add.
1660 * @note This effect is applied to each pair of objects in the order they are listed
1661 * in the transit list of objects. The first object in the pair will be the
1662 * "front" object and the second will be the "back" object.
1663 * @note When this function is called, it gets the current objects in
1664 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
1665 * will not cause any changes in the set of objects that this effect is being
1668 * @see elm_transit_effect_add()
1670 * @param transit Transit object.
1671 * @param axis Flipping Axis(X or Y).
1672 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1673 * @return Resizable flip effect context data.
1676 * @warning Is higher recommended just create a transit with this effect when
1677 * the window that the objects of the transit belongs has already been created.
1678 * This is because this effect needs the geometry information about the objects,
1679 * and if the window was not created yet, it can get a wrong information.
1680 * @warning Is not recommended remove or add an object after the transit begins
1681 * to run, because the order of the objects will be affected.
1684 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1686 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1687 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1689 if (!effect_context) return NULL;
1690 elm_transit_effect_add(transit,
1691 _transit_effect_resizable_flip_op, effect_context,
1692 _transit_effect_resizable_flip_context_free);
1693 return effect_context;
1697 ///////////////////////////////////////////////////////////////////////////////
1699 ///////////////////////////////////////////////////////////////////////////////
1700 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1702 struct _Elm_Transit_Effect_Wipe
1704 Elm_Transit_Effect_Wipe_Type type;
1705 Elm_Transit_Effect_Wipe_Dir dir;
1709 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1715 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1716 w2 = w - (w * progress);
1718 evas_map_point_image_uv_set(map, 0, 0, 0);
1719 evas_map_point_image_uv_set(map, 1, w2, 0);
1720 evas_map_point_image_uv_set(map, 2, w2, h);
1721 evas_map_point_image_uv_set(map, 3, 0, h);
1722 evas_map_point_coord_set(map, 0, x, y, 0);
1723 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1724 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1725 evas_map_point_coord_set(map, 3, x, h2, 0);
1727 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1728 w2 = (w * progress);
1730 evas_map_point_image_uv_set(map, 0, w2, 0);
1731 evas_map_point_image_uv_set(map, 1, w, 0);
1732 evas_map_point_image_uv_set(map, 2, w, h);
1733 evas_map_point_image_uv_set(map, 3, w2, h);
1734 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1735 evas_map_point_coord_set(map, 1, x + w, y, 0);
1736 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1737 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1739 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1741 h2 = h - (h * progress);
1742 evas_map_point_image_uv_set(map, 0, 0, 0);
1743 evas_map_point_image_uv_set(map, 1, w, 0);
1744 evas_map_point_image_uv_set(map, 2, w, h2);
1745 evas_map_point_image_uv_set(map, 3, 0, h2);
1746 evas_map_point_coord_set(map, 0, x, y, 0);
1747 evas_map_point_coord_set(map, 1, w2, y, 0);
1748 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1749 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1751 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1753 h2 = (h * progress);
1754 evas_map_point_image_uv_set(map, 0, 0, h2);
1755 evas_map_point_image_uv_set(map, 1, w, h2);
1756 evas_map_point_image_uv_set(map, 2, w, h);
1757 evas_map_point_image_uv_set(map, 3, 0, h);
1758 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1759 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1760 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1761 evas_map_point_coord_set(map, 3, x, y + h, 0);
1766 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1770 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1776 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1777 w2 = (w - (w * progress));
1779 evas_map_point_image_uv_set(map, 0, w2, 0);
1780 evas_map_point_image_uv_set(map, 1, w, 0);
1781 evas_map_point_image_uv_set(map, 2, w, h);
1782 evas_map_point_image_uv_set(map, 3, w2, h);
1783 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1784 evas_map_point_coord_set(map, 1, w, y, 0);
1785 evas_map_point_coord_set(map, 2, w, h2, 0);
1786 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1788 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1789 w2 = (w * progress);
1791 evas_map_point_image_uv_set(map, 0, 0, 0);
1792 evas_map_point_image_uv_set(map, 1, w2, 0);
1793 evas_map_point_image_uv_set(map, 2, w2, h);
1794 evas_map_point_image_uv_set(map, 3, 0, h);
1795 evas_map_point_coord_set(map, 0, x, y, 0);
1796 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1797 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1798 evas_map_point_coord_set(map, 3, x, h2, 0);
1800 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1802 h2 = (h - (h * progress));
1803 evas_map_point_image_uv_set(map, 0, 0, h2);
1804 evas_map_point_image_uv_set(map, 1, w, h2);
1805 evas_map_point_image_uv_set(map, 2, w, h);
1806 evas_map_point_image_uv_set(map, 3, 0, h);
1807 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1808 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1809 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1810 evas_map_point_coord_set(map, 3, x, y + h, 0);
1812 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1814 h2 = (h * progress);
1815 evas_map_point_image_uv_set(map, 0, 0, 0);
1816 evas_map_point_image_uv_set(map, 1, w, 0);
1817 evas_map_point_image_uv_set(map, 2, w, h2);
1818 evas_map_point_image_uv_set(map, 3, 0, h2);
1819 evas_map_point_coord_set(map, 0, x, y, 0);
1820 evas_map_point_coord_set(map, 1, w2, y, 0);
1821 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1822 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1827 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1831 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1833 EINA_SAFETY_ON_NULL_RETURN(data);
1834 EINA_SAFETY_ON_NULL_RETURN(transit);
1837 Elm_Transit_Effect_Wipe *wipe = data;
1838 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1840 EINA_LIST_FOREACH(transit->objs, elist, obj)
1842 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1843 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1844 evas_object_show(obj);
1845 else evas_object_hide(obj);
1846 evas_object_map_enable_set(obj, EINA_FALSE);
1853 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1855 EINA_SAFETY_ON_NULL_RETURN(data);
1856 EINA_SAFETY_ON_NULL_RETURN(transit);
1857 Elm_Transit_Effect_Wipe *wipe = data;
1859 Evas_Coord _x, _y, _w, _h;
1863 map = evas_map_new(4);
1866 EINA_LIST_FOREACH(transit->objs, elist, obj)
1868 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1870 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1871 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1873 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1875 evas_object_map_enable_set(obj, EINA_TRUE);
1876 evas_object_map_set(obj, map);
1882 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1884 Elm_Transit_Effect_Wipe *wipe;
1886 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1887 if (!wipe) return NULL;
1896 * Add the Wipe Effect to Elm_Transit.
1898 * @note This API is one of the facades. It creates wipe effect context
1899 * and add it's required APIs to elm_transit_effect_add.
1900 * @note This effect will be applied to the objects that are in the transit,
1901 * If you change the set of objects in the transit with elm_transit_object_add()
1902 * or elm_transit_object_remove(), the set of objects affected by this effect
1903 * will be changed too.
1905 * @see elm_transit_effect_add()
1907 * @param transit Transit object.
1908 * @param type Wipe type. Hide or show.
1909 * @param dir Wipe Direction.
1910 * @return Wipe effect context data.
1913 * @warning Is higher recommended just create a transit with this effect when
1914 * the window that the objects of the transit belongs has already been created.
1915 * This is because this effect needs the geometry information about the objects,
1916 * and if the window was not created yet, it can get a wrong information.
1917 * @warning Is not recommended remove or add an object after the transit begins
1918 * to run, because the order of the objects will be affected.
1921 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1923 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1924 void *effect_context = _transit_effect_wipe_context_new(type, dir);
1926 if (!effect_context) return NULL;
1927 elm_transit_effect_add(transit,
1928 _transit_effect_wipe_op, effect_context,
1929 _transit_effect_wipe_context_free);
1930 return effect_context;
1934 ///////////////////////////////////////////////////////////////////////////////
1936 ///////////////////////////////////////////////////////////////////////////////
1937 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1939 struct _Elm_Transit_Effect_Color
1941 struct _unsigned_color {
1942 unsigned int r, g, b, a;
1944 struct _signed_color {
1950 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
1956 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
1958 EINA_SAFETY_ON_NULL_RETURN(data);
1959 EINA_SAFETY_ON_NULL_RETURN(transit);
1960 Elm_Transit_Effect_Color *color = data;
1963 unsigned int r, g, b, a;
1965 r = (color->from.r + (int)((float)color->to.r * progress));
1966 g = (color->from.g + (int)((float)color->to.g * progress));
1967 b = (color->from.b + (int)((float)color->to.b * progress));
1968 a = (color->from.a + (int)((float)color->to.a * progress));
1970 EINA_LIST_FOREACH(transit->objs, elist, obj)
1971 evas_object_color_set(obj, r, g, b, a);
1975 _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)
1977 Elm_Transit_Effect_Color *color;
1979 color = ELM_NEW(Elm_Transit_Effect_Color);
1980 if (!color) return NULL;
1982 color->from.r = from_r;
1983 color->from.g = from_g;
1984 color->from.b = from_b;
1985 color->from.a = from_a;
1986 color->to.r = to_r - from_r;
1987 color->to.g = to_g - from_g;
1988 color->to.b = to_b - from_b;
1989 color->to.a = to_a - from_a;
1995 * Add the Color Effect to Elm_Transit.
1997 * @note This API is one of the facades. It creates color effect context
1998 * and add it's required APIs to elm_transit_effect_add.
1999 * @note This effect will be applied to the objects that are in the transit,
2000 * If you change the set of objects in the transit with elm_transit_object_add()
2001 * or elm_transit_object_remove(), the set of objects affected by this effect
2002 * will be changed too.
2004 * @see elm_transit_effect_add()
2006 * @param transit Transit object.
2007 * @param from_r RGB R when effect begins.
2008 * @param from_g RGB G when effect begins.
2009 * @param from_b RGB B when effect begins.
2010 * @param from_a RGB A when effect begins.
2011 * @param to_r RGB R when effect ends.
2012 * @param to_g RGB G when effect ends.
2013 * @param to_b RGB B when effect ends.
2014 * @param to_a RGB A when effect ends.
2015 * @return Color effect context data.
2020 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)
2022 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2023 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2025 if (!effect_context) return NULL;
2026 elm_transit_effect_add(transit,
2027 _transit_effect_color_op, effect_context,
2028 _transit_effect_color_context_free);
2029 return effect_context;
2032 ///////////////////////////////////////////////////////////////////////////////
2034 ///////////////////////////////////////////////////////////////////////////////
2035 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2036 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2038 struct _Elm_Transit_Effect_Fade_Node
2040 Evas_Object *before;
2042 struct _signed_color before_color, after_color;
2045 Eina_Bool inversed : 1;
2048 struct _Elm_Transit_Effect_Fade
2054 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2056 Elm_Transit_Effect_Fade *fade = data;
2058 Elm_Transit_Effect_Fade_Node *fade_node;
2060 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2062 if (fade_node->before == obj)
2063 evas_object_event_callback_del(fade_node->after,
2064 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2065 else if (fade_node->after == obj)
2066 evas_object_event_callback_del(fade_node->before,
2067 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2070 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2077 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2079 Elm_Transit_Effect_Fade_Node *fade;
2080 Eina_List *data_list = NULL;
2083 count = eina_list_count(transit->objs);
2084 for (i = 0; i < (count - 1); i += 2)
2086 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2089 eina_list_free(data_list);
2093 fade->before = eina_list_nth(transit->objs, i);
2094 fade->after = eina_list_nth(transit->objs, i+1);
2096 evas_object_color_get(fade->before,
2097 &fade->before_color.r, &fade->before_color.g,
2098 &fade->before_color.b, &fade->before_color.a);
2099 evas_object_color_get(fade->after,
2100 &fade->after_color.r, &fade->after_color.g,
2101 &fade->after_color.b, &fade->after_color.a);
2103 fade->before_alpha = (255 - fade->before_color.a);
2104 fade->after_alpha = (255 - fade->after_color.a);
2106 data_list = eina_list_append(data_list, fade);
2108 evas_object_event_callback_add(fade->before,
2109 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2110 evas_object_event_callback_add(fade->after,
2111 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2117 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2119 EINA_SAFETY_ON_NULL_RETURN(data);
2120 Elm_Transit_Effect_Fade *fade = data;
2121 Elm_Transit_Effect_Fade_Node *fade_node;
2122 Eina_List *elist, *elist_next;
2124 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2126 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2127 fade_node->before_color.g,
2128 fade_node->before_color.b,
2129 fade_node->before_color.a);
2130 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2131 fade_node->after_color.g,
2132 fade_node->after_color.b,
2133 fade_node->after_color.a);
2135 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2136 evas_object_event_callback_del(fade_node->before,
2137 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2138 evas_object_event_callback_del(fade_node->after,
2139 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2147 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2149 EINA_SAFETY_ON_NULL_RETURN(data);
2150 Elm_Transit_Effect_Fade *fade = data;
2152 Elm_Transit_Effect_Fade_Node *fade_node;
2156 fade->nodes = _fade_nodes_build(transit, fade);
2158 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2162 if (!fade_node->inversed)
2164 evas_object_hide(fade_node->after);
2165 evas_object_show(fade_node->before);
2166 fade_node->inversed = EINA_TRUE;
2169 _progress = (1 - (progress * 2));
2171 evas_object_color_set(fade_node->before,
2172 fade_node->before_color.r * _progress,
2173 fade_node->before_color.g * _progress,
2174 fade_node->before_color.b * _progress,
2175 fade_node->before_color.a +
2176 fade_node->before_alpha * (1 - _progress));
2180 if (fade_node->inversed)
2182 evas_object_hide(fade_node->before);
2183 evas_object_show(fade_node->after);
2184 fade_node->inversed = EINA_FALSE;
2187 _progress = ((progress - 0.5) * 2);
2189 evas_object_color_set(fade_node->after,
2190 fade_node->after_color.r * _progress,
2191 fade_node->after_color.g * _progress,
2192 fade_node->after_color.b * _progress,
2193 fade_node->after_color.a +
2194 fade_node->after_alpha * (1 - _progress));
2200 _transit_effect_fade_context_new(void)
2202 Elm_Transit_Effect_Fade *fade;
2203 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2204 if (!fade) return NULL;
2209 * Add the Fade Effect to Elm_Transit.
2211 * @note This API is one of the facades. It creates fade effect context
2212 * and add it's required APIs to elm_transit_effect_add.
2213 * @note This effect is applied to each pair of objects in the order they are listed
2214 * in the transit list of objects. The first object in the pair will be the
2215 * "before" object and the second will be the "after" object.
2216 * @note When this function is called, it gets the current objects in
2217 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2218 * will not cause any changes in the set of objects that this effect is being
2221 * @see elm_transit_effect_add()
2223 * @param transit Transit object.
2224 * @return Fade effect context data.
2227 * @warning Is higher recommended just create a transit with this effect when
2228 * the window that the objects of the transit belongs has already been created.
2229 * This is because this effect needs the color information about the objects,
2230 * and if the window was not created yet, it can get a wrong information.
2231 * @warning Is not recommended remove or add an object after the transit begins
2232 * to run, because the order of the objects will be affected.
2235 elm_transit_effect_fade_add(Elm_Transit *transit)
2237 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2239 void *effect_context = _transit_effect_fade_context_new();
2240 if (!effect_context) return NULL;
2241 elm_transit_effect_add(transit,
2242 _transit_effect_fade_op, effect_context,
2243 _transit_effect_fade_context_free);
2244 return effect_context;
2248 ///////////////////////////////////////////////////////////////////////////////
2250 ///////////////////////////////////////////////////////////////////////////////
2251 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2252 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2254 struct _Elm_Transit_Effect_Blend_Node
2256 Evas_Object *before;
2258 struct _signed_color from, to;
2261 struct _Elm_Transit_Effect_Blend
2267 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2269 Elm_Transit_Effect_Blend *blend = data;
2271 Elm_Transit_Effect_Blend_Node *blend_node;
2273 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2275 if (blend_node->after == obj)
2276 evas_object_event_callback_del(blend_node->before,
2277 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2278 else if (blend_node->before == obj)
2279 evas_object_event_callback_del(blend_node->after,
2280 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2283 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2290 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2292 Elm_Transit_Effect_Blend_Node *blend_node;
2293 Eina_List *data_list = NULL;
2296 count = eina_list_count(transit->objs);
2297 for (i = 0; i < (count - 1); i += 2)
2299 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2302 eina_list_free(data_list);
2306 blend_node->before = eina_list_nth(transit->objs, i);
2307 blend_node->after = eina_list_nth(transit->objs, i + 1);
2308 evas_object_show(blend_node->before);
2309 evas_object_show(blend_node->after);
2311 evas_object_color_get(blend_node->before, &blend_node->from.r,
2312 &blend_node->from.g, &blend_node->from.b,
2313 &blend_node->from.a);
2314 evas_object_color_get(blend_node->after, &blend_node->to.r,
2315 &blend_node->to.g, &blend_node->to.b,
2318 data_list = eina_list_append(data_list, blend_node);
2320 evas_object_event_callback_add(blend_node->before,
2321 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2322 evas_object_event_callback_add(blend_node->after,
2323 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2329 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2331 EINA_SAFETY_ON_NULL_RETURN(data);
2332 Elm_Transit_Effect_Blend *blend = data;
2333 Elm_Transit_Effect_Blend_Node *blend_node;
2334 Eina_List *elist, *elist_next;
2336 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2338 evas_object_color_set(blend_node->before,
2339 blend_node->from.r, blend_node->from.g,
2340 blend_node->from.b, blend_node->from.a);
2341 evas_object_color_set(blend_node->after, blend_node->to.r,
2342 blend_node->to.g, blend_node->to.b,
2345 if (elm_transit_auto_reverse_get(transit))
2346 evas_object_hide(blend_node->after);
2348 evas_object_hide(blend_node->before);
2350 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2352 evas_object_event_callback_del(blend_node->before,
2353 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2354 evas_object_event_callback_del(blend_node->after,
2355 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2362 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2364 EINA_SAFETY_ON_NULL_RETURN(data);
2365 EINA_SAFETY_ON_NULL_RETURN(transit);
2366 Elm_Transit_Effect_Blend *blend = data;
2367 Elm_Transit_Effect_Blend_Node *blend_node;
2370 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2372 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2374 evas_object_color_set(blend_node->before,
2375 (int)(blend_node->from.r * (1 - progress)),
2376 (int)(blend_node->from.g * (1 - progress)),
2377 (int)(blend_node->from.b * (1 - progress)),
2378 (int)(blend_node->from.a * (1 - progress)));
2379 evas_object_color_set(blend_node->after,
2380 (int)(blend_node->to.r * progress),
2381 (int)(blend_node->to.g * progress),
2382 (int)(blend_node->to.b * progress),
2383 (int)(blend_node->to.a * progress));
2388 _transit_effect_blend_context_new(void)
2390 Elm_Transit_Effect_Blend *blend;
2392 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2393 if (!blend) return NULL;
2398 * Add the Blend Effect to Elm_Transit.
2400 * @note This API is one of the facades. It creates blend effect context
2401 * and add it's required APIs to elm_transit_effect_add.
2402 * @note This effect is applied to each pair of objects in the order they are listed
2403 * in the transit list of objects. The first object in the pair will be the
2404 * "before" object and the second will be the "after" object.
2405 * @note When this function be called, it gets the current objects in
2406 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2407 * will not cause any changes in the set of objects that this effect is being
2410 * @see elm_transit_effect_add()
2412 * @param transit Transit object.
2413 * @return Blend effect context data.
2416 * @warning Is higher recommended just create a transit with this effect when
2417 * the window that the objects of the transit belongs has already been created.
2418 * This is because this effect needs the color information about the objects,
2419 * and if the window was not created yet, it can get a wrong information.
2420 * @warning Is not recommended remove or add an object after the transit begins
2421 * to run, because the order of the objects will be affected.
2424 elm_transit_effect_blend_add(Elm_Transit *transit)
2426 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2427 void *effect_context = _transit_effect_blend_context_new();
2429 if (!effect_context) return NULL;
2430 elm_transit_effect_add(transit,
2431 _transit_effect_blend_op, effect_context,
2432 _transit_effect_blend_context_free);
2433 return effect_context;
2437 ///////////////////////////////////////////////////////////////////////////////
2439 ///////////////////////////////////////////////////////////////////////////////
2440 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2442 struct _Elm_Transit_Effect_Rotation
2448 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2454 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2456 EINA_SAFETY_ON_NULL_RETURN(data);
2457 EINA_SAFETY_ON_NULL_RETURN(transit);
2458 Elm_Transit_Effect_Rotation *rotation = data;
2460 Evas_Coord x, y, w, h;
2462 float half_w, half_h;
2466 map = evas_map_new(4);
2469 EINA_LIST_FOREACH(transit->objs, elist, obj)
2471 evas_map_util_points_populate_from_object_full(map, obj, 0);
2472 degree = rotation->from + (float)(progress * rotation->to);
2474 evas_object_geometry_get(obj, &x, &y, &w, &h);
2476 half_w = (float)w * 0.5;
2477 half_h = (float)h * 0.5;
2479 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2480 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2481 evas_object_map_enable_set(obj, EINA_TRUE);
2482 evas_object_map_set(obj, map);
2488 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2490 Elm_Transit_Effect_Rotation *rotation;
2492 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2493 if (!rotation) return NULL;
2495 rotation->from = from_degree;
2496 rotation->to = to_degree - from_degree;
2502 * Add the Rotation Effect to Elm_Transit.
2504 * @note This API is one of the facades. It creates rotation effect context
2505 * and add it's required APIs to elm_transit_effect_add.
2506 * @note This effect will be applied to the objects that are in the transit,
2507 * If you change the set of objects in the transit with elm_transit_object_add()
2508 * or elm_transit_object_remove(), the set of objects affected by this effect
2509 * will be changed too.
2511 * @see elm_transit_effect_add()
2513 * @param transit Transit object.
2514 * @param from_degree Degree when effect begins.
2515 * @param to_degree Degree when effect is ends.
2516 * @return Rotation effect context data.
2519 * @warning Is higher recommended just create a transit with this effect when
2520 * the window that the objects of the transit belongs has already been created.
2521 * This is because this effect needs the geometry information about the objects,
2522 * and if the window was not created yet, it can get a wrong information.
2523 * @warning Is not recommended remove or add an object after the transit begins
2524 * to run, because the order of the objects will be affected.
2527 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2529 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2530 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2532 if (!effect_context) return NULL;
2533 elm_transit_effect_add(transit,
2534 _transit_effect_rotation_op, effect_context,
2535 _transit_effect_rotation_context_free);
2536 return effect_context;
2540 ///////////////////////////////////////////////////////////////////////////////
2541 // ImageAnimation FX
2542 ///////////////////////////////////////////////////////////////////////////////
2543 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2545 struct _Elm_Transit_Effect_Image_Animation
2551 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2553 EINA_SAFETY_ON_NULL_RETURN(data);
2554 Elm_Transit_Effect_Image_Animation *image_animation = data;
2556 Eina_List *elist, *elist_next;
2558 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2560 image_animation->images =
2561 eina_list_remove_list(image_animation->images, elist);
2562 eina_stringshare_del(image);
2569 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2571 EINA_SAFETY_ON_NULL_RETURN(data);
2572 EINA_SAFETY_ON_NULL_RETURN(transit);
2576 Elm_Transit_Effect_Image_Animation *image_animation = data;
2577 unsigned int count = 0;
2580 type = eina_stringshare_add("icon");
2581 len = eina_list_count(image_animation->images);
2583 if (!len) count = floor(progress * len);
2584 else count = floor(progress * (len - 1));
2586 EINA_LIST_FOREACH(transit->objs, elist, obj)
2588 if (elm_widget_type_check(obj, type))
2589 elm_icon_file_set(obj,
2590 eina_list_nth(image_animation->images, count), NULL);
2593 eina_stringshare_del(type);
2597 _transit_effect_image_animation_context_new(Eina_List *images)
2599 Elm_Transit_Effect_Image_Animation *image_animation;
2600 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2602 if (!image_animation) return NULL;
2603 image_animation->images = images;
2604 return image_animation;
2608 * Add the Rotation Effect to Elm_Transit.
2610 * @note This API is one of the facades. It creates image animation effect context
2611 * and add it's required APIs to elm_transit_effect_add.
2612 * The @p images parameter is a list images paths. This list and
2613 * its contents will be deleted at the end of the effect by
2614 * elm_transit_effect_image_animation_context_free() function.
2615 * @note This effect will be applied to the objects that are in the transit,
2616 * If you change the set of objects in the transit with elm_transit_object_add()
2617 * or elm_transit_object_remove(), the set of objects affected by this effect
2618 * will be changed too.
2622 * char buf[PATH_MAX];
2623 * Eina_List *images = NULL;
2624 * Elm_Transit *transi = elm_transit_add();
2626 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2627 * images = eina_list_append(images, eina_stringshare_add(buf));
2629 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2630 * images = eina_list_append(images, eina_stringshare_add(buf));
2631 * elm_transit_effect_image_animation_add(transi, images);
2635 * @see elm_transit_effect_add()
2637 * @param transit Transit object.
2638 * @param images Eina_List of images file paths. This list and
2639 * its contents will be deleted at the end of the effect by
2640 * elm_transit_effect_image_animation_context_free() function.
2641 * @return Image Animation effect context data.
2646 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2648 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2649 void *effect_context = _transit_effect_image_animation_context_new(images);
2651 if (!effect_context) return NULL;
2652 elm_transit_effect_add(transit,
2653 _transit_effect_image_animation_op, effect_context,
2654 _transit_effect_image_animation_context_free);
2655 return effect_context;