edje: make it possible to change body attributes via
authorBruno Dilly <bdilly@profusion.mobi>
Fri, 7 Dec 2012 18:44:17 +0000 (18:44 +0000)
committerBruno Dilly <bdilly@profusion.mobi>
Fri, 7 Dec 2012 18:44:17 +0000 (18:44 +0000)
 script

Support physics attributes on set_state_val and get_state_val
So custom_states can be created

SVN revision: 80484

legacy/edje/data/include/edje.inc
legacy/edje/src/examples/physics_actions.edc
legacy/edje/src/lib/edje_embryo.c
legacy/edje/src/lib/edje_private.h

index a0d40a0..286dfeb 100644 (file)
@@ -210,7 +210,10 @@ enum State_Param
        STATE_MAP_BACK_CULL = 39,
        STATE_MAP_PERSP_ON = 40,
        STATE_PERSP_ZPLANE = 41,
-       STATE_PERSP_FOCAL = 42
+       STATE_PERSP_FOCAL = 42,
+       STATE_PHYSICS_MASS = 43,
+       STATE_PHYSICS_FRICTION = 44,
+       STATE_PHYSICS_RESTITUTION = 45
 };
 
 native set_state_val(part_id, State_Param:p, ...);
index 5d5723a..54f1f43 100644 (file)
@@ -451,6 +451,30 @@ collections {
             target: "blue_circle";
          }
 
+         program {
+            name: "customize";
+            signal: "custom";
+            script {
+               new Float: mass, Float:rest, Float:fric;
+
+               custom_state(PART:"red_circle", "default", 0.0);
+               set_state_val(PART:"red_circle", STATE_COLOR, 0, 0, 0, 255);
+               set_state_val(PART:"red_circle", STATE_PHYSICS_MASS, 4.5);
+               set_state_val(PART:"red_circle", STATE_PHYSICS_RESTITUTION, 0.1);
+               set_state_val(PART:"red_circle", STATE_PHYSICS_FRICTION, 0.345);
+               set_state(PART:"red_circle", "custom", 0.0);
+
+               get_state_val(PART:"red_circle", STATE_PHYSICS_MASS, mass);
+               get_state_val(PART:"red_circle", STATE_PHYSICS_RESTITUTION,
+                     rest);
+               get_state_val(PART:"red_circle", STATE_PHYSICS_FRICTION,
+                     fric);
+               send_message(MSG_STRING_FLOAT_SET, 1, "Mass", mass);
+               send_message(MSG_STRING_FLOAT_SET, 1, "Friction", fric);
+               send_message(MSG_STRING_FLOAT_SET, 1, "Restitution", rest);
+            }
+         }
+
       }
 
    }
index 8417536..15722d2 100644 (file)
@@ -2258,6 +2258,26 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
         GETINT(rp->custom->description->persp.focal, params[3]);
         
         break;
+#ifdef HAVE_EPHYSICS
+      case EDJE_STATE_PARAM_PHYSICS_MASS:
+        CHKPARAM(3);
+
+        GETFLOAT_T(rp->custom->description->physics.mass, params[3]);
+
+        break;
+      case EDJE_STATE_PARAM_PHYSICS_RESTITUTION:
+        CHKPARAM(3);
+
+        GETFLOAT_T(rp->custom->description->physics.restitution, params[3]);
+
+        break;
+      case EDJE_STATE_PARAM_PHYSICS_FRICTION:
+        CHKPARAM(3);
+
+        GETFLOAT_T(rp->custom->description->physics.friction, params[3]);
+
+        break;
+#endif
       default:
         break;
      }
@@ -2641,6 +2661,26 @@ _edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
         SETINT(rp->custom->description->visible, params[3]);
 
         break;
+#ifdef HAVE_EPHYSICS
+      case EDJE_STATE_PARAM_PHYSICS_MASS:
+        CHKPARAM(3);
+
+        SETFLOAT_T(rp->custom->description->physics.mass, params[3]);
+
+        break;
+      case EDJE_STATE_PARAM_PHYSICS_RESTITUTION:
+        CHKPARAM(3);
+
+        SETFLOAT_T(rp->custom->description->physics.restitution, params[3]);
+
+        break;
+      case EDJE_STATE_PARAM_PHYSICS_FRICTION:
+        CHKPARAM(3);
+
+        SETFLOAT_T(rp->custom->description->physics.friction, params[3]);
+
+        break;
+#endif
       default:
         break;
      }
index 806ad5a..d67e479 100644 (file)
@@ -414,7 +414,10 @@ typedef struct _Edje_Markup_Filter_Callback Edje_Markup_Filter_Callback;
 #define EDJE_STATE_PARAM_MAP_PERSP_ON   40
 #define EDJE_STATE_PARAM_PERSP_ZPLANE   41
 #define EDJE_STATE_PARAM_PERSP_FOCAL    42
-#define EDJE_STATE_PARAM_LAST           43
+#define EDJE_STATE_PARAM_PHYSICS_MASS   43
+#define EDJE_STATE_PARAM_PHYSICS_FRICTION 44
+#define EDJE_STATE_PARAM_PHYSICS_RESTITUTION 45
+#define EDJE_STATE_PARAM_LAST           46
 
 #define EDJE_ENTRY_EDIT_MODE_NONE 0
 #define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1