X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flib%2Felm_transit.c;h=7fb4fe08f4f2b1be2fac0d7da923242a9ee34f93;hb=9d446c30b60c3d6661b641aa6f04b4a8f3752c0d;hp=f0a02cff42d6d551cee48e1d556236b6b6a81a16;hpb=ecea69816e59726c844da7015246eb231533d033;p=framework%2Fuifw%2Felementary.git diff --git a/src/lib/elm_transit.c b/src/lib/elm_transit.c index f0a02cf..3116daa 100644 --- a/src/lib/elm_transit.c +++ b/src/lib/elm_transit.c @@ -17,40 +17,8 @@ } \ } while (0) -/** - * - * @defgroup Transit Transit - * @ingroup Elementary - * - * Transit (see Warning below) is designed to set the various effects for the - * Evas_Object such like translation, rotation, etc. For using Effects, Create - * transit and insert effects which are interesting. - * Once effects are inserted into transit, transit will manage those effects. - * (ex deleting). - * - * Example: - * @code - * Elm_Transit *trans = elm_transit_add(); - * elm_transit_object_add(trans, obj); - * void *effect_context = elm_transit_effect_translation_context_new(0.0, 0.0, - * 280.0, 280.0); - * elm_transit_effect_add(transit, - * elm_transit_effect_translation_op, effect_context, - * elm_transit_effect_translation_context_free); - * elm_transit_duration_set(transit, 5); - * elm_transit_auto_reverse_set(transit, EINA_TRUE); - * elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE); - * elm_transit_repeat_times_set(transit, -1); - * @endcode - * - * @warning We strongly recomend to use elm_transit just when edje can not do - * the trick. Edje has more advantage than Elm_Transit, it has more flexibility and - * animations can be manipulated inside the theme. - */ - -static const char _transit_key[] = "_elm_transit"; - -#define FOCAL 2000 + +#define _TRANSIT_FOCAL 2000 struct _Elm_Transit { @@ -58,11 +26,13 @@ struct _Elm_Transit EINA_MAGIC; Ecore_Animator *animator; - Eina_List *effect_list; + Eina_Inlist *effect_list; Eina_List *objs; + Elm_Transit *prev_chain_transit; + Eina_List *next_chain_transits; Elm_Transit_Tween_Mode tween_mode; struct { - void (*func) (void *data, Elm_Transit *transit); + Elm_Transit_Del_Cb func; void *arg; } del_data; struct { @@ -83,70 +53,182 @@ struct _Elm_Transit Eina_Bool auto_reverse : 1; Eina_Bool event_enabled : 1; Eina_Bool deleted : 1; + Eina_Bool state_keep : 1; + Eina_Bool finished : 1; }; -struct _Elm_Transit_Effect +struct _Elm_Transit_Effect_Module { - void (*animation_op) (void *data, Elm_Transit *transit, double progress); - void (*user_data_free) (void *data, Elm_Transit *transit); - void *user_data; + EINA_INLIST; + Elm_Transit_Effect_Transition_Cb transition_cb; + Elm_Transit_Effect_End_Cb end_cb; + Elm_Transit_Effect *effect; Eina_Bool deleted : 1; }; -struct _Elm_Obj_Data +struct _Elm_Transit_Obj_State +{ + Evas_Coord x, y, w, h; + int r,g,b,a; + Evas_Map *map; + Eina_Bool map_enabled : 1; + Eina_Bool visible : 1; +}; + +struct _Elm_Transit_Obj_Data { - Eina_Bool state; - Elm_Transit *transit; + struct _Elm_Transit_Obj_State *state; + Eina_Bool freeze_events : 1; }; -typedef struct _Elm_Transit_Effect Elm_Transit_Effect; -typedef struct _Elm_Obj_Data Elm_Obj_Data; +typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module; +typedef struct _Elm_Transit_Obj_Data Elm_Transit_Obj_Data; +typedef struct _Elm_Transit_Obj_State Elm_Transit_Obj_State; + +static void _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj); +static void _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj); +static void _transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data); +static void _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__); +static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj); +static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module); +static void _transit_remove_dead_effects(Elm_Transit *transit); +static void _transit_chain_go(Elm_Transit *transit); +static void _transit_del(Elm_Transit *transit); +static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress); +static Eina_Bool _transit_animate_cb(void *data); + +static char *_transit_key= "_elm_transit_key"; static void -_elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +_transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj) { - Elm_Transit *transit = data; + Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key); - Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key); - evas_object_pass_events_set(obj, obj_data->state); - free(obj_data); - transit->objs = eina_list_remove(transit->objs, obj); + if (!obj_data) + obj_data = ELM_NEW(Elm_Transit_Obj_Data); + + obj_data->freeze_events = evas_object_freeze_events_get(obj); + + if ((!transit->state_keep) && (obj_data->state)) + { + free(obj_data->state); + obj_data->state = NULL; + } + else + { + _transit_obj_states_save(obj, obj_data); + } + + evas_object_data_set(obj, _transit_key, obj_data); +} + +static void +_transit_obj_states_save(Evas_Object *obj, Elm_Transit_Obj_Data *obj_data) +{ + Elm_Transit_Obj_State *state = obj_data->state; + + if (!state) + state = calloc(1, sizeof(Elm_Transit_Obj_State)); + if (!state) return; + + evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h); + evas_object_color_get(obj, &state->r, &state->g, &state->b, &state->a); + state->visible = evas_object_visible_get(obj); + state->map_enabled = evas_object_map_enable_get(obj); + if (evas_object_map_get(obj)) + state->map = evas_map_dup(evas_object_map_get(obj)); + obj_data->state = state; +} + +static void +_remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj) +{ + //Remove duplicated objects + //TODO: Need to consider about optimizing here + while(1) + { + if (!eina_list_data_find_list(transit->objs, obj)) + break; + transit->objs = eina_list_remove(transit->objs, obj); + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, + _transit_obj_remove_cb, + transit); + } +} + +static void +_transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + Elm_Transit *transit = data; + Elm_Transit_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key); + if (obj_data) + { + if (obj_data->state) + free(obj_data->state); + free(obj_data); + } + _remove_obj_from_list(transit, obj); if (!transit->objs) elm_transit_del(transit); } static void -_elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj) +_transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj) { - Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key); + Elm_Transit_Obj_Data *obj_data; + Elm_Transit_Obj_State *state; - evas_object_pass_events_set(obj, obj_data->state); + obj_data = evas_object_data_get(obj, _transit_key); + if (!obj_data) return; + evas_object_data_del(obj, _transit_key); + evas_object_freeze_events_set(obj, obj_data->freeze_events); + state = obj_data->state; + if (state) + { + //recover the states of the object. + if (!transit->state_keep) + { + evas_object_move(obj, state->x, state->y); + evas_object_resize(obj, state->w, state->h); + evas_object_color_set(obj, state->r, state->g, state->b, state->a); + if (state->visible) evas_object_show(obj); + else evas_object_hide(obj); + if (state->map_enabled) + evas_object_map_enable_set(obj, EINA_TRUE); + else + evas_object_map_enable_set(obj, EINA_FALSE); + if (state->map) + evas_object_map_set(obj, state->map); + } + free(state); + } free(obj_data); - transit->objs = eina_list_remove(transit->objs, obj); - evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, - _elm_transit_object_remove_cb); } static void -_elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect *effect, Eina_List *elist) +_transit_obj_remove(Elm_Transit *transit, Evas_Object *obj) { - if (effect->user_data_free) - effect->user_data_free(effect->user_data, transit); + _remove_obj_from_list(transit, obj); + _transit_obj_data_recover(transit, obj); +} - transit->effect_list = eina_list_remove_list(transit->effect_list, elist); - free(effect); +static void +_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module) +{ + if (effect_module->end_cb) + effect_module->end_cb(effect_module->effect, transit); + free(effect_module); } static void -_remove_dead_effects(Elm_Transit *transit) +_transit_remove_dead_effects(Elm_Transit *transit) { - Eina_List *elist, *elist_next; - Elm_Transit_Effect *effect; + Elm_Transit_Effect_Module *effect_module; - EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect) + EINA_INLIST_FOREACH(transit->effect_list, effect_module) { - if (effect->deleted) + if (effect_module->deleted) { - _elm_transit_effect_del(transit, effect, elist); + _transit_effect_del(transit, effect_module); transit->effects_pending_del--; if (!transit->effects_pending_del) return; } @@ -154,89 +236,147 @@ _remove_dead_effects(Elm_Transit *transit) } static void -_elm_transit_del(Elm_Transit *transit) +_transit_chain_go(Elm_Transit *transit) { + ELM_TRANSIT_CHECK_OR_RETURN(transit); + elm_transit_go(transit); + _transit_animate_cb(transit); +} + +static void +_transit_del(Elm_Transit *transit) +{ + Elm_Transit_Effect_Module *effect_module; + Elm_Transit *chain_transit; Eina_List *elist, *elist_next; - Elm_Transit_Effect *effect; if (transit->animator) - ecore_animator_del(transit->animator); + ecore_animator_del(transit->animator); - EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect) - _elm_transit_effect_del(transit, effect, elist); + //remove effects + while (transit->effect_list) + { + effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module); + transit->effect_list = eina_inlist_remove(transit->effect_list, transit->effect_list); + _transit_effect_del(transit, effect_module); + } + //remove objects. while (transit->objs) - _elm_transit_object_remove(transit, eina_list_data_get(transit->objs)); + _transit_obj_remove(transit, eina_list_data_get(transit->objs)); + + transit->deleted = EINA_TRUE; if (transit->del_data.func) - transit->del_data.func(transit->del_data.arg, transit); + transit->del_data.func(transit->del_data.arg, transit); + + //cut off the chain transit relationship + EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit) + chain_transit->prev_chain_transit = NULL; + + if (transit->prev_chain_transit) + transit->prev_chain_transit->next_chain_transits = + eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit); + + // run chain transits + if (transit->finished && transit->next_chain_transits) + { + EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit) + _transit_chain_go(chain_transit); + + } + + eina_list_free(transit->next_chain_transits); EINA_MAGIC_SET(transit, EINA_MAGIC_NONE); free(transit); } -static void +//If the transit is deleted then EINA_FALSE is retruned. +static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress) { - Eina_List *elist; - Elm_Transit_Effect *effect; + Elm_Transit_Effect_Module *effect_module; transit->walking++; - EINA_LIST_FOREACH(transit->effect_list, elist, effect) + EINA_INLIST_FOREACH(transit->effect_list, effect_module) { if (transit->deleted) break; - if (!effect->deleted) - effect->animation_op(effect->user_data, transit, progress); + if (!effect_module->deleted) + effect_module->transition_cb(effect_module->effect, transit, progress); } transit->walking--; - if (transit->walking) return; + if (transit->walking) return EINA_TRUE; - if (transit->deleted) _elm_transit_del(transit); - else if (transit->effects_pending_del) _remove_dead_effects(transit); + if (transit->deleted) + { + _transit_del(transit); + return EINA_FALSE; + } + + else if (transit->effects_pending_del) _transit_remove_dead_effects(transit); + + return EINA_TRUE; } static Eina_Bool -_animator_animate_cb(void *data) +_transit_animate_cb(void *data) { Elm_Transit *transit = data; double elapsed_time, duration; transit->time.current = ecore_loop_time_get(); elapsed_time = transit->time.current - transit->time.begin; - duration = transit->time.duration + transit->time.delayed; + duration = transit->time.duration + transit->time.delayed; - if (elapsed_time > duration) - elapsed_time = duration; + if (elapsed_time > duration) + elapsed_time = duration; transit->progress = elapsed_time / duration; switch (transit->tween_mode) { + case ELM_TRANSIT_TWEEN_MODE_LINEAR: + transit->progress = ecore_animator_pos_map(transit->progress, + ECORE_POS_MAP_LINEAR, + 0, 0); case ELM_TRANSIT_TWEEN_MODE_ACCELERATE: - transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0)); - break; + transit->progress = ecore_animator_pos_map(transit->progress, + ECORE_POS_MAP_ACCELERATE, + 0, 0); + break; case ELM_TRANSIT_TWEEN_MODE_DECELERATE: - transit->progress = sin(transit->progress * ELM_PI / 2.0); - break; + transit->progress = ecore_animator_pos_map(transit->progress, + ECORE_POS_MAP_DECELERATE, + 0, 0); + break; case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL: - transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0; - break; + transit->progress = ecore_animator_pos_map(transit->progress, + ECORE_POS_MAP_SINUSOIDAL, + 0, 0); + break; default: - break; + break; } /* Reverse? */ if (transit->repeat.reverse) transit->progress = 1 - transit->progress; - if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress); + if (transit->time.duration > 0) + { + if (!_transit_animate_op(transit, transit->progress)) + return ECORE_CALLBACK_CANCEL; + } /* Not end. Keep going. */ if (elapsed_time < duration) return ECORE_CALLBACK_RENEW; /* Repeat and reverse and time done! */ - if ((transit->repeat.current == transit->repeat.count) - && (!transit->auto_reverse || transit->repeat.reverse)) + if ((transit->repeat.count >= 0) && + (transit->repeat.current == transit->repeat.count) && + ((!transit->auto_reverse) || transit->repeat.reverse)) { + transit->finished = EINA_TRUE; elm_transit_del(transit); return ECORE_CALLBACK_CANCEL; } @@ -254,25 +394,15 @@ _animator_animate_cb(void *data) return ECORE_CALLBACK_RENEW; } -/** - * Add new transit. - * - * @note Is not necessary to delete the transit object, it will be deleted at - * the end of its operation. - * @note The transit will start playing when the program enter in the main loop, is not - * necessary to give a start to the transit. - * - * @param duration The duration of the transit in seconds. When transit starts - * to run, it will last a @p duration time. - * @return The transit object. - * - * @ingroup Transit - */ EAPI Elm_Transit * elm_transit_add(void) { Elm_Transit *transit = ELM_NEW(Elm_Transit); - if (!transit) return NULL; + if (!transit) + { + ERR("Failed to allocate a elm_transit object!"); + return NULL; + } EINA_MAGIC_SET(transit, ELM_TRANSIT_MAGIC); @@ -280,124 +410,63 @@ elm_transit_add(void) return transit; } -/** - * Stops the animation and delete the @p transit object. - * - * Call this function if you wants to stop the animation before the duration - * time. Make sure the @p transit object is still alive with - * elm_transit_del_cb_set() function. - * All added effects will be deleted, calling its repective data_free_cb - * functions. The function setted by elm_tansit_del_cb_set() will be called. - * - * @see elm_transit_del_cb_set() - * - * @param transit The transit object to be deleted. - * - * @ingroup Transit - * @warning Just call this function if you are sure the transit is alive. - */ + EAPI void elm_transit_del(Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit); if (transit->walking) transit->deleted = EINA_TRUE; - else _elm_transit_del(transit); -} - -/** - * Add a new effect to the transit. - * - * @note The cb function and the data are the key to the effect. If you try to - * add an already added effect, nothing is done. - * @note After the first addition of an effect in @p transit, if its - * effect list become empty again, the @p transit will be killed by - * elm_transit_del(transit) function. - * - * Exemple: - * @code - * Elm_Transit *transit = elm_transit_add(); - * elm_transit_effect_add(transit, - * elm_transit_effect_blend_op, - * elm_transit_effect_blend_context_new(), - * elm_transit_effect_blend_context_free); - * @endcode - * - * @param transit The transit object. - * @param cb The operation function. It is called when the animation begins, - * it is the function that actually performs the animation. It is called with - * the @p data, @p transit and the time progression of the animation (a double - * value between 0.0 and 1.0). - * @param data The context data of the effect. - * @param data_free_cb The function to free the context data, it will be called - * at the end of the effect, it must finalize the animation and free the - * @p data. - * - * @ingroup Transit - * @warning The transit free the context data at the and of the transition with - * the data_free_cb function, do not use the context data in another transit. - */ + else _transit_del(transit); +} + EAPI void -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)) +elm_transit_effect_add(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect, Elm_Transit_Effect_End_Cb end_cb) { ELM_TRANSIT_CHECK_OR_RETURN(transit); - EINA_SAFETY_ON_NULL_RETURN(cb); - Elm_Transit_Effect *effect; - Eina_List *elist; - - EINA_LIST_FOREACH(transit->effect_list, elist, effect) + EINA_SAFETY_ON_NULL_RETURN(transition_cb); + Elm_Transit_Effect_Module *effect_module; + + EINA_INLIST_FOREACH(transit->effect_list, effect_module) + if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) + { + WRN("elm_transit does not allow to add the duplicated effect! : transit=%p", transit); + return; + } + + effect_module = ELM_NEW(Elm_Transit_Effect_Module); + if (!effect_module) { - if ((effect->animation_op == cb) && (effect->user_data == data)) return; + ERR("Failed to allocate a new effect!: transit=%p", transit); + return; } - effect = ELM_NEW(Elm_Transit_Effect); - if (!effect) return; + effect_module->end_cb = end_cb; + effect_module->transition_cb = transition_cb; + effect_module->effect = effect; - effect->user_data_free = data_free_cb; - effect->animation_op = cb; - effect->user_data = data; - - transit->effect_list = eina_list_append(transit->effect_list, effect); + transit->effect_list = eina_inlist_append(transit->effect_list, (Eina_Inlist*) effect_module); } -/** - * Delete an added effect. - * - * This function will remove the effect from the @p transit, calling the - * data_free_cb to free the @p data. - * - * @see elm_transit_effect_add() - * - * @note If the effect is not found, nothing is done. - * @note If the effect list become empty, this function will call - * elm_transit_del(transit), that is, it will kill the @p transit. - * - * @param transit The transit object. - * @param cb The operation function. - * @param data The context data of the effect. - * - * @ingroup Transit - */ EAPI void -elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit *transit, double progress), void *data) +elm_transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Transition_Cb transition_cb, Elm_Transit_Effect *effect) { ELM_TRANSIT_CHECK_OR_RETURN(transit); - EINA_SAFETY_ON_NULL_RETURN(cb); - Eina_List *elist, *elist_next; - Elm_Transit_Effect *effect; + EINA_SAFETY_ON_NULL_RETURN(transition_cb); + Elm_Transit_Effect_Module *effect_module; - EINA_LIST_FOREACH_SAFE(transit->effect_list, elist, elist_next, effect) + EINA_INLIST_FOREACH(transit->effect_list, effect_module) { - if ((effect->animation_op == cb) && (effect->user_data == data)) + if ((effect_module->transition_cb == transition_cb) && (effect_module->effect == effect)) { if (transit->walking) { - effect->deleted = EINA_TRUE; + effect_module->deleted = EINA_TRUE; transit->effects_pending_del++; } else { - _elm_transit_effect_del(transit, effect, elist); + _transit_effect_del(transit, effect_module); if (!transit->effect_list) elm_transit_del(transit); } return; @@ -405,89 +474,38 @@ elm_transit_effect_del(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit } } -/** - * Add new object to apply the effects. - * - * @note After the first addition of an object in @p transit, if its - * object list become empty again, the @p transit will be killed by - * elm_transit_del(transit) function. - * @note If the @p obj belongs to another transit, the @p obj will be - * removed from it and it will only belong to the @p transit. If the old - * transit stays without objects, it will die. - * @note When you add an object into the @p transit, its state from - * evas_object_pass_events_get(obj) is saved, and it is applied when the - * transit ends, if you change this state whith evas_object_pass_events_set() - * after add the object, this state will change again when @p transit stops to - * run. - * - * @param transit The transit object. - * @param obj Object to be animated. - * - * @ingroup Transit - * @warning See the documentation of the effect if is safe add or remove - * an object after @p transit begins to run. - */ EAPI void elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj) { ELM_TRANSIT_CHECK_OR_RETURN(transit); EINA_SAFETY_ON_NULL_RETURN(obj); - Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key); - if (obj_data) + if (transit->animator) { - if (obj_data->transit == transit) return; - elm_transit_object_remove(obj_data->transit, obj); + if (!evas_object_data_get(obj, _transit_key)) + { + _transit_obj_data_update(transit, obj); + evas_object_freeze_events_set(obj, EINA_TRUE); + } } - obj_data = ELM_NEW(Elm_Obj_Data); - obj_data->state = evas_object_pass_events_get(obj); - obj_data->transit = transit; - evas_object_data_set(obj, _transit_key, obj_data); + evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, + _transit_obj_remove_cb, + transit); transit->objs = eina_list_append(transit->objs, obj); +} - if (!transit->event_enabled) - evas_object_pass_events_set(obj, EINA_TRUE); - - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _elm_transit_object_remove_cb, transit); -} - -/** - * Removes an added object from the transit. - * - * @note If the @p obj is not in the @p transit, nothing is done. - * @note If the list become empty, this function will call - * elm_transit_del(transit), that is, it will kill the @p transit. - * - * @param transit The transit object. - * @param obj Object to be removed from @p transit. - * - * @ingroup Transit - * @warning See the documentation of the effect if is safe add or remove - * an object after @p transit begins to run. - */ EAPI void elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj) { ELM_TRANSIT_CHECK_OR_RETURN(transit); EINA_SAFETY_ON_NULL_RETURN(obj); - Elm_Obj_Data *obj_data = evas_object_data_get(obj, _transit_key); - if ((!obj_data) || (obj_data->transit != transit)) return; - _elm_transit_object_remove(transit, obj); + _transit_obj_remove(transit, obj); if (!transit->objs) elm_transit_del(transit); } -/** - * Get the objects of the transit. - * - * @param transit The transit object. - * @return a Eina_List with the objects from the transit. - * - * @ingroup Transit - */ EAPI const Eina_List * elm_transit_objects_get(const Elm_Transit *transit) { @@ -495,124 +513,29 @@ elm_transit_objects_get(const Elm_Transit *transit) return transit->objs; } -/** - * Set the event enabled when transit is operating. - * - * If @p enabled is EINA_TRUE, the objects of the transit will receives - * events from mouse and keyboard during the animation. - * @note When you add an object with elm_transit_object_add(), its state from - * evas_object_pass_events_get(obj) is saved, and it is applied when the - * transit ends, if you change this state with evas_object_pass_events_set() - * after add the object, this state will change again when @p transit stops to - * run. - * - * @param transit The transit object. - * @param enabled Disable or enable. - * - * @ingroup Transit - */ EAPI void elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled) { ELM_TRANSIT_CHECK_OR_RETURN(transit); + + Eina_List *list; Evas_Object *obj; - Eina_List *elist; - Elm_Obj_Data *obj_data; if (transit->event_enabled == enabled) return; + transit->event_enabled = !!enabled; + if (!transit->animator) return; - transit->event_enabled = enabled; - - if (enabled) - { - EINA_LIST_FOREACH(transit->objs, elist, obj) - { - obj_data = evas_object_data_get(obj, _transit_key); - evas_object_pass_events_set(obj, obj_data->state); - } - } - else - { - EINA_LIST_FOREACH(transit->objs, elist, obj) - evas_object_pass_events_set(obj, EINA_TRUE); - } + EINA_LIST_FOREACH(transit->objs, list, obj) + evas_object_freeze_events_set(obj, enabled); } -/** - * Get the value of event enabled status. - * - * @see elm_transit_event_enabled_set() - * - * @param transit The Transit object - * @return EINA_TRUE, when event is enabled. If @p transit is NULL - * EINA_FALSE is returned - * - * @ingroup Transit - */ EAPI Eina_Bool elm_transit_event_enabled_get(const Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE); - return transit->event_enabled; } - -/** - * Set the event enabled when transit is operating. - * - * If @p disabled is EINA_TRUE, the objects of the transit will receives - * events from mouse and keyboard during the animation. - * @note When you add an object with elm_transit_object_add(), its state from - * evas_object_pass_events_get(obj) is saved, and it is applied when the - * transit ends, if you change this state with evas_object_pass_events_set() - * after add the object, this state will change again when @p transit stops to - * run. - * - * @see elm_transit_event_enabled_set() - * - * @param transit The transit object. - * @param disabled Disable or enable. - * - * @ingroup Transit - */ -EINA_DEPRECATED EAPI void -elm_transit_event_block_set(Elm_Transit *transit, Eina_Bool disabled) -{ - elm_transit_event_enabled_set(transit, disabled); -} - - -/** - * Get the value of event block enabled status. - * - * @see elm_transit_event_enabled_set(), elm_transit_event_enabled_get() - * - * @param transit The Transit object - * @return EINA_TRUE, when event is enabled. If @p transit is NULL - * EINA_FALSE is returned - * - * @ingroup Transit - */ -EINA_DEPRECATED EAPI Eina_Bool -elm_transit_event_block_get(const Elm_Transit *transit) -{ - return !elm_transit_event_enabled_get(transit); -} - -/** - * Set the user-callback function when the transit is deleted. - * - * @note Using this function twice will overwrite the first function setted. - * @note the @p transit object will be deleted after call @p cb function. - * - * @param transit The transit object. - * @param cb Callback function pointer. This function will be called before - * the deletion of the transit. - * @param data Callback funtion user data. It is the @p op parameter. - * - * @ingroup Transit - */ EAPI void elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit *transit), void *data) { @@ -621,20 +544,6 @@ elm_transit_del_cb_set(Elm_Transit *transit, void (*cb) (void *data, Elm_Transit transit->del_data.arg = data; } -/** - * Set reverse effect automatically. - * - * If auto reverse is setted, after running the effects with the progress - * parameter from 0 to 1, it will call the effecs again with the progress - * from 1 to 0. The transit will last for a time iqual to (2 * duration * repeat), - * where the duration was setted with the function elm_transit_add and - * the repeat with the function elm_transit_repeat_times_set(). - * - * @param transit The transit object. - * @param reverse EINA_TRUE means the auto_reverse is on. - * - * @ingroup Transit - */ EAPI void elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse) { @@ -642,39 +551,13 @@ elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse) transit->auto_reverse = reverse; } -/** - * Get if the auto reverse is on. - * - * @see elm_transit_auto_reverse_set() - * - * @param transit The transit object. - * @return EINA_TRUE means auto reverse is on. If @p transit is NULL - * EINA_FALSE is returned - * - * @ingroup Transit - */ EAPI Eina_Bool -elm_transit_auto_reverse_get(Elm_Transit *transit) +elm_transit_auto_reverse_get(const Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE); return transit->auto_reverse; } -/** - * Set the transit repeat count. Effect will be repeated by repeat count. - * - * This function sets the number of repetition the transit will run after - * the first one, that is, if @p repeat is 1, the transit will run 2 times. - * If the @p repeat is a negative number, it will repeat infinite times. - * - * @note If this function is called during the transit execution, the transit - * will run @p repeat times, ignoring the times it already performed. - * - * @param transit The transit object - * @param repeat Repeat count - * - * @ingroup Transit - */ EAPI void elm_transit_repeat_times_set(Elm_Transit *transit, int repeat) { @@ -683,57 +566,20 @@ elm_transit_repeat_times_set(Elm_Transit *transit, int repeat) transit->repeat.current = 0; } -/** - * Get the transit repeat count. - * - * @see elm_transit_repeat_times_set() - * - * @param transit The Transit object. - * @return The repeat count. If @p transit is NULL - * 0 is returned - * - * @ingroup Transit - */ EAPI int -elm_transit_repeat_times_get(Elm_Transit *transit) +elm_transit_repeat_times_get(const Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, 0); return transit->repeat.count; } -/** - * Set the transit animation acceleration type. - * - * This function sets the tween mode of the transit that can be: - * ELM_TRANSIT_TWEEN_MODE_LINEAR - The default mode. - * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Starts in accelerate mode and ends decelerating. - * ELM_TRANSIT_TWEEN_MODE_DECELERATE - The animation will be slowed over time. - * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - The animation will accelerate over time. - * - * @param transit The transit object. - * @param tween_mode The tween type. - * - * @ingroup Transit - */ EAPI void elm_transit_tween_mode_set(Elm_Transit *transit, Elm_Transit_Tween_Mode tween_mode) { ELM_TRANSIT_CHECK_OR_RETURN(transit); - transit->tween_mode = tween_mode; } -/** - * Get the transit animation acceleration type. - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * @return The tween type. If @p transit is NULL - * ELM_TRANSIT_TWEEN_MODE_LINEAR is returned. - * - * @ingroup Transit - */ EAPI Elm_Transit_Tween_Mode elm_transit_tween_mode_get(const Elm_Transit *transit) { @@ -741,76 +587,51 @@ elm_transit_tween_mode_get(const Elm_Transit *transit) return transit->tween_mode; } -/** - * Set the transit animation time - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * @param duration The animation time. - * - * @ingroup Transit - */ EAPI void elm_transit_duration_set(Elm_Transit *transit, double duration) { ELM_TRANSIT_CHECK_OR_RETURN(transit); - if (transit->animator) return; + if (transit->animator) + { + WRN("elm_transit does not allow to set the duration time in operating! : transit=%p", transit); + return; + } transit->time.duration = duration; } -/** - * Get the transit animation time - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * - * @return The transit animation time. - * - * @ingroup Transit - */ -EAPI double +EAPI double elm_transit_duration_get(const Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, 0.0); return transit->time.duration; } -/** - * Starts the transition. - * Once this API is called, the transit begins to measure the time. - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * - * @ingroup Transit - */ EAPI void elm_transit_go(Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit); + Eina_List *elist; + Evas_Object *obj; + if (transit->animator) - ecore_animator_del(transit->animator); + ecore_animator_del(transit->animator); + + EINA_LIST_FOREACH(transit->objs, elist, obj) + _transit_obj_data_update(transit, obj); + + if (!transit->event_enabled) + { + EINA_LIST_FOREACH(transit->objs, elist, obj) + evas_object_freeze_events_set(obj, EINA_TRUE); + } transit->time.paused = 0; transit->time.delayed = 0; transit->time.begin = ecore_loop_time_get(); - transit->animator = ecore_animator_add(_animator_animate_cb, transit); -} - -/** - * Pause/Resume the transition. - * If you call elm_transit_go again, paused states will affect no anymore. - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * - * @ingroup Transit - */ + transit->animator = ecore_animator_add(_transit_animate_cb, transit); +} + EAPI void elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused) { @@ -820,57 +641,32 @@ elm_transit_paused_set(Elm_Transit *transit, Eina_Bool paused) if (paused) { - if (transit->time.paused > 0) - return; + if (transit->time.paused > 0) + return; ecore_animator_freeze(transit->animator); transit->time.paused = ecore_loop_time_get(); } else { - if (transit->time.paused == 0) - return; + if (transit->time.paused == 0) + return; ecore_animator_thaw(transit->animator); transit->time.delayed += (ecore_loop_time_get() - transit->time.paused); transit->time.paused = 0; } } -/** - * Get the value of paused status. - * - * @see elm_transit_paused_set() - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * @return EINA_TRUE means transition is paused. If @p transit is NULL - * EINA_FALSE is returned - * - * @ingroup Transit - */ EAPI Eina_Bool elm_transit_paused_get(const Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE); - if (transit->time.paused == 0) - return EINA_FALSE; + if (transit->time.paused == 0) + return EINA_FALSE; return EINA_TRUE; } -/** - * Get the time progression of the animation (a double value between 0.0 and 1.0). - * - * @note @p transit can not be NULL - * - * @param transit The transit object. - * - * @return The time progression value. If @p transit is NULL - * 0 is returned - * - * @ingroup Transit - */ EAPI double elm_transit_progress_value_get(const Elm_Transit *transit) { @@ -879,9 +675,74 @@ elm_transit_progress_value_get(const Elm_Transit *transit) return transit->progress; } -/////////////////////////////////////////////////////////////////////////////// -//Resizing FX -/////////////////////////////////////////////////////////////////////////////// +EAPI void +elm_transit_objects_final_state_keep_set(Elm_Transit *transit, Eina_Bool state_keep) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit); + + if (transit->state_keep == state_keep) return; + if (transit->animator) + { + WRN("elm_transit does not allow to change final state keep mode in operating! : transit=%p", transit); + return; + } + transit->state_keep = !!state_keep; +} + +EAPI Eina_Bool +elm_transit_objects_final_state_keep_get(const Elm_Transit *transit) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit, EINA_FALSE); + return transit->state_keep; +} + +EAPI void +elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit); + ELM_TRANSIT_CHECK_OR_RETURN(chain_transit); + + if (transit == chain_transit) + { + WRN("You add a same transit as a chain transit! : transit=%p, chain_transit=%p", transit, chain_transit); + return; + } + if (transit == chain_transit->prev_chain_transit) + return; + + if (chain_transit->prev_chain_transit) + chain_transit->prev_chain_transit->next_chain_transits = eina_list_remove(chain_transit->prev_chain_transit->next_chain_transits, chain_transit); + + chain_transit->prev_chain_transit = transit; + transit->next_chain_transits = eina_list_append(transit->next_chain_transits, chain_transit); +} + +EAPI void +elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit); + ELM_TRANSIT_CHECK_OR_RETURN(chain_transit); + + if (chain_transit->prev_chain_transit != transit) + { + WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit); + return; + } + + chain_transit->prev_chain_transit = NULL; + transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit); +} + +EAPI Eina_List * +elm_transit_chain_transits_get(const Elm_Transit * transit) +{ + ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); + return transit->next_chain_transits; +} + +/////////////////////////////////////////////////////////////////////////// +//Resizing Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Resizing Elm_Transit_Effect_Resizing; struct _Elm_Transit_Effect_Resizing @@ -892,29 +753,30 @@ struct _Elm_Transit_Effect_Resizing }; static void -_transit_effect_resizing_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_resizing_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - free(data); + Elm_Transit_Effect_Resizing *resizing = effect; + free(resizing); } static void -_transit_effect_resizing_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_resizing_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Evas_Coord w, h; Evas_Object *obj; Eina_List *elist; - Elm_Transit_Effect_Resizing *resizing = data; + Elm_Transit_Effect_Resizing *resizing = effect; w = resizing->from.w + (resizing->to.w * progress); h = resizing->from.h + (resizing->to.h * progress); EINA_LIST_FOREACH(transit->objs, elist, obj) - evas_object_resize(obj, w, h); + evas_object_resize(obj, w, h); } -static void * +static Elm_Transit_Effect * _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h) { Elm_Transit_Effect_Resizing *resizing; @@ -930,43 +792,26 @@ _transit_effect_resizing_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_ return resizing; } -/** - * Add the Resizing Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates resizing effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect will be applied to the objects that are in the transit, - * @note If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param from_w Object width size when effect begins. - * @param from_h Object height size when effect begins. - * @param to_w Object width size when effect ends. - * @param to_h Object height size when effect ends. - * @return Resizing effect context data. - * - * @ingroup Transit - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_resizing_add(Elm_Transit *transit, Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h); + Elm_Transit_Effect *effect = _transit_effect_resizing_context_new(from_w, from_h, to_w, to_h); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_resizing_op, effect_context, + if (!effect) + { + ERR("Failed to allocate resizing effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_resizing_op, effect, _transit_effect_resizing_context_free); - return effect_context; + return effect; } -/////////////////////////////////////////////////////////////////////////////// -//Translation FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Translation Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Translation Elm_Transit_Effect_Translation; typedef struct _Elm_Transit_Effect_Translation_Node Elm_Transit_Effect_Translation_Node; @@ -1028,10 +873,10 @@ _translation_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Translation *t } void -_transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_translation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); - Elm_Transit_Effect_Translation *translation = data; + EINA_SAFETY_ON_NULL_RETURN(effect); + Elm_Transit_Effect_Translation *translation = effect; Eina_List *elist, *elist_next; Elm_Transit_Effect_Translation_Node *translation_node; @@ -1047,17 +892,17 @@ _transit_effect_translation_context_free(void *data, Elm_Transit *transit __UNUS } void -_transit_effect_translation_op(void *data, Elm_Transit *transit, double progress __UNUSED__) +_transit_effect_translation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Evas_Coord x, y; - Elm_Transit_Effect_Translation *translation = data; + Elm_Transit_Effect_Translation *translation = effect; Elm_Transit_Effect_Translation_Node *translation_node; Eina_List *elist; if (!translation->nodes) - translation->nodes = _translation_nodes_build(transit, translation); + translation->nodes = _translation_nodes_build(transit, translation); EINA_LIST_FOREACH(translation->nodes, elist, translation_node) { @@ -1069,7 +914,7 @@ _transit_effect_translation_op(void *data, Elm_Transit *transit, double progress } } -static void * +static Elm_Transit_Effect * _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy) { Elm_Transit_Effect_Translation *translation; @@ -1085,50 +930,26 @@ _transit_effect_translation_context_new(Evas_Coord from_dx, Evas_Coord from_dy, return translation; } -/** - * Add the Translation Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates translation effect context - * and add it's required APIs to elm_transit_effect_add. - * @note When this function is called, it gets the current objects in - * the transit, that is, elm_transit_object_remove() and elm_transit_object_add() - * will not cause any changes in the set of objects that this effect is being - * applied. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param from_dx X Position variation when effect begins. - * @param from_dy Y Position variation when effect begins. - * @param to_dx X Position variation when effect ends. - * @param to_dy Y Position variation when effect ends. - * @return Translation effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_translation_add(Elm_Transit *transit, Evas_Coord from_dx, Evas_Coord from_dy, Evas_Coord to_dx, Evas_Coord to_dy) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy); + Elm_Transit_Effect *effect = _transit_effect_translation_context_new(from_dx, from_dy, to_dx, to_dy); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_translation_op, effect_context, + if (!effect) + { + ERR("Failed to allocate translation effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_translation_op, effect, _transit_effect_translation_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Zoom FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Zoom Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Zoom Elm_Transit_Effect_Zoom; struct _Elm_Transit_Effect_Zoom @@ -1137,19 +958,20 @@ struct _Elm_Transit_Effect_Zoom }; void -_transit_effect_zoom_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_zoom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - free(data); + Elm_Transit_Effect_Zoom *zoom = effect; + free(zoom); } static void -_transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress) +_transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Evas_Object *obj; Eina_List *elist; - Elm_Transit_Effect_Zoom *zoom = data; + Elm_Transit_Effect_Zoom *zoom = effect; Evas_Map *map; Evas_Coord x, y, w, h; @@ -1161,14 +983,14 @@ _transit_effect_zoom_op(void *data, Elm_Transit *transit , double progress) evas_object_geometry_get(obj, &x, &y, &w, &h); evas_map_util_points_populate_from_object_full(map, obj, zoom->from + (progress * zoom->to)); - evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL); + evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL); evas_object_map_set(obj, map); evas_object_map_enable_set(obj, EINA_TRUE); } evas_map_free(map); } -static void * +static Elm_Transit_Effect * _transit_effect_zoom_context_new(float from_rate, float to_rate) { Elm_Transit_Effect_Zoom *zoom; @@ -1176,53 +998,32 @@ _transit_effect_zoom_context_new(float from_rate, float to_rate) zoom = ELM_NEW(Elm_Transit_Effect_Zoom); if (!zoom) return NULL; - zoom->from = (FOCAL - (from_rate * FOCAL)) * (1 / from_rate); - zoom->to = ((FOCAL - (to_rate * FOCAL)) * (1 / to_rate)) - zoom->from; + zoom->from = (_TRANSIT_FOCAL - (from_rate * _TRANSIT_FOCAL)) * (1 / from_rate); + zoom->to = ((_TRANSIT_FOCAL - (to_rate * _TRANSIT_FOCAL)) * (1 / to_rate)) - zoom->from; return zoom; } -/** - * Add the Zoom Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates zoom effect context - * and add it's required APIs to elm_transit_effect_add. - * @note If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param from_rate Scale rate when effect begins (1 is current rate). - * @param to_rate Scale rate when effect ends. - * @return Zoom effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_zoom_add(Elm_Transit *transit, float from_rate, float to_rate) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_zoom_context_new(from_rate, to_rate); + Elm_Transit_Effect *effect = _transit_effect_zoom_context_new(from_rate, to_rate); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_zoom_op, effect_context, + if (!effect) + { + ERR("Failed to allocate zoom effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_zoom_op, effect, _transit_effect_zoom_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Flip FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Flip Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Flip Elm_Transit_Effect_Flip; struct _Elm_Transit_Effect_Flip @@ -1232,10 +1033,11 @@ struct _Elm_Transit_Effect_Flip }; static void -_transit_effect_flip_context_free(void *data, Elm_Transit *transit) +_transit_effect_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); + Elm_Transit_Effect_Flip *flip = effect; Evas_Object *front, *back; int i; int count = eina_list_count(transit->objs); @@ -1247,17 +1049,17 @@ _transit_effect_flip_context_free(void *data, Elm_Transit *transit) evas_object_map_enable_set(front, EINA_FALSE); evas_object_map_enable_set(back, EINA_FALSE); } - free(data); + free(flip); } static void -_transit_effect_flip_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Evas_Object *obj, *front, *back; int count, i; - Elm_Transit_Effect_Flip *flip = data; + Elm_Transit_Effect_Flip *flip = effect; Evas_Map *map; float degree; Evas_Coord x, y, w, h; @@ -1269,6 +1071,7 @@ _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress) else degree = (float)(progress * -180); count = eina_list_count(transit->objs); + for (i = 0; i < (count - 1); i += 2) { Evas_Coord half_w, half_h; @@ -1279,7 +1082,7 @@ _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress) if ((degree < 90) && (degree > -90)) { obj = front; - if (front != back) + if (front != back) { evas_object_hide(back); evas_object_show(front); @@ -1324,7 +1127,7 @@ _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress) evas_map_util_3d_rotate(map, degree, 0, 0, x + half_w, y + half_h, 0); } - evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL); + evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL); evas_object_map_enable_set(front, EINA_TRUE); evas_object_map_enable_set(back, EINA_TRUE); evas_object_map_set(obj, map); @@ -1332,7 +1135,7 @@ _transit_effect_flip_op(void *data, Elm_Transit *transit, double progress) evas_map_free(map); } -static void * +static Elm_Transit_Effect * _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw) { Elm_Transit_Effect_Flip *flip; @@ -1346,49 +1149,26 @@ _transit_effect_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw return flip; } -/** - * Add the Flip Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates flip effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect is applied to each pair of objects in the order they are listed - * in the transit list of objects. The first object in the pair will be the - * "front" object and the second will be the "back" object. - * @note If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param axis Flipping Axis(X or Y). - * @param cw Flipping Direction. EINA_TRUE is clock-wise. - * @return Flip effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_flip_context_new(axis, cw); + Elm_Transit_Effect *effect = _transit_effect_flip_context_new(axis, cw); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_flip_op, effect_context, + if (!effect) + { + ERR("Failed to allocate flip effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_flip_op, effect, _transit_effect_flip_context_free); - return effect_context; + return effect; } -/////////////////////////////////////////////////////////////////////////////// -//ResizableFlip FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//ResizableFlip Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Resizable_Flip Elm_Transit_Effect_ResizableFlip; typedef struct _Elm_Transit_Effect_Resizable_Flip_Node Elm_Transit_Effect_ResizableFlip_Node; @@ -1418,11 +1198,11 @@ _resizable_flip_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node) { if (resizable_flip_node->front == obj) - evas_object_event_callback_del(resizable_flip_node->back, - EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb); + evas_object_event_callback_del(resizable_flip_node->back, + EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb); else if (resizable_flip_node->back == obj) - evas_object_event_callback_del(resizable_flip_node->front, - EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb); + evas_object_event_callback_del(resizable_flip_node->front, + EVAS_CALLBACK_DEL, _resizable_flip_object_del_cb); else continue; resizable_flip->nodes = eina_list_remove_list(resizable_flip->nodes, @@ -1531,11 +1311,11 @@ _set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *fl } void -_transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_resizable_flip_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); - Elm_Transit_Effect_ResizableFlip *resizable_flip = data; + Elm_Transit_Effect_ResizableFlip *resizable_flip = effect; Eina_List *elist, *elist_next; Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node; @@ -1558,15 +1338,15 @@ _transit_effect_resizable_flip_context_free(void *data, Elm_Transit *transit __U } void -_transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, double progress) +_transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); Evas_Map *map; Evas_Object *obj; float x, y, w, h; float degree; Evas_Coord half_w, half_h; - Elm_Transit_Effect_ResizableFlip *resizable_flip = data; + Elm_Transit_Effect_ResizableFlip *resizable_flip = effect; Elm_Transit_Effect_ResizableFlip_Node *resizable_flip_node; Eina_List *elist; @@ -1577,8 +1357,8 @@ _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, d else degree = (float)(progress * -180); if (!resizable_flip->nodes) - resizable_flip->nodes = _resizable_flip_nodes_build(transit, - resizable_flip); + resizable_flip->nodes = _resizable_flip_nodes_build(transit, + resizable_flip); EINA_LIST_FOREACH(resizable_flip->nodes, elist, resizable_flip_node) { @@ -1630,7 +1410,7 @@ _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, d 0, x + half_w, y + half_h, 0); } - evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL); + evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL); evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE); evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE); evas_object_map_set(obj, map); @@ -1638,7 +1418,7 @@ _transit_effect_resizable_flip_op(void *data, Elm_Transit *transit __UNUSED__, d evas_map_free(map); } -static void * +static Elm_Transit_Effect * _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw) { Elm_Transit_Effect_ResizableFlip *resizable_flip; @@ -1652,51 +1432,26 @@ _transit_effect_resizable_flip_context_new(Elm_Transit_Effect_Flip_Axis axis, Ei return resizable_flip; } -/** - * Add the Resizable Flip Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates resizable flip effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect is applied to each pair of objects in the order they are listed - * in the transit list of objects. The first object in the pair will be the - * "front" object and the second will be the "back" object. - * @note When this function is called, it gets the current objects in - * the transit, that is, elm_transit_object_remove() and elm_transit_object_add() - * will not cause any changes in the set of objects that this effect is being - * applied. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param axis Flipping Axis(X or Y). - * @param cw Flipping Direction. EINA_TRUE is clock-wise. - * @return Resizable flip effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_resizable_flip_add(Elm_Transit *transit, Elm_Transit_Effect_Flip_Axis axis, Eina_Bool cw) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_resizable_flip_context_new(axis, cw); + Elm_Transit_Effect *effect = _transit_effect_resizable_flip_context_new(axis, cw); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_resizable_flip_op, effect_context, + if (!effect) + { + ERR("Failed to allocate resizable_flip effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_resizable_flip_op, effect, _transit_effect_resizable_flip_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Wipe FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Wipe Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Wipe Elm_Transit_Effect_Wipe; struct _Elm_Transit_Effect_Wipe @@ -1763,7 +1518,7 @@ _elm_fx_wipe_hide(Evas_Map * map, Elm_Transit_Effect_Wipe_Dir dir, float x, floa default: break; } - evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL); + evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL); } static void @@ -1824,24 +1579,24 @@ _elm_fx_wipe_show(Evas_Map *map, Elm_Transit_Effect_Wipe_Dir dir, float x, float default: break; } - evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, FOCAL); + evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL); } static void -_transit_effect_wipe_context_free(void *data, Elm_Transit *transit) +_transit_effect_wipe_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Eina_List *elist; Evas_Object *obj; - Elm_Transit_Effect_Wipe *wipe = data; + Elm_Transit_Effect_Wipe *wipe = effect; Eina_Bool reverse = elm_transit_auto_reverse_get(transit); EINA_LIST_FOREACH(transit->objs, elist, obj) { if ((wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW && !reverse) || (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE && reverse)) - evas_object_show(obj); + evas_object_show(obj); else evas_object_hide(obj); evas_object_map_enable_set(obj, EINA_FALSE); } @@ -1850,11 +1605,11 @@ _transit_effect_wipe_context_free(void *data, Elm_Transit *transit) } static void -_transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); - Elm_Transit_Effect_Wipe *wipe = data; + Elm_Transit_Effect_Wipe *wipe = effect; Evas_Map *map; Evas_Coord _x, _y, _w, _h; Eina_List *elist; @@ -1868,9 +1623,9 @@ _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress) evas_object_geometry_get(obj, &_x, &_y, &_w, &_h); if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW) - _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress); + _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress); else - _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress); + _elm_fx_wipe_hide(map, wipe->dir, _x, _y, _w, _h, (float)progress); evas_object_map_enable_set(obj, EINA_TRUE); evas_object_map_set(obj, map); @@ -1878,7 +1633,7 @@ _transit_effect_wipe_op(void *data, Elm_Transit *transit, double progress) evas_map_free(map); } -static void * +static Elm_Transit_Effect * _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir) { Elm_Transit_Effect_Wipe *wipe; @@ -1892,48 +1647,26 @@ _transit_effect_wipe_context_new(Elm_Transit_Effect_Wipe_Type type, Elm_Transit_ return wipe; } -/** - * Add the Wipe Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates wipe effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect will be applied to the objects that are in the transit, - * If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param type Wipe type. Hide or show. - * @param dir Wipe Direction. - * @return Wipe effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ EAPI void * elm_transit_effect_wipe_add(Elm_Transit *transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_wipe_context_new(type, dir); + void *effect = _transit_effect_wipe_context_new(type, dir); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_wipe_op, effect_context, + if (!effect) + { + ERR("Failed to allocate wipe effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_wipe_op, effect, _transit_effect_wipe_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Color FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Color Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Color Elm_Transit_Effect_Color; struct _Elm_Transit_Effect_Color @@ -1947,17 +1680,18 @@ struct _Elm_Transit_Effect_Color }; static void -_transit_effect_color_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_color_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - free(data); + Elm_Transit_Effect_Color *color = effect; + free(color); } static void -_transit_effect_color_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_color_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); - Elm_Transit_Effect_Color *color = data; + Elm_Transit_Effect_Color *color = effect; Evas_Object *obj; Eina_List *elist; unsigned int r, g, b, a; @@ -1968,10 +1702,10 @@ _transit_effect_color_op(void *data, Elm_Transit *transit, double progress) a = (color->from.a + (int)((float)color->to.a * progress)); EINA_LIST_FOREACH(transit->objs, elist, obj) - evas_object_color_set(obj, r, g, b, a); + evas_object_color_set(obj, r, g, b, a); } -static void * +static Elm_Transit_Effect * _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) { Elm_Transit_Effect_Color *color; @@ -1991,47 +1725,26 @@ _transit_effect_color_context_new(unsigned int from_r, unsigned int from_g, unsi return color; } -/** - * Add the Color Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates color effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect will be applied to the objects that are in the transit, - * If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param from_r RGB R when effect begins. - * @param from_g RGB G when effect begins. - * @param from_b RGB B when effect begins. - * @param from_a RGB A when effect begins. - * @param to_r RGB R when effect ends. - * @param to_g RGB G when effect ends. - * @param to_b RGB B when effect ends. - * @param to_a RGB A when effect ends. - * @return Color effect context data. - * - * @ingroup Transit - */ -EAPI void * +EAPI Elm_Transit_Effect * 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) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a); + Elm_Transit_Effect *effect = _transit_effect_color_context_new(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_color_op, effect_context, + if (!effect) + { + ERR("Failed to allocate color effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_color_op, effect, _transit_effect_color_context_free); - return effect_context; + return effect; } -/////////////////////////////////////////////////////////////////////////////// -//Fade FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Fade Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Fade Elm_Transit_Effect_Fade; typedef struct _Elm_Transit_Effect_Fade_Node Elm_Transit_Effect_Fade_Node; @@ -2060,11 +1773,11 @@ _fade_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *even EINA_LIST_FOREACH(fade->nodes, elist, fade_node) { if (fade_node->before == obj) - evas_object_event_callback_del(fade_node->after, - EVAS_CALLBACK_DEL, _fade_object_del_cb); + evas_object_event_callback_del(fade_node->after, + EVAS_CALLBACK_DEL, _fade_object_del_cb); else if (fade_node->after == obj) - evas_object_event_callback_del(fade_node->before, - EVAS_CALLBACK_DEL, _fade_object_del_cb); + evas_object_event_callback_del(fade_node->before, + EVAS_CALLBACK_DEL, _fade_object_del_cb); else continue; fade->nodes = eina_list_remove_list(fade->nodes, elist); @@ -2081,7 +1794,7 @@ _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data) int i, count; count = eina_list_count(transit->objs); - for (i = 0; i < (count - 1); i += 2) + for (i = 0; i < count; i += 2) { fade = ELM_NEW(Elm_Transit_Effect_Fade_Node); if (!fade) @@ -2114,10 +1827,10 @@ _fade_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Fade *fade_data) } static void -_transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_fade_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); - Elm_Transit_Effect_Fade *fade = data; + EINA_SAFETY_ON_NULL_RETURN(effect); + Elm_Transit_Effect_Fade *fade = effect; Elm_Transit_Effect_Fade_Node *fade_node; Eina_List *elist, *elist_next; @@ -2144,16 +1857,16 @@ _transit_effect_fade_context_free(void *data, Elm_Transit *transit __UNUSED__) } static void -_transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double progress) +_transit_effect_fade_op(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); - Elm_Transit_Effect_Fade *fade = data; + EINA_SAFETY_ON_NULL_RETURN(effect); + Elm_Transit_Effect_Fade *fade = effect; Eina_List *elist; Elm_Transit_Effect_Fade_Node *fade_node; float _progress; if (!fade->nodes) - fade->nodes = _fade_nodes_build(transit, fade); + fade->nodes = _fade_nodes_build(transit, fade); EINA_LIST_FOREACH(fade->nodes, elist, fade_node) { @@ -2196,7 +1909,7 @@ _transit_effect_fade_op(void *data, Elm_Transit *transit __UNUSED__, double prog } } -static void * +static Elm_Transit_Effect * _transit_effect_fade_context_new(void) { Elm_Transit_Effect_Fade *fade; @@ -2205,49 +1918,27 @@ _transit_effect_fade_context_new(void) return fade; } -/** - * Add the Fade Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates fade effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect is applied to each pair of objects in the order they are listed - * in the transit list of objects. The first object in the pair will be the - * "before" object and the second will be the "after" object. - * @note When this function is called, it gets the current objects in - * the transit, that is, elm_transit_object_remove() and elm_transit_object_add() - * will not cause any changes in the set of objects that this effect is being - * applied. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @return Fade effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the color information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_fade_add(Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_fade_context_new(); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_fade_op, effect_context, + Elm_Transit_Effect *effect = _transit_effect_fade_context_new(); + + if (!effect) + { + ERR("Failed to allocate fade effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_fade_op, effect, _transit_effect_fade_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Blend FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Blend Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Blend Elm_Transit_Effect_Blend; typedef struct _Elm_Transit_Effect_Blend_Node Elm_Transit_Effect_Blend_Node; @@ -2273,11 +1964,11 @@ _blend_object_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *eve EINA_LIST_FOREACH(blend->nodes, elist, blend_node) { if (blend_node->after == obj) - evas_object_event_callback_del(blend_node->before, - EVAS_CALLBACK_DEL, _blend_object_del_cb); + evas_object_event_callback_del(blend_node->before, + EVAS_CALLBACK_DEL, _blend_object_del_cb); else if (blend_node->before == obj) - evas_object_event_callback_del(blend_node->after, - EVAS_CALLBACK_DEL, _blend_object_del_cb); + evas_object_event_callback_del(blend_node->after, + EVAS_CALLBACK_DEL, _blend_object_del_cb); else continue; blend->nodes = eina_list_remove_list(blend->nodes, elist); @@ -2326,10 +2017,10 @@ _blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend) } void -_transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_blend_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); - Elm_Transit_Effect_Blend *blend = data; + EINA_SAFETY_ON_NULL_RETURN(effect); + Elm_Transit_Effect_Blend *blend = effect; Elm_Transit_Effect_Blend_Node *blend_node; Eina_List *elist, *elist_next; @@ -2343,9 +2034,9 @@ _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__) blend_node->to.a); if (elm_transit_auto_reverse_get(transit)) - evas_object_hide(blend_node->after); + evas_object_hide(blend_node->after); else - evas_object_hide(blend_node->before); + evas_object_hide(blend_node->before); blend->nodes = eina_list_remove_list(blend->nodes, elist); @@ -2355,15 +2046,15 @@ _transit_effect_blend_context_free(void *data, Elm_Transit *transit __UNUSED__) EVAS_CALLBACK_DEL, _blend_object_del_cb); free(blend_node); } - free(data); + free(blend); } void -_transit_effect_blend_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_blend_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); - Elm_Transit_Effect_Blend *blend = data; + Elm_Transit_Effect_Blend *blend = effect; Elm_Transit_Effect_Blend_Node *blend_node; Eina_List *elist; @@ -2384,7 +2075,7 @@ _transit_effect_blend_op(void *data, Elm_Transit *transit, double progress) } } -static void * +static Elm_Transit_Effect * _transit_effect_blend_context_new(void) { Elm_Transit_Effect_Blend *blend; @@ -2394,49 +2085,26 @@ _transit_effect_blend_context_new(void) return blend; } -/** - * Add the Blend Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates blend effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect is applied to each pair of objects in the order they are listed - * in the transit list of objects. The first object in the pair will be the - * "before" object and the second will be the "after" object. - * @note When this function be called, it gets the current objects in - * the transit, that is, elm_transit_object_remove() and elm_transit_object_add() - * will not cause any changes in the set of objects that this effect is being - * applied. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @return Blend effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the color information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_blend_add(Elm_Transit *transit) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_blend_context_new(); + Elm_Transit_Effect *effect = _transit_effect_blend_context_new(); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_blend_op, effect_context, + if (!effect) + { + ERR("Failed to allocate blend effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_blend_op, effect, _transit_effect_blend_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -//Rotation FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//Rotation Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Rotation Elm_Transit_Effect_Rotation; struct _Elm_Transit_Effect_Rotation @@ -2445,17 +2113,18 @@ struct _Elm_Transit_Effect_Rotation }; static void -_transit_effect_rotation_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_rotation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - free(data); + Elm_Transit_Effect_Rotation *rotation = effect; + free(rotation); } static void -_transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_rotation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); - Elm_Transit_Effect_Rotation *rotation = data; + Elm_Transit_Effect_Rotation *rotation = effect; Evas_Map *map; Evas_Coord x, y, w, h; float degree; @@ -2476,15 +2145,15 @@ _transit_effect_rotation_op(void *data, Elm_Transit *transit, double progress) half_w = (float)w * 0.5; half_h = (float)h * 0.5; - evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0); - evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, FOCAL); + evas_map_util_rotate(map, degree, x + half_w, y + half_h); + evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL); evas_object_map_enable_set(obj, EINA_TRUE); evas_object_map_set(obj, map); } evas_map_free(map); } -static void * +static Elm_Transit_Effect * _transit_effect_rotation_context_new(float from_degree, float to_degree) { Elm_Transit_Effect_Rotation *rotation; @@ -2498,48 +2167,26 @@ _transit_effect_rotation_context_new(float from_degree, float to_degree) return rotation; } -/** - * Add the Rotation Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates rotation effect context - * and add it's required APIs to elm_transit_effect_add. - * @note This effect will be applied to the objects that are in the transit, - * If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param from_degree Degree when effect begins. - * @param to_degree Degree when effect is ends. - * @return Rotation effect context data. - * - * @ingroup Transit - * @warning Is higher recommended just create a transit with this effect when - * the window that the objects of the transit belongs has already been created. - * This is because this effect needs the geometry information about the objects, - * and if the window was not created yet, it can get a wrong information. - * @warning Is not recommended remove or add an object after the transit begins - * to run, because the order of the objects will be affected. - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_rotation_add(Elm_Transit *transit, float from_degree, float to_degree) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_rotation_context_new(from_degree, to_degree); + Elm_Transit_Effect *effect = _transit_effect_rotation_context_new(from_degree, to_degree); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_rotation_op, effect_context, + if (!effect) + { + ERR("Failed to allocate rotation effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_rotation_op, effect, _transit_effect_rotation_context_free); - return effect_context; + return effect; } - -/////////////////////////////////////////////////////////////////////////////// -// ImageAnimation FX -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +//ImageAnimation Effect +/////////////////////////////////////////////////////////////////////////// typedef struct _Elm_Transit_Effect_Image_Animation Elm_Transit_Effect_Image_Animation; struct _Elm_Transit_Effect_Image_Animation @@ -2548,10 +2195,10 @@ struct _Elm_Transit_Effect_Image_Animation }; static void -_transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __UNUSED__) +_transit_effect_image_animation_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__) { - EINA_SAFETY_ON_NULL_RETURN(data); - Elm_Transit_Effect_Image_Animation *image_animation = data; + EINA_SAFETY_ON_NULL_RETURN(effect); + Elm_Transit_Effect_Image_Animation *image_animation = effect; const char *image; Eina_List *elist, *elist_next; @@ -2562,18 +2209,18 @@ _transit_effect_image_animation_context_free(void *data, Elm_Transit *transit __ eina_stringshare_del(image); } - free(data); + free(image_animation); } static void -_transit_effect_image_animation_op(void *data, Elm_Transit *transit, double progress) +_transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress) { - EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(effect); EINA_SAFETY_ON_NULL_RETURN(transit); Eina_List *elist; Evas_Object *obj; const char *type; - Elm_Transit_Effect_Image_Animation *image_animation = data; + Elm_Transit_Effect_Image_Animation *image_animation = effect; unsigned int count = 0; int len; @@ -2585,15 +2232,15 @@ _transit_effect_image_animation_op(void *data, Elm_Transit *transit, double prog EINA_LIST_FOREACH(transit->objs, elist, obj) { - if (elm_widget_type_check(obj, type)) - elm_icon_file_set(obj, - eina_list_nth(image_animation->images, count), NULL); + if (elm_widget_type_check(obj, type, __func__)) + elm_icon_file_set(obj, + eina_list_nth(image_animation->images, count), NULL); } eina_stringshare_del(type); } -static void * +static Elm_Transit_Effect * _transit_effect_image_animation_context_new(Eina_List *images) { Elm_Transit_Effect_Image_Animation *image_animation; @@ -2604,53 +2251,19 @@ _transit_effect_image_animation_context_new(Eina_List *images) return image_animation; } -/** - * Add the Rotation Effect to Elm_Transit. - * - * @note This API is one of the facades. It creates image animation effect context - * and add it's required APIs to elm_transit_effect_add. - * The @p images parameter is a list images paths. This list and - * its contents will be deleted at the end of the effect by - * elm_transit_effect_image_animation_context_free() function. - * @note This effect will be applied to the objects that are in the transit, - * If you change the set of objects in the transit with elm_transit_object_add() - * or elm_transit_object_remove(), the set of objects affected by this effect - * will be changed too. - * - * Example: - * @code - * char buf[PATH_MAX]; - * Eina_List *images = NULL; - * Elm_Transit *transi = elm_transit_add(); - * - * snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR); - * images = eina_list_append(images, eina_stringshare_add(buf)); - * - * snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); - * images = eina_list_append(images, eina_stringshare_add(buf)); - * elm_transit_effect_image_animation_add(transi, images); - * - * @endcode - * - * @see elm_transit_effect_add() - * - * @param transit Transit object. - * @param images Eina_List of images file paths. This list and - * its contents will be deleted at the end of the effect by - * elm_transit_effect_image_animation_context_free() function. - * @return Image Animation effect context data. - * - * @ingroup Transit - */ -EAPI void * +EAPI Elm_Transit_Effect * elm_transit_effect_image_animation_add(Elm_Transit *transit, Eina_List *images) { ELM_TRANSIT_CHECK_OR_RETURN(transit, NULL); - void *effect_context = _transit_effect_image_animation_context_new(images); + Elm_Transit_Effect *effect = _transit_effect_image_animation_context_new(images); - if (!effect_context) return NULL; - elm_transit_effect_add(transit, - _transit_effect_image_animation_op, effect_context, + if (!effect) + { + ERR("Failed to allocate image_animation effect! : transit=%p", transit); + return NULL; + } + elm_transit_effect_add(transit, + _transit_effect_image_animation_op, effect, _transit_effect_image_animation_context_free); - return effect_context; + return effect; }