cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=dae7b7349ecf79a41b0e89edc5e501b690119da4
commit dae7b7349ecf79a41b0e89edc5e501b690119da4 Author: Vorobiov Vitalii <vi.vorob...@samsung.com> Date: Wed Oct 30 22:00:11 2013 +0900 edje: make setters for "edje_edit_state_image_..." return Eina_Bool. This patch make the following function return Eina_Bool so the caller can detect errors. edje_edit_state_image_set edje_edit_state_image_border_set edje_edit_state_image_border_fill_set Reviewers: cedric, seoz CC: reutskiy.v.v Differential Revision: https://phab.enlightenment.org/D295 Signed-off-by: Cedric Bail <cedric.b...@free.fr> --- src/lib/edje/Edje_Edit.h | 24 +++++++++++++------ src/lib/edje/edje_edit.c | 60 +++++++++++++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 31ec1a9..0b1e5c4 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -2598,8 +2598,10 @@ EAPI const char * edje_edit_state_image_get(Evas_Object *obj, const char *part, * @param state The name of the state to set the image that will be used (not including the state value). * @param value The state value. * @param image The name of the image (must be an image contained in the edje file). + * + * @return EINA_TRUE if successful, EINA_FALSE - otherwise. */ -EAPI void edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image); +EAPI Eina_Bool edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image); /** Get image id for a given image name. * @@ -2659,33 +2661,41 @@ EAPI void edje_edit_state_image_border_get(Evas_Object *obj, const char *part, c * @param r Right border value (or -1). * @param t Top border value (or -1). * @param b Bottom border value (or -1). + * + * @return EINA_TRUE if successful, EINA_FALSE - otherwise. */ -EAPI void edje_edit_state_image_border_set(Evas_Object *obj, const char *part, const char *state, double value, int l, int r, int t, int b); +EAPI Eina_Bool edje_edit_state_image_border_set(Evas_Object *obj, const char *part, const char *state, double value, int l, int r, int t, int b); /** Get if the image center should be draw. * - * 1 means to draw the center, 0 to don't draw it. + * 1 or 2 means to draw the center, 0 to don't draw it. + * If 1 - then the center will apply alpha channel. + * If 2 (SOLID mode) - then the center of an image wont have alpha channel (Just black color). * * @param obj Object being edited. * @param part Part that contain state. * @param state The name of the state to get the image border fill (not including the state value). * @param value The state value. * - * @return 1 if the center of the bordered image is draw, 0 otherwise. + * @return 2 if the center of the bordered image is draw without alpha, 1 dawing with alpha and 0 not drawing the center. */ EAPI unsigned char edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const char *state, double value); /** Set if the image center should be draw. * - * 1 means to draw the center, 0 to don't draw it. + * 1 or 2 means to draw the center, 0 to don't draw it. + * If 1 - then the center will apply alpha channel. + * If 2 (SOLID mode) - then the center of an image wont have alpha channel (Just black color). * * @param obj Object being edited. * @param part Part that contain state. * @param state The name of the state to set the image border fill (not including the state value). * @param value The state value. - * @param fill Fill to be se. 1 if the center of the bordered image is draw, 0 otherwise. + * @param fill Fill to be set. 1 or 2 if the center of the bordered image is draw, 0 otherwise. + * + * @return EINA_TRUE if successful, EINA_FALSE - otherwise. */ -EAPI void edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill); +EAPI Eina_Bool edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill); /** Get the list of all the tweens images in the given part state. * diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 384f97e..22d3b6d 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -4581,27 +4581,30 @@ edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, return eina_stringshare_add(image); } -EAPI void +EAPI Eina_Bool edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image) { Edje_Part_Description_Image *img; int id; - GET_PD_OR_RETURN(); + if ((!obj) || (!part) || (!state) || (!image)) + return EINA_FALSE; - if (!image) return; + eina_error_set(0); + GET_PD_OR_RETURN(EINA_FALSE); if (rp->part->type != EDJE_PART_TYPE_IMAGE) - return; + return EINA_FALSE; id = _edje_image_id_find(eed, image); - //printf("SET IMAGE for %s [%s]\n", state, image); img = (Edje_Part_Description_Image *) pd; if (id > -1) img->image.id = id; + else return EINA_FALSE; edje_object_calc_force(obj); + return EINA_TRUE; } EAPI Eina_List * @@ -4727,26 +4730,31 @@ edje_edit_state_image_border_get(Evas_Object *obj, const char *part, const char if (b) *b = img->image.border.b; } -EAPI void +EAPI Eina_Bool edje_edit_state_image_border_set(Evas_Object *obj, const char *part, const char *state, double value, int l, int r, int t, int b) { Edje_Part_Description_Image *img; - GET_PD_OR_RETURN(); + if ((!obj) || (!part) || (!state)) + return EINA_FALSE; + if ((l < -1) || (r < -1) || (t < -1) || (b < -1)) + return EINA_FALSE; + + eina_error_set(0); + GET_PD_OR_RETURN(EINA_FALSE); if (rp->part->type != EDJE_PART_TYPE_IMAGE) - return; + return EINA_FALSE; img = (Edje_Part_Description_Image *) pd; - //printf("SET IMAGE_BORDER of state '%s'\n", state); - - if (l > -1) img->image.border.l = l; - if (r > -1) img->image.border.r = r; - if (t > -1) img->image.border.t = t; - if (b > -1) img->image.border.b = b; + img->image.border.l = l; + img->image.border.r = r; + img->image.border.t = t; + img->image.border.b = b; edje_object_calc_force(obj); + return EINA_TRUE; } EAPI unsigned char @@ -4761,29 +4769,35 @@ edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const img = (Edje_Part_Description_Image *) pd; - if (img->image.border.no_fill == 0) return 1; - else if (img->image.border.no_fill == 1) return 0; - else if (img->image.border.no_fill == 2) return 2; + if (img->image.border.no_fill == 2) return 2; + else return !img->image.border.no_fill; + return 0; } -EAPI void +EAPI Eina_Bool edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill) { Edje_Part_Description_Image *img; - GET_PD_OR_RETURN(); + if ((!obj) || (!part) || (!state)) + return EINA_FALSE; + if ((fill < 0) || (fill > 2)) + return EINA_FALSE; + + eina_error_set(0); + GET_PD_OR_RETURN(EINA_FALSE); if (rp->part->type != EDJE_PART_TYPE_IMAGE) - return; + return EINA_FALSE; img = (Edje_Part_Description_Image *) pd; - if (fill == 0) img->image.border.no_fill = 1; - else if (fill == 1) img->image.border.no_fill = 0; - else if (fill == 2) img->image.border.no_fill = 2; + if (fill == 2) img->image.border.no_fill = 2; + else img->image.border.no_fill = !fill; edje_object_calc_force(obj); + return EINA_TRUE; } /******************/ --