summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-12-03 16:36:32 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-12-03 16:36:32 +0000
commit9af2e7f69b2eb0382a5fd71df61e67590a61083f (patch)
treefe0c9ca8cfef2c793f18022f8e7bd4076a3c6f65 /legacy
parent71334e1a16d33784bf2059054c0814a22d7b57ee (diff)
edje: initial support to physics block inside
description Only mass is set by now. SVN revision: 80082
Diffstat (limited to 'legacy')
-rw-r--r--legacy/edje/src/bin/edje_cc_handlers.c59
-rw-r--r--legacy/edje/src/examples/physics_basic.edc21
-rw-r--r--legacy/edje/src/lib/edje_calc.c9
-rw-r--r--legacy/edje/src/lib/edje_data.c32
-rw-r--r--legacy/edje/src/lib/edje_private.h11
5 files changed, 126 insertions, 6 deletions
diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c
index bc95a03acc..f6cd40b0da 100644
--- a/legacy/edje/src/bin/edje_cc_handlers.c
+++ b/legacy/edje/src/bin/edje_cc_handlers.c
@@ -96,6 +96,7 @@
96 * <li>@ref sec_collections_group_parts_items "Items"</li> 96 * <li>@ref sec_collections_group_parts_items "Items"</li>
97 * </ul> 97 * </ul>
98 * <li>@ref sec_collections_group_parts_description_table "Table"</li> 98 * <li>@ref sec_collections_group_parts_description_table "Table"</li>
99 * <li>@ref sec_collections_group_parts_description_physics "Physics"</li>
99 * <li>@ref sec_collections_group_parts_description_map "Map (3d/transformations)"</li> 100 * <li>@ref sec_collections_group_parts_description_map "Map (3d/transformations)"</li>
100 * <ul> 101 * <ul>
101 * <li>@ref sec_collections_group_parts_description_map_rotation "Rotation"</li> 102 * <li>@ref sec_collections_group_parts_description_map_rotation "Rotation"</li>
@@ -308,6 +309,9 @@ static void st_collections_group_parts_part_description_table_homogeneous(void);
308static void st_collections_group_parts_part_description_table_align(void); 309static void st_collections_group_parts_part_description_table_align(void);
309static void st_collections_group_parts_part_description_table_padding(void); 310static void st_collections_group_parts_part_description_table_padding(void);
310static void st_collections_group_parts_part_description_table_min(void); 311static void st_collections_group_parts_part_description_table_min(void);
312#ifdef HAVE_EPHYSICS
313static void st_collections_group_parts_part_description_physics_mass(void);
314#endif
311static void st_collections_group_parts_part_description_map_perspective(void); 315static void st_collections_group_parts_part_description_map_perspective(void);
312static void st_collections_group_parts_part_description_map_light(void); 316static void st_collections_group_parts_part_description_map_light(void);
313static void st_collections_group_parts_part_description_map_rotation_center(void); 317static void st_collections_group_parts_part_description_map_rotation_center(void);
@@ -588,6 +592,9 @@ New_Statement_Handler statement_handlers[] =
588 {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align}, 592 {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align},
589 {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding}, 593 {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding},
590 {"collections.group.parts.part.description.table.min", st_collections_group_parts_part_description_table_min}, 594 {"collections.group.parts.part.description.table.min", st_collections_group_parts_part_description_table_min},
595#ifdef HAVE_EPHYSICS
596 {"collections.group.parts.part.description.physics.mass", st_collections_group_parts_part_description_physics_mass},
597#endif
591 {"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective}, 598 {"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective},
592 {"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light}, 599 {"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light},
593 {"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center}, 600 {"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center},
@@ -833,6 +840,9 @@ New_Object_Handler object_handlers[] =
833 {"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */ 840 {"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */
834 {"collections.group.parts.part.description.box", NULL}, 841 {"collections.group.parts.part.description.box", NULL},
835 {"collections.group.parts.part.description.table", NULL}, 842 {"collections.group.parts.part.description.table", NULL},
843#ifdef HAVE_EPHYSICS
844 {"collections.group.parts.part.description.physics", NULL},
845#endif
836 {"collections.group.parts.part.description.map", NULL}, 846 {"collections.group.parts.part.description.map", NULL},
837 {"collections.group.parts.part.description.map.rotation", NULL}, 847 {"collections.group.parts.part.description.map.rotation", NULL},
838 {"collections.group.parts.part.description.perspective", NULL}, 848 {"collections.group.parts.part.description.perspective", NULL},
@@ -1072,6 +1082,10 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c
1072 exit(-1); 1082 exit(-1);
1073 } 1083 }
1074 1084
1085#ifdef HAVE_EPHYSICS
1086 result->physics.mass = FROM_DOUBLE(1.0);
1087#endif
1088
1075 return result; 1089 return result;
1076} 1090}
1077 1091
@@ -3328,7 +3342,6 @@ st_collections_group_parts_part_type(void)
3328 current_part->type = type; 3342 current_part->type = type;
3329} 3343}
3330 3344
3331#ifdef HAVE_EPHYSICS
3332/** 3345/**
3333 @page edcref 3346 @page edcref
3334 @property 3347 @property
@@ -3355,6 +3368,7 @@ st_collections_group_parts_part_type(void)
3355 @endproperty 3368 @endproperty
3356 @since 1.8.0 3369 @since 1.8.0
3357*/ 3370*/
3371#ifdef HAVE_EPHYSICS
3358static void 3372static void
3359st_collections_group_parts_part_physics_body(void) 3373st_collections_group_parts_part_physics_body(void)
3360{ 3374{
@@ -7146,6 +7160,49 @@ st_collections_group_parts_part_description_table_min(void)
7146} 7160}
7147 7161
7148/** 7162/**
7163 @edcsubsection{collections_group_parts_description_physics,Physics}
7164 */
7165
7166/**
7167 @page edcref
7168 @block
7169 physics
7170 @context
7171 description {
7172 ..
7173 physics {
7174 mass: 5.31;
7175 }
7176 ..
7177 }
7178
7179 @description
7180 @endblock
7181
7182 @property
7183 mass
7184 @parameters
7185 [body's mass in kilograms]
7186 @effect
7187 Double value used to set inertial mass of the body.
7188 It is a quantitative measure of an object's resistance to the change of
7189 its speed. If mass is set to 0 the body will have infinite mass,
7190 so it will be immovable, static.
7191 @endproperty
7192 @since 1.8.0
7193*/
7194
7195#ifdef HAVE_EPHYSICS
7196static void
7197st_collections_group_parts_part_description_physics_mass(void)
7198{
7199 check_arg_count(1);
7200
7201 current_desc->physics.mass = parse_float(0);
7202}
7203#endif
7204
7205/**
7149 @edcsubsection{collections_group_parts_description_map,Map} 7206 @edcsubsection{collections_group_parts_description_map,Map}
7150 */ 7207 */
7151 7208
diff --git a/legacy/edje/src/examples/physics_basic.edc b/legacy/edje/src/examples/physics_basic.edc
index cc98fdc170..e613aed6ef 100644
--- a/legacy/edje/src/examples/physics_basic.edc
+++ b/legacy/edje/src/examples/physics_basic.edc
@@ -31,6 +31,16 @@ collections {
31 rel1.relative: 0.55 0.1; 31 rel1.relative: 0.55 0.1;
32 rel2.relative: 0.75 0.3; 32 rel2.relative: 0.75 0.3;
33 aspect: 1 1; 33 aspect: 1 1;
34 physics {
35 mass: 10.8;
36 }
37 }
38 description {
39 state: "light" 0.0;
40 inherit: "default" 0.0;
41 physics {
42 mass: 6.66;
43 }
34 } 44 }
35 } 45 }
36 46
@@ -60,5 +70,16 @@ collections {
60 } 70 }
61 } 71 }
62 72
73 programs {
74 program {
75 name: "load";
76 signal: "load";
77 in: 2 0;
78 action: STATE_SET "light" 0.0;
79 transition: LINEAR 0.5;
80 target: "red_box";
81 }
82 }
83
63 } 84 }
64} 85}
diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c
index 618f3c74b6..97d884089e 100644
--- a/legacy/edje/src/lib/edje_calc.c
+++ b/legacy/edje/src/lib/edje_calc.c
@@ -2289,6 +2289,9 @@ _edje_part_recalc_single(Edje *ed,
2289 break; 2289 break;
2290 } 2290 }
2291 2291
2292#ifdef HAVE_EPHYSICS
2293 params->physics.mass = desc->physics.mass;
2294#endif
2292 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params); 2295 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
2293} 2296}
2294 2297
@@ -2802,6 +2805,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2802 p3->color.b = INTP(p1->color.b, p2->color.b, pos2); 2805 p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
2803 p3->color.a = INTP(p1->color.a, p2->color.a, pos2); 2806 p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
2804 2807
2808#ifdef HAVE_EPHYSICS
2809 p3->physics.mass = TO_DOUBLE(FINTP(p1->physics.mass, p2->physics.mass,
2810 pos));
2811#endif
2812
2805 switch (part_type) 2813 switch (part_type)
2806 { 2814 {
2807 case EDJE_PART_TYPE_IMAGE: 2815 case EDJE_PART_TYPE_IMAGE:
@@ -2992,6 +3000,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2992 NULL, NULL, NULL); 3000 NULL, NULL, NULL);
2993 ephysics_body_move(ep->body, 3001 ephysics_body_move(ep->body,
2994 ed->x + pf->x, ed->y + pf->y, z); 3002 ed->x + pf->x, ed->y + pf->y, z);
3003 ephysics_body_mass_set(ep->body, pf->physics.mass);
2995 } 3004 }
2996 else 3005 else
2997#endif 3006#endif
diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c
index 6eca7729c4..da879ba942 100644
--- a/legacy/edje/src/lib/edje_data.c
+++ b/legacy/edje/src/lib/edje_data.c
@@ -451,8 +451,7 @@ _edje_edd_init(void)
451 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE); 451 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE);
452 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING); 452 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING);
453 453
454#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \ 454#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
455 { \
456 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", state.name, EET_T_STRING); \ 455 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", state.name, EET_T_STRING); \
457 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", state.value, EET_T_DOUBLE); \ 456 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", state.value, EET_T_DOUBLE); \
458 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", visible, EET_T_CHAR); \ 457 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", visible, EET_T_CHAR); \
@@ -508,11 +507,22 @@ _edje_edd_init(void)
508 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", map.persp_on, EET_T_UCHAR); \ 507 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", map.persp_on, EET_T_UCHAR); \
509 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", map.backcull, EET_T_UCHAR); \ 508 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", map.backcull, EET_T_UCHAR); \
510 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", persp.zplane, EET_T_INT); \ 509 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", persp.zplane, EET_T_INT); \
511 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT); \ 510 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT);
511
512#ifdef HAVE_EPHYSICS
513#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
514 { \
515 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
516 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.mass", physics.mass, EET_T_DOUBLE); \
512 } 517 }
518#else
519#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
520 { \
521 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
522 }
523#endif
513 524
514#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \ 525#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
515 { \
516 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", Dec.state.name, EET_T_STRING); \ 526 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", Dec.state.name, EET_T_STRING); \
517 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", Dec.state.value, EET_T_DOUBLE); \ 527 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", Dec.state.value, EET_T_DOUBLE); \
518 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", Dec.visible, EET_T_CHAR); \ 528 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", Dec.visible, EET_T_CHAR); \
@@ -563,7 +573,19 @@ _edje_edd_init(void)
563 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", Dec.map.backcull, EET_T_UCHAR); \ 573 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", Dec.map.backcull, EET_T_UCHAR); \
564 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", Dec.persp.zplane, EET_T_INT); \ 574 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", Dec.persp.zplane, EET_T_INT); \
565 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", Dec.persp.focal, EET_T_INT); \ 575 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", Dec.persp.focal, EET_T_INT); \
576
577#ifdef HAVE_EPHYSICS
578#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
579 { \
580 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
581 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.mass", Dec.physics.mass, EET_T_DOUBLE); \
582 }
583#else
584#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
585 { \
586 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
566 } 587 }
588#endif
567 589
568 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common); 590 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
569 eddc.func.mem_free = mem_free_rectangle; 591 eddc.func.mem_free = mem_free_rectangle;
diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h
index 26adfaa190..76a3ab0e83 100644
--- a/legacy/edje/src/lib/edje_private.h
+++ b/legacy/edje/src/lib/edje_private.h
@@ -958,6 +958,12 @@ struct _Edje_Part_Description_Common
958 int focal; 958 int focal;
959 } persp; 959 } persp;
960 960
961#ifdef HAVE_EPHYSICS
962 struct {
963 double mass;
964 } physics;
965#endif
966
961 unsigned char visible; /* is it shown */ 967 unsigned char visible; /* is it shown */
962 unsigned char limit; /* 0 == no, 1 = width, 2 = height, 3 = both */ 968 unsigned char limit; /* 0 == no, 1 = width, 2 = height, 3 = both */
963}; 969};
@@ -1286,6 +1292,11 @@ struct _Edje_Calc_Params
1286 int focal; 1292 int focal;
1287 } persp; 1293 } persp;
1288 } map; 1294 } map;
1295#ifdef HAVE_EPHYSICS
1296 struct {
1297 double mass; // 8
1298 } physics; // 8
1299#endif
1289 unsigned char persp_on : 1; 1300 unsigned char persp_on : 1;
1290 unsigned char lighted : 1; 1301 unsigned char lighted : 1;
1291 unsigned char mapped : 1; 1302 unsigned char mapped : 1;