cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=bb878758e620ff5a0eb26098f1ae60c98808418b
commit bb878758e620ff5a0eb26098f1ae60c98808418b Author: Vorobiov Vitalii <[email protected]> Date: Mon Jun 16 18:57:29 2014 +0200 edje: Edje_Edit - add edje_edit_part_item_align functions. Summary: Getters and setters of align for box/table items. Following functions were added: - edje_edit_part_item_align_x_set - edje_edit_part_item_align_x_get - edje_edit_part_item_align_y_set - edje_edit_part_item_align_y_get @feature Reviewers: raster, seoz, cedric, Hermet CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D1045 Signed-off-by: Cedric BAIL <[email protected]> --- src/lib/edje/Edje_Edit.h | 46 +++++++++++++++++++++++++++++++++++++ src/lib/edje/edje_edit.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 2adcdf3..78b1fbd 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -1834,6 +1834,52 @@ EAPI Eina_Bool edje_edit_part_item_padding_get(Evas_Object *obj, const char *par */ EAPI Eina_Bool edje_edit_part_item_padding_set(Evas_Object *obj, const char *part, const char *item_name, int l, int r, int t, int b); +/** Get the horizontal align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain item. + * @param item The name of the item to get horizontal align value. + * + * @return The horizontal align value for the given align (value is between -1.0 and 1.0) + * @since 1.11 + */ +EAPI double edje_edit_part_item_align_x_get(Evas_Object *obj, const char *part, const char *item); + +/** Set the horizontal align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain itemf + * @param item The name of the item to set horizontal align value. + * @param align_x New value of the horizontal align. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + * @since 1.11 + */ +EAPI Eina_Bool edje_edit_part_item_align_x_set(Evas_Object *obj, const char *part, const char *item, double align_x); + +/** Get the vertical align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain item. + * @param item The name of the item to get vertical align value. + * + * @return The vertical align value for the given align (value is between -1.0 and 1.0) + * @since 1.11 + */ +EAPI double edje_edit_part_item_align_y_get(Evas_Object *obj, const char *part, const char *item); + +/** Set the vertical align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain item. + * @param item The name of the item to set vertical align value. + * @param align_y New value of the vertical align. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + * @since 1.11 + */ +EAPI Eina_Bool edje_edit_part_item_align_y_set(Evas_Object *obj, const char *part, const char *item, double align_y); + //@} /******************************************************************************/ /************************** STATES API ************************************/ diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index e45e282..9c6a8f9 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -4064,6 +4064,61 @@ edje_edit_part_item_padding_set(Evas_Object *obj, const char *part, const char * return EINA_TRUE; } +#define FUNC_PART_ITEM_DOUBLE(Name, Value) \ + EAPI double \ + edje_edit_part_item_##Name##_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 0.0; \ + GET_RP_OR_RETURN(0.0); \ + 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; \ + return TO_DOUBLE(item->Value); \ + } \ + EAPI Eina_Bool \ + edje_edit_part_item_##Name##_set(Evas_Object *obj, const char *part, const char *item_name, double v) \ + { \ + Edje_Part *ep; \ + unsigned int i; \ + Edje_Pack_Element *item = NULL; \ + if ((!obj) || (!part) || (!item_name)) \ + return EINA_FALSE; \ + if ((v < -1.0) || (v > 1.0)) \ + 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->Value = FROM_DOUBLE(v); \ + return EINA_TRUE; \ + } + +FUNC_PART_ITEM_DOUBLE(align_x, align.x); +FUNC_PART_ITEM_DOUBLE(align_y, align.y); + +#undef FUNC_PART_ITEM_DOUBLE + /*********************/ /* PART STATES API */ /*********************/ @@ -9435,7 +9490,9 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf) BUF_APPENDF(I7"padding: %d %d %d %d;\n", item->padding.l, item->padding.r, item->padding.t, item->padding.b); - //TODO align + + if (TO_DOUBLE(item->align.x) != 0.5 || TO_DOUBLE(item->align.y) != 0.5) + BUF_APPENDF(I7"align: %g %g;\n", TO_DOUBLE(item->align.x), TO_DOUBLE(item->align.y)); //TODO weight //TODO options //TODO col --
