From 3038d41ba1070b3b5c4e682429fbfad4ea4fbea9 Mon Sep 17 00:00:00 2001 From: Vorobiov Vitalii Date: Thu, 31 Oct 2013 11:05:42 +0900 Subject: [PATCH] edje: make functions return Eina_Bool and fix documentation. Make the following functions return Eina_Bool so the caller can detect errors: edje_edit_state_font_set edje_edit_part_effect_set Also deleted duplicate of the "edje_edit_state_font_set" function in Edje_Edit.h Moved some defines (EDJE_TEXT_EFFECT_MASK_BASIC, EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION etc), so doxygen generation was fixed. Also added link (see also) in "edje_edit_part_effect_set" to the Edje_Text_Effect enum. Reviewers: cedric, seoz CC: reutskiy.v.v Differential Revision: https://phab.enlightenment.org/D302 Signed-off-by: Cedric Bail --- src/lib/edje/Edje_Common.h | 12 +++++++----- src/lib/edje/Edje_Edit.h | 22 +++++++++------------- src/lib/edje/edje_edit.c | 19 +++++++++++++------ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h index 8ae1e57..8e72b75 100644 --- a/src/lib/edje/Edje_Common.h +++ b/src/lib/edje/Edje_Common.h @@ -1211,11 +1211,16 @@ typedef enum _Edje_Part_Type * @{ */ -typedef enum _Edje_Text_Effect -{ #define EDJE_TEXT_EFFECT_MASK_BASIC 0xf #define EDJE_TEXT_EFFECT_BASIC_SET(x, s) \ do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_BASIC) | (s); } while (0) + +#define EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION (0x7 << 4) +#define EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(x, s) \ + do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) | (s); } while (0) + +typedef enum _Edje_Text_Effect +{ EDJE_TEXT_EFFECT_NONE = 0, EDJE_TEXT_EFFECT_PLAIN = 1, EDJE_TEXT_EFFECT_OUTLINE = 2, @@ -1230,9 +1235,6 @@ typedef enum _Edje_Text_Effect EDJE_TEXT_EFFECT_LAST = 11, -#define EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION (0x7 << 4) -#define EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(x, s) \ - do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) | (s); } while (0) EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT = (0x0 << 4), EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM = (0x1 << 4), EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT = (0x2 << 4), diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index efd7055..77dfff9 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -908,12 +908,17 @@ EAPI Eina_Bool edje_edit_part_source_set(Evas_Object *obj, const char *part, con EAPI Edje_Text_Effect edje_edit_part_effect_get(Evas_Object *obj, const char *part); /** Set the effect for a given part. + * Effects and shadow directions can be combined. + * + * For effect and shadow direction list please look at Edje Part Text ref page. * * @param obj Object being edited. * @param part Part to set the effect to. Only makes sense on type TEXT. * @param effect Effect to set for the part. + * + * @see Edje_Part_Text */ -EAPI void edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect); +EAPI Eina_Bool edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect); /** Get the current selected state in part. * @@ -2254,8 +2259,10 @@ EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, c * @param state State in which the font is set. * @param value Value of the state. * @param font The font name to use. + * + * @return EINA_TRUE if successful, EINA_FALSE - otherwise. */ -EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font); +EAPI Eina_Bool edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font); /** Get the text size of a part state * @@ -2561,17 +2568,6 @@ EAPI const char *edje_edit_font_path_get(Evas_Object *obj, const char *alias); */ EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value); -/** Set font name for a given part state. - * - * @param obj Object being edited. - * @param part Part that contain state. - * @param state The name of the state to set the name of the font that will be used (not including the state value). - * @param value The state value. - * @param font The name of the font to use in the given part state. - */ -EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font); - - //@} /******************************************************************************/ /************************** IMAGES API ************************************/ diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 6cc37b2..34dfb45 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -4262,16 +4262,18 @@ edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, return eina_stringshare_add(edje_string_get(&txt->text.font)); } -EAPI void +EAPI Eina_Bool edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font) { Edje_Part_Description_Text *txt; - GET_PD_OR_RETURN(); + if ((!obj) || (!part) || (!state)) + return EINA_FALSE; + GET_PD_OR_RETURN(EINA_FALSE); if ((rp->part->type != EDJE_PART_TYPE_TEXT) && (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) - return; + return EINA_FALSE; txt = (Edje_Part_Description_Text*) pd; @@ -4280,6 +4282,7 @@ edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, txt->text.font.id = 0; edje_object_calc_force(obj); + return EINA_TRUE; } EAPI Edje_Text_Effect @@ -4291,15 +4294,19 @@ edje_edit_part_effect_get(Evas_Object *obj, const char *part) return rp->part->effect; } -EAPI void +EAPI Eina_Bool edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect) { - GET_RP_OR_RETURN(); + if ((!obj) || (!part)) return EINA_FALSE; + GET_RP_OR_RETURN(EINA_FALSE); - //printf("SET EFFECT of part: %s [%d]\n", part, effect); + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return EINA_FALSE; rp->part->effect = effect; edje_object_calc_force(obj); + return EINA_TRUE; } /****************/ -- 2.7.4