From 9503e68946e93115dd4c3b97668f89ecf46e3470 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Mon, 18 Jul 2011 15:55:33 +0900 Subject: [PATCH] elm_transit - merged with opensource 1. added a new APIs elm_transit_chain_transit_del 2. type defined to Elm_Transit_Del_Cb for transit deleltion callback function. 3. fixed the logic for chaining transition.fixed to call the chain transitions when the transit is finished actually. --- src/lib/Elementary.h.in | 4 ++- src/lib/elm_transit.c | 66 ++++++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 7cc629d..b001d3d 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -3036,6 +3036,7 @@ extern "C" { typedef void Elm_Transit_Effect; typedef void (*Elm_Transit_Effect_Transition_Cb) (Elm_Transit_Effect *effect, Elm_Transit *transit, double progress); typedef void (*Elm_Transit_Effect_End_Cb) (Elm_Transit_Effect *effect, Elm_Transit *transit); + typedef void (*Elm_Transit_Del_Cb) (void *data, Elm_Transit *transit); EAPI Elm_Transit *elm_transit_add(void); EAPI void elm_transit_del(Elm_Transit *transit) EINA_ARG_NONNULL(1); @@ -3050,7 +3051,7 @@ extern "C" { EINA_DEPRECATED EAPI Eina_Bool elm_transit_event_block_get(const Elm_Transit *transit) EINA_ARG_NONNULL(1); EAPI void elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_transit_event_enabled_get(const Elm_Transit *transit) EINA_ARG_NONNULL(1); - EAPI void elm_transit_del_cb_set(Elm_Transit *transit, void (*cb)(void *data, Elm_Transit* transit), void *data) EINA_ARG_NONNULL(1); + EAPI void elm_transit_del_cb_set(Elm_Transit *transit, Elm_Transit_Del_Cb cb, void *data) EINA_ARG_NONNULL(1); EAPI void elm_transit_auto_reverse_set(Elm_Transit *transit, Eina_Bool reverse) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_transit_auto_reverse_get(const Elm_Transit *transit) EINA_ARG_NONNULL(1); EAPI void elm_transit_repeat_times_set(Elm_Transit *transit, int repeat) EINA_ARG_NONNULL(1); @@ -3064,6 +3065,7 @@ extern "C" { EAPI Eina_Bool elm_transit_paused_get(const Elm_Transit *transit) EINA_ARG_NONNULL(1); EAPI double elm_transit_progress_value_get(const Elm_Transit *transit) EINA_ARG_NONNULL(1); EAPI void elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_transit) EINA_ARG_NONNULL(1, 2); + EAPI void elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit) EINA_ARG_NONNULL(1, 2); EAPI Eina_List *elm_transit_chain_transits_get(const Elm_Transit *transit); 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); diff --git a/src/lib/elm_transit.c b/src/lib/elm_transit.c index 6b653dc..ccf7579 100644 --- a/src/lib/elm_transit.c +++ b/src/lib/elm_transit.c @@ -62,7 +62,7 @@ struct _Elm_Transit Eina_List *next_chain_transits; Elm_Transit_Tween_Mode tween_mode; struct { - Elm_Transit_Effect_End_Cb func; + Elm_Transit_Del_Cb func; void *arg; } del_data; struct { @@ -84,6 +84,7 @@ struct _Elm_Transit Eina_Bool event_enabled : 1; Eina_Bool deleted : 1; Eina_Bool state_keep : 1; + Eina_Bool finished : 1; }; struct _Elm_Transit_Effect_Module @@ -113,6 +114,7 @@ struct _Elm_Transit_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); @@ -121,7 +123,6 @@ 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_del(Elm_Transit *transit); -static void _transit_chain_transits_go(Elm_Transit *transit); static void _transit_animate_op(Elm_Transit *transit, double progress); static Eina_Bool _transit_animate_cb(void *data); @@ -270,18 +271,10 @@ _transit_del(Elm_Transit *transit) Elm_Transit *chain_transit; Eina_List *elist, *elist_next; - EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit) - { - if (transit->prev_chain_transit) - transit->prev_chain_transit->next_chain_transits = eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit); - chain_transit->prev_chain_transit = NULL; - } - - eina_list_free(transit->next_chain_transits); - if (transit->animator) ecore_animator_del(transit->animator); + //remove effects while (transit->effect_list) { effect_module = EINA_INLIST_CONTAINER_GET(transit->effect_list, Elm_Transit_Effect_Module); @@ -289,6 +282,7 @@ _transit_del(Elm_Transit *transit) _transit_effect_del(transit, effect_module); } + //remove objects. while (transit->objs) _transit_obj_remove(transit, eina_list_data_get(transit->objs)); @@ -297,22 +291,25 @@ _transit_del(Elm_Transit *transit) if (transit->del_data.func) transit->del_data.func(transit->del_data.arg, transit); - EINA_MAGIC_SET(transit, EINA_MAGIC_NONE); - free(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; -static void -_transit_chain_transits_go(Elm_Transit *transit) -{ - Eina_List *elist, *elist_next; - Elm_Transit *chain_transit; - Evas_Object *obj; + if (transit->prev_chain_transit) + transit->prev_chain_transit->next_chain_transits = + eina_list_remove(transit->prev_chain_transit->next_chain_transits, transit); - EINA_LIST_FOREACH(transit->objs, elist, obj) - _transit_obj_data_recover(transit, obj); + // run chain transits + if (transit->finished && transit->next_chain_transits) + { + EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit) + elm_transit_go(chain_transit); + } - EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit) - elm_transit_go(chain_transit); + eina_list_free(transit->next_chain_transits); + + EINA_MAGIC_SET(transit, EINA_MAGIC_NONE); + free(transit); } static void @@ -377,10 +374,7 @@ _transit_animate_cb(void *data) (transit->repeat.current == transit->repeat.count) && ((!transit->auto_reverse) || transit->repeat.reverse)) { - /* run chain transit */ - if (transit->next_chain_transits) - _transit_chain_transits_go(transit); - + transit->finished = EINA_TRUE; elm_transit_del(transit); return ECORE_CALLBACK_CANCEL; } @@ -1107,6 +1101,22 @@ elm_transit_chain_transit_add(Elm_Transit *transit, Elm_Transit *chain_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("These two transit 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); +} + /** * Get the current chain transit list. * -- 2.7.4