cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=08075be88549da00d74c68180a3222ccc3a8b08a

commit 08075be88549da00d74c68180a3222ccc3a8b08a
Author: Vorobiov Vitalii <[email protected]>
Date:   Fri Jun 13 18:09:30 2014 +0200

    edje: Edje_Edit - add bunch of BOX and TABLE param get/set functions.
    
    Summary:
    Add some functions for setting and getting params of the items in BOX or 
TABLE parts.
    Next item's params are added:
    - min
    - max
    - prefer
    - aspect
    
    Functions of them looks like that:
    - edje_edit_part_item_min_w_get
    - edje_edit_part_item_min_w_set
    - edje_edit_part_item_min_h_get
    - edje_edit_part_item_min_h_set
    - edje_edit_part_item_prefer_w_set
    - ... etc
    
    Also this commit adds code generation for them.
    
    @feature
    
    Reviewers: cedric, seoz, raster, Hermet
    
    CC: reutskiy.v.v, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1035
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h | 176 +++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/edje/edje_edit.c |  75 ++++++++++++++++++--
 2 files changed, 245 insertions(+), 6 deletions(-)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index ae004a9..7c48f32 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -1592,6 +1592,182 @@ EAPI Eina_Bool 
edje_edit_part_item_source_set(Evas_Object *obj, const char *part
  */
 EAPI const char * edje_edit_part_item_source_get(Evas_Object *obj, const char 
*part, const char *item_name);
 
+/** Get the minimum width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get minimum width.
+ *
+ * @return The minimum width value.
+ */
+EAPI int edje_edit_part_item_min_w_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the minimum width value of a part's item.
+ * The minimum width should be greater than 0.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set minimum width.
+ * @param min_w Minimum width value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_min_w_set(Evas_Object *obj, const char 
*part, const char *item, int min_w);
+
+/** Get the minimum height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get minimum height.
+ *
+ * @return The minimum height value.
+ */
+EAPI int edje_edit_part_item_min_h_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the minimum height value of a part's item.
+ * The minimum height should be greater than 0.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set minimum height.
+ * @param min_h Minimum height value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_min_h_set(Evas_Object *obj, const char 
*part, const char *item, int min_h);
+
+/** Get the maximum width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get maximum width.
+ *
+ * @return The maximum width value.
+ */
+EAPI int edje_edit_part_item_max_w_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the maximum width value of a part's item.
+ * The maximum width should be greater than -1.
+ * The value -1 means that state doesn't have any boundaries on width 
direction.
+ * (it can be any size that is bigger than it's min)
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set maximum width.
+ * @param max_w Maximum width value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_max_w_set(Evas_Object *obj, const char 
*part, const char *item, int max_w);
+
+/** Get the maximum height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get maximum height.
+ *
+ * @return The maximum height value.
+ */
+EAPI int edje_edit_part_item_max_h_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the maximum height value of a part's item.
+ * The maximum height should be greater than -1.
+ * The value -1 means that state doesn't have any boundaries on height 
direction.
+ * (it can be any size that is bigger than it's min)
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set maximum height.
+ * @param max_h Maximum height value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_max_h_set(Evas_Object *obj, const char 
*part, const char *item, int max_h);
+
+/** Get the aspect width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get aspect width.
+ *
+ * @return The aspect width value.
+ */
+EAPI int edje_edit_part_item_aspect_w_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the aspect width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set aspect width.
+ * @param aspect_w Maximum width value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_aspect_w_set(Evas_Object *obj, const char 
*part, const char *item, int aspect_w);
+
+/** Get the aspect height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get aspect height.
+ *
+ * @return The maximum height value.
+ */
+EAPI int edje_edit_part_item_aspect_h_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the aspect height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set aspect height.
+ * @param max_h Maximum height value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_aspect_h_set(Evas_Object *obj, const char 
*part, const char *item, int aspect_h);
+
+/** Get the prefer width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get prefer width.
+ *
+ * @return The prefer width value.
+ */
+EAPI int edje_edit_part_item_prefer_w_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the prefer width value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set prefer width.
+ * @param prefer_w Maximum width value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_prefer_w_set(Evas_Object *obj, const char 
*part, const char *item, int prefer_w);
+
+/** Get the prefer height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to get prefer height.
+ *
+ * @return The maximum height value.
+ */
+EAPI int edje_edit_part_item_prefer_h_get(Evas_Object *obj, const char *part, 
const char *item);
+
+/** Set the prefer height value of a part's item.
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain state.
+ * @param item The name of the item to set prefer height.
+ * @param max_h Maximum height value.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_prefer_h_set(Evas_Object *obj, const char 
*part, const char *item, int prefer_h);
+
 //@}
 
/******************************************************************************/
 /**************************   STATES API   
************************************/
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index d171600..9f155e7 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -3863,6 +3863,64 @@ edje_edit_part_item_source_get(Evas_Object *obj, const 
char *part, const char *i
    return eina_stringshare_add(item->source);
 }
 
+#define FUNC_PART_ITEM_INT(Class, Value, Min)                          \
+  EAPI int                                                             \
+  edje_edit_part_item_##Class##_##Value##_get(Evas_Object *obj, const char 
*part, const char *item_name) \
+  {                                                                    \
+     Edje_Part *ep;                                                    \
+     unsigned int i;                                                   \
+     Edje_Pack_Element *item = NULL;                                   \
+     if ((!obj) || (!part) || (!item_name))                            \
+       return Min;                                                     \
+     GET_RP_OR_RETURN(Min);                                            \
+     ep = rp->part;                                                    \
+     for (i = 0; i < ep->items_count; ++i)                             \
+       {                                                               \
+          if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item_name))) \
+            {                                                          \
+               item = ep->items[i];                                    \
+               break;                                                  \
+            }                                                          \
+       }                                                               \
+     if (!item) return Min;                                            \
+     return item->Class.Value;                                         \
+  }                                                                    \
+  EAPI Eina_Bool                                                       \
+  edje_edit_part_item_##Class##_##Value##_set(Evas_Object *obj, const char 
*part, const char *item_name, int v) \
+  {                                                                    \
+     Edje_Part *ep;                                                    \
+     unsigned int i;                                                   \
+     Edje_Pack_Element *item = NULL;                                   \
+     if ((!obj) || (!part) || (!item_name))                            \
+       return EINA_FALSE;                                              \
+     if (v < Min) return EINA_FALSE;                                    \
+     GET_RP_OR_RETURN(EINA_FALSE);                                     \
+     ep = rp->part;                                                    \
+     if ((rp->part->type != EDJE_PART_TYPE_BOX) &&                     \
+        (rp->part->type != EDJE_PART_TYPE_TABLE))                      \
+       return EINA_FALSE;                                              \
+     for (i = 0; i < ep->items_count; ++i)                             \
+       {                                                               \
+          if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item_name))) \
+            {                                                          \
+               item = ep->items[i];                                    \
+               break;                                                  \
+            }                                                          \
+       }                                                               \
+     if (!item) return EINA_FALSE;                                     \
+     item->Class.Value = v;                                            \
+     return EINA_TRUE;                                                 \
+  }
+
+FUNC_PART_ITEM_INT(min, w, 0);
+FUNC_PART_ITEM_INT(min, h, 0);
+FUNC_PART_ITEM_INT(max, w, -1);
+FUNC_PART_ITEM_INT(max, h, -1);
+FUNC_PART_ITEM_INT(aspect, w, 0);
+FUNC_PART_ITEM_INT(aspect, h, 0);
+FUNC_PART_ITEM_INT(prefer, w, 0);
+FUNC_PART_ITEM_INT(prefer, h, 0);
+
 /*********************/
 /*  PART STATES API  */
 /*********************/
@@ -9091,20 +9149,25 @@ _edje_generate_source_of_part(Evas_Object *obj, 
Edje_Part *ep, Eina_Strbuf *buf)
                     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
+                  if ((item->min.w != 0) || (item->min.h != 0))
+                    BUF_APPENDF(I7"min: %d %d;\n", item->min.h, item->min.h);
+                  if ((item->max.w != 0) || (item->max.h != 0))
+                    BUF_APPENDF(I7"max: %d %d;\n", item->max.h, item->max.h);
+                  //TODO aspect mode
+                  if ((item->aspect.w != 0) || (item->aspect.h != 0))
+                    BUF_APPENDF(I7"aspect: %d %d;\n", item->aspect.h, 
item->aspect.h);
+                  if ((item->prefer.w != 0) || (item->prefer.h != 0))
+                    BUF_APPENDF(I7"prefer: %d %d;\n", item->prefer.h, 
item->prefer.h);
+                  if ((item->spread.w != 1) || (item->spread.h != 1))
+                    BUF_APPENDF(I7"spread: %d %d;\n", item->spread.h, 
item->spread.h);
                   //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");

-- 


Reply via email to