From 3973ecf2e80b0546bcd26cc7a56b6719f0263fee Mon Sep 17 00:00:00 2001 From: Andrii Kroitor Date: Fri, 1 Nov 2013 11:03:30 +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_part_drag_x_set edje_edit_part_drag_y_set edje_edit_part_drag_step_x_set edje_edit_part_drag_step_y_set edje_edit_part_drag_count_x_set edje_edit_part_drag_count_y_set Added functions for threshold: edje_edit_part_drag_threshold_set edje_edit_part_drag_threshold_get Fixed description of 'count' parameter of dragable.x/y Reviewers: cedric, seoz Reviewed By: cedric CC: reutskiy.v.v Differential Revision: https://phab.enlightenment.org/D304 Signed-off-by: Cedric Bail --- src/bin/edje/edje_cc_handlers.c | 6 ++-- src/lib/edje/Edje_Edit.h | 43 +++++++++++++++++++++---- src/lib/edje/edje_edit.c | 56 ++++++++++++++++----------------- 3 files changed, 69 insertions(+), 36 deletions(-) diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index 0c1e5cafc0..76cf7e19a0 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -4369,7 +4369,8 @@ st_collections_group_parts_part_access(void) enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second parameter takes any integer and will limit movement to values divisible by it, causing the part to jump from position to position. - The third parameter, (question from the author: What is count for?). + If step is set to 0 it is calculated as width of confine part divided by + count. @endproperty */ static void @@ -4394,7 +4395,8 @@ st_collections_group_parts_part_dragable_x(void) enabled, 1 will set the starting point at 0.0 and -1 at 1.0. The second parameter takes any integer and will limit movement to values divisibles by it, causing the part to jump from position to position. - The third parameter, (question from the author: What is count for?). + If step is set to 0 it is calculated as height of confine part divided by + count. @endproperty */ static void diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index ab7bda6ff7..10ad69fc80 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -1026,8 +1026,10 @@ EAPI int edje_edit_part_drag_x_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set if should be dragged horizontally. * @param drag 1 (or -1) if the part should be dragged horizontally, 0 otherwise. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag); +EAPI Eina_Bool edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag); /** Get vertical dragable state for part. * @@ -1043,8 +1045,10 @@ EAPI int edje_edit_part_drag_y_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set if should be dragged vertically. * @param drag 1 (or -1) of the part shpuld be dragged vertically, 0 otherwise. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag); +EAPI Eina_Bool edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag); /** Get horizontal dragable step for part. * @@ -1060,8 +1064,10 @@ EAPI int edje_edit_part_drag_step_x_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set the drag horizontal step value. * @param step The step the will be dragged. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_step_x_set(Evas_Object *obj, const char *part, int step); +EAPI Eina_Bool edje_edit_part_drag_step_x_set(Evas_Object *obj, const char *part, int step); /** Get vertical dragable step for part. * @@ -1077,8 +1083,10 @@ EAPI int edje_edit_part_drag_step_y_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set the drag vertical step value. * @param step The step the will be dragged. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_step_y_set(Evas_Object *obj, const char *part, int step); +EAPI Eina_Bool edje_edit_part_drag_step_y_set(Evas_Object *obj, const char *part, int step); /** Get horizontal dragable count for part. * @@ -1092,8 +1100,10 @@ EAPI int edje_edit_part_drag_count_x_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set the drag horizontal count value. * @param count The count value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_count_x_set(Evas_Object *obj, const char *part, int count); +EAPI Eina_Bool edje_edit_part_drag_count_x_set(Evas_Object *obj, const char *part, int count); /** Get vertical dragable count for part. * @@ -1107,8 +1117,10 @@ EAPI int edje_edit_part_drag_count_y_get(Evas_Object *obj, const char *part); * @param obj Object being edited. * @param part Part to set the drag vertical count value. * @param count The count value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_part_drag_count_y_set(Evas_Object *obj, const char *part, int count); +EAPI Eina_Bool edje_edit_part_drag_count_y_set(Evas_Object *obj, const char *part, int count); /** Get the name of the part that is used as 'confine' for the given draggies. * @@ -1148,6 +1160,25 @@ EAPI const char * edje_edit_part_drag_event_get(Evas_Object *obj, const char *pa */ EAPI Eina_Bool edje_edit_part_drag_event_set(Evas_Object *obj, const char *part, const char *event); +/** Get the name of the part that is used as 'threshold' for the given draggies. + * + * @param obj Object being edited. + * @param part Part to get the name that is used as 'threshold' for the given draggies. + * + * @return The name of the threshold part or NULL (if unset). + */ +EAPI const char * edje_edit_part_drag_threshold_get(Evas_Object *obj, const char *part); + +/** Set the name of the part that is used as 'threshold' for the given draggies. + * + * @param obj Object being edited. + * @param part Part to set the name that is used as 'threshold' for the given draggies. + * @param confine The name of the threshold part or NULL to unset confine. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_drag_threshold_set(Evas_Object *obj, const char *part, const char *threshold); + //@} /******************************************************************************/ diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 2699604d1b..46ad74c97d 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -2506,76 +2506,75 @@ EAPI int edje_edit_part_drag_x_get(Evas_Object *obj, const char *part) { GET_RP_OR_RETURN(0); - //printf("Get dragX for part: %s\n", part); return rp->part->dragable.x; } -EAPI void +EAPI Eina_Bool edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag) { - GET_RP_OR_RETURN(); - //printf("Set dragX for part: %s\n", part); + GET_RP_OR_RETURN(EINA_FALSE); rp->part->dragable.x = drag; if (!drag && !rp->part->dragable.y) { - free(rp->drag); - rp->drag = NULL; - return; + free(rp->drag); + rp->drag = NULL; + return EINA_TRUE; } - if (rp->drag) return; + if (rp->drag) return EINA_TRUE; rp->drag = _alloc(sizeof (Edje_Real_Part_Drag)); - if (!rp->drag) return; + if (!rp->drag) return EINA_FALSE; rp->drag->step.x = rp->part->dragable.step_x; rp->drag->step.y = rp->part->dragable.step_y; + return EINA_TRUE; } EAPI int edje_edit_part_drag_y_get(Evas_Object *obj, const char *part) { GET_RP_OR_RETURN(0); - //printf("Get dragY for part: %s\n", part); return rp->part->dragable.y; } -EAPI void +EAPI Eina_Bool edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag) { - GET_RP_OR_RETURN(); - //printf("Set dragY for part: %s\n", part); + GET_RP_OR_RETURN(EINA_FALSE); rp->part->dragable.y = drag; if (!drag && !rp->part->dragable.x) { - free(rp->drag); - rp->drag = NULL; - return; + free(rp->drag); + rp->drag = NULL; + return EINA_TRUE; } - if (rp->drag) return; + if (rp->drag) return EINA_TRUE; rp->drag = _alloc(sizeof (Edje_Real_Part_Drag)); - if (!rp->drag) return; + if (!rp->drag) return EINA_FALSE; rp->drag->step.x = rp->part->dragable.step_x; rp->drag->step.y = rp->part->dragable.step_y; + return EINA_TRUE; } -#define FUNC_PART_DRAG_INT(Class, Value) \ - EAPI int \ +#define FUNC_PART_DRAG_INT(Class, Value) \ + EAPI int \ edje_edit_part_drag_##Class##_##Value##_get(Evas_Object *obj, const char *part) \ - { \ - GET_RP_OR_RETURN(0); \ - return rp->part->dragable.Class##_##Value; \ - } \ - EAPI void \ + { \ + GET_RP_OR_RETURN(0); \ + return rp->part->dragable.Class##_##Value; \ + } \ + EAPI Eina_Bool \ edje_edit_part_drag_##Class##_##Value##_set(Evas_Object *obj, const char *part, int v) \ - { \ - GET_RP_OR_RETURN(); \ - rp->part->dragable.Class##_##Value = v; \ + { \ + GET_RP_OR_RETURN(EINA_FALSE); \ + rp->part->dragable.Class##_##Value = v; \ + return EINA_TRUE; \ } FUNC_PART_DRAG_INT(step, x); @@ -2620,6 +2619,7 @@ FUNC_PART_DRAG_INT(count, y); FUNC_PART_DRAG_ID(confine); FUNC_PART_DRAG_ID(event); +FUNC_PART_DRAG_ID(threshold); /*********************/ /* PART STATES API */