Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        Edje_Edit.h edje_calc.c edje_embryo.c edje_load.c 


Log Message:
added basic support for custom state magic. only description.align can be changed at 
runtime so far.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/Edje_Edit.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- Edje_Edit.h 29 Oct 2004 15:12:01 -0000      1.19
+++ Edje_Edit.h 29 Oct 2004 17:56:04 -0000      1.20
@@ -140,6 +140,10 @@
 
 #define EDJE_VAR_MAGIC_BASE 0x12fe84ba
 
+#define EDJE_STATE_PARAM_NONE         0
+#define EDJE_STATE_PARAM_ALIGNMENT    1
+#define EDJE_STATE_PARAM_LAST         2
+
 /*----------*/
 
 struct _Edje_File
@@ -533,7 +537,7 @@
       Edje_Real_Part        *rel1_to_y;
       Edje_Real_Part        *rel2_to_x;
       Edje_Real_Part        *rel2_to_y;
-   } param1, param2;
+   } param1, param2, custom;
 
    Edje_Real_Part           *confine_to;
    Edje_Real_Part           *clip_to;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_calc.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -3 -r1.46 -r1.47
--- edje_calc.c 29 Oct 2004 15:12:01 -0000      1.46
+++ edje_calc.c 29 Oct 2004 17:56:04 -0000      1.47
@@ -58,6 +58,9 @@
    if (!strcmp(name, "default") && val == 0.0)
      return ep->default_desc;
 
+   if (!strcmp(name, "custom"))
+     return rp->custom.description;
+
    if (!strcmp(name, "default"))
      {
        ret = ep->default_desc;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_embryo.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- edje_embryo.c       29 Oct 2004 14:49:10 -0000      1.37
+++ edje_embryo.c       29 Oct 2004 17:56:05 -0000      1.38
@@ -121,7 +121,11 @@
  * replace_float(id, n, Float:v)
  * Float:fetch_float(id, n)
  *
- * still need to implement this:
+ * custom_state(part_id, state[], Float:state_val = 0.0)
+ * set_state_val(part_id, State_Param:param, ...)
+ * get_state_val(part_id, State_Param:param, ...)
+ *
+ * Supported parameters: align[Float:x, Float:y]
  *
  * ** part_id and program_id need to be able to be "found" from strings
  * 
@@ -139,22 +143,11 @@
  * get_repeat_events(part_id)
  * set_clip(part_id, clip_part_id)
  * get_clip(part_id)
- */
-/* MODIFY STATE VALUES
- * 
- * THIS COPIES THE STATE VALUES OF THE GIVEN STATE/VAL TO CREATE A CUSTOM STATE
- * 
- * custom_state(part_id, state[], Float:state_val)
- * 
- * THESE ALWAYS WORK ON THE CUTSOM STATE ONLY
- * 
- * set_state_val(part_id, Param:param, ...)
- * get_state_val(part_id, Param:param, ...)
- * 
- * FOR THESE PROPERTIES:
- * 
- * visible
- * align[x,y]
+ *
+ *
+ * Need to implement support for the following properties
+ * in get/set_state_val():
+ *
  * min[w,h]
  * max[w,h]
  * step[x,y]
@@ -1418,6 +1411,167 @@
    return(0);
 }
 
+/* custom_state(part_id, state[], Float:state_val = 0.0) */
+static Embryo_Cell
+_edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Edje *ed = embryo_program_data_get(ep);
+   Edje_Real_Part *rp;
+   Edje_Part_Description *parent, *d;
+   Evas_List *l;
+   char *name;
+   float val;
+
+   CHKPARAM(3);
+
+   if (params[1] < 0)
+     return 0;
+
+   if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
+     return 0;
+
+   /* check whether this part already has a "custom" state */
+   if (rp->custom.description)
+     return 0;
+
+   GETSTR(name, params[2]);
+   if (!name)
+     return 0;
+
+   val = EMBRYO_CELL_TO_FLOAT(params[3]);
+
+   if (!(parent = _edje_part_description_find(ed, rp, name, val)))
+     return 0;
+
+   /* now create the custom state */
+   if (!(d = calloc(1, sizeof(Edje_Part_Description))))
+     return 0;
+
+   *d = *parent;
+
+   d->state.name = strdup("custom");
+   d->state.value = 0.0;
+
+   /* make sure all the allocated memory is getting copied,
+    * not just referenced
+    */
+   d->image.tween_list = NULL;
+
+   for (l = parent->image.tween_list; l; l = l->next)
+     {
+       Edje_Part_Image_Id *iid = l->data, *iid_new;
+
+       iid_new = calloc(1, sizeof(Edje_Part_Image_Id));
+       iid_new->id = iid->id;
+
+       d->image.tween_list = evas_list_append(d->image.tween_list, iid_new);
+     }
+
+#define STRDUP(x) x ? strdup(x) : NULL
+   d->color_class = STRDUP(d->color_class);
+   d->text.text = STRDUP(d->text.text);
+   d->text.text_class = STRDUP(d->text.text_class);
+   d->text.font = STRDUP(d->text.font);
+#undef STRDUP
+
+   rp->custom.description = d;
+
+   return 0;
+}
+
+/* set_state_val(part_id, State_Param:p, ...) */
+static Embryo_Cell
+_edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Edje *ed = embryo_program_data_get(ep);
+   Edje_Real_Part *rp;
+   Embryo_Cell *cptr;
+
+   /* we need at least 3 arguments */
+   if (params[0] < (sizeof(Embryo_Cell) * 3))
+     return 0;
+
+   if (params[1] < 0)
+     return 0;
+
+   if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
+     return 0;
+
+   /* check whether this part has a "custom" state */
+   if (!rp->custom.description)
+     return 0;
+
+   switch (params[2])
+     {
+      case EDJE_STATE_PARAM_ALIGNMENT:
+        CHKPARAM(4);
+
+        cptr = embryo_data_address_get(ep, params[3]);
+        if (cptr)
+          rp->custom.description->align.x = EMBRYO_CELL_TO_FLOAT(*cptr);
+
+        cptr = embryo_data_address_get(ep, params[4]);
+        if (cptr)
+          rp->custom.description->align.y = EMBRYO_CELL_TO_FLOAT(*cptr);
+
+        break;
+      default:
+        break;
+     }
+
+   return 0;
+}
+
+/* get_state_val(part_id, State_Param:p, ...) */
+static Embryo_Cell
+_edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Edje *ed = embryo_program_data_get(ep);
+   Edje_Real_Part *rp;
+   Embryo_Cell *cptr;
+   float f;
+
+   /* we need at least 3 arguments */
+   if (params[0] < (sizeof(Embryo_Cell) * 3))
+     return 0;
+
+   if (params[1] < 0)
+     return 0;
+
+   if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
+     return 0;
+
+   /* check whether this part has a "custom" state */
+   if (!rp->custom.description)
+     return 0;
+
+   switch (params[2])
+     {
+      case EDJE_STATE_PARAM_ALIGNMENT:
+        CHKPARAM(4);
+
+        cptr = embryo_data_address_get(ep, params[3]);
+        if (cptr)
+          {
+             f = rp->custom.description->align.x;
+             *cptr = EMBRYO_FLOAT_TO_CELL(f);
+          }
+
+        cptr = embryo_data_address_get(ep, params[4]);
+        if (cptr)
+          {
+             f = rp->custom.description->align.y;
+             *cptr = EMBRYO_FLOAT_TO_CELL(f);
+          }
+
+        break;
+      default:
+        break;
+     }
+
+   return 0;
+}
+
 void
 _edje_embryo_script_init(Edje *ed)
 {
@@ -1487,6 +1641,9 @@
    
    embryo_program_native_call_add(ep, "send_message", _edje_embryo_fn_send_message);
    embryo_program_native_call_add(ep, "get_geometry", _edje_embryo_fn_get_geometry);
+   embryo_program_native_call_add(ep, "custom_state", _edje_embryo_fn_custom_state);
+   embryo_program_native_call_add(ep, "set_state_val", _edje_embryo_fn_set_state_val);
+   embryo_program_native_call_add(ep, "get_state_val", _edje_embryo_fn_get_state_val);
    
    embryo_program_vm_push(ep); /* neew a new vm to run in */
    _edje_embryo_globals_init(ed);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_load.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- edje_load.c 20 Oct 2004 06:25:43 -0000      1.50
+++ edje_load.c 29 Oct 2004 17:56:12 -0000      1.51
@@ -1,3 +1,7 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+
 #include "Edje.h"
 #include "edje_private.h"
 
@@ -620,6 +624,12 @@
             if (rp->text.font) free(rp->text.font);
             if (rp->text.cache.in_str) free(rp->text.cache.in_str);
             if (rp->text.cache.out_str) free(rp->text.cache.out_str);       
+
+            if (rp->custom.description)
+              {
+                 _edje_collection_free_part_description_free(rp->custom.description);
+              }
+
             free(rp);
          }
        ed->parts = NULL;




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to