edje: keep real part geometry updated

Using a callback for body and world update events for that.
It will make it possible to set parts to be relative
to parts that have a physics body.



SVN revision: 80277
This commit is contained in:
Bruno Dilly 2012-12-05 19:30:00 +00:00
parent c6eac0ed78
commit 31d4de28f3
3 changed files with 60 additions and 5 deletions

View File

@ -47,6 +47,23 @@ collections {
}
}
part {
name: "box_shadow";
type: RECT;
description {
state: "default" 0.0;
color: 0 0 0 120;
rel1 {
to_y: "red_box";
relative: 0.9 0.1;
}
rel2 {
to_y: "red_box";
relative: 1 0.9;
}
}
}
part {
name: "blue_circle";
type: IMAGE;

View File

@ -2456,6 +2456,10 @@ _edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf, Eina_B
NULL, NULL, NULL);
ephysics_body_move(ep->body, ep->edje->x + pf->x,
ep->edje->y + pf->y, z);
ep->x = pf->x;
ep->y = pf->y;
ep->w = pf->w;
ep->h = pf->h;
}
ephysics_body_mass_set(ep->body, pf->physics.mass);
}
@ -2464,6 +2468,16 @@ _edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf, Eina_B
ephysics_body_friction_set(ep->body, pf->physics.friction);
}
static void
_edje_physics_body_update_cb(void *data, EPhysics_Body *body, void *event_info __UNUSED__)
{
Edje_Real_Part *rp = data;
ephysics_body_geometry_get(body, &(rp->x), &(rp->y), NULL,
&(rp->w), &(rp->h), NULL);
ephysics_body_evas_object_update(body);
rp->edje->dirty = EINA_TRUE;
}
static void
_edje_physics_body_add(Edje_Real_Part *rp, EPhysics_World *world)
{
@ -2516,6 +2530,8 @@ _edje_physics_body_add(Edje_Real_Part *rp, EPhysics_World *world)
}
ephysics_body_evas_object_set(rp->body, rp->object, resize);
ephysics_body_event_callback_add(rp->body, EPHYSICS_CALLBACK_BODY_UPDATE,
_edje_physics_body_update_cb, rp);
}
#endif
@ -3283,25 +3299,35 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
}
else
{
#ifdef HAVE_EPHYSICS
if (!ep->body)
{
#endif
evas_object_map_enable_set(mo, 0);
evas_object_map_set(mo, NULL);
#ifdef HAVE_EPHYSICS
}
#endif
}
}
}
#ifdef HAVE_EPHYSICS
ep->prev_description = chosen_desc;
if (!ep->body)
{
#endif
ep->x = pf->x;
ep->y = pf->y;
ep->w = pf->w;
ep->h = pf->h;
#ifdef HAVE_EPHYSICS
}
#endif
ep->calculated |= flags;
ep->calculating = FLAG_NONE;
#ifdef HAVE_EPHYSICS
ep->prev_description = chosen_desc;
#endif
#ifdef EDJE_CALC_CACHE
if (ep->calculated == FLAG_XY)
{

View File

@ -341,6 +341,15 @@ _edje_programs_patterns_init(Edje *ed)
ssp->sources_patterns = edje_match_programs_source_init(all, j);
}
#ifdef HAVE_EPHYSICS
static void
_edje_physics_world_update_cb(void *data, EPhysics_World *world __UNUSED__, void *event_info __UNUSED__)
{
Edje *edje = data;
_edje_recalc_do(edje);
}
#endif
int
_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path, Eina_Array *nested)
{
@ -447,6 +456,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
{
ephysics_init();
ed->world = ephysics_world_new();
ephysics_world_event_callback_add(
ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
_edje_physics_world_update_cb, ed);
}
#endif