edje: parts with bodies aren't move at each recalc
Otherwise at each recalc they will be moved to initial position again. SVN revision: 80275
This commit is contained in:
parent
f9293909d9
commit
3038f33e82
|
@ -6,7 +6,6 @@ collections {
|
||||||
|
|
||||||
group {
|
group {
|
||||||
name: "example_group";
|
name: "example_group";
|
||||||
min: 100 100;
|
|
||||||
|
|
||||||
parts {
|
parts {
|
||||||
part {
|
part {
|
||||||
|
|
|
@ -2433,6 +2433,88 @@ _edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static Eina_Bool
|
||||||
|
_edje_physics_world_geometry_check(EPhysics_World *world)
|
||||||
|
{
|
||||||
|
Evas_Coord w, h, d;
|
||||||
|
ephysics_world_render_geometry_get(world, NULL, NULL, NULL, &w, &h, &d);
|
||||||
|
return (w && h && d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf)
|
||||||
|
{
|
||||||
|
/* Boundaries geometry and mass shouldn't be changed */
|
||||||
|
if (ep->part->physics_body < EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP)
|
||||||
|
{
|
||||||
|
Evas_Coord z;
|
||||||
|
|
||||||
|
ephysics_body_geometry_get(ep->body, NULL, NULL, &z, NULL, NULL, NULL);
|
||||||
|
ephysics_body_move(ep->body, ep->edje->x + pf->x, ep->edje->y + pf->y,
|
||||||
|
z);
|
||||||
|
ephysics_body_mass_set(ep->body, pf->physics.mass);
|
||||||
|
}
|
||||||
|
|
||||||
|
ephysics_body_restitution_set(ep->body, pf->physics.restitution);
|
||||||
|
ephysics_body_friction_set(ep->body, pf->physics.friction);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edje_physics_body_add(Edje_Real_Part *rp, EPhysics_World *world)
|
||||||
|
{
|
||||||
|
Eina_Bool resize = EINA_TRUE;
|
||||||
|
|
||||||
|
switch (rp->part->physics_body)
|
||||||
|
{
|
||||||
|
case EDJE_PART_PHYSICS_BODY_RIGID_BOX:
|
||||||
|
rp->body = ephysics_body_box_add(world);
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_RIGID_CIRCLE:
|
||||||
|
rp->body = ephysics_body_circle_add(world);
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_SOFT_BOX:
|
||||||
|
rp->body = ephysics_body_soft_box_add(world);
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_SOFT_CIRCLE:
|
||||||
|
rp->body = ephysics_body_soft_circle_add(world);
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_CLOTH:
|
||||||
|
rp->body = ephysics_body_cloth_add(world, 0, 0);
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP:
|
||||||
|
rp->body = ephysics_body_top_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BOTTOM:
|
||||||
|
rp->body = ephysics_body_bottom_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_RIGHT:
|
||||||
|
rp->body = ephysics_body_right_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_LEFT:
|
||||||
|
rp->body = ephysics_body_left_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_FRONT:
|
||||||
|
rp->body = ephysics_body_front_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BACK:
|
||||||
|
rp->body = ephysics_body_back_boundary_add(world);
|
||||||
|
resize = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR("Invalid body: %i", rp->part->physics_body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ephysics_body_evas_object_set(rp->body, rp->object, resize);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
_edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
|
_edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
|
||||||
{
|
{
|
||||||
|
@ -2991,8 +3073,14 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
||||||
if (!pf->visible)
|
if (!pf->visible)
|
||||||
{
|
{
|
||||||
evas_object_hide(ep->object);
|
evas_object_hide(ep->object);
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
/* body attributes should be updated for invisible objects */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
evas_object_show(ep->object);
|
evas_object_show(ep->object);
|
||||||
/* move and resize are needed for all previous object => no break here. */
|
/* move and resize are needed for all previous object => no break here. */
|
||||||
case EDJE_PART_TYPE_SWALLOW:
|
case EDJE_PART_TYPE_SWALLOW:
|
||||||
|
@ -3000,17 +3088,20 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
||||||
case EDJE_PART_TYPE_EXTERNAL:
|
case EDJE_PART_TYPE_EXTERNAL:
|
||||||
/* visibility and color have no meaning on SWALLOW and GROUP part. */
|
/* visibility and color have no meaning on SWALLOW and GROUP part. */
|
||||||
#ifdef HAVE_EPHYSICS
|
#ifdef HAVE_EPHYSICS
|
||||||
if (ep->body)
|
if ((ep->part->physics_body) && (!ep->body))
|
||||||
{
|
{
|
||||||
Evas_Coord z;
|
if (_edje_physics_world_geometry_check(ep->edje->world))
|
||||||
ephysics_body_geometry_get(ep->body, NULL, NULL, &z,
|
{
|
||||||
NULL, NULL, NULL);
|
_edje_physics_body_add(ep, ep->edje->world);
|
||||||
ephysics_body_move(ep->body,
|
_edje_physics_body_props_update(ep, pf);
|
||||||
ed->x + pf->x, ed->y + pf->y, z);
|
}
|
||||||
ephysics_body_mass_set(ep->body, pf->physics.mass);
|
}
|
||||||
ephysics_body_restitution_set(ep->body,
|
else if (ep->body)
|
||||||
pf->physics.restitution);
|
{
|
||||||
ephysics_body_friction_set(ep->body, pf->physics.friction);
|
if (((ep->prev_description) &&
|
||||||
|
(chosen_desc != ep->prev_description)) ||
|
||||||
|
(pf != p1))
|
||||||
|
_edje_physics_body_props_update(ep, pf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -3197,6 +3288,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
||||||
ep->calculated |= flags;
|
ep->calculated |= flags;
|
||||||
ep->calculating = FLAG_NONE;
|
ep->calculating = FLAG_NONE;
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
ep->prev_description = chosen_desc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef EDJE_CALC_CACHE
|
#ifdef EDJE_CALC_CACHE
|
||||||
if (ep->calculated == FLAG_XY)
|
if (ep->calculated == FLAG_XY)
|
||||||
{
|
{
|
||||||
|
|
|
@ -341,53 +341,6 @@ _edje_programs_patterns_init(Edje *ed)
|
||||||
ssp->sources_patterns = edje_match_programs_source_init(all, j);
|
ssp->sources_patterns = edje_match_programs_source_init(all, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_EPHYSICS
|
|
||||||
static void
|
|
||||||
_edje_physics_body_add(Edje_Real_Part *rp, EPhysics_World *world)
|
|
||||||
{
|
|
||||||
switch (rp->part->physics_body)
|
|
||||||
{
|
|
||||||
case EDJE_PART_PHYSICS_BODY_RIGID_BOX:
|
|
||||||
rp->body = ephysics_body_box_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_RIGID_CIRCLE:
|
|
||||||
rp->body = ephysics_body_circle_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_SOFT_BOX:
|
|
||||||
rp->body = ephysics_body_soft_box_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_SOFT_CIRCLE:
|
|
||||||
rp->body = ephysics_body_soft_circle_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_CLOTH:
|
|
||||||
rp->body = ephysics_body_cloth_add(world, 0, 0);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP:
|
|
||||||
rp->body = ephysics_body_top_boundary_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BOTTOM:
|
|
||||||
rp->body = ephysics_body_bottom_boundary_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_RIGHT:
|
|
||||||
rp->body = ephysics_body_right_boundary_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_LEFT:
|
|
||||||
rp->body = ephysics_body_left_boundary_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_FRONT:
|
|
||||||
rp->body = ephysics_body_front_boundary_add(world);
|
|
||||||
break;
|
|
||||||
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BACK:
|
|
||||||
rp->body = ephysics_body_back_boundary_add(world);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERR("Invalid body: %i", rp->part->physics_body);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ephysics_body_evas_object_set(rp->body, rp->object, EINA_TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
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)
|
_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path, Eina_Array *nested)
|
||||||
{
|
{
|
||||||
|
@ -728,10 +681,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
if (rp->part->clip_to_id < 0)
|
if (rp->part->clip_to_id < 0)
|
||||||
evas_object_clip_set(rp->object, ed->base->clipper);
|
evas_object_clip_set(rp->object, ed->base->clipper);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_EPHYSICS
|
|
||||||
if (ep->physics_body)
|
|
||||||
_edje_physics_body_add(rp, ed->world);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1412,6 +1412,7 @@ struct _Edje_Real_Part
|
||||||
Edje_Real_Part *clip_to; // 4
|
Edje_Real_Part *clip_to; // 4
|
||||||
Edje_Running_Program *program; // 4
|
Edje_Running_Program *program; // 4
|
||||||
#ifdef HAVE_EPHYSICS
|
#ifdef HAVE_EPHYSICS
|
||||||
|
Edje_Part_Description_Common *prev_description; // 4
|
||||||
EPhysics_Body *body; // 4
|
EPhysics_Body *body; // 4
|
||||||
#endif
|
#endif
|
||||||
union {
|
union {
|
||||||
|
|
Loading…
Reference in New Issue