* animations can be manipulated inside the theme.
*/
-static const char _transit_key[] = "_elm_transit";
-
#define _TRANSIT_FOCAL 2000
struct _Elm_Transit
Ecore_Animator *animator;
Eina_Inlist *effect_list;
Eina_List *objs;
+ Eina_Hash *objs_data_hash;
Elm_Transit *prev_chain_transit;
Eina_List *next_chain_transits;
Elm_Transit_Tween_Mode tween_mode;
struct _Elm_Obj_Data
{
- Elm_Transit *transit;
struct _Elm_Obj_State *state;
Eina_Bool pass_events : 1;
};
typedef struct _Elm_Obj_State Elm_Obj_State;
static void
-_elm_transit_obj_states_save(Evas_Object *obj)
+_elm_transit_obj_states_save(Evas_Object *obj, Elm_Obj_Data *obj_data)
{
- Elm_Obj_Data *obj_data;
Elm_Obj_State *state;
- obj_data = evas_object_data_get(obj, _transit_key);
- if ((!obj_data) || (obj_data->state)) return;
+ if (obj_data->state) return;
state = calloc(1, sizeof(Elm_Obj_State));
if (!state) return;
evas_object_geometry_get(obj, &state->x, &state->y, &state->w, &state->h);
obj_data->state = state;
}
+static Eina_Bool
+_hash_foreach_pass_events_set(const Eina_Hash *hash, const void *key, void *data, void *fdata)
+{
+ Elm_Transit *transit = fdata;
+ evas_object_pass_events_set((Evas_Object*) key, transit->event_enabled);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_hash_foreach_obj_states_save(const Eina_Hash *hash, const void *key, void *data, void *fdata)
+{
+ _elm_transit_obj_states_save((Evas_Object *) key, (Elm_Obj_Data *) data);
+ return EINA_TRUE;
+}
+
static void
_elm_transit_object_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
Elm_Transit *transit = data;
- Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
+ Elm_Obj_Data *obj_data = eina_hash_find(transit->objs_data_hash, obj);
if (!obj_data) return;
+ eina_hash_del_by_key(transit->objs_data_hash, obj);
evas_object_pass_events_set(obj, obj_data->pass_events);
if (obj_data->state)
free(obj_data->state);
static void
_elm_transit_object_remove(Elm_Transit *transit, Evas_Object *obj)
{
- Elm_Obj_Data *obj_data = evas_object_data_del(obj, _transit_key);
+ Elm_Obj_Data *obj_data = eina_hash_find(transit->objs_data_hash, obj);
+ if (!obj_data) return;
+ eina_hash_del_by_key(transit->objs_data_hash, obj);
Elm_Obj_State *state = obj_data->state;
evas_object_pass_events_set(obj, obj_data->pass_events);
transit->objs = eina_list_remove(transit->objs, obj);
}
- evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
- _elm_transit_object_remove_cb);
+ evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
+ _elm_transit_object_remove_cb,
+ transit);
}
static void
{
if (effect_module->end_cb)
effect_module->end_cb(effect_module->effect, transit);
-
- transit->effect_list = eina_inlist_remove(transit->effect_list, (Eina_Inlist*) effect_module);
free(effect_module);
}
if (transit->animator)
ecore_animator_del(transit->animator);
- EINA_INLIST_FOREACH(transit->effect_list, effect_module)
- _elm_transit_effect_del(transit, effect_module);
+ 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);
+ }
while (transit->objs)
_elm_transit_object_remove(transit, eina_list_data_get(transit->objs));
if (transit->del_data.func)
transit->del_data.func(transit->del_data.arg, transit);
+ eina_hash_free(transit->objs_data_hash);
+
EINA_MAGIC_SET(transit, EINA_MAGIC_NONE);
free(transit);
}
elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
+ transit->objs_data_hash = eina_hash_pointer_new(NULL);
+
return transit;
}
/**
EINA_SAFETY_ON_NULL_RETURN(obj);
Elm_Obj_Data *obj_data;
- obj_data = evas_object_data_get(obj, _transit_key);
-
- if ((obj_data) && (obj_data->transit != transit))
- elm_transit_object_remove(obj_data->transit, obj);
+ obj_data = ELM_NEW(Elm_Obj_Data);
+ obj_data->pass_events = evas_object_pass_events_get(obj);
+ if (!transit->event_enabled)
+ evas_object_pass_events_set(obj, EINA_TRUE);
- if ((!obj_data) || (obj_data->transit != transit))
- {
- obj_data = ELM_NEW(Elm_Obj_Data);
- obj_data->pass_events = evas_object_pass_events_get(obj);
- obj_data->transit = transit;
- evas_object_data_set(obj, _transit_key, obj_data);
- 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);
- }
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+ _elm_transit_object_remove_cb,
+ transit);
transit->objs = eina_list_append(transit->objs, obj);
+ eina_hash_add(transit->objs_data_hash, obj, obj_data);
if (!transit->state_keep)
- _elm_transit_obj_states_save(obj);
-
+ _elm_transit_obj_states_save(obj, obj_data);
}
/**
EINA_SAFETY_ON_NULL_RETURN(obj);
Elm_Obj_Data *obj_data;
- obj_data = evas_object_data_get(obj, _transit_key);
-
- if ((!obj_data) || (obj_data->transit != transit)) return;
+ obj_data = eina_hash_find(transit->objs_data_hash, obj);
+ if (!obj_data) return;
_elm_transit_object_remove(transit, obj);
if (!transit->objs) elm_transit_del(transit);
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->pass_events);
- }
- }
- else
- {
- EINA_LIST_FOREACH(transit->objs, elist, obj)
- evas_object_pass_events_set(obj, EINA_TRUE);
- }
+ eina_hash_foreach(transit->objs_data_hash, _hash_foreach_pass_events_set, transit);
}
/**
return transit->progress;
}
+
+
/**
* Enable/disable keeping up the objects states.
* If it is not kept, the objects states will be reset when transition ends.
{
Eina_List *list;
Evas_Object *obj;
+ Elm_Obj_Data *obj_data;
ELM_TRANSIT_CHECK_OR_RETURN(transit);
if (transit->state_keep == state_keep) return;
if (transit->animator) return;
transit->state_keep = !!state_keep;
- if (!state_keep)
- {
- EINA_LIST_FOREACH(transit->objs, list, obj)
- _elm_transit_obj_states_save(obj);
- }
+ if (state_keep) return;
+ eina_hash_foreach(transit->objs_data_hash, _hash_foreach_obj_states_save, NULL);
}
/**
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;