edje: make edje edit rel setters return Eina_Bool.

Make the following function return an Eina_Bool so the caller can detect
errors if it want :
edje_edit_state_rel1_relative_x_set
edje_edit_state_rel1_relative_y_set
edje_edit_state_rel2_relative_x_set
edje_edit_state_rel2_relative_y_set
edje_edit_state_rel1_offset_x_set
edje_edit_state_rel1_offset_y_set
edje_edit_state_rel2_offset_x_set
edje_edit_state_rel2_offset_y_set
edje_edit_state_rel1_to_x_set
edje_edit_state_rel1_to_y_set
edje_edit_state_rel2_to_x_set
edje_edit_state_rel2_to_y_set

Reviewers: cedric, seoz

CC: reutskiy.v.v

Differential Revision: https://phab.enlightenment.org/D296

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
This commit is contained in:
Andrii Kroitor 2013-10-30 21:54:23 +09:00 committed by Cedric Bail
parent 503cbbe80b
commit 5d0e0c3f16
2 changed files with 82 additions and 67 deletions

View File

@ -1260,8 +1260,10 @@ EAPI double edje_edit_state_rel2_relative_y_get(Evas_Object *obj, const char *pa
* @param state The name of the state to set 'rel1 relative X' (not including the state value). * @param state The name of the state to set 'rel1 relative X' (not including the state value).
* @param value The state value. * @param value The state value.
* @param x The new 'rel1 relative X' value to set'. * @param x The new 'rel1 relative X' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); EAPI Eina_Bool edje_edit_state_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
/** Set the 'rel1 relative Y' value of state. /** Set the 'rel1 relative Y' value of state.
* *
@ -1270,8 +1272,10 @@ EAPI void edje_edit_state_rel1_relative_x_set(Evas_Object *obj, const char *part
* @param state The name of the state to set 'rel1 relative Y' (not including the state value). * @param state The name of the state to set 'rel1 relative Y' (not including the state value).
* @param value The state value. * @param value The state value.
* @param y The new 'rel1 relative Y' value to set'. * @param y The new 'rel1 relative Y' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); EAPI Eina_Bool edje_edit_state_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
/** Set the 'rel2 relative X' value of state. /** Set the 'rel2 relative X' value of state.
* *
@ -1280,8 +1284,10 @@ EAPI void edje_edit_state_rel1_relative_y_set(Evas_Object *obj, const char *part
* @param state The name of the state to set 'rel2 relative X' (not including the state value). * @param state The name of the state to set 'rel2 relative X' (not including the state value).
* @param value The state value. * @param value The state value.
* @param x The new 'rel2 relative X' value to set'. * @param x The new 'rel2 relative X' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); EAPI Eina_Bool edje_edit_state_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
/** Set the 'rel2 relative Y' value of state. /** Set the 'rel2 relative Y' value of state.
* *
@ -1290,8 +1296,10 @@ EAPI void edje_edit_state_rel2_relative_x_set(Evas_Object *obj, const char *part
* @param state The name of the state to set 'rel2 relative Y' (not including the state value). * @param state The name of the state to set 'rel2 relative Y' (not including the state value).
* @param value The state value. * @param value The state value.
* @param y The new 'rel2 relative Y' value to set'. * @param y The new 'rel2 relative Y' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); EAPI Eina_Bool edje_edit_state_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
/** Get the 'rel1 offset X' value of state. /** Get the 'rel1 offset X' value of state.
* *
@ -1344,8 +1352,10 @@ EAPI int edje_edit_state_rel2_offset_y_get(Evas_Object *obj, const char *part, c
* @param state The name of the state to set 'rel1 offset X' (not including the state value). * @param state The name of the state to set 'rel1 offset X' (not including the state value).
* @param value The state value. * @param value The state value.
* @param x The new 'rel1 offset X' value to set'. * @param x The new 'rel1 offset X' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); EAPI Eina_Bool edje_edit_state_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
/** Set the 'rel1 offset Y' value of state. /** Set the 'rel1 offset Y' value of state.
* *
@ -1354,8 +1364,10 @@ EAPI void edje_edit_state_rel1_offset_x_set(Evas_Object *obj, const char *part,
* @param state The name of the state to set 'rel1 offset Y' (not including the state value). * @param state The name of the state to set 'rel1 offset Y' (not including the state value).
* @param value The state value. * @param value The state value.
* @param y The new 'rel1 offset Y' value to set'. * @param y The new 'rel1 offset Y' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); EAPI Eina_Bool edje_edit_state_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
/** Set the 'rel2 offset X' value of state. /** Set the 'rel2 offset X' value of state.
* *
@ -1364,8 +1376,10 @@ EAPI void edje_edit_state_rel1_offset_y_set(Evas_Object *obj, const char *part,
* @param state The name of the state to set 'rel2 offset X' (not including the state value). * @param state The name of the state to set 'rel2 offset X' (not including the state value).
* @param value The state value. * @param value The state value.
* @param x The new 'rel2 offset X' value to set'. * @param x The new 'rel2 offset X' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); EAPI Eina_Bool edje_edit_state_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
/** Set the 'rel2 offset Y' value of state. /** Set the 'rel2 offset Y' value of state.
* *
@ -1374,8 +1388,10 @@ EAPI void edje_edit_state_rel2_offset_x_set(Evas_Object *obj, const char *part,
* @param state The name of the state to set 'rel2 offset Y' (not including the state value). * @param state The name of the state to set 'rel2 offset Y' (not including the state value).
* @param value The state value. * @param value The state value.
* @param y The new 'rel2 offset Y' value to set'. * @param y The new 'rel2 offset Y' value to set'.
*
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); EAPI Eina_Bool edje_edit_state_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
/** Get the part name rel1x is relative to. /** Get the part name rel1x is relative to.
* *
@ -1429,9 +1445,9 @@ EAPI const char * edje_edit_state_rel2_to_y_get(Evas_Object *obj, const char *pa
* @param value The state value. * @param value The state value.
* @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
* *
* @return The part name rel1x is relative to or NULL if the part is relative to the whole interface. * @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); EAPI Eina_Bool edje_edit_state_rel1_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
/** Set the part rel1y is relative to. /** Set the part rel1y is relative to.
* *
@ -1441,9 +1457,9 @@ EAPI void edje_edit_state_rel1_to_x_set(Evas_Object *obj, const char *part, cons
* @param value The state value. * @param value The state value.
* @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
* *
* @return The part name rel1y is relative to or NULL if the part is relative to the whole interface. * @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel1_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); EAPI Eina_Bool edje_edit_state_rel1_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
/** Set the part rel2x is relative to. /** Set the part rel2x is relative to.
* *
@ -1453,9 +1469,9 @@ EAPI void edje_edit_state_rel1_to_y_set(Evas_Object *obj, const char *part, cons
* @param value The state value. * @param value The state value.
* @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
* *
* @return The part name rel2x is relative to or NULL if the part is relative to the whole interface. * @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); EAPI Eina_Bool edje_edit_state_rel2_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
/** Set the part rel2y is relative to. /** Set the part rel2y is relative to.
* *
@ -1465,9 +1481,9 @@ EAPI void edje_edit_state_rel2_to_x_set(Evas_Object *obj, const char *part, cons
* @param value The state value. * @param value The state value.
* @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
* *
* @return The part name rel2y is relative to or NULL if the part is relative to the whole interface. * @return EINA_TRUE if successful, EINA_FALSE otherwise.
*/ */
EAPI void edje_edit_state_rel2_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); EAPI Eina_Bool edje_edit_state_rel2_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
/** Get the color of a part state. /** Get the color of a part state.
* *

View File

@ -3176,19 +3176,20 @@ edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, doubl
return EINA_TRUE; return EINA_TRUE;
} }
#define FUNC_STATE_RELATIVE_DOUBLE(Sub, Value) \ #define FUNC_STATE_RELATIVE_DOUBLE(Sub, Value) \
EAPI double \ EAPI double \
edje_edit_state_##Sub##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ edje_edit_state_##Sub##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
{ \ { \
GET_PD_OR_RETURN(0); \ GET_PD_OR_RETURN(0); \
return TO_DOUBLE(pd->Sub.relative_##Value); \ return TO_DOUBLE(pd->Sub.relative_##Value); \
} \ } \
EAPI void \ EAPI Eina_Bool \
edje_edit_state_##Sub##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ edje_edit_state_##Sub##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
{ \ { \
GET_PD_OR_RETURN(); \ GET_PD_OR_RETURN(EINA_FALSE); \
pd->Sub.relative_##Value = FROM_DOUBLE(v); \ pd->Sub.relative_##Value = FROM_DOUBLE(v); \
edje_object_calc_force(obj); \ edje_object_calc_force(obj); \
return EINA_TRUE; \
} }
FUNC_STATE_RELATIVE_DOUBLE(rel1, x); FUNC_STATE_RELATIVE_DOUBLE(rel1, x);
@ -3197,18 +3198,19 @@ FUNC_STATE_RELATIVE_DOUBLE(rel2, x);
FUNC_STATE_RELATIVE_DOUBLE(rel2, y); FUNC_STATE_RELATIVE_DOUBLE(rel2, y);
#define FUNC_STATE_OFFSET_INT(Sub, Value) \ #define FUNC_STATE_OFFSET_INT(Sub, Value) \
EAPI int \ EAPI int \
edje_edit_state_##Sub##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ edje_edit_state_##Sub##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
{ \ { \
GET_PD_OR_RETURN(0); \ GET_PD_OR_RETURN(0); \
return pd->Sub.offset_##Value; \ return pd->Sub.offset_##Value; \
} \ } \
EAPI void \ EAPI Eina_Bool \
edje_edit_state_##Sub##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ edje_edit_state_##Sub##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
{ \ { \
GET_PD_OR_RETURN(); \ GET_PD_OR_RETURN(EINA_FALSE); \
pd->Sub.offset_##Value = TO_INT(FROM_DOUBLE(v)); \ pd->Sub.offset_##Value = TO_INT(FROM_DOUBLE(v)); \
edje_object_calc_force(obj); \ edje_object_calc_force(obj); \
return EINA_TRUE; \
} }
FUNC_STATE_OFFSET_INT(rel1, x); FUNC_STATE_OFFSET_INT(rel1, x);
@ -3216,37 +3218,34 @@ FUNC_STATE_OFFSET_INT(rel1, y);
FUNC_STATE_OFFSET_INT(rel2, x); FUNC_STATE_OFFSET_INT(rel2, x);
FUNC_STATE_OFFSET_INT(rel2, y); FUNC_STATE_OFFSET_INT(rel2, y);
#define FUNC_STATE_REL(Sub, Value) \ #define FUNC_STATE_REL(Sub, Value) \
EAPI const char * \ EAPI const char * \
edje_edit_state_##Sub##_to_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ edje_edit_state_##Sub##_to_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
{ \ { \
Edje_Real_Part *rel; \ Edje_Real_Part *rel; \
\ GET_PD_OR_RETURN(NULL); \
GET_PD_OR_RETURN(NULL); \ if (pd->Sub.id_##Value == -1) return NULL; \
\
if (pd->Sub.id_##Value == -1) return NULL; \
\
rel = ed->table_parts[pd->Sub.id_##Value % ed->table_parts_size]; \ rel = ed->table_parts[pd->Sub.id_##Value % ed->table_parts_size]; \
\ if (rel->part->name) return eina_stringshare_add(rel->part->name); \
if (rel->part->name) return eina_stringshare_add(rel->part->name); \ return NULL; \
return NULL; \ } \
} \ EAPI Eina_Bool \
EAPI void \ edje_edit_state_##Sub##_to_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, const char *to) \
edje_edit_state_##Sub##_to_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, const char *to) \ { \
{ \ Edje_Real_Part *relp; \
Edje_Real_Part *relp; \ GET_PD_OR_RETURN(EINA_FALSE); \
\ if ((to) && (strcmp(to, ""))) \
GET_PD_OR_RETURN(); \ { \
\ relp = _edje_real_part_get(ed, to); \
if (to) \ if (!relp) return EINA_FALSE; \
{ \ pd->Sub.id_##Value = relp->part->id; \
relp = _edje_real_part_get(ed, to); \ return EINA_TRUE; \
if (!relp) return; \ } \
pd->Sub.id_##Value = relp->part->id; \ else \
} \ { \
else \ pd->Sub.id_##Value = -1; \
pd->Sub.id_##Value = -1; \ return EINA_FALSE; \
\ } \
} }
//note after this call edje_edit_part_selected_state_set() to update !! need to fix this //note after this call edje_edit_part_selected_state_set() to update !! need to fix this
//_edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, "state", 0.1); //Why segfault?? //_edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, "state", 0.1); //Why segfault??