cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=942322a1eb0fc0885029b7b2c74748a5e6a4b01f

commit 942322a1eb0fc0885029b7b2c74748a5e6a4b01f
Author: Vorobiov Vitalii <[email protected]>
Date:   Tue Jun 10 17:22:24 2014 +0200

    edje: Edje_Edit - add edje_edit_part_item_append functions.
    
    Summary:
    First function of the "BOX and TABLE support" feature.
    Implements only few stuff
    - edje_edit_part_item_append function, that append new item to the items of 
BOX or TABLE part
    - support TABLE and PART source code generation
    
    @feature
    
    Reviewers: cedric, Hermet, seoz, raster
    
    CC: reutskiy.v.v, cedric
    
    Differential Revision: https://phab.enlightenment.org/D961
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h |  10 +++++
 src/lib/edje/edje_edit.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 5f98856..5fbae8a 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -1552,6 +1552,16 @@ EAPI const char * 
edje_edit_part_drag_threshold_get(Evas_Object *obj, const char
  */
 EAPI Eina_Bool edje_edit_part_drag_threshold_set(Evas_Object *obj, const char 
*part, const char *threshold);
 
+/** Append new item to box or table part.
+ *
+ * @param obj Object being edited.
+ * @param part Part to add a new item. This part should have BOX or TABLE type.
+ * @param item_name Name of new item that is not exist in BOX or TABLE yet.
+ * @param source_group Source (means group name) of the
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_append(Evas_Object *obj, const char *part, 
const char *item_name, const char *source_group);
 
 //@}
 
/******************************************************************************/
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index d8a28a9..ea7bd39 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -3417,6 +3417,71 @@ FUNC_PART_DRAG_ID(confine);
 FUNC_PART_DRAG_ID(event);
 FUNC_PART_DRAG_ID(threshold);
 
+EAPI Eina_Bool
+edje_edit_part_item_append(Evas_Object *obj, const char *part, const char 
*item_name, const char *source_group)
+{
+
+   Edje_Part *ep;
+   unsigned int i;
+   Edje_Pack_Element *item;
+
+   GET_RP_OR_RETURN(EINA_FALSE);
+
+   /* There is only Box and Table is allowed. */
+   if ((rp->part->type != EDJE_PART_TYPE_BOX) &&
+      (rp->part->type != EDJE_PART_TYPE_TABLE))
+     return EINA_FALSE;
+
+   ep = rp->part;
+
+   if (!ed->file) return EINA_FALSE;
+
+   /* check if a source group is exists. */
+   if (!eina_hash_find(ed->file->collection, source_group))
+     return EINA_FALSE;
+
+   for (i = 0; i < ep->items_count; ++i)
+     {
+        if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item_name)))
+          return EINA_FALSE;
+     }
+
+   ep->items_count++;
+   ep->items = realloc(ep->items, sizeof (Edje_Pack_Element *) * 
ep->items_count);
+   item = _alloc(sizeof (Edje_Pack_Element));
+   ep->items[ep->items_count - 1] = item;
+
+   item->type = EDJE_PART_TYPE_GROUP;
+   item->name = eina_stringshare_add(item_name);
+   item->source = eina_stringshare_add(source_group);
+   item->min.w = 0;
+   item->min.h = 0;
+   item->prefer.w = 0;
+   item->prefer.h = 0;
+   item->max.w = -1;
+   item->max.h = -1;
+   item->padding.l = 0;
+   item->padding.r = 0;
+   item->padding.t = 0;
+   item->padding.b = 0;
+   item->align.x = FROM_DOUBLE(0.5);
+   item->align.y = FROM_DOUBLE(0.5);
+   item->weight.x = FROM_DOUBLE(0.0);
+   item->weight.y = FROM_DOUBLE(0.0);
+   item->aspect.w = 0;
+   item->aspect.h = 0;
+   item->aspect.mode = EDJE_ASPECT_CONTROL_NONE;
+   item->options = NULL;
+   item->col = -1;
+   item->row = -1;
+   item->colspan = 1;
+   item->rowspan = 1;
+   item->spread.w = 1;
+   item->spread.h = 1;
+
+   return EINA_TRUE;
+}
+
 /*********************/
 /*  PART STATES API  */
 /*********************/
@@ -8499,6 +8564,8 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part 
*ep, Eina_Strbuf *buf)
    char *data;
    Eina_Bool ret = EINA_TRUE;
    const char *api_name, *api_description;
+   unsigned int i = 0;
+   Edje_Pack_Element *item;
 
    GET_RP_OR_RETURN(EINA_FALSE);
 
@@ -8588,6 +8655,44 @@ _edje_generate_source_of_part(Evas_Object *obj, 
Edje_Part *ep, Eina_Strbuf *buf)
                       effects[effect]);
      }
 
+   //Box
+   if ((edje_edit_part_type_get(obj, part) == EDJE_PART_TYPE_BOX) ||
+       (edje_edit_part_type_get(obj, part) == EDJE_PART_TYPE_TABLE))
+     {
+        if (ep->items_count != 0)
+          {
+             BUF_APPEND(I4"box {\n");
+             BUF_APPEND(I5"items {\n");
+             for (i = 0; i < ep->items_count; ++i)
+               {
+                  item = ep->items[i];
+                  BUF_APPEND(I6"item {\n");
+                  BUF_APPENDF(I7"type: %s;\n", types[item->type]);
+                  if (item->name)
+                    BUF_APPENDF(I7"name: \"%s\";\n", item->name);
+                  if (item->source)
+                    BUF_APPENDF(I7"source: \"%s\";\n", item->source);
+                  //TODO min
+                  //TODO prefer
+                  //TODO max
+                  //TODO padding
+                  //TODO align
+                  //TODO weight
+                  //TODO aspect
+                  //TODO aspect mode
+                  //TODO options
+                  //TODO col
+                  //TODO row
+                  //TODO colspan
+                  //TODO rowspan
+                  //TODO spread
+                  BUF_APPEND(I6"}\n");
+               }
+             BUF_APPEND(I5"}\n");
+             BUF_APPEND(I4"}\n");
+          }
+     }
+
    //Dragable
    str = edje_edit_part_drag_event_get(obj, part);
    if (rp->part->dragable.x || rp->part->dragable.y || str)

-- 


Reply via email to