raster pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=8c74a8fbb04243df53eb195c1a2f992287723371
commit 8c74a8fbb04243df53eb195c1a2f992287723371 Author: Andrii Kroitor <an.kroi...@samsung.com> Date: Thu Jul 3 16:54:44 2014 +0900 Edje_Edit: added API for group.limits Summary: added functions: edje_edit_group_limits_vertical_list_get edje_edit_group_limits_vertical_add edje_edit_group_limits_vertical_del edje_edit_group_limits_horizontal_list_get edje_edit_group_limits_horizontal_add edje_edit_group_limits_horizontal_del edje_edit_limits_list_free Reviewers: cedric, seoz, raster, Hermet CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D1073 --- src/lib/edje/Edje_Edit.h | 71 ++++++++++++++++++++++++++++++++++++ src/lib/edje/edje_edit.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index db5c9c1..f5b3ced 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -85,6 +85,13 @@ struct _Edje_Part_Image_Use }; typedef struct _Edje_Part_Image_Use Edje_Part_Image_Use; +struct _Edje_Edit_Limit +{ + Eina_Stringshare *name; + int value; +}; +typedef struct _Edje_Edit_Limit Edje_Edit_Limit; + /** * @file * @brief Functions to deal with edje internal object. Don't use in standard @@ -402,6 +409,70 @@ EAPI Eina_Bool edje_edit_group_broadcast_signal_get(Evas_Object *obj); EAPI Eina_Bool edje_edit_group_broadcast_signal_set(Evas_Object *obj, Eina_Bool bs); //@} + + +/** Retrieves a list with the item names inside the vertical limits block at the group level. + * + * @param obj Object being edited. + * + * @return List of strings, each being a name of vertical limit in the limits block for the group. + */ +EAPI Eina_List * edje_edit_group_limits_vertical_list_get(Evas_Object *obj); + +/** Delete given pair name-value from the vertical limits block at the group level. + * + * @param obj Object being edited. + * @param name Limit name. + * @param value Limit value. + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_limits_vertical_del(Evas_Object *obj, const char *name, int value); + +/** Add given pair name-value to the vertical limits block at the group level. + * + * @param obj Object being edited. + * @param name Limit name. + * @param value Limit value. + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_limits_vertical_add(Evas_Object *obj, const char *name, int value); + +/** Retrieves a list with the item names inside the horizontal limits block at the group level. + * + * @param obj Object being edited. + * + * @return List of strings, each being a name of horizontal limit in the limits block for the group. + */ +EAPI Eina_List * edje_edit_group_limits_horizontal_list_get(Evas_Object *obj); + +/** Delete given pair name-value from the horizontal limits block at the group level. + * + * @param obj Object being edited. + * @param name Limit name. + * @param value Limit value. + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_limits_horizontal_del(Evas_Object *obj, const char *name, int value); + +/** Add given pair name-value to the horizontal limits block at the group level. + * + * @param obj Object being edited. + * @param name Limit name. + * @param value Limit value. + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_limits_horizontal_add(Evas_Object *obj, const char *name, int value); + +/** Free an Eina_List of (Edje_Edit_List *) allocated by an edje_edit_limits_vertical_list_get() or edje_edit_limits_horizontal_list_get() functions. + * + * @param lst List to free. + */ +EAPI void edje_edit_limits_list_free(Eina_List *lst); + /******************************************************************************/ /************************** ALIAS API **************************************/ /******************************************************************************/ diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 9ebd81e..d62939a 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -1872,6 +1872,101 @@ edje_edit_group_broadcast_signal_set(Evas_Object *obj, Eina_Bool bs) return EINA_TRUE; } +#define LIMITS(TYPE) \ +EAPI Eina_List * \ +edje_edit_group_limits_##TYPE##_list_get(Evas_Object * obj) \ +{ \ + Eina_List *limits = NULL; \ + unsigned int i; \ + Edje_Edit_Limit *lim; \ + \ + GET_ED_OR_RETURN(NULL); \ + \ + if (!ed->file || !ed->collection) \ + return NULL; \ + lim = calloc(ed->collection->limits.TYPE##_count, sizeof(Edje_Edit_Limit)); \ + for(i = 0; i < ed->collection->limits.TYPE##_count; i++) \ + { \ + lim[i].name = eina_stringshare_add(ed->collection->limits.TYPE[i]->name); \ + lim[i].value = ed->collection->limits.TYPE[i]->value; \ + limits = eina_list_append(limits, &lim[i]); \ + } \ + \ + return limits; \ +} \ + \ +EAPI Eina_Bool \ +edje_edit_group_limits_##TYPE##_del(Evas_Object * obj, const char * name, int value) \ +{ \ + unsigned int i; \ + unsigned int new_count; \ + \ + if ((!name) || (value < 1)) \ + return EINA_FALSE; \ + GET_ED_OR_RETURN(EINA_FALSE); \ + GET_EED_OR_RETURN(EINA_FALSE); \ + \ + new_count = ed->collection->limits.TYPE##_count - 1; \ + for(i = 0; i < ed->collection->limits.TYPE##_count; i++) \ + if ((ed->collection->limits.TYPE[i]->value == value) \ + && (!strcmp(ed->collection->limits.TYPE[i]->name, name))) \ + { \ + _edje_if_string_free(ed, ed->collection->limits.TYPE[i]->name); \ + free(ed->collection->limits.TYPE[i]); \ + if (i < new_count) \ + { \ + ed->collection->limits.TYPE[i] = \ + ed->collection->limits.TYPE[ed->collection->limits.TYPE##_count - 1]; \ + } \ + ed->collection->limits.TYPE = realloc(ed->collection->limits.TYPE, \ + new_count * sizeof(Edje_Limit *)); \ + --ed->collection->limits.TYPE##_count; \ + _edje_edit_flag_script_dirty(eed, EINA_TRUE); \ + \ + return EINA_TRUE; \ + } \ + return EINA_FALSE; \ +} \ + \ +EAPI Eina_Bool \ +edje_edit_group_limits_##TYPE##_add(Evas_Object * obj, const char * name, int value) \ +{ \ + unsigned int i; \ + unsigned int new_count; \ + \ + if ((!name) || (value < 1)) \ + return EINA_FALSE; \ + GET_ED_OR_RETURN(EINA_FALSE); \ + \ + for(i = 0; i < ed->collection->limits.TYPE##_count; i++) \ + if ((ed->collection->limits.TYPE[i]->value == value) \ + && (!strcmp(ed->collection->limits.TYPE[i]->name, name))) \ + { \ + return EINA_FALSE; \ + } \ + new_count = ed->collection->limits.TYPE##_count + 1; \ + ed->collection->limits.TYPE = realloc(ed->collection->limits.TYPE, \ + new_count * sizeof(Edje_Limit *)); \ + ed->collection->limits.TYPE[new_count-1] = malloc(sizeof(Edje_Limit)); \ + ed->collection->limits.TYPE[new_count-1]->name = eina_stringshare_add(name); \ + ed->collection->limits.TYPE[new_count-1]->value = value; \ + ++ed->collection->limits.TYPE##_count; \ + return EINA_TRUE; \ +} + +LIMITS(vertical); +LIMITS(horizontal); + +EAPI void +edje_edit_limits_list_free(Eina_List *list) +{ + Edje_Edit_Limit *lim = eina_list_data_get(list); + Edje_Edit_Limit *item; + EINA_LIST_FREE(list, item) + eina_stringshare_del(item->name); + free(lim); +} + /****************/ /* ALIAS API */ /****************/ --