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)
349 if ((effect->animation_op == cb) && (effect->user_data == data)) return;
351 effect = ELM_NEW(Elm_Transit_Effect);
354 effect->user_data_free = data_free_cb;
355 effect->animation_op = cb;
356 effect->user_data = data;
358 transit->effect_list = eina_list_append(transit->effect_list, effect);
362 * Delete an added effect.
364 * This function will remove the effect from the @p transit, calling the
365 * data_free_cb to free the @p data.
367 * @see elm_transit_effect_add()
369 * @note If the effect is not found, nothing is done.
370 * @note If the effect list become empty, this function will call
371 * elm_transit_del(transit), that is, it will kill the @p transit.
373 * @param transit The transit object.
374 * @param cb The operation function.
375 * @param data The context data of the effect.
380 elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data)
382 ELM_TRANSIT_CHECK_OR_RETURN(transit);
383 EINA_SAFETY_ON_NULL_RETURN(cb);
384 Eina_List *elist, *elist_next;
385 Elm_Transit_Effect *effect;
387 EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect)
389 if ((effect->animation_op == cb) && (effect->user_data == data))
391 if (transit->walking)
393 effect->deleted = EINA_TRUE;
394 transit->effects_pending_del++;
398 _elm_transit_effect_del(transit, effect, elist);
399 if (!transit->effect_list) elm_transit_del(transit);
407 * Add new object to apply the effects.
409 * @note After the first addition of an object in @p transit, if its
410 * object list become empty again, the @p transit will be killed by
411 * elm_transit_del(transit) function.
412 * @note If the @p obj belongs to another transit, the @p obj will be
413 * removed from it and it will only belong to the @p transit. If the old
414 * transit stays without objects, it will die.
415 * @note When you add an object into the @p transit, its state from
416 * evas_object_pass_events_get(obj) is saved, and it is applied when the
417 * transit ends, if you change this state whith evas_object_pass_events_set()
418 * after add the object, this state will change again when @p transit stops to
421 * @param transit The transit object.
422 * @param obj Object to be animated.
425 * @warning It is not allowed to add a new object after transit begins to go.
428 elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
430 ELM_TRANSIT_CHECK_OR_RETURN(transit);
431 EINA_SAFETY_ON_NULL_RETURN(obj);
432 Elm_Obj_Data *obj_data;
434 if (transit->animator) return;
436 obj_data = evas_object_data_get(obj, _transit_key);
440 if (obj_data->transit == transit) return;
441 elm_transit_object_remove(obj_data->transit, obj);
444 obj_data = ELM_NEW(Elm_Obj_Data);
445 obj_data->state = evas_object_pass_events_get(obj);
446 obj_data->transit = transit;
447 evas_object_data_set(obj, _transit_key, obj_data);
449 transit->objs = eina_list_append(transit->objs, obj);
451 if (!transit->event_enabled)
452 evas_object_pass_events_set(obj, EINA_TRUE);
454 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
455 _elm_transit_object_remove_cb, transit);
459 * Removes an added object from the transit.
461 * @note If the @p obj is not in the @p transit, nothing is done.
462 * @note If the list become empty, this function will call
463 * elm_transit_del(transit), that is, it will kill the @p transit.
465 * @param transit The transit object.
466 * @param obj Object to be removed from @p transit.
469 * @warning It is not allowed to remove objects after transit begins to go.
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;
478 if (transit->animator) return;
480 obj_data = evas_object_data_get(obj, _transit_key);
482 if ((!obj_data) || (obj_data->transit != transit)) return;
484 _elm_transit_object_remove(transit, obj);
485 if (!transit->objs) elm_transit_del(transit);
489 * Get the objects of the transit.
491 * @param transit The transit object.
492 * @return a Eina_List with the objects from the transit.
496 EAPI const Eina_List *
497 elm_transit_objects_get(const Elm_Transit *transit)
499 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
500 return transit->objs;
504 * Set the event enabled when transit is operating.
506 * If @p enabled is EINA_TRUE, the objects of the transit will receives
507 * events from mouse and keyboard during the animation.
508 * @note When you add an object with elm_transit_object_add(), its state from
509 * evas_object_pass_events_get(obj) is saved, and it is applied when the
510 * transit ends, if you change this state with evas_object_pass_events_set()
511 * after add the object, this state will change again when @p transit stops to
514 * @param transit The transit object.
515 * @param enabled Disable or enable.
520 elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
522 ELM_TRANSIT_CHECK_OR_RETURN(transit);
525 Elm_Obj_Data *obj_data;
527 if (transit->event_enabled == enabled) return;
529 transit->event_enabled = !!enabled;
533 EINA_LIST_FOREACH(transit->objs, elist, obj)
535 obj_data = evas_object_data_get(obj, _transit_key);
536 evas_object_pass_events_set(obj, obj_data->state);
541 EINA_LIST_FOREACH(transit->objs, elist, obj)
542 evas_object_pass_events_set(obj, EINA_TRUE);
547 * Get the value of event enabled status.
549 * @see elm_transit_event_enabled_set()
551 * @param transit The Transit object
552 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
553 * EINA_FALSE is returned
558 elm_transit_event_enabled_get(const Elm_Transit *transit)
560 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
561 return transit->event_enabled;
566 * Set the event enabled when transit is operating.
568 * If @p disabled is EINA_TRUE, the objects of the transit will receives
569 * events from mouse and keyboard during the animation.
570 * @note When you add an object with elm_transit_object_add(), its state from
571 * evas_object_pass_events_get(obj) is saved, and it is applied when the
572 * transit ends, if you change this state with evas_object_pass_events_set()
573 * after add the object, this state will change again when @p transit stops to
576 * @see elm_transit_event_enabled_set()
578 * @param transit The transit object.
579 * @param disabled Disable or enable.
583 EINA_DEPRECATED EAPI void
584 elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled)
586 elm_transit_event_enabled_set(transit, disabled);
591 * Get the value of event block enabled status.
593 * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get()
595 * @param transit The Transit object
596 * @return EINA_TRUE, when event is enabled. If @p transit is NULL
597 * EINA_FALSE is returned
601 EINA_DEPRECATED EAPI Eina_Bool
602 elm_transit_event_block_get(const Elm_Transit *transit)
604 return !elm_transit_event_enabled_get(transit);
608 * Set the user-callback function when the transit is deleted.
610 * @note Using this function twice will overwrite the first function setted.
611 * @note the @p transit object will be deleted after call @p cb function.
613 * @param transit The transit object.
614 * @param cb Callback function pointer. This function will be called before
615 * the deletion of the transit.
616 * @param data Callback funtion user data. It is the @p op parameter.
621 elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data)
623 ELM_TRANSIT_CHECK_OR_RETURN(transit);
624 transit->del_data.func = cb;
625 transit->del_data.arg = data;
629 * Set reverse effect automatically.
631 * If auto reverse is setted, after running the effects with the progress
632 * parameter from 0 to 1, it will call the effecs again with the progress
633 * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat),
634 * where the duration was setted with the function elm_transit_add and
635 * the repeat with the function elm_transit_repeat_times_set().
637 * @param transit The transit object.
638 * @param reverse EINA_TRUE means the auto_reverse is on.
643 elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse)
645 ELM_TRANSIT_CHECK_OR_RETURN(transit);
646 transit->auto_reverse = reverse;
650 * Get if the auto reverse is on.
652 * @see elm_transit_auto_reverse_set()
654 * @param transit The transit object.
655 * @return EINA_TRUE means auto reverse is on. If @p transit is NULL
656 * EINA_FALSE is returned
661 elm_transit_auto_reverse_get(Elm_Transit *transit)
663 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
664 return transit->auto_reverse;
668 * Set the transit repeat count. Effect will be repeated by repeat count.
670 * This function sets the number of repetition the transit will run after
671 * the first one, that is, if @p repeat is 1, the transit will run 2 times.
672 * If the @p repeat is a negative number, it will repeat infinite times.
674 * @note If this function is called during the transit execution, the transit
675 * will run @p repeat times, ignoring the times it already performed.
677 * @param transit The transit object
678 * @param repeat Repeat count
683 elm_transit_repeat_times_set(Elm_Transit *transit, int repeat)
685 ELM_TRANSIT_CHECK_OR_RETURN(transit);
686 transit->repeat.count = repeat;
687 transit->repeat.current = 0;
691 * Get the transit repeat count.
693 * @see elm_transit_repeat_times_set()
695 * @param transit The Transit object.
696 * @return The repeat count. If @p transit is NULL
702 elm_transit_repeat_times_get(Elm_Transit *transit)
704 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
705 return transit->repeat.count;
709 * Set the transit animation acceleration type.
711 * This function sets the tween mode of the transit that can be:
712 * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode.
713 * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating.
714 * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time.
715 * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time.
717 * @param transit The transit object.
718 * @param tween_mode The tween type.
723 elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode)
725 ELM_TRANSIT_CHECK_OR_RETURN(transit);
726 transit->tween_mode = tween_mode;
730 * Get the transit animation acceleration type.
732 * @note @p transit can not be NULL
734 * @param transit The transit object.
735 * @return The tween type. If @p transit is NULL
736 * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned.
740 EAPI Elm_Transit_Tween_Mode
741 elm_transit_tween_mode_get(const Elm_Transit *transit)
743 ELM_TRANSIT_CHECK_OR_RETURN(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
744 return transit->tween_mode;
748 * Set the transit animation time
750 * @note @p transit can not be NULL
752 * @param transit The transit object.
753 * @param duration The animation time.
758 elm_transit_duration_set(Elm_Transit *transit, double duration)
760 ELM_TRANSIT_CHECK_OR_RETURN(transit);
761 if (transit->animator) return;
762 transit->time.duration = duration;
766 * Get the transit animation time
768 * @note @p transit can not be NULL
770 * @param transit The transit object.
772 * @return The transit animation time.
777 elm_transit_duration_get(const Elm_Transit *transit)
779 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0);
780 return transit->time.duration;
784 * Starts the transition.
785 * Once this API is called, the transit begins to measure the time.
787 * @note @p transit can not be NULL
789 * @param transit The transit object.
794 elm_transit_go(Elm_Transit *transit)
796 ELM_TRANSIT_CHECK_OR_RETURN(transit);
798 if (transit->animator)
799 ecore_animator_del(transit->animator);
801 transit->time.paused = 0;
802 transit->time.delayed = 0;
803 transit->time.begin = ecore_loop_time_get();
804 transit->animator = ecore_animator_add(_animator_animate_cb, transit);
808 * Pause/Resume the transition.
809 * If you call elm_transit_go again, paused states will affect no anymore.
811 * @note @p transit can not be NULL
813 * @param transit The transit object.
818 elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused)
820 ELM_TRANSIT_CHECK_OR_RETURN(transit);
822 if (!transit->animator) return;
826 if (transit->time.paused > 0)
828 ecore_animator_freeze(transit->animator);
829 transit->time.paused = ecore_loop_time_get();
833 if (transit->time.paused == 0)
835 ecore_animator_thaw(transit->animator);
836 transit->time.delayed += (ecore_loop_time_get() - transit->time.paused);
837 transit->time.paused = 0;
842 * Get the value of paused status.
844 * @see elm_transit_paused_set()
846 * @note @p transit can not be NULL
848 * @param transit The transit object.
849 * @return EINA_TRUE means transition is paused. If @p transit is NULL
850 * EINA_FALSE is returned
855 elm_transit_paused_get(const Elm_Transit *transit)
857 ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE);
859 if (transit->time.paused == 0)
866 * Get the time progression of the animation (a double value between 0.0 and 1.0).
868 * @note @p transit can not be NULL
870 * @param transit The transit object.
872 * @return The time progression value. If @p transit is NULL
878 elm_transit_progress_value_get(const Elm_Transit *transit)
880 ELM_TRANSIT_CHECK_OR_RETURN(transit, 0);
881 return transit->progress;
884 ///////////////////////////////////////////////////////////////////////////////
886 ///////////////////////////////////////////////////////////////////////////////
887 typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing;
889 struct _Elm_Transit_Effect_Resizing
897 _transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__)
903 _transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress)
905 EINA_SAFETY_ON_NULL_RETURN(data);
906 EINA_SAFETY_ON_NULL_RETURN(transit);
910 Elm_Transit_Effect_Resizing *resizing = data;
912 w = resizing->from.w + (resizing->to.w * progress);
913 h = resizing->from.h + (resizing->to.h * progress);
915 EINA_LIST_FOREACH(transit->objs, elist, obj)
916 evas_object_resize(obj, w, h);
920 _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
922 Elm_Transit_Effect_Resizing *resizing;
924 resizing = ELM_NEW(Elm_Transit_Effect_Resizing);
925 if (!resizing) return NULL;
927 resizing->from.w = from_w;
928 resizing->from.h = from_h;
929 resizing->to.w = to_w - from_w;
930 resizing->to.h = to_h - from_h;
936 * Add the Resizing Effect to Elm_Transit.
938 * @note This API is one of the facades. It creates resizing effect context
939 * and add it's required APIs to elm_transit_effect_add.
941 * @see elm_transit_effect_add()
943 * @param transit Transit object.
944 * @param from_w Object width size when effect begins.
945 * @param from_h Object height size when effect begins.
946 * @param to_w Object width size when effect ends.
947 * @param to_h Object height size when effect ends.
948 * @return Resizing effect context data.
953 elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
955 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
956 void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h);
958 if (!effect_context) return NULL;
959 elm_transit_effect_add(transit,
960 _transit_effect_resizing_op, effect_context,
961 _transit_effect_resizing_context_free);
962 return effect_context;
965 ///////////////////////////////////////////////////////////////////////////////
967 ///////////////////////////////////////////////////////////////////////////////
968 typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation;
969 typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node;
971 struct _Elm_Transit_Effect_Translation_Node
977 struct _Elm_Transit_Effect_Translation
979 struct _position_variation {
986 _translation_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
988 Elm_Transit_Effect_Translation *translation = data;
990 Elm_Transit_Effect_Translation_Node *translation_node;
992 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
994 if (translation_node->obj != obj) continue;
995 translation->nodes = eina_list_remove_list(translation->nodes, elist);
996 free(translation_node);
1002 _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *translation)
1004 Elm_Transit_Effect_Translation_Node *translation_node;
1005 const Eina_List *elist;
1007 Eina_List *data_list = NULL;
1008 const Eina_List *objs = elm_transit_objects_get(transit);
1010 EINA_LIST_FOREACH(objs, elist, obj)
1012 translation_node = ELM_NEW(Elm_Transit_Effect_Translation_Node);
1013 if (!translation_node)
1015 eina_list_free(data_list);
1018 translation_node->obj = obj;
1019 evas_object_geometry_get(obj, &(translation_node->x),
1020 &(translation_node->y), NULL, NULL);
1021 data_list = eina_list_append(data_list, translation_node);
1022 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1023 _translation_object_del_cb, translation);
1029 _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__)
1031 EINA_SAFETY_ON_NULL_RETURN(data);
1032 Elm_Transit_Effect_Translation *translation = data;
1033 Eina_List *elist, *elist_next;
1034 Elm_Transit_Effect_Translation_Node *translation_node;
1036 EINA_LIST_FOREACH_SAFE(translation->nodes,
1037 elist, elist_next, translation_node)
1039 evas_object_event_callback_del(translation_node->obj,
1040 EVAS_CALLBACK_DEL, _translation_object_del_cb);
1041 translation->nodes = eina_list_remove_list(translation->nodes, elist);
1042 free(translation_node);
1048 _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__)
1050 EINA_SAFETY_ON_NULL_RETURN(data);
1051 EINA_SAFETY_ON_NULL_RETURN(transit);
1053 Elm_Transit_Effect_Translation *translation = data;
1054 Elm_Transit_Effect_Translation_Node *translation_node;
1057 if (!translation->nodes)
1058 translation->nodes = _translation_nodes_build(transit, translation);
1060 EINA_LIST_FOREACH(translation->nodes, elist, translation_node)
1062 x = translation_node->x + translation->from.dx
1063 + (translation->to.dx * progress);
1064 y = translation_node->y + translation->from.dy
1065 + (translation->to.dy * progress);
1066 evas_object_move(translation_node->obj, x, y);
1071 _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1073 Elm_Transit_Effect_Translation *translation;
1075 translation = ELM_NEW(Elm_Transit_Effect_Translation);
1076 if (!translation) return NULL;
1078 translation->from.dx = from_dx;
1079 translation->from.dy = from_dy;
1080 translation->to.dx = to_dx - from_dx;
1081 translation->to.dy = to_dy - from_dy;
1087 * Add the Translation Effect to Elm_Transit.
1089 * @note This API is one of the facades. It creates translation effect context
1090 * and add it's required APIs to elm_transit_effect_add.
1092 * @see elm_transit_effect_add()
1094 * @param transit Transit object.
1095 * @param from_dx X Position variation when effect begins.
1096 * @param from_dy Y Position variation when effect begins.
1097 * @param to_dx X Position variation when effect ends.
1098 * @param to_dy Y Position variation when effect ends.
1099 * @return Translation effect context data.
1102 * @warning Is higher recommended just create a transit with this effect when
1103 * the window that the objects of the transit belongs has already been created.
1104 * This is because this effect needs the geometry information about the objects,
1105 * and if the window was not created yet, it can get a wrong information.
1108 elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy)
1110 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1111 void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy);
1113 if (!effect_context) return NULL;
1114 elm_transit_effect_add(transit,
1115 _transit_effect_translation_op, effect_context,
1116 _transit_effect_translation_context_free);
1117 return effect_context;
1121 ///////////////////////////////////////////////////////////////////////////////
1123 ///////////////////////////////////////////////////////////////////////////////
1124 typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom;
1126 struct _Elm_Transit_Effect_Zoom
1132 _transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__)
1138 _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress)
1140 EINA_SAFETY_ON_NULL_RETURN(data);
1141 EINA_SAFETY_ON_NULL_RETURN(transit);
1144 Elm_Transit_Effect_Zoom *zoom = data;
1146 Evas_Coord x, y, w, h;
1148 map = evas_map_new(4);
1151 EINA_LIST_FOREACH(transit->objs, elist, obj)
1153 evas_object_geometry_get(obj, &x, &y, &w, &h);
1154 evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
1155 (progress * zoom->to));
1156 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1157 evas_object_map_set(obj, map);
1158 evas_object_map_enable_set(obj, EINA_TRUE);
1164 _transit_effect_zoom_context_new(float from_rate, float to_rate)
1166 Elm_Transit_Effect_Zoom *zoom;
1168 zoom = ELM_NEW(Elm_Transit_Effect_Zoom);
1169 if (!zoom) return NULL;
1171 zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate);
1172 zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from;
1178 * Add the Zoom Effect to Elm_Transit.
1180 * @note This API is one of the facades. It creates zoom effect context
1181 * and add it's required APIs to elm_transit_effect_add.
1183 * @see elm_transit_effect_add()
1185 * @param transit Transit object.
1186 * @param from_rate Scale rate when effect begins (1 is current rate).
1187 * @param to_rate Scale rate when effect ends.
1188 * @return Zoom effect context data.
1191 * @warning Is higher recommended just create a transit with this effect when
1192 * the window that the objects of the transit belongs has already been created.
1193 * This is because this effect needs the geometry information about the objects,
1194 * and if the window was not created yet, it can get a wrong information.
1197 elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate)
1199 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1200 void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate);
1202 if (!effect_context) return NULL;
1203 elm_transit_effect_add(transit,
1204 _transit_effect_zoom_op, effect_context,
1205 _transit_effect_zoom_context_free);
1206 return effect_context;
1210 ///////////////////////////////////////////////////////////////////////////////
1212 ///////////////////////////////////////////////////////////////////////////////
1213 typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip;
1215 struct _Elm_Transit_Effect_Flip
1217 Elm_Transit_Effect_Flip_Axis axis;
1222 _transit_effect_flip_context_free(void *data, Elm_Transit *transit)
1224 EINA_SAFETY_ON_NULL_RETURN(data);
1225 EINA_SAFETY_ON_NULL_RETURN(transit);
1226 Evas_Object *front, *back;
1228 int count = eina_list_count(transit->objs);
1230 for (i = 0; i < (count - 1); i += 2)
1232 front = eina_list_nth(transit->objs, i);
1233 back = eina_list_nth(transit->objs, i+1);
1234 evas_object_map_enable_set(front, EINA_FALSE);
1235 evas_object_map_enable_set(back, EINA_FALSE);
1241 _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress)
1243 EINA_SAFETY_ON_NULL_RETURN(data);
1244 EINA_SAFETY_ON_NULL_RETURN(transit);
1245 Evas_Object *obj, *front, *back;
1247 Elm_Transit_Effect_Flip *flip = data;
1250 Evas_Coord x, y, w, h;
1252 map = evas_map_new(4);
1255 if (flip->cw) degree = (float)(progress * 180);
1256 else degree = (float)(progress * -180);
1258 count = eina_list_count(transit->objs);
1259 for (i = 0; i < (count - 1); i += 2)
1261 Evas_Coord half_w, half_h;
1263 front = eina_list_nth(transit->objs, i);
1264 back = eina_list_nth(transit->objs, i+1);
1266 if ((degree < 90) && (degree > -90))
1271 evas_object_hide(back);
1272 evas_object_show(front);
1280 evas_object_hide(front);
1281 evas_object_show(back);
1285 evas_map_util_points_populate_from_object_full(map, obj, 0);
1286 evas_object_geometry_get(obj, &x, &y, &w, &h);
1290 if (flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1292 if ((degree >= 90) || (degree <= -90))
1294 evas_map_point_image_uv_set(map, 0, w, 0);
1295 evas_map_point_image_uv_set(map, 1, 0, 0);
1296 evas_map_point_image_uv_set(map, 2, 0, h);
1297 evas_map_point_image_uv_set(map, 3, w, h);
1299 evas_map_util_3d_rotate(map, 0, degree,
1300 0, x + half_w, y + half_h, 0);
1304 if ((degree >= 90) || (degree <= -90))
1306 evas_map_point_image_uv_set(map, 0, 0, h);
1307 evas_map_point_image_uv_set(map, 1, w, h);
1308 evas_map_point_image_uv_set(map, 2, w, 0);
1309 evas_map_point_image_uv_set(map, 3, 0, 0);
1311 evas_map_util_3d_rotate(map, degree,
1312 0, 0, x + half_w, y + half_h, 0);
1314 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1315 evas_object_map_enable_set(front, EINA_TRUE);
1316 evas_object_map_enable_set(back, EINA_TRUE);
1317 evas_object_map_set(obj, map);
1323 _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1325 Elm_Transit_Effect_Flip *flip;
1327 flip = ELM_NEW(Elm_Transit_Effect_Flip);
1328 if (!flip) return NULL;
1337 * Add the Flip Effect to Elm_Transit.
1339 * @note This API is one of the facades. It creates flip effect context
1340 * and add it's required APIs to elm_transit_effect_add.
1341 * @note This effect is applied to each pair of objects in the order they are listed
1342 * in the transit list of objects. The first object in the pair will be the
1343 * "front" object and the second will be the "back" object.
1345 * @see elm_transit_effect_add()
1347 * @param transit Transit object.
1348 * @param axis Flipping Axis(X or Y).
1349 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1350 * @return Flip effect context data.
1353 * @warning Is higher recommended just create a transit with this effect when
1354 * the window that the objects of the transit belongs has already been created.
1355 * This is because this effect needs the geometry information about the objects,
1356 * and if the window was not created yet, it can get a wrong information.
1359 elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1361 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1362 void *effect_context = _transit_effect_flip_context_new(axis, cw);
1364 if (!effect_context) return NULL;
1365 elm_transit_effect_add(transit,
1366 _transit_effect_flip_op, effect_context,
1367 _transit_effect_flip_context_free);
1368 return effect_context;
1371 ///////////////////////////////////////////////////////////////////////////////
1373 ///////////////////////////////////////////////////////////////////////////////
1374 typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip;
1375 typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node;
1377 struct _Elm_Transit_Effect_Resizable_Flip_Node
1383 } from_pos, from_size, to_pos, to_size;
1386 struct _Elm_Transit_Effect_Resizable_Flip
1390 Elm_Transit_Effect_Flip_Axis axis;
1394 _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1396 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1398 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1400 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1402 if (resizable_flip_node->front == obj)
1403 evas_object_event_callback_del(resizable_flip_node->back,
1404 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1405 else if (resizable_flip_node->back == obj)
1406 evas_object_event_callback_del(resizable_flip_node->front,
1407 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1410 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1412 free(resizable_flip_node);
1418 _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFlip *resizable_flip)
1420 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1421 Eina_List *data_list = NULL;
1422 Evas_Coord front_x, front_y, front_w, front_h;
1423 Evas_Coord back_x, back_y, back_w, back_h;
1426 count = eina_list_count(transit->objs);
1427 for (i = 0; i < (count - 1); i += 2)
1429 resizable_flip_node = ELM_NEW(Elm_Transit_Effect_ResizableFlip_Node);
1430 if (!resizable_flip_node)
1432 eina_list_free(data_list);
1436 resizable_flip_node->front = eina_list_nth(transit->objs, i);
1437 resizable_flip_node->back = eina_list_nth(transit->objs, i+1);
1439 evas_object_geometry_get(resizable_flip_node->front,
1440 &front_x, &front_y, &front_w, &front_h);
1441 evas_object_geometry_get(resizable_flip_node->back,
1442 &back_x, &back_y, &back_w, &back_h);
1444 resizable_flip_node->from_pos.x = front_x;
1445 resizable_flip_node->from_pos.y = front_y;
1446 resizable_flip_node->to_pos.x = back_x - front_x;
1447 resizable_flip_node->to_pos.y = back_y - front_y;
1449 resizable_flip_node->from_size.x = front_w;
1450 resizable_flip_node->from_size.y = front_h;
1451 resizable_flip_node->to_size.x = back_w - front_w;
1452 resizable_flip_node->to_size.y = back_h - front_h;
1454 data_list = eina_list_append(data_list, resizable_flip_node);
1456 evas_object_event_callback_add(resizable_flip_node->back,
1457 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1458 evas_object_event_callback_add(resizable_flip_node->front,
1459 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb, resizable_flip);
1466 _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1468 if ((degree >= 90) || (degree <= -90))
1470 evas_map_point_image_uv_set(map, 0,
1471 (flip->from_size.x * 2) + flip->to_size.x,
1473 evas_map_point_image_uv_set(map, 1, 0, 0);
1474 evas_map_point_image_uv_set(map, 2, 0,
1475 (flip->from_size.y * 2) + flip->to_size.y);
1476 evas_map_point_image_uv_set(map, 3,
1477 (flip->from_size.x * 2) + flip->to_size.x,
1478 (flip->from_size.y * 2) + flip->to_size.y);
1482 evas_map_point_image_uv_set(map, 0, 0, 0);
1483 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1484 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1486 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1491 _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
1493 if ((degree >= 90) || (degree <= -90))
1495 evas_map_point_image_uv_set(map, 0, 0,
1496 (flip->from_size.y * 2) + flip->to_size.y);
1497 evas_map_point_image_uv_set(map, 1,
1498 (flip->from_size.x * 2) + flip->to_size.x,
1499 (flip->from_size.y * 2) + flip->to_size.y);
1500 evas_map_point_image_uv_set(map, 2,
1501 (flip->from_size.x * 2) + flip->to_size.x,
1503 evas_map_point_image_uv_set(map, 3, 0, 0);
1507 evas_map_point_image_uv_set(map, 0, 0, 0);
1508 evas_map_point_image_uv_set(map, 1, flip->from_size.x, 0);
1509 evas_map_point_image_uv_set(map, 2, flip->from_size.x,
1511 evas_map_point_image_uv_set(map, 3, 0, flip->from_size.y);
1516 _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__)
1518 EINA_SAFETY_ON_NULL_RETURN(data);
1520 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1521 Eina_List *elist, *elist_next;
1522 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1524 EINA_LIST_FOREACH_SAFE(resizable_flip->nodes,
1525 elist, elist_next, resizable_flip_node)
1527 evas_object_map_enable_set(resizable_flip_node->front, EINA_FALSE);
1528 evas_object_map_enable_set(resizable_flip_node->back, EINA_FALSE);
1530 resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes,
1533 evas_object_event_callback_del(resizable_flip_node->back,
1534 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1535 evas_object_event_callback_del(resizable_flip_node->front,
1536 EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb);
1537 free(resizable_flip_node);
1539 free(resizable_flip);
1543 _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
1545 EINA_SAFETY_ON_NULL_RETURN(data);
1550 Evas_Coord half_w, half_h;
1551 Elm_Transit_Effect_ResizableFlip *resizable_flip = data;
1552 Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node;
1555 map = evas_map_new(4);
1558 if (resizable_flip->cw) degree = (float)(progress * 180);
1559 else degree = (float)(progress * -180);
1561 if (!resizable_flip->nodes)
1562 resizable_flip->nodes = _resizable_flip_nodes_build(transit,
1565 EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node)
1567 if ((degree < 90) && (degree > -90))
1569 obj = resizable_flip_node->front;
1570 if (resizable_flip_node->front != resizable_flip_node->back)
1572 evas_object_hide(resizable_flip_node->back);
1573 evas_object_show(resizable_flip_node->front);
1578 obj = resizable_flip_node->back;
1579 if (resizable_flip_node->front != resizable_flip_node->back)
1581 evas_object_hide(resizable_flip_node->front);
1582 evas_object_show(resizable_flip_node->back);
1586 x = resizable_flip_node->from_pos.x +
1587 (resizable_flip_node->to_pos.x * progress);
1588 y = resizable_flip_node->from_pos.y +
1589 (resizable_flip_node->to_pos.y * progress);
1590 w = resizable_flip_node->from_size.x +
1591 (resizable_flip_node->to_size.x * progress);
1592 h = resizable_flip_node->from_size.y +
1593 (resizable_flip_node->to_size.y * progress);
1594 evas_map_point_coord_set(map, 0, x, y, 0);
1595 evas_map_point_coord_set(map, 1, x + w, y, 0);
1596 evas_map_point_coord_set(map, 2, x + w, y + h, 0);
1597 evas_map_point_coord_set(map, 3, x, y + h, 0);
1599 half_w = (Evas_Coord)(w / 2);
1600 half_h = (Evas_Coord)(h / 2);
1602 if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
1604 _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
1605 evas_map_util_3d_rotate(map, 0, degree,
1606 0, x + half_w, y + half_h, 0);
1610 _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
1611 evas_map_util_3d_rotate(map, degree, 0,
1612 0, x + half_w, y + half_h, 0);
1615 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
1616 evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
1617 evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
1618 evas_object_map_set(obj, map);
1624 _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1626 Elm_Transit_Effect_ResizableFlip *resizable_flip;
1628 resizable_flip = ELM_NEW(Elm_Transit_Effect_ResizableFlip);
1629 if (!resizable_flip) return NULL;
1631 resizable_flip->cw = cw;
1632 resizable_flip->axis = axis;
1634 return resizable_flip;
1638 * Add the Resizable Flip Effect to Elm_Transit.
1640 * @note This API is one of the facades. It creates resizable flip effect context
1641 * and add it's required APIs to elm_transit_effect_add.
1642 * @note This effect is applied to each pair of objects in the order they are listed
1643 * in the transit list of objects. The first object in the pair will be the
1644 * "front" object and the second will be the "back" object.
1646 * @see elm_transit_effect_add()
1648 * @param transit Transit object.
1649 * @param axis Flipping Axis(X or Y).
1650 * @param cw Flipping Direction. EINA_TRUE is clock-wise.
1651 * @return Resizable flip effect context data.
1654 * @warning Is higher recommended just create a transit with this effect when
1655 * the window that the objects of the transit belongs has already been created.
1656 * This is because this effect needs the geometry information about the objects,
1657 * and if the window was not created yet, it can get a wrong information.
1660 elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw)
1662 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1663 void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw);
1665 if (!effect_context) return NULL;
1666 elm_transit_effect_add(transit,
1667 _transit_effect_resizable_flip_op, effect_context,
1668 _transit_effect_resizable_flip_context_free);
1669 return effect_context;
1673 ///////////////////////////////////////////////////////////////////////////////
1675 ///////////////////////////////////////////////////////////////////////////////
1676 typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe;
1678 struct _Elm_Transit_Effect_Wipe
1680 Elm_Transit_Effect_Wipe_Type type;
1681 Elm_Transit_Effect_Wipe_Dir dir;
1685 _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1691 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1692 w2 = w - (w * progress);
1694 evas_map_point_image_uv_set(map, 0, 0, 0);
1695 evas_map_point_image_uv_set(map, 1, w2, 0);
1696 evas_map_point_image_uv_set(map, 2, w2, h);
1697 evas_map_point_image_uv_set(map, 3, 0, h);
1698 evas_map_point_coord_set(map, 0, x, y, 0);
1699 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1700 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1701 evas_map_point_coord_set(map, 3, x, h2, 0);
1703 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1704 w2 = (w * progress);
1706 evas_map_point_image_uv_set(map, 0, w2, 0);
1707 evas_map_point_image_uv_set(map, 1, w, 0);
1708 evas_map_point_image_uv_set(map, 2, w, h);
1709 evas_map_point_image_uv_set(map, 3, w2, h);
1710 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1711 evas_map_point_coord_set(map, 1, x + w, y, 0);
1712 evas_map_point_coord_set(map, 2, x + w, h2, 0);
1713 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1715 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1717 h2 = h - (h * progress);
1718 evas_map_point_image_uv_set(map, 0, 0, 0);
1719 evas_map_point_image_uv_set(map, 1, w, 0);
1720 evas_map_point_image_uv_set(map, 2, w, h2);
1721 evas_map_point_image_uv_set(map, 3, 0, h2);
1722 evas_map_point_coord_set(map, 0, x, y, 0);
1723 evas_map_point_coord_set(map, 1, w2, y, 0);
1724 evas_map_point_coord_set(map, 2, w2, y+h2, 0);
1725 evas_map_point_coord_set(map, 3, x, y+h2, 0);
1727 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1729 h2 = (h * progress);
1730 evas_map_point_image_uv_set(map, 0, 0, h2);
1731 evas_map_point_image_uv_set(map, 1, w, h2);
1732 evas_map_point_image_uv_set(map, 2, w, h);
1733 evas_map_point_image_uv_set(map, 3, 0, h);
1734 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1735 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1736 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1737 evas_map_point_coord_set(map, 3, x, y + h, 0);
1742 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1746 _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float y, float w, float h, float progress)
1752 case ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT:
1753 w2 = (w - (w * progress));
1755 evas_map_point_image_uv_set(map, 0, w2, 0);
1756 evas_map_point_image_uv_set(map, 1, w, 0);
1757 evas_map_point_image_uv_set(map, 2, w, h);
1758 evas_map_point_image_uv_set(map, 3, w2, h);
1759 evas_map_point_coord_set(map, 0, x + w2, y, 0);
1760 evas_map_point_coord_set(map, 1, w, y, 0);
1761 evas_map_point_coord_set(map, 2, w, h2, 0);
1762 evas_map_point_coord_set(map, 3, x + w2, h2, 0);
1764 case ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT:
1765 w2 = (w * progress);
1767 evas_map_point_image_uv_set(map, 0, 0, 0);
1768 evas_map_point_image_uv_set(map, 1, w2, 0);
1769 evas_map_point_image_uv_set(map, 2, w2, h);
1770 evas_map_point_image_uv_set(map, 3, 0, h);
1771 evas_map_point_coord_set(map, 0, x, y, 0);
1772 evas_map_point_coord_set(map, 1, x + w2, y, 0);
1773 evas_map_point_coord_set(map, 2, x + w2, h2, 0);
1774 evas_map_point_coord_set(map, 3, x, h2, 0);
1776 case ELM_TRANSIT_EFFECT_WIPE_DIR_UP:
1778 h2 = (h - (h * progress));
1779 evas_map_point_image_uv_set(map, 0, 0, h2);
1780 evas_map_point_image_uv_set(map, 1, w, h2);
1781 evas_map_point_image_uv_set(map, 2, w, h);
1782 evas_map_point_image_uv_set(map, 3, 0, h);
1783 evas_map_point_coord_set(map, 0, x, y + h2, 0);
1784 evas_map_point_coord_set(map, 1, w2, y + h2, 0);
1785 evas_map_point_coord_set(map, 2, w2, y + h, 0);
1786 evas_map_point_coord_set(map, 3, x, y + h, 0);
1788 case ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN:
1790 h2 = (h * progress);
1791 evas_map_point_image_uv_set(map, 0, 0, 0);
1792 evas_map_point_image_uv_set(map, 1, w, 0);
1793 evas_map_point_image_uv_set(map, 2, w, h2);
1794 evas_map_point_image_uv_set(map, 3, 0, h2);
1795 evas_map_point_coord_set(map, 0, x, y, 0);
1796 evas_map_point_coord_set(map, 1, w2, y, 0);
1797 evas_map_point_coord_set(map, 2, w2, y + h2, 0);
1798 evas_map_point_coord_set(map, 3, x, y + h2, 0);
1803 evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL);
1807 _transit_effect_wipe_context_free(void *data, Elm_Transit *transit)
1809 EINA_SAFETY_ON_NULL_RETURN(data);
1810 EINA_SAFETY_ON_NULL_RETURN(transit);
1813 Elm_Transit_Effect_Wipe *wipe = data;
1814 Eina_Bool reverse = elm_transit_auto_reverse_get(transit);
1816 EINA_LIST_FOREACH(transit->objs, elist, obj)
1818 if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse)
1819 || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse))
1820 evas_object_show(obj);
1821 else evas_object_hide(obj);
1822 evas_object_map_enable_set(obj, EINA_FALSE);
1829 _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress)
1831 EINA_SAFETY_ON_NULL_RETURN(data);
1832 EINA_SAFETY_ON_NULL_RETURN(transit);
1833 Elm_Transit_Effect_Wipe *wipe = data;
1835 Evas_Coord _x, _y, _w, _h;
1839 map = evas_map_new(4);
1842 EINA_LIST_FOREACH(transit->objs, elist, obj)
1844 evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
1846 if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
1847 _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1849 _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress);
1851 evas_object_map_enable_set(obj, EINA_TRUE);
1852 evas_object_map_set(obj, map);
1858 _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1860 Elm_Transit_Effect_Wipe *wipe;
1862 wipe = ELM_NEW(Elm_Transit_Effect_Wipe);
1863 if (!wipe) return NULL;
1872 * Add the Wipe Effect to Elm_Transit.
1874 * @note This API is one of the facades. It creates wipe effect context
1875 * and add it's required APIs to elm_transit_effect_add.
1877 * @see elm_transit_effect_add()
1879 * @param transit Transit object.
1880 * @param type Wipe type. Hide or show.
1881 * @param dir Wipe Direction.
1882 * @return Wipe effect context data.
1885 * @warning Is higher recommended just create a transit with this effect when
1886 * the window that the objects of the transit belongs has already been created.
1887 * This is because this effect needs the geometry information about the objects,
1888 * and if the window was not created yet, it can get a wrong information.
1891 elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir)
1893 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1894 void *effect_context = _transit_effect_wipe_context_new(type, dir);
1896 if (!effect_context) return NULL;
1897 elm_transit_effect_add(transit,
1898 _transit_effect_wipe_op, effect_context,
1899 _transit_effect_wipe_context_free);
1900 return effect_context;
1904 ///////////////////////////////////////////////////////////////////////////////
1906 ///////////////////////////////////////////////////////////////////////////////
1907 typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color;
1909 struct _Elm_Transit_Effect_Color
1911 struct _unsigned_color {
1912 unsigned int r, g, b, a;
1914 struct _signed_color {
1920 _transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__)
1926 _transit_effect_color_op(void *data, Elm_Transit *transit, double progress)
1928 EINA_SAFETY_ON_NULL_RETURN(data);
1929 EINA_SAFETY_ON_NULL_RETURN(transit);
1930 Elm_Transit_Effect_Color *color = data;
1933 unsigned int r, g, b, a;
1935 r = (color->from.r + (int)((float)color->to.r * progress));
1936 g = (color->from.g + (int)((float)color->to.g * progress));
1937 b = (color->from.b + (int)((float)color->to.b * progress));
1938 a = (color->from.a + (int)((float)color->to.a * progress));
1940 EINA_LIST_FOREACH(transit->objs, elist, obj)
1941 evas_object_color_set(obj, r, g, b, a);
1945 _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)
1947 Elm_Transit_Effect_Color *color;
1949 color = ELM_NEW(Elm_Transit_Effect_Color);
1950 if (!color) return NULL;
1952 color->from.r = from_r;
1953 color->from.g = from_g;
1954 color->from.b = from_b;
1955 color->from.a = from_a;
1956 color->to.r = to_r - from_r;
1957 color->to.g = to_g - from_g;
1958 color->to.b = to_b - from_b;
1959 color->to.a = to_a - from_a;
1965 * Add the Color Effect to Elm_Transit.
1967 * @note This API is one of the facades. It creates color effect context
1968 * and add it's required APIs to elm_transit_effect_add.
1970 * @see elm_transit_effect_add()
1972 * @param transit Transit object.
1973 * @param from_r RGB R when effect begins.
1974 * @param from_g RGB G when effect begins.
1975 * @param from_b RGB B when effect begins.
1976 * @param from_a RGB A when effect begins.
1977 * @param to_r RGB R when effect ends.
1978 * @param to_g RGB G when effect ends.
1979 * @param to_b RGB B when effect ends.
1980 * @param to_a RGB A when effect ends.
1981 * @return Color effect context data.
1986 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)
1988 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
1989 void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a);
1991 if (!effect_context) return NULL;
1992 elm_transit_effect_add(transit,
1993 _transit_effect_color_op, effect_context,
1994 _transit_effect_color_context_free);
1995 return effect_context;
1998 ///////////////////////////////////////////////////////////////////////////////
2000 ///////////////////////////////////////////////////////////////////////////////
2001 typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade;
2002 typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node;
2004 struct _Elm_Transit_Effect_Fade_Node
2006 Evas_Object *before;
2008 struct _signed_color before_color, after_color;
2011 Eina_Bool inversed : 1;
2014 struct _Elm_Transit_Effect_Fade
2020 _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2022 Elm_Transit_Effect_Fade *fade = data;
2024 Elm_Transit_Effect_Fade_Node *fade_node;
2026 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2028 if (fade_node->before == obj)
2029 evas_object_event_callback_del(fade_node->after,
2030 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2031 else if (fade_node->after == obj)
2032 evas_object_event_callback_del(fade_node->before,
2033 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2036 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2043 _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data)
2045 Elm_Transit_Effect_Fade_Node *fade;
2046 Eina_List *data_list = NULL;
2049 count = eina_list_count(transit->objs);
2050 for (i = 0; i < (count - 1); i += 2)
2052 fade = ELM_NEW(Elm_Transit_Effect_Fade_Node);
2055 eina_list_free(data_list);
2059 fade->before = eina_list_nth(transit->objs, i);
2060 fade->after = eina_list_nth(transit->objs, i+1);
2062 evas_object_color_get(fade->before,
2063 &fade->before_color.r, &fade->before_color.g,
2064 &fade->before_color.b, &fade->before_color.a);
2065 evas_object_color_get(fade->after,
2066 &fade->after_color.r, &fade->after_color.g,
2067 &fade->after_color.b, &fade->after_color.a);
2069 fade->before_alpha = (255 - fade->before_color.a);
2070 fade->after_alpha = (255 - fade->after_color.a);
2072 data_list = eina_list_append(data_list, fade);
2074 evas_object_event_callback_add(fade->before,
2075 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2076 evas_object_event_callback_add(fade->after,
2077 EVAS_CALLBACK_DEL, _fade_object_del_cb, fade_data);
2083 _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__)
2085 EINA_SAFETY_ON_NULL_RETURN(data);
2086 Elm_Transit_Effect_Fade *fade = data;
2087 Elm_Transit_Effect_Fade_Node *fade_node;
2088 Eina_List *elist, *elist_next;
2090 EINA_LIST_FOREACH_SAFE(fade->nodes, elist, elist_next, fade_node)
2092 evas_object_color_set(fade_node->before, fade_node->before_color.r,
2093 fade_node->before_color.g,
2094 fade_node->before_color.b,
2095 fade_node->before_color.a);
2096 evas_object_color_set(fade_node->after, fade_node->after_color.r,
2097 fade_node->after_color.g,
2098 fade_node->after_color.b,
2099 fade_node->after_color.a);
2101 fade->nodes = eina_list_remove_list(fade->nodes, elist);
2102 evas_object_event_callback_del(fade_node->before,
2103 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2104 evas_object_event_callback_del(fade_node->after,
2105 EVAS_CALLBACK_DEL, _fade_object_del_cb);
2113 _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress)
2115 EINA_SAFETY_ON_NULL_RETURN(data);
2116 Elm_Transit_Effect_Fade *fade = data;
2118 Elm_Transit_Effect_Fade_Node *fade_node;
2122 fade->nodes = _fade_nodes_build(transit, fade);
2124 EINA_LIST_FOREACH(fade->nodes, elist, fade_node)
2128 if (!fade_node->inversed)
2130 evas_object_hide(fade_node->after);
2131 evas_object_show(fade_node->before);
2132 fade_node->inversed = EINA_TRUE;
2135 _progress = (1 - (progress * 2));
2137 evas_object_color_set(fade_node->before,
2138 fade_node->before_color.r * _progress,
2139 fade_node->before_color.g * _progress,
2140 fade_node->before_color.b * _progress,
2141 fade_node->before_color.a +
2142 fade_node->before_alpha * (1 - _progress));
2146 if (fade_node->inversed)
2148 evas_object_hide(fade_node->before);
2149 evas_object_show(fade_node->after);
2150 fade_node->inversed = EINA_FALSE;
2153 _progress = ((progress - 0.5) * 2);
2155 evas_object_color_set(fade_node->after,
2156 fade_node->after_color.r * _progress,
2157 fade_node->after_color.g * _progress,
2158 fade_node->after_color.b * _progress,
2159 fade_node->after_color.a +
2160 fade_node->after_alpha * (1 - _progress));
2166 _transit_effect_fade_context_new(void)
2168 Elm_Transit_Effect_Fade *fade;
2169 fade = ELM_NEW(Elm_Transit_Effect_Fade);
2170 if (!fade) return NULL;
2175 * Add the Fade Effect to Elm_Transit.
2177 * @note This API is one of the facades. It creates fade effect context
2178 * and add it's required APIs to elm_transit_effect_add.
2179 * @note This effect is applied to each pair of objects in the order they are listed
2180 * in the transit list of objects. The first object in the pair will be the
2181 * "before" object and the second will be the "after" object.
2183 * @see elm_transit_effect_add()
2185 * @param transit Transit object.
2186 * @return Fade effect context data.
2189 * @warning Is higher recommended just create a transit with this effect when
2190 * the window that the objects of the transit belongs has already been created.
2191 * This is because this effect needs the color information about the objects,
2192 * and if the window was not created yet, it can get a wrong information.
2195 elm_transit_effect_fade_add(Elm_Transit *transit)
2197 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2199 void *effect_context = _transit_effect_fade_context_new();
2200 if (!effect_context) return NULL;
2201 elm_transit_effect_add(transit,
2202 _transit_effect_fade_op, effect_context,
2203 _transit_effect_fade_context_free);
2204 return effect_context;
2208 ///////////////////////////////////////////////////////////////////////////////
2210 ///////////////////////////////////////////////////////////////////////////////
2211 typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend;
2212 typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node;
2214 struct _Elm_Transit_Effect_Blend_Node
2216 Evas_Object *before;
2218 struct _signed_color from, to;
2221 struct _Elm_Transit_Effect_Blend
2227 _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2229 Elm_Transit_Effect_Blend *blend = data;
2231 Elm_Transit_Effect_Blend_Node *blend_node;
2233 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2235 if (blend_node->after == obj)
2236 evas_object_event_callback_del(blend_node->before,
2237 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2238 else if (blend_node->before == obj)
2239 evas_object_event_callback_del(blend_node->after,
2240 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2243 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2250 _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)
2252 Elm_Transit_Effect_Blend_Node *blend_node;
2253 Eina_List *data_list = NULL;
2256 count = eina_list_count(transit->objs);
2257 for (i = 0; i < (count - 1); i += 2)
2259 blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);
2262 eina_list_free(data_list);
2266 blend_node->before = eina_list_nth(transit->objs, i);
2267 blend_node->after = eina_list_nth(transit->objs, i + 1);
2268 evas_object_show(blend_node->before);
2269 evas_object_show(blend_node->after);
2271 evas_object_color_get(blend_node->before, &blend_node->from.r,
2272 &blend_node->from.g, &blend_node->from.b,
2273 &blend_node->from.a);
2274 evas_object_color_get(blend_node->after, &blend_node->to.r,
2275 &blend_node->to.g, &blend_node->to.b,
2278 data_list = eina_list_append(data_list, blend_node);
2280 evas_object_event_callback_add(blend_node->before,
2281 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2282 evas_object_event_callback_add(blend_node->after,
2283 EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);
2289 _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__)
2291 EINA_SAFETY_ON_NULL_RETURN(data);
2292 Elm_Transit_Effect_Blend *blend = data;
2293 Elm_Transit_Effect_Blend_Node *blend_node;
2294 Eina_List *elist, *elist_next;
2296 EINA_LIST_FOREACH_SAFE(blend->nodes, elist, elist_next, blend_node)
2298 evas_object_color_set(blend_node->before,
2299 blend_node->from.r, blend_node->from.g,
2300 blend_node->from.b, blend_node->from.a);
2301 evas_object_color_set(blend_node->after, blend_node->to.r,
2302 blend_node->to.g, blend_node->to.b,
2305 if (elm_transit_auto_reverse_get(transit))
2306 evas_object_hide(blend_node->after);
2308 evas_object_hide(blend_node->before);
2310 blend->nodes = eina_list_remove_list(blend->nodes, elist);
2312 evas_object_event_callback_del(blend_node->before,
2313 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2314 evas_object_event_callback_del(blend_node->after,
2315 EVAS_CALLBACK_DEL, _blend_object_del_cb);
2322 _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress)
2324 EINA_SAFETY_ON_NULL_RETURN(data);
2325 EINA_SAFETY_ON_NULL_RETURN(transit);
2326 Elm_Transit_Effect_Blend *blend = data;
2327 Elm_Transit_Effect_Blend_Node *blend_node;
2330 if (!blend->nodes) blend->nodes = _blend_nodes_build(transit, blend);
2332 EINA_LIST_FOREACH(blend->nodes, elist, blend_node)
2334 evas_object_color_set(blend_node->before,
2335 (int)(blend_node->from.r * (1 - progress)),
2336 (int)(blend_node->from.g * (1 - progress)),
2337 (int)(blend_node->from.b * (1 - progress)),
2338 (int)(blend_node->from.a * (1 - progress)));
2339 evas_object_color_set(blend_node->after,
2340 (int)(blend_node->to.r * progress),
2341 (int)(blend_node->to.g * progress),
2342 (int)(blend_node->to.b * progress),
2343 (int)(blend_node->to.a * progress));
2348 _transit_effect_blend_context_new(void)
2350 Elm_Transit_Effect_Blend *blend;
2352 blend = ELM_NEW(Elm_Transit_Effect_Blend);
2353 if (!blend) return NULL;
2358 * Add the Blend Effect to Elm_Transit.
2360 * @note This API is one of the facades. It creates blend effect context
2361 * and add it's required APIs to elm_transit_effect_add.
2362 * @note This effect is applied to each pair of objects in the order they are listed
2363 * in the transit list of objects. The first object in the pair will be the
2364 * "before" object and the second will be the "after" object.
2366 * @see elm_transit_effect_add()
2368 * @param transit Transit object.
2369 * @return Blend effect context data.
2372 * @warning Is higher recommended just create a transit with this effect when
2373 * the window that the objects of the transit belongs has already been created.
2374 * This is because this effect needs the color information about the objects,
2375 * and if the window was not created yet, it can get a wrong information.
2378 elm_transit_effect_blend_add(Elm_Transit *transit)
2380 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2381 void *effect_context = _transit_effect_blend_context_new();
2383 if (!effect_context) return NULL;
2384 elm_transit_effect_add(transit,
2385 _transit_effect_blend_op, effect_context,
2386 _transit_effect_blend_context_free);
2387 return effect_context;
2391 ///////////////////////////////////////////////////////////////////////////////
2393 ///////////////////////////////////////////////////////////////////////////////
2394 typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation;
2396 struct _Elm_Transit_Effect_Rotation
2402 _transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2408 _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress)
2410 EINA_SAFETY_ON_NULL_RETURN(data);
2411 EINA_SAFETY_ON_NULL_RETURN(transit);
2412 Elm_Transit_Effect_Rotation *rotation = data;
2414 Evas_Coord x, y, w, h;
2416 float half_w, half_h;
2420 map = evas_map_new(4);
2423 EINA_LIST_FOREACH(transit->objs, elist, obj)
2425 evas_map_util_points_populate_from_object_full(map, obj, 0);
2426 degree = rotation->from + (float)(progress * rotation->to);
2428 evas_object_geometry_get(obj, &x, &y, &w, &h);
2430 half_w = (float)w * 0.5;
2431 half_h = (float)h * 0.5;
2433 evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
2434 evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL);
2435 evas_object_map_enable_set(obj, EINA_TRUE);
2436 evas_object_map_set(obj, map);
2442 _transit_effect_rotation_context_new(float from_degree, float to_degree)
2444 Elm_Transit_Effect_Rotation *rotation;
2446 rotation = ELM_NEW(Elm_Transit_Effect_Rotation);
2447 if (!rotation) return NULL;
2449 rotation->from = from_degree;
2450 rotation->to = to_degree - from_degree;
2456 * Add the Rotation Effect to Elm_Transit.
2458 * @note This API is one of the facades. It creates rotation effect context
2459 * and add it's required APIs to elm_transit_effect_add.
2461 * @see elm_transit_effect_add()
2463 * @param transit Transit object.
2464 * @param from_degree Degree when effect begins.
2465 * @param to_degree Degree when effect is ends.
2466 * @return Rotation effect context data.
2469 * @warning Is higher recommended just create a transit with this effect when
2470 * the window that the objects of the transit belongs has already been created.
2471 * This is because this effect needs the geometry information about the objects,
2472 * and if the window was not created yet, it can get a wrong information.
2475 elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree)
2477 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2478 void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree);
2480 if (!effect_context) return NULL;
2481 elm_transit_effect_add(transit,
2482 _transit_effect_rotation_op, effect_context,
2483 _transit_effect_rotation_context_free);
2484 return effect_context;
2488 ///////////////////////////////////////////////////////////////////////////////
2489 // ImageAnimation FX
2490 ///////////////////////////////////////////////////////////////////////////////
2491 typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation;
2493 struct _Elm_Transit_Effect_Image_Animation
2499 _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__)
2501 EINA_SAFETY_ON_NULL_RETURN(data);
2502 Elm_Transit_Effect_Image_Animation *image_animation = data;
2504 Eina_List *elist, *elist_next;
2506 EINA_LIST_FOREACH_SAFE(image_animation->images, elist, elist_next, image)
2508 image_animation->images =
2509 eina_list_remove_list(image_animation->images, elist);
2510 eina_stringshare_del(image);
2517 _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress)
2519 EINA_SAFETY_ON_NULL_RETURN(data);
2520 EINA_SAFETY_ON_NULL_RETURN(transit);
2524 Elm_Transit_Effect_Image_Animation *image_animation = data;
2525 unsigned int count = 0;
2528 type = eina_stringshare_add("icon");
2529 len = eina_list_count(image_animation->images);
2531 if (!len) count = floor(progress * len);
2532 else count = floor(progress * (len - 1));
2534 EINA_LIST_FOREACH(transit->objs, elist, obj)
2536 if (elm_widget_type_check(obj, type))
2537 elm_icon_file_set(obj,
2538 eina_list_nth(image_animation->images, count), NULL);
2541 eina_stringshare_del(type);
2545 _transit_effect_image_animation_context_new(Eina_List *images)
2547 Elm_Transit_Effect_Image_Animation *image_animation;
2548 image_animation = ELM_NEW(Elm_Transit_Effect_Image_Animation);
2550 if (!image_animation) return NULL;
2551 image_animation->images = images;
2552 return image_animation;
2556 * Add the ImageAnimation Effect to Elm_Transit.
2558 * @note This API is one of the facades. It creates image animation effect context
2559 * and add it's required APIs to elm_transit_effect_add.
2560 * The @p images parameter is a list images paths. This list and
2561 * its contents will be deleted at the end of the effect by
2562 * elm_transit_effect_image_animation_context_free() function.
2566 * char buf[PATH_MAX];
2567 * Eina_List *images = NULL;
2568 * Elm_Transit *transi = elm_transit_add();
2570 * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
2571 * images = eina_list_append(images, eina_stringshare_add(buf));
2573 * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
2574 * images = eina_list_append(images, eina_stringshare_add(buf));
2575 * elm_transit_effect_image_animation_add(transi, images);
2579 * @see elm_transit_effect_add()
2581 * @param transit Transit object.
2582 * @param images Eina_List of images file paths. This list and
2583 * its contents will be deleted at the end of the effect by
2584 * elm_transit_effect_image_animation_context_free() function.
2585 * @return Image Animation effect context data.
2590 elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images)
2592 ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL);
2593 void *effect_context = _transit_effect_image_animation_context_new(images);
2595 if (!effect_context) return NULL;
2596 elm_transit_effect_add(transit,
2597 _transit_effect_image_animation_op, effect_context,
2598 _transit_effect_image_animation_context_free);
2599 return effect_context;