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 if (transit->del_data.func)
166 transit->del_data.func(transit->del_data.arg, transit);
168 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
169 _elm_transit_effect_del(transit, effect, elist);
171 while (transit->objs)
172 _elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
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_smooth_set(map, EINA_TRUE);
1163 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1164 (progress * zoom->to));
1165 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1166 evas_object_map_set(obj, map);
1167 evas_object_map_enable_set(obj, EINA_TRUE);
1173 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1175 Elm_Transit_Effect_Zoom *zoom;
1177 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1178 if (!zoom) return NULL;
1180 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1181 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1187 * Add the Zoom Effect to Elm_Transit.
1189 * @note This API is one of the facades. It creates zoom effect context
1190 * and add it's required APIs to elm_transit_effect_add.
1191 * @note If you change the set of objects in the transit with elm_transit_object_add()
1192 * or elm_transit_object_remove(), the set of objects affected by this effect
1193 * will be changed too.
1195 * @see elm_transit_effect_add()
1197 * @param transit Transit object.
1198 * @param from_rate Scale rate when effect begins (1 is current rate).
1199 * @param to_rate Scale rate when effect ends.
1200 * @return Zoom effect context data.
1203 * @warning Is higher recommended just create a transit with this effect when
1204 * the window that the objects of the transit belongs has already been created.
1205 * This is because this effect needs the geometry information about the objects,
1206 * and if the window was not created yet, it can get a wrong information.
1207 * @warning Is not recommended remove or add an object after the transit begins
1208 * to run, because the order of the objects will be affected.
1211 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1213 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1214 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1216 if (!effect_context) return NULL;
1217 elm_transit_effect_add(transit,
1218 _transit_effect_zoom_op, effect_context,
1219 _transit_effect_zoom_context_free);
1220 return effect_context;
1224 ///////////////////////////////////////////////////////////////////////////////
1226 ///////////////////////////////////////////////////////////////////////////////
1227 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1229 struct _Elm_Transit_Effect_Flip
1231 Elm_Transit_Effect_Flip_Axis axis;
1236 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1238 EINA_SAFETY_ON_NULL_RETURN(data);
1239 EINA_SAFETY_ON_NULL_RETURN(transit);
1240 Evas_Object *front, *back;
1242 int count = eina_list_count(transit->objs);
1244 for (i = 0; i < (count - 1); i += 2)
1246 front = eina_list_nth(transit->objs, i);
1247 back = eina_list_nth(transit->objs, i+1);
1248 evas_object_map_enable_set(front, EINA_FALSE);
1249 evas_object_map_enable_set(back, EINA_FALSE);
1255 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1257 EINA_SAFETY_ON_NULL_RETURN(data);
1258 EINA_SAFETY_ON_NULL_RETURN(transit);
1259 Evas_Object *obj, *front, *back;
1261 Elm_Transit_Effect_Flip *flip = data;
1264 Evas_Coord x, y, w, h;
1266 map = evas_map_new(4);
1269 if (flip->cw) degree = (float)(progress * 180);
1270 else degree = (float)(progress * -180);
1272 count = eina_list_count(transit->objs);
1273 for (i = 0; i < (count - 1); i += 2)
1275 Evas_Coord half_w, half_h;
1277 front = eina_list_nth(transit->objs, i);
1278 back = eina_list_nth(transit->objs, i+1);
1280 if ((degree < 90) && (degree > -90))
1285 evas_object_hide(back);
1286 evas_object_show(front);
1294 evas_object_hide(front);
1295 evas_object_show(back);
1299 evas_map_smooth_set(map, EINA_TRUE);
1300 evas_map_util_points_populate_from_object_full(map, obj, 0);
1301 evas_object_geometry_get(obj, &x, &y, &w, &h);
1305 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1307 if ((degree >= 90) || (degree <= -90))
1309 evas_map_point_image_uv_set(map, 0, w, 0);
1310 evas_map_point_image_uv_set(map, 1, 0, 0);
1311 evas_map_point_image_uv_set(map, 2, 0, h);
1312 evas_map_point_image_uv_set(map, 3, w, h);
1314 evas_map_util_3d_rotate(map, 0, degree,
1315 0, x + half_w, y + half_h, 0);
1319 if ((degree >= 90) || (degree <= -90))
1321 evas_map_point_image_uv_set(map, 0, 0, h);
1322 evas_map_point_image_uv_set(map, 1, w, h);
1323 evas_map_point_image_uv_set(map, 2, w, 0);
1324 evas_map_point_image_uv_set(map, 3, 0, 0);
1326 evas_map_util_3d_rotate(map, degree,
1327 0, 0, x + half_w, y + half_h, 0);
1329 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1330 evas_object_map_enable_set(front, EINA_TRUE);
1331 evas_object_map_enable_set(back, EINA_TRUE);
1332 evas_object_map_set(obj, map);
1338 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1340 Elm_Transit_Effect_Flip *flip;
1342 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1343 if (!flip) return NULL;
1352 * Add the Flip Effect to Elm_Transit.
1354 * @note This API is one of the facades. It creates flip effect context
1355 * and add it's required APIs to elm_transit_effect_add.
1356 * @note This effect is applied to each pair of objects in the order they are listed
1357 * in the transit list of objects. The first object in the pair will be the
1358 * "front" object and the second will be the "back" object.
1359 * @note If you change the set of objects in the transit with elm_transit_object_add()
1360 * or elm_transit_object_remove(), the set of objects affected by this effect
1361 * will be changed too.
1363 * @see elm_transit_effect_add()
1365 * @param transit Transit object.
1366 * @param axis Flipping Axis(X or Y).
1367 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1368 * @return Flip effect context data.
1371 * @warning Is higher recommended just create a transit with this effect when
1372 * the window that the objects of the transit belongs has already been created.
1373 * This is because this effect needs the geometry information about the objects,
1374 * and if the window was not created yet, it can get a wrong information.
1375 * @warning Is not recommended remove or add an object after the transit begins
1376 * to run, because the order of the objects will be affected.
1379 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1381 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1382 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1384 if (!effect_context) return NULL;
1385 elm_transit_effect_add(transit,
1386 _transit_effect_flip_op, effect_context,
1387 _transit_effect_flip_context_free);
1388 return effect_context;
1391 ///////////////////////////////////////////////////////////////////////////////
1393 ///////////////////////////////////////////////////////////////////////////////
1394 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1395 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1397 struct _Elm_Transit_Effect_Resizable_Flip_Node
1403 } from_pos, from_size, to_pos, to_size;
1406 struct _Elm_Transit_Effect_Resizable_Flip
1410 Elm_Transit_Effect_Flip_Axis axis;
1414 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1416 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1418 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1420 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1422 if (resizable_flip_node->front == obj)
1423 evas_object_event_callback_del(resizable_flip_node->back,
1424 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1425 else if (resizable_flip_node->back == obj)
1426 evas_object_event_callback_del(resizable_flip_node->front,
1427 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1430 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1432 free(resizable_flip_node);
1438 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1440 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1441 Eina_List *data_list = NULL;
1442 Evas_Coord front_x, front_y, front_w, front_h;
1443 Evas_Coord back_x, back_y, back_w, back_h;
1446 count = eina_list_count(transit->objs);
1447 for (i = 0; i < (count - 1); i += 2)
1449 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1450 if (!resizable_flip_node)
1452 eina_list_free(data_list);
1456 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1457 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1459 evas_object_geometry_get(resizable_flip_node->front,
1460 &front_x, &front_y, &front_w, &front_h);
1461 evas_object_geometry_get(resizable_flip_node->back,
1462 &back_x, &back_y, &back_w, &back_h);
1464 resizable_flip_node->from_pos.x = front_x;
1465 resizable_flip_node->from_pos.y = front_y;
1466 resizable_flip_node->to_pos.x = back_x - front_x;
1467 resizable_flip_node->to_pos.y = back_y - front_y;
1469 resizable_flip_node->from_size.x = front_w;
1470 resizable_flip_node->from_size.y = front_h;
1471 resizable_flip_node->to_size.x = back_w - front_w;
1472 resizable_flip_node->to_size.y = back_h - front_h;
1474 data_list = eina_list_append(data_list, resizable_flip_node);
1476 evas_object_event_callback_add(resizable_flip_node->back,
1477 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1478 evas_object_event_callback_add(resizable_flip_node->front,
1479 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1486 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1488 if ((degree >= 90) || (degree <= -90))
1490 evas_map_point_image_uv_set(map, 0,
1491 (flip->from_size.x * 2) + flip->to_size.x,
1493 evas_map_point_image_uv_set(map, 1, 0, 0);
1494 evas_map_point_image_uv_set(map, 2, 0,
1495 (flip->from_size.y * 2) + flip->to_size.y);
1496 evas_map_point_image_uv_set(map, 3,
1497 (flip->from_size.x * 2) + flip->to_size.x,
1498 (flip->from_size.y * 2) + flip->to_size.y);
1502 evas_map_point_image_uv_set(map, 0, 0, 0);
1503 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1504 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1506 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1511 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1513 if ((degree >= 90) || (degree <= -90))
1515 evas_map_point_image_uv_set(map, 0, 0,
1516 (flip->from_size.y * 2) + flip->to_size.y);
1517 evas_map_point_image_uv_set(map, 1,
1518 (flip->from_size.x * 2) + flip->to_size.x,
1519 (flip->from_size.y * 2) + flip->to_size.y);
1520 evas_map_point_image_uv_set(map, 2,
1521 (flip->from_size.x * 2) + flip->to_size.x,
1523 evas_map_point_image_uv_set(map, 3, 0, 0);
1527 evas_map_point_image_uv_set(map, 0, 0, 0);
1528 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1529 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1531 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1536 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1538 EINA_SAFETY_ON_NULL_RETURN(data);
1540 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1541 Eina_List *elist, *elist_next;
1542 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1544 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1545 elist, elist_next, resizable_flip_node)
1547 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1548 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1550 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1553 evas_object_event_callback_del(resizable_flip_node->back,
1554 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1555 evas_object_event_callback_del(resizable_flip_node->front,
1556 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1557 free(resizable_flip_node);
1559 free(resizable_flip);
1563 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1565 EINA_SAFETY_ON_NULL_RETURN(data);
1570 Evas_Coord half_w, half_h;
1571 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1572 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1575 map = evas_map_new(4);
1578 if (resizable_flip->cw) degree = (float)(progress * 180);
1579 else degree = (float)(progress * -180);
1581 if (!resizable_flip->nodes)
1582 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1585 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1587 if ((degree < 90) && (degree > -90))
1589 obj = resizable_flip_node->front;
1590 if (resizable_flip_node->front != resizable_flip_node->back)
1592 evas_object_hide(resizable_flip_node->back);
1593 evas_object_show(resizable_flip_node->front);
1598 obj = resizable_flip_node->back;
1599 if (resizable_flip_node->front != resizable_flip_node->back)
1601 evas_object_hide(resizable_flip_node->front);
1602 evas_object_show(resizable_flip_node->back);
1606 evas_map_smooth_set(map, EINA_TRUE);
1608 x = resizable_flip_node->from_pos.x +
1609 (resizable_flip_node->to_pos.x * progress);
1610 y = resizable_flip_node->from_pos.y +
1611 (resizable_flip_node->to_pos.y * progress);
1612 w = resizable_flip_node->from_size.x +
1613 (resizable_flip_node->to_size.x * progress);
1614 h = resizable_flip_node->from_size.y +
1615 (resizable_flip_node->to_size.y * progress);
1616 evas_map_point_coord_set(map, 0, x, y, 0);
1617 evas_map_point_coord_set(map, 1, x + w, y, 0);
1618 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1619 evas_map_point_coord_set(map, 3, x, y + h, 0);
1621 half_w = (Evas_Coord)(w / 2);
1622 half_h = (Evas_Coord)(h / 2);
1624 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1626 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1627 evas_map_util_3d_rotate(map, 0, degree,
1628 0, x + half_w, y + half_h, 0);
1632 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1633 evas_map_util_3d_rotate(map, degree, 0,
1634 0, x + half_w, y + half_h, 0);
1637 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1638 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1639 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1640 evas_object_map_set(obj, map);
1646 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1648 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1650 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1651 if (!resizable_flip) return NULL;
1653 resizable_flip->cw = cw;
1654 resizable_flip->axis = axis;
1656 return resizable_flip;
1660 * Add the Resizable Flip Effect to Elm_Transit.
1662 * @note This API is one of the facades. It creates resizable flip effect context
1663 * and add it's required APIs to elm_transit_effect_add.
1664 * @note This effect is applied to each pair of objects in the order they are listed
1665 * in the transit list of objects. The first object in the pair will be the
1666 * "front" object and the second will be the "back" object.
1667 * @note When this function is called, it gets the current objects in
1668 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
1669 * will not cause any changes in the set of objects that this effect is being
1672 * @see elm_transit_effect_add()
1674 * @param transit Transit object.
1675 * @param axis Flipping Axis(X or Y).
1676 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1677 * @return Resizable flip effect context data.
1680 * @warning Is higher recommended just create a transit with this effect when
1681 * the window that the objects of the transit belongs has already been created.
1682 * This is because this effect needs the geometry information about the objects,
1683 * and if the window was not created yet, it can get a wrong information.
1684 * @warning Is not recommended remove or add an object after the transit begins
1685 * to run, because the order of the objects will be affected.
1688 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1690 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1691 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1693 if (!effect_context) return NULL;
1694 elm_transit_effect_add(transit,
1695 _transit_effect_resizable_flip_op, effect_context,
1696 _transit_effect_resizable_flip_context_free);
1697 return effect_context;
1701 ///////////////////////////////////////////////////////////////////////////////
1703 ///////////////////////////////////////////////////////////////////////////////
1704 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1706 struct _Elm_Transit_Effect_Wipe
1708 Elm_Transit_Effect_Wipe_Type type;
1709 Elm_Transit_Effect_Wipe_Dir dir;
1713 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1719 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1720 w2 = w - (w * progress);
1722 evas_map_point_image_uv_set(map, 0, 0, 0);
1723 evas_map_point_image_uv_set(map, 1, w2, 0);
1724 evas_map_point_image_uv_set(map, 2, w2, h);
1725 evas_map_point_image_uv_set(map, 3, 0, h);
1726 evas_map_point_coord_set(map, 0, x, y, 0);
1727 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1728 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1729 evas_map_point_coord_set(map, 3, x, h2, 0);
1731 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1732 w2 = (w * progress);
1734 evas_map_point_image_uv_set(map, 0, w2, 0);
1735 evas_map_point_image_uv_set(map, 1, w, 0);
1736 evas_map_point_image_uv_set(map, 2, w, h);
1737 evas_map_point_image_uv_set(map, 3, w2, h);
1738 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1739 evas_map_point_coord_set(map, 1, x + w, y, 0);
1740 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1741 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1743 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1745 h2 = h - (h * progress);
1746 evas_map_point_image_uv_set(map, 0, 0, 0);
1747 evas_map_point_image_uv_set(map, 1, w, 0);
1748 evas_map_point_image_uv_set(map, 2, w, h2);
1749 evas_map_point_image_uv_set(map, 3, 0, h2);
1750 evas_map_point_coord_set(map, 0, x, y, 0);
1751 evas_map_point_coord_set(map, 1, w2, y, 0);
1752 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1753 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1755 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1757 h2 = (h * progress);
1758 evas_map_point_image_uv_set(map, 0, 0, h2);
1759 evas_map_point_image_uv_set(map, 1, w, h2);
1760 evas_map_point_image_uv_set(map, 2, w, h);
1761 evas_map_point_image_uv_set(map, 3, 0, h);
1762 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1763 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1764 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1765 evas_map_point_coord_set(map, 3, x, y + h, 0);
1770 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1774 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1780 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1781 w2 = (w - (w * progress));
1783 evas_map_point_image_uv_set(map, 0, w2, 0);
1784 evas_map_point_image_uv_set(map, 1, w, 0);
1785 evas_map_point_image_uv_set(map, 2, w, h);
1786 evas_map_point_image_uv_set(map, 3, w2, h);
1787 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1788 evas_map_point_coord_set(map, 1, w, y, 0);
1789 evas_map_point_coord_set(map, 2, w, h2, 0);
1790 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1792 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1793 w2 = (w * progress);
1795 evas_map_point_image_uv_set(map, 0, 0, 0);
1796 evas_map_point_image_uv_set(map, 1, w2, 0);
1797 evas_map_point_image_uv_set(map, 2, w2, h);
1798 evas_map_point_image_uv_set(map, 3, 0, h);
1799 evas_map_point_coord_set(map, 0, x, y, 0);
1800 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1801 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1802 evas_map_point_coord_set(map, 3, x, h2, 0);
1804 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1806 h2 = (h - (h * progress));
1807 evas_map_point_image_uv_set(map, 0, 0, h2);
1808 evas_map_point_image_uv_set(map, 1, w, h2);
1809 evas_map_point_image_uv_set(map, 2, w, h);
1810 evas_map_point_image_uv_set(map, 3, 0, h);
1811 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1812 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1813 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1814 evas_map_point_coord_set(map, 3, x, y + h, 0);
1816 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1818 h2 = (h * progress);
1819 evas_map_point_image_uv_set(map, 0, 0, 0);
1820 evas_map_point_image_uv_set(map, 1, w, 0);
1821 evas_map_point_image_uv_set(map, 2, w, h2);
1822 evas_map_point_image_uv_set(map, 3, 0, h2);
1823 evas_map_point_coord_set(map, 0, x, y, 0);
1824 evas_map_point_coord_set(map, 1, w2, y, 0);
1825 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1826 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1831 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1835 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1837 EINA_SAFETY_ON_NULL_RETURN(data);
1838 EINA_SAFETY_ON_NULL_RETURN(transit);
1841 Elm_Transit_Effect_Wipe *wipe = data;
1842 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1844 EINA_LIST_FOREACH(transit->objs, elist, obj)
1846 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1847 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1848 evas_object_show(obj);
1849 else evas_object_hide(obj);
1850 evas_object_map_enable_set(obj, EINA_FALSE);
1857 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1859 EINA_SAFETY_ON_NULL_RETURN(data);
1860 EINA_SAFETY_ON_NULL_RETURN(transit);
1861 Elm_Transit_Effect_Wipe *wipe = data;
1863 Evas_Coord _x, _y, _w, _h;
1867 map = evas_map_new(4);
1870 evas_map_smooth_set(map, EINA_TRUE);
1872 EINA_LIST_FOREACH(transit->objs, elist, obj)
1874 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1876 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1877 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1879 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1881 evas_object_map_enable_set(obj, EINA_TRUE);
1882 evas_object_map_set(obj, map);
1888 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1890 Elm_Transit_Effect_Wipe *wipe;
1892 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1893 if (!wipe) return NULL;
1902 * Add the Wipe Effect to Elm_Transit.
1904 * @note This API is one of the facades. It creates wipe effect context
1905 * and add it's required APIs to elm_transit_effect_add.
1906 * @note This effect will be applied to the objects that are in the transit,
1907 * If you change the set of objects in the transit with elm_transit_object_add()
1908 * or elm_transit_object_remove(), the set of objects affected by this effect
1909 * will be changed too.
1911 * @see elm_transit_effect_add()
1913 * @param transit Transit object.
1914 * @param type Wipe type. Hide or show.
1915 * @param dir Wipe Direction.
1916 * @return Wipe effect context data.
1919 * @warning Is higher recommended just create a transit with this effect when
1920 * the window that the objects of the transit belongs has already been created.
1921 * This is because this effect needs the geometry information about the objects,
1922 * and if the window was not created yet, it can get a wrong information.
1923 * @warning Is not recommended remove or add an object after the transit begins
1924 * to run, because the order of the objects will be affected.
1927 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1929 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1930 void *effect_context = _transit_effect_wipe_context_new(type, dir);
1932 if (!effect_context) return NULL;
1933 elm_transit_effect_add(transit,
1934 _transit_effect_wipe_op, effect_context,
1935 _transit_effect_wipe_context_free);
1936 return effect_context;
1940 ///////////////////////////////////////////////////////////////////////////////
1942 ///////////////////////////////////////////////////////////////////////////////
1943 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1945 struct _Elm_Transit_Effect_Color
1947 struct _unsigned_color {
1948 unsigned int r, g, b, a;
1950 struct _signed_color {
1956 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
1962 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
1964 EINA_SAFETY_ON_NULL_RETURN(data);
1965 EINA_SAFETY_ON_NULL_RETURN(transit);
1966 Elm_Transit_Effect_Color *color = data;
1969 unsigned int r, g, b, a;
1971 r = (color->from.r + (int)((float)color->to.r * progress));
1972 g = (color->from.g + (int)((float)color->to.g * progress));
1973 b = (color->from.b + (int)((float)color->to.b * progress));
1974 a = (color->from.a + (int)((float)color->to.a * progress));
1976 EINA_LIST_FOREACH(transit->objs, elist, obj)
1977 evas_object_color_set(obj, r, g, b, a);
1981 _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)
1983 Elm_Transit_Effect_Color *color;
1985 color = ELM_NEW(Elm_Transit_Effect_Color);
1986 if (!color) return NULL;
1988 color->from.r = from_r;
1989 color->from.g = from_g;
1990 color->from.b = from_b;
1991 color->from.a = from_a;
1992 color->to.r = to_r - from_r;
1993 color->to.g = to_g - from_g;
1994 color->to.b = to_b - from_b;
1995 color->to.a = to_a - from_a;
2001 * Add the Color Effect to Elm_Transit.
2003 * @note This API is one of the facades. It creates color effect context
2004 * and add it's required APIs to elm_transit_effect_add.
2005 * @note This effect will be applied to the objects that are in the transit,
2006 * If you change the set of objects in the transit with elm_transit_object_add()
2007 * or elm_transit_object_remove(), the set of objects affected by this effect
2008 * will be changed too.
2010 * @see elm_transit_effect_add()
2012 * @param transit Transit object.
2013 * @param from_r RGB R when effect begins.
2014 * @param from_g RGB G when effect begins.
2015 * @param from_b RGB B when effect begins.
2016 * @param from_a RGB A when effect begins.
2017 * @param to_r RGB R when effect ends.
2018 * @param to_g RGB G when effect ends.
2019 * @param to_b RGB B when effect ends.
2020 * @param to_a RGB A when effect ends.
2021 * @return Color effect context data.
2026 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)
2028 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2029 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
2031 if (!effect_context) return NULL;
2032 elm_transit_effect_add(transit,
2033 _transit_effect_color_op, effect_context,
2034 _transit_effect_color_context_free);
2035 return effect_context;
2038 ///////////////////////////////////////////////////////////////////////////////
2040 ///////////////////////////////////////////////////////////////////////////////
2041 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2042 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2044 struct _Elm_Transit_Effect_Fade_Node
2046 Evas_Object *before;
2048 struct _signed_color before_color, after_color;
2051 Eina_Bool inversed : 1;
2054 struct _Elm_Transit_Effect_Fade
2060 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2062 Elm_Transit_Effect_Fade *fade = data;
2064 Elm_Transit_Effect_Fade_Node *fade_node;
2066 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2068 if (fade_node->before == obj)
2069 evas_object_event_callback_del(fade_node->after,
2070 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2071 else if (fade_node->after == obj)
2072 evas_object_event_callback_del(fade_node->before,
2073 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2076 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2083 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2085 Elm_Transit_Effect_Fade_Node *fade;
2086 Eina_List *data_list = NULL;
2089 count = eina_list_count(transit->objs);
2090 for (i = 0; i < (count - 1); i += 2)
2092 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2095 eina_list_free(data_list);
2099 fade->before = eina_list_nth(transit->objs, i);
2100 fade->after = eina_list_nth(transit->objs, i+1);
2102 evas_object_color_get(fade->before,
2103 &fade->before_color.r, &fade->before_color.g,
2104 &fade->before_color.b, &fade->before_color.a);
2105 evas_object_color_get(fade->after,
2106 &fade->after_color.r, &fade->after_color.g,
2107 &fade->after_color.b, &fade->after_color.a);
2109 fade->before_alpha = (255 - fade->before_color.a);
2110 fade->after_alpha = (255 - fade->after_color.a);
2112 data_list = eina_list_append(data_list, fade);
2114 evas_object_event_callback_add(fade->before,
2115 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2116 evas_object_event_callback_add(fade->after,
2117 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2123 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2125 EINA_SAFETY_ON_NULL_RETURN(data);
2126 Elm_Transit_Effect_Fade *fade = data;
2127 Elm_Transit_Effect_Fade_Node *fade_node;
2128 Eina_List *elist, *elist_next;
2130 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2132 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2133 fade_node->before_color.g,
2134 fade_node->before_color.b,
2135 fade_node->before_color.a);
2136 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2137 fade_node->after_color.g,
2138 fade_node->after_color.b,
2139 fade_node->after_color.a);
2141 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2142 evas_object_event_callback_del(fade_node->before,
2143 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2144 evas_object_event_callback_del(fade_node->after,
2145 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2153 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2155 EINA_SAFETY_ON_NULL_RETURN(data);
2156 Elm_Transit_Effect_Fade *fade = data;
2158 Elm_Transit_Effect_Fade_Node *fade_node;
2162 fade->nodes = _fade_nodes_build(transit, fade);
2164 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2168 if (!fade_node->inversed)
2170 evas_object_hide(fade_node->after);
2171 evas_object_show(fade_node->before);
2172 fade_node->inversed = EINA_TRUE;
2175 _progress = (1 - (progress * 2));
2177 evas_object_color_set(fade_node->before,
2178 fade_node->before_color.r * _progress,
2179 fade_node->before_color.g * _progress,
2180 fade_node->before_color.b * _progress,
2181 fade_node->before_color.a +
2182 fade_node->before_alpha * (1 - _progress));
2186 if (fade_node->inversed)
2188 evas_object_hide(fade_node->before);
2189 evas_object_show(fade_node->after);
2190 fade_node->inversed = EINA_FALSE;
2193 _progress = ((progress - 0.5) * 2);
2195 evas_object_color_set(fade_node->after,
2196 fade_node->after_color.r * _progress,
2197 fade_node->after_color.g * _progress,
2198 fade_node->after_color.b * _progress,
2199 fade_node->after_color.a +
2200 fade_node->after_alpha * (1 - _progress));
2206 _transit_effect_fade_context_new(void)
2208 Elm_Transit_Effect_Fade *fade;
2209 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2210 if (!fade) return NULL;
2215 * Add the Fade Effect to Elm_Transit.
2217 * @note This API is one of the facades. It creates fade effect context
2218 * and add it's required APIs to elm_transit_effect_add.
2219 * @note This effect is applied to each pair of objects in the order they are listed
2220 * in the transit list of objects. The first object in the pair will be the
2221 * "before" object and the second will be the "after" object.
2222 * @note When this function is called, it gets the current objects in
2223 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2224 * will not cause any changes in the set of objects that this effect is being
2227 * @see elm_transit_effect_add()
2229 * @param transit Transit object.
2230 * @return Fade effect context data.
2233 * @warning Is higher recommended just create a transit with this effect when
2234 * the window that the objects of the transit belongs has already been created.
2235 * This is because this effect needs the color information about the objects,
2236 * and if the window was not created yet, it can get a wrong information.
2237 * @warning Is not recommended remove or add an object after the transit begins
2238 * to run, because the order of the objects will be affected.
2241 elm_transit_effect_fade_add(Elm_Transit *transit)
2243 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2245 void *effect_context = _transit_effect_fade_context_new();
2246 if (!effect_context) return NULL;
2247 elm_transit_effect_add(transit,
2248 _transit_effect_fade_op, effect_context,
2249 _transit_effect_fade_context_free);
2250 return effect_context;
2254 ///////////////////////////////////////////////////////////////////////////////
2256 ///////////////////////////////////////////////////////////////////////////////
2257 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2258 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2260 struct _Elm_Transit_Effect_Blend_Node
2262 Evas_Object *before;
2264 struct _signed_color from, to;
2267 struct _Elm_Transit_Effect_Blend
2273 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2275 Elm_Transit_Effect_Blend *blend = data;
2277 Elm_Transit_Effect_Blend_Node *blend_node;
2279 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2281 if (blend_node->after == obj)
2282 evas_object_event_callback_del(blend_node->before,
2283 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2284 else if (blend_node->before == obj)
2285 evas_object_event_callback_del(blend_node->after,
2286 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2289 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2296 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2298 Elm_Transit_Effect_Blend_Node *blend_node;
2299 Eina_List *data_list = NULL;
2302 count = eina_list_count(transit->objs);
2303 for (i = 0; i < (count - 1); i += 2)
2305 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2308 eina_list_free(data_list);
2312 blend_node->before = eina_list_nth(transit->objs, i);
2313 blend_node->after = eina_list_nth(transit->objs, i + 1);
2314 evas_object_show(blend_node->before);
2315 evas_object_show(blend_node->after);
2317 evas_object_color_get(blend_node->before, &blend_node->from.r,
2318 &blend_node->from.g, &blend_node->from.b,
2319 &blend_node->from.a);
2320 evas_object_color_get(blend_node->after, &blend_node->to.r,
2321 &blend_node->to.g, &blend_node->to.b,
2324 data_list = eina_list_append(data_list, blend_node);
2326 evas_object_event_callback_add(blend_node->before,
2327 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2328 evas_object_event_callback_add(blend_node->after,
2329 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2335 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2337 EINA_SAFETY_ON_NULL_RETURN(data);
2338 Elm_Transit_Effect_Blend *blend = data;
2339 Elm_Transit_Effect_Blend_Node *blend_node;
2340 Eina_List *elist, *elist_next;
2342 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2344 evas_object_color_set(blend_node->before,
2345 blend_node->from.r, blend_node->from.g,
2346 blend_node->from.b, blend_node->from.a);
2347 evas_object_color_set(blend_node->after, blend_node->to.r,
2348 blend_node->to.g, blend_node->to.b,
2351 if (elm_transit_auto_reverse_get(transit))
2352 evas_object_hide(blend_node->after);
2354 evas_object_hide(blend_node->before);
2356 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2358 evas_object_event_callback_del(blend_node->before,
2359 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2360 evas_object_event_callback_del(blend_node->after,
2361 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2368 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2370 EINA_SAFETY_ON_NULL_RETURN(data);
2371 EINA_SAFETY_ON_NULL_RETURN(transit);
2372 Elm_Transit_Effect_Blend *blend = data;
2373 Elm_Transit_Effect_Blend_Node *blend_node;
2376 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2378 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2380 evas_object_color_set(blend_node->before,
2381 (int)(blend_node->from.r * (1 - progress)),
2382 (int)(blend_node->from.g * (1 - progress)),
2383 (int)(blend_node->from.b * (1 - progress)),
2384 (int)(blend_node->from.a * (1 - progress)));
2385 evas_object_color_set(blend_node->after,
2386 (int)(blend_node->to.r * progress),
2387 (int)(blend_node->to.g * progress),
2388 (int)(blend_node->to.b * progress),
2389 (int)(blend_node->to.a * progress));
2394 _transit_effect_blend_context_new(void)
2396 Elm_Transit_Effect_Blend *blend;
2398 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2399 if (!blend) return NULL;
2404 * Add the Blend Effect to Elm_Transit.
2406 * @note This API is one of the facades. It creates blend effect context
2407 * and add it's required APIs to elm_transit_effect_add.
2408 * @note This effect is applied to each pair of objects in the order they are listed
2409 * in the transit list of objects. The first object in the pair will be the
2410 * "before" object and the second will be the "after" object.
2411 * @note When this function be called, it gets the current objects in
2412 * the transit, that is, elm_transit_object_remove() and elm_transit_object_add()
2413 * will not cause any changes in the set of objects that this effect is being
2416 * @see elm_transit_effect_add()
2418 * @param transit Transit object.
2419 * @return Blend effect context data.
2422 * @warning Is higher recommended just create a transit with this effect when
2423 * the window that the objects of the transit belongs has already been created.
2424 * This is because this effect needs the color information about the objects,
2425 * and if the window was not created yet, it can get a wrong information.
2426 * @warning Is not recommended remove or add an object after the transit begins
2427 * to run, because the order of the objects will be affected.
2430 elm_transit_effect_blend_add(Elm_Transit *transit)
2432 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2433 void *effect_context = _transit_effect_blend_context_new();
2435 if (!effect_context) return NULL;
2436 elm_transit_effect_add(transit,
2437 _transit_effect_blend_op, effect_context,
2438 _transit_effect_blend_context_free);
2439 return effect_context;
2443 ///////////////////////////////////////////////////////////////////////////////
2445 ///////////////////////////////////////////////////////////////////////////////
2446 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2448 struct _Elm_Transit_Effect_Rotation
2454 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2460 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2462 EINA_SAFETY_ON_NULL_RETURN(data);
2463 EINA_SAFETY_ON_NULL_RETURN(transit);
2464 Elm_Transit_Effect_Rotation *rotation = data;
2466 Evas_Coord x, y, w, h;
2468 float half_w, half_h;
2472 map = evas_map_new(4);
2475 evas_map_smooth_set(map, EINA_TRUE);
2477 EINA_LIST_FOREACH(transit->objs, elist, obj)
2479 evas_map_util_points_populate_from_object_full(map, obj, 0);
2480 degree = rotation->from + (float)(progress * rotation->to);
2482 evas_object_geometry_get(obj, &x, &y, &w, &h);
2484 half_w = (float)w * 0.5;
2485 half_h = (float)h * 0.5;
2487 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2488 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2489 evas_object_map_enable_set(obj, EINA_TRUE);
2490 evas_object_map_set(obj, map);
2496 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2498 Elm_Transit_Effect_Rotation *rotation;
2500 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2501 if (!rotation) return NULL;
2503 rotation->from = from_degree;
2504 rotation->to = to_degree - from_degree;
2510 * Add the Rotation Effect to Elm_Transit.
2512 * @note This API is one of the facades. It creates rotation effect context
2513 * and add it's required APIs to elm_transit_effect_add.
2514 * @note This effect will be applied to the objects that are in the transit,
2515 * If you change the set of objects in the transit with elm_transit_object_add()
2516 * or elm_transit_object_remove(), the set of objects affected by this effect
2517 * will be changed too.
2519 * @see elm_transit_effect_add()
2521 * @param transit Transit object.
2522 * @param from_degree Degree when effect begins.
2523 * @param to_degree Degree when effect is ends.
2524 * @return Rotation effect context data.
2527 * @warning Is higher recommended just create a transit with this effect when
2528 * the window that the objects of the transit belongs has already been created.
2529 * This is because this effect needs the geometry information about the objects,
2530 * and if the window was not created yet, it can get a wrong information.
2531 * @warning Is not recommended remove or add an object after the transit begins
2532 * to run, because the order of the objects will be affected.
2535 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2537 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2538 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2540 if (!effect_context) return NULL;
2541 elm_transit_effect_add(transit,
2542 _transit_effect_rotation_op, effect_context,
2543 _transit_effect_rotation_context_free);
2544 return effect_context;
2548 ///////////////////////////////////////////////////////////////////////////////
2549 // ImageAnimation FX
2550 ///////////////////////////////////////////////////////////////////////////////
2551 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2553 struct _Elm_Transit_Effect_Image_Animation
2559 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2561 EINA_SAFETY_ON_NULL_RETURN(data);
2562 Elm_Transit_Effect_Image_Animation *image_animation = data;
2564 Eina_List *elist, *elist_next;
2566 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2568 image_animation->images =
2569 eina_list_remove_list(image_animation->images, elist);
2570 eina_stringshare_del(image);
2577 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2579 EINA_SAFETY_ON_NULL_RETURN(data);
2580 EINA_SAFETY_ON_NULL_RETURN(transit);
2584 Elm_Transit_Effect_Image_Animation *image_animation = data;
2585 unsigned int count = 0;
2588 type = eina_stringshare_add("icon");
2589 len = eina_list_count(image_animation->images);
2591 if (!len) count = floor(progress * len);
2592 else count = floor(progress * (len - 1));
2594 EINA_LIST_FOREACH(transit->objs, elist, obj)
2596 if (elm_widget_type_check(obj, type))
2597 elm_icon_file_set(obj,
2598 eina_list_nth(image_animation->images, count), NULL);
2601 eina_stringshare_del(type);
2605 _transit_effect_image_animation_context_new(Eina_List *images)
2607 Elm_Transit_Effect_Image_Animation *image_animation;
2608 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2610 if (!image_animation) return NULL;
2611 image_animation->images = images;
2612 return image_animation;
2616 * Add the Rotation Effect to Elm_Transit.
2618 * @note This API is one of the facades. It creates image animation effect context
2619 * and add it's required APIs to elm_transit_effect_add.
2620 * The @p images parameter is a list images paths. This list and
2621 * its contents will be deleted at the end of the effect by
2622 * elm_transit_effect_image_animation_context_free() function.
2623 * @note This effect will be applied to the objects that are in the transit,
2624 * If you change the set of objects in the transit with elm_transit_object_add()
2625 * or elm_transit_object_remove(), the set of objects affected by this effect
2626 * will be changed too.
2630 * char buf[PATH_MAX];
2631 * Eina_List *images = NULL;
2632 * Elm_Transit *transi = elm_transit_add();
2634 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2635 * images = eina_list_append(images, eina_stringshare_add(buf));
2637 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2638 * images = eina_list_append(images, eina_stringshare_add(buf));
2639 * elm_transit_effect_image_animation_add(transi, images);
2643 * @see elm_transit_effect_add()
2645 * @param transit Transit object.
2646 * @param images Eina_List of images file paths. This list and
2647 * its contents will be deleted at the end of the effect by
2648 * elm_transit_effect_image_animation_context_free() function.
2649 * @return Image Animation effect context data.
2654 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2656 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2657 void *effect_context = _transit_effect_image_animation_context_new(images);
2659 if (!effect_context) return NULL;
2660 elm_transit_effect_add(transit,
2661 _transit_effect_image_animation_op, effect_context,
2662 _transit_effect_image_animation_context_free);
2663 return effect_context;