edje_edit: Add edje_edit_part_item_aspect_mode functions.
authorVorobiov Vitalii <vi.vorobiov@samsung.com>
Thu, 3 Jul 2014 07:59:16 +0000 (16:59 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 3 Jul 2014 07:59:16 +0000 (16:59 +0900)
Summary:
Add two main functions for TABLE and BOX part items:
- edje_edit_part_item_aspect_mode_get
- edje_edit_part_item_aspect_mode_set

Also add support to generate source code of changed aspect mode for an item

@feature

Reviewers: cedric, Hermet, seoz, raster

CC: reutskiy.v.v, cedric
Differential Revision: https://phab.enlightenment.org/D1075

src/lib/edje/Edje_Edit.h
src/lib/edje/edje_edit.c

index f5b3ced..b21f459 100644 (file)
@@ -1911,6 +1911,45 @@ EAPI Eina_Bool edje_edit_part_item_aspect_h_set(Evas_Object *obj, const char *pa
  */
 EAPI int edje_edit_part_item_prefer_w_get(Evas_Object *obj, const char *part, const char *item);
 
+/** Get aspect mode for an item of TABLE or BOX.
+ *
+ * This may return next values:
+ * - EDJE_ASPECT_CONTROL_NONE
+ * - EDJE_ASPECT_CONTROL_NEITHER
+ * - EDJE_ASPECT_CONTROL_HORIZONTAL
+ * - EDJE_ASPECT_CONTROL_VERTICAL
+ * - EDJE_ASPECT_CONTROL_BOTH
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain item.
+ * @param item The name of the item to set aspect mode.
+ *
+ * @return One of possible enum Edje_Aspect_Control.
+ * @since 1.11
+ */
+EAPI Edje_Aspect_Control
+edje_edit_part_item_aspect_mode_get(Evas_Object *obj, const char *part, const char *item);
+
+/** Set aspect mode for an item of TABLE or BOX.
+ *
+ * Mode may be next:
+ * - EDJE_ASPECT_CONTROL_NONE
+ * - EDJE_ASPECT_CONTROL_NEITHER
+ * - EDJE_ASPECT_CONTROL_HORIZONTAL
+ * - EDJE_ASPECT_CONTROL_VERTICAL
+ * - EDJE_ASPECT_CONTROL_BOTH
+ *
+ * @param obj Object being edited.
+ * @param part Part that contain item.
+ * @param item The name of the item to set aspect mode.
+ * @param mode One of possible enum from Edje_Aspect_Control:
+
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ * @since 1.11
+ */
+EAPI Eina_Bool
+edje_edit_part_item_aspect_mode_set(Evas_Object *obj, const char *part, const char *item, Edje_Aspect_Control mode);
+
 /** Set the prefer width value of a part's item.
  *
  * @param obj Object being edited.
index d62939a..bb34cc1 100644 (file)
@@ -4245,6 +4245,67 @@ FUNC_PART_ITEM_INT(aspect, h, 0);
 FUNC_PART_ITEM_INT(prefer, w, 0);
 FUNC_PART_ITEM_INT(prefer, h, 0);
 
+EAPI Edje_Aspect_Control
+edje_edit_part_item_aspect_mode_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 EDJE_ASPECT_CONTROL_NONE;
+
+   GET_RP_OR_RETURN(EDJE_ASPECT_CONTROL_NONE);
+
+   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 EDJE_ASPECT_CONTROL_NONE;
+
+   return item->aspect.mode;
+
+}
+
+EAPI Eina_Bool
+edje_edit_part_item_aspect_mode_set(Evas_Object *obj, const char *part, const char *item_name, Edje_Aspect_Control mode)
+{
+   Edje_Part *ep;
+   unsigned int i;
+   Edje_Pack_Element *item = NULL;
+
+   if ((!obj) || (!part) || (!item_name))
+     return EINA_FALSE;
+
+   GET_RP_OR_RETURN(EINA_FALSE);
+
+   if ((rp->part->type != EDJE_PART_TYPE_BOX) &&
+       (rp->part->type != EDJE_PART_TYPE_TABLE))
+     return EINA_FALSE;
+
+   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 EINA_FALSE;
+
+   item->aspect.mode = mode;
+
+   return EINA_TRUE;
+
+}
+
 EAPI Eina_Bool
 edje_edit_part_item_padding_get(Evas_Object *obj, const char *part, const char *item_name, int *l, int *r, int *t, int *b)
 {
@@ -9039,6 +9100,7 @@ static const char *effects[] = {"NONE", "PLAIN", "OUTLINE", "SOFT_OUTLINE", "SHA
 static const char *shadow_direction[] = {"BOTTOM_RIGHT", "BOTTOM", "BOTTOM_LEFT", "LEFT", "TOP_LEFT", "TOP", "TOP_RIGHT", "RIGHT"};
 static const char *prefers[] = {"NONE", "VERTICAL", "HORIZONTAL", "BOTH"};
 static const char *entry_mode[] = {"NONE", "PLAIN", "EDITABLE", "PASSWORD"};
+static const char *aspect_mode[] = {"NONE", "NEITHER", "HORIZONTAL", "VERTICAL", "BOTH"};
 
 static Eina_Bool
 _edje_generate_source_of_group(Edje *ed, Edje_Part_Collection_Directory_Entry *pce, Eina_Strbuf *buf);
@@ -9976,7 +10038,8 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf)
                     BUF_APPENDF(I7"min: %d %d;\n", item->min.h, item->min.h);
                   if ((item->max.w != -1) || (item->max.h != -1))
                     BUF_APPENDF(I7"max: %d %d;\n", item->max.h, item->max.h);
-                  //TODO aspect mode
+                  if (item->aspect.mode)
+                    BUF_APPENDF(I7"aspect_mode: \"%s\";\n", aspect_mode[item->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))