From 42b7ef900b78797906e8dddf4cdebd707e8ef7bc Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Tue, 11 Dec 2012 18:52:35 +0000 Subject: [PATCH] edje: handle z-axis body attributes SVN revision: 80678 --- legacy/edje/data/include/edje.inc | 4 ++- legacy/edje/src/bin/edje_cc_handlers.c | 50 ++++++++++++++++++++++++++++ legacy/edje/src/examples/physics_3d.edc | 2 ++ legacy/edje/src/examples/physics_actions.edc | 8 +++++ legacy/edje/src/lib/edje_calc.c | 31 ++++++++++++----- legacy/edje/src/lib/edje_data.c | 4 +++ legacy/edje/src/lib/edje_embryo.c | 20 +++++++++++ legacy/edje/src/lib/edje_private.h | 8 ++++- 8 files changed, 116 insertions(+), 11 deletions(-) diff --git a/legacy/edje/data/include/edje.inc b/legacy/edje/data/include/edje.inc index 3c2c996..5fc9ec2 100644 --- a/legacy/edje/data/include/edje.inc +++ b/legacy/edje/data/include/edje.inc @@ -223,7 +223,9 @@ enum State_Param STATE_PHYSICS_HARDNESS = 52, STATE_PHYSICS_MOV_FREEDOM_LIN = 53, STATE_PHYSICS_MOV_FREEDOM_ANG = 54, - STATE_PHYSICS_BACK_CULL = 55 + STATE_PHYSICS_BACK_CULL = 55, + STATE_PHYSICS_Z = 56, + STATE_PHYSICS_DEPTH = 57 }; native set_state_val(part_id, State_Param:p, ...); diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c index 02c7fc2..da54fd7 100644 --- a/legacy/edje/src/bin/edje_cc_handlers.c +++ b/legacy/edje/src/bin/edje_cc_handlers.c @@ -328,6 +328,8 @@ static void st_collections_group_parts_part_description_physics_density(void); static void st_collections_group_parts_part_description_physics_hardness(void); static void st_collections_group_parts_part_description_physics_ignore_part_pos(void); static void st_collections_group_parts_part_description_physics_light_on(void); +static void st_collections_group_parts_part_description_physics_z(void); +static void st_collections_group_parts_part_description_physics_depth(void); static void st_collections_group_parts_part_description_physics_movement_freedom_linear(void); static void st_collections_group_parts_part_description_physics_movement_freedom_angular(void); static void st_collections_group_parts_part_description_physics_backface_cull(void); @@ -635,6 +637,8 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.physics.movement_freedom.angular", st_collections_group_parts_part_description_physics_movement_freedom_angular}, {"collections.group.parts.part.description.physics.ignore_part_pos", st_collections_group_parts_part_description_physics_ignore_part_pos}, {"collections.group.parts.part.description.physics.light_on", st_collections_group_parts_part_description_physics_light_on}, + {"collections.group.parts.part.description.physics.z", st_collections_group_parts_part_description_physics_z}, + {"collections.group.parts.part.description.physics.depth", st_collections_group_parts_part_description_physics_depth}, {"collections.group.parts.part.description.physics.backface_cull", st_collections_group_parts_part_description_physics_backface_cull}, {"collections.group.parts.part.description.physics.faces.face.type", st_collections_group_parts_part_description_physics_face_type}, {"collections.group.parts.part.description.physics.faces.face.source", st_collections_group_parts_part_description_physics_face_source}, @@ -1149,6 +1153,8 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c result->physics.mov_freedom.lin.x = 1; result->physics.mov_freedom.lin.y = 1; result->physics.mov_freedom.ang.z = 1; + result->physics.z = -15; + result->physics.depth = 30; #endif return result; @@ -7265,6 +7271,8 @@ st_collections_group_parts_part_description_table_min(void) density: 3.2; hardness: 0.42; light_on: 1; + z: -15; + depth: 30; movement_freedom { .. } @@ -7568,6 +7576,48 @@ st_collections_group_parts_part_description_physics_light_on(void) /** @page edcref @property + z + @parameters + [body position in z axis] + @effect + Defines body position in z axis. It's set to -15 by default. + @endproperty + @since 1.8.0 +*/ +#ifdef HAVE_EPHYSICS +static void +st_collections_group_parts_part_description_physics_z(void) +{ + check_arg_count(1); + + current_desc->physics.z = parse_int(0); +} +#endif + +/** + @page edcref + @property + depth + @parameters + [body's depth] + @effect + Defines body's depth (z axis). It's set to 30 by default. + @endproperty + @since 1.8.0 +*/ +#ifdef HAVE_EPHYSICS +static void +st_collections_group_parts_part_description_physics_depth(void) +{ + check_arg_count(1); + + current_desc->physics.depth = parse_int(0); +} +#endif + +/** + @page edcref + @property backface_cull @parameters [1 or 0] diff --git a/legacy/edje/src/examples/physics_3d.edc b/legacy/edje/src/examples/physics_3d.edc index 0c1d759..7e58dcb 100644 --- a/legacy/edje/src/examples/physics_3d.edc +++ b/legacy/edje/src/examples/physics_3d.edc @@ -156,6 +156,8 @@ collections { aspect: 1 1; physics { mass: 30; + z: -24; + depth: 48; restitution: 0.85; movement_freedom { linear: 1 1 1; diff --git a/legacy/edje/src/examples/physics_actions.edc b/legacy/edje/src/examples/physics_actions.edc index 7ff1894..945e808 100644 --- a/legacy/edje/src/examples/physics_actions.edc +++ b/legacy/edje/src/examples/physics_actions.edc @@ -514,6 +514,8 @@ collections { set_state_val(PART:"red_circle", STATE_PHYSICS_LIGHT_ON, 1); set_state_val(PART:"red_circle", STATE_PHYSICS_IGNORE_PART_POS, 1); + set_state_val(PART:"red_circle", STATE_PHYSICS_Z, -40); + set_state_val(PART:"red_circle", STATE_PHYSICS_DEPTH, 80); set_state(PART:"red_circle", "custom", 0.0); get_state_val(PART:"red_circle", STATE_PHYSICS_MASS, mass); @@ -541,6 +543,12 @@ collections { get_state_val(PART:"red_circle", STATE_PHYSICS_IGNORE_PART_POS, val); send_message(MSG_STRING_INT, 1, "Ignore Part Pos", val); + + get_state_val(PART:"red_circle", STATE_PHYSICS_Z, val); + send_message(MSG_STRING_INT, 1, "Z", val); + + get_state_val(PART:"red_circle", STATE_PHYSICS_DEPTH, val); + send_message(MSG_STRING_INT, 1, "Depth", val); } } diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c index 8c884d9..86c8a74 100644 --- a/legacy/edje/src/lib/edje_calc.c +++ b/legacy/edje/src/lib/edje_calc.c @@ -2314,6 +2314,8 @@ _edje_part_recalc_single(Edje *ed, params->physics.mov_freedom.ang.y = desc->physics.mov_freedom.ang.y; params->physics.mov_freedom.ang.z = desc->physics.mov_freedom.ang.z; params->physics.backcull = desc->physics.backcull; + params->physics.z = desc->physics.z; + params->physics.depth = desc->physics.depth; #endif _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params); } @@ -2478,22 +2480,28 @@ _edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf, Eina_B pf->physics.mov_freedom.ang.x, pf->physics.mov_freedom.ang.y, pf->physics.mov_freedom.ang.z); + /* Boundaries geometry and mass shouldn't be changed */ if (ep->part->physics_body < EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP) { + Evas_Coord x, y, z, w, h, d; + if (pos_update) { - 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); + ep->edje->y + pf->y, pf->physics.z); ep->x = pf->x; ep->y = pf->y; ep->w = pf->w; ep->h = pf->h; } + ephysics_body_geometry_get(ep->body, &x, &y, &z, &w, &h, &d); + if ((d) && (d != pf->physics.depth)) + ephysics_body_resize(ep->body, w, h, pf->physics.depth); + if (z != pf->physics.z) + ephysics_body_move(ep->body, x, y, pf->physics.z); + ephysics_body_material_set(ep->body, pf->physics.material); if (!pf->physics.material) { @@ -3008,6 +3016,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta p3->physics.sleep.angular = TO_DOUBLE(FINTP( p1->physics.sleep.angular, p2->physics.sleep.angular, pos)); + p3->physics.z = INTP(p1->physics.z, p2->physics.z, pos); + p3->physics.depth = INTP(p1->physics.depth, p2->physics.depth, pos); + if ((p1->physics.ignore_part_pos) && (p2->physics.ignore_part_pos)) p3->physics.ignore_part_pos = 1; else @@ -3241,6 +3252,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta case EDJE_PART_TYPE_EXTERNAL: /* visibility and color have no meaning on SWALLOW and GROUP part. */ #ifdef HAVE_EPHYSICS + eo_do(ep->object, + evas_obj_size_set(pf->w, pf->h)); if ((ep->part->physics_body) && (!ep->body)) { if (_edje_physics_world_geometry_check(ep->edje->world)) @@ -3258,13 +3271,13 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta ep, pf, !pf->physics.ignore_part_pos); } else -#endif - { - eo_do(ep->object, - evas_obj_position_set(ed->x + pf->x, ed->y + pf->y)); - } + eo_do(ep->object, + evas_obj_position_set(ed->x + pf->x, ed->y + pf->y)); +#else eo_do(ep->object, + evas_obj_position_set(ed->x + pf->x, ed->y + pf->y), evas_obj_size_set(pf->w, pf->h)); +#endif if (ep->nested_smart) { /* Move, Resize all nested parts */ diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c index 204aa95..4837085 100644 --- a/legacy/edje/src/lib/edje_data.c +++ b/legacy/edje/src/lib/edje_data.c @@ -537,6 +537,8 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.material", physics.material, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.density", physics.density, EET_T_DOUBLE); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.hardness", physics.hardness, EET_T_DOUBLE); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.z", physics.z, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.depth", physics.depth, EET_T_INT); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_pos", physics.ignore_part_pos, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.light_on", physics.light_on, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.backcull", physics.backcull, EET_T_UCHAR); \ @@ -621,6 +623,8 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.material", Dec.physics.material, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.density", Dec.physics.density, EET_T_DOUBLE); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.hardness", Dec.physics.hardness, EET_T_DOUBLE); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.z", Dec.physics.z, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.depth", Dec.physics.depth, EET_T_INT); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_pos", Dec.physics.ignore_part_pos, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.light_on", Dec.physics.light_on, EET_T_UCHAR); \ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.backcull", Dec.physics.backcull, EET_T_UCHAR); \ diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index 898df51..a8668ee 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -2338,6 +2338,16 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params) GETINT(rp->custom->description->physics.backcull, params[3]); break; + case EDJE_STATE_PARAM_PHYSICS_Z: + CHKPARAM(3); + + GETINT(rp->custom->description->physics.z, params[3]); + break; + case EDJE_STATE_PARAM_PHYSICS_DEPTH: + CHKPARAM(3); + + GETINT(rp->custom->description->physics.depth, params[3]); + break; #endif default: break; @@ -2866,6 +2876,16 @@ _edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params) SETINT(rp->custom->description->physics.backcull, params[3]); break; + case EDJE_STATE_PARAM_PHYSICS_Z: + CHKPARAM(3); + + SETINT(rp->custom->description->physics.z, params[3]); + break; + case EDJE_STATE_PARAM_PHYSICS_DEPTH: + CHKPARAM(3); + + SETINT(rp->custom->description->physics.depth, params[3]); + break; #endif default: break; diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index 2f6e317..e20fe0d 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -428,7 +428,9 @@ typedef struct _Edje_Markup_Filter_Callback Edje_Markup_Filter_Callback; #define EDJE_STATE_PARAM_PHYSICS_MOV_FREEDOM_LIN 53 #define EDJE_STATE_PARAM_PHYSICS_MOV_FREEDOM_ANG 54 #define EDJE_STATE_PARAM_PHYSICS_BACK_CULL 55 -#define EDJE_STATE_PARAM_LAST 56 +#define EDJE_STATE_PARAM_PHYSICS_Z 56 +#define EDJE_STATE_PARAM_PHYSICS_DEPTH 57 +#define EDJE_STATE_PARAM_LAST 58 #define EDJE_ENTRY_EDIT_MODE_NONE 0 #define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1 @@ -1016,6 +1018,8 @@ struct _Edje_Part_Description_Common double linear; double angular; } sleep; + int z; + int depth; Eina_List *faces; /* faces for 3d effects */ struct { struct { @@ -1379,6 +1383,8 @@ struct _Edje_Calc_Params double linear; //8 double angular; //8 } sleep; // 16 + int z; // 4 + int depth; // 4 struct { struct { unsigned char x; -- 2.7.4