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
This commit is contained in:
Andrii Kroitor 2014-07-03 16:54:44 +09:00 committed by Carsten Haitzler (Rasterman)
parent 30df128be5
commit 8c74a8fbb0
2 changed files with 166 additions and 0 deletions

View File

@ -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 **************************************/
/******************************************************************************/

View File

@ -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 */
/****************/