From dcbb62739ceafda4d2c016b119c00fb1ded30b28 Mon Sep 17 00:00:00 2001 From: Vitalii Vorobiov Date: Fri, 19 Feb 2016 14:06:31 +0000 Subject: [PATCH] Edje_Edit: target can be insert into different place in program's target list Here is API for that: > edje_edit_program_target_insert_at --- src/lib/edje/Edje_Edit.h | 19 ++++++++++ src/lib/edje/edje_edit.c | 94 ++++++++++++++++++++++++++---------------------- 2 files changed, 71 insertions(+), 42 deletions(-) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 08b2132..96d6c48 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -5981,6 +5981,25 @@ EAPI Eina_List * edje_edit_program_targets_get(Evas_Object *obj, const char *pro */ EAPI Eina_Bool edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target); +/** Add a new target program to certain place in list of 'targets' in the given program. + * + * If program action is @c EDJE_ACTION_TYPE_ACTION_STOP, then 'target' + * must be an existing program name. If it's @c + * EDJE_ACTION_TYPE_STATE_SET, then 'target' must be an existing part + * name. + * + * @param obj Object being edited. + * @param prog The name of the program to add a new target. + * @param target The name of the new target itself. + * @param place Specific play for target to be inserted into. + * + * @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise. + * + * @since 1.18 + */ +EAPI Eina_Bool +edje_edit_program_target_insert_at(Evas_Object *obj, const char *prog, const char *target, int place); + /** Deletes a target from the list of 'targets' in the given program. * * If program action is EDJE_ACTION_TYPE_ACTION_STOP then 'target' must be an existing program name. diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 7f30907..c8f50f4 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -9789,18 +9789,14 @@ edje_edit_program_targets_clear(Evas_Object *obj, const char *prog) return EINA_TRUE; } -EAPI Eina_Bool -edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target) +static int +_program_target_id_get(Evas_Object *obj, Edje *ed, Edje_Action_Type action, const char *target) { - int id; - Edje_Program_Target *t; + int id = -1; Edje_Program *tar; Edje_Real_Part *rp; - GET_ED_OR_RETURN(EINA_FALSE); - GET_EPR_OR_RETURN(EINA_FALSE); - - switch (epr->action) + switch (action) { case EDJE_ACTION_TYPE_STATE_SET: case EDJE_ACTION_TYPE_SIGNAL_EMIT: @@ -9816,21 +9812,36 @@ edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *tar #endif /* the target is a part */ rp = _edje_real_part_get(ed, target); - if (!rp) return EINA_FALSE; + if (!rp) return -1; id = rp->part->id; break; case EDJE_ACTION_TYPE_ACTION_STOP: /* the target is a program */ tar = _edje_program_get_byname(obj, target); - if (!tar) return EINA_FALSE; + if (!tar) return -1; id = tar->id; break; default: - return EINA_FALSE; + return -1; } + return id; +} + +EAPI Eina_Bool +edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target) +{ + int id; + Edje_Program_Target *t; + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + id = _program_target_id_get(obj, ed, epr->action, target); + if (id == -1) return EINA_FALSE; + t = _alloc(sizeof(Edje_Program_Target)); if (!t) return EINA_FALSE; @@ -9841,47 +9852,46 @@ edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *tar } EAPI Eina_Bool -edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target) +edje_edit_program_target_insert_at(Evas_Object *obj, const char *prog, const char *target, int place) { int id; - Eina_List *l; - Edje_Real_Part *rp; - Edje_Program *tar; Edje_Program_Target *t; + Eina_List *l; GET_ED_OR_RETURN(EINA_FALSE); GET_EPR_OR_RETURN(EINA_FALSE); - switch (epr->action) - { - case EDJE_ACTION_TYPE_STATE_SET: - case EDJE_ACTION_TYPE_SIGNAL_EMIT: - case EDJE_ACTION_TYPE_DRAG_VAL_SET: - case EDJE_ACTION_TYPE_DRAG_VAL_STEP: - case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: - case EDJE_ACTION_TYPE_FOCUS_SET: - case EDJE_ACTION_TYPE_FOCUS_OBJECT: -#ifdef HAVE_EPHYSICS - case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR: - case EDJE_ACTION_TYPE_PHYSICS_STOP: - case EDJE_ACTION_TYPE_PHYSICS_ROT_SET: -#endif - /* the target is a part */ - rp = _edje_real_part_get(ed, target); - if (!rp) return EINA_FALSE; - id = rp->part->id; - break; + id = _program_target_id_get(obj, ed, epr->action, target); + if (id == -1) return EINA_FALSE; - case EDJE_ACTION_TYPE_ACTION_STOP: - /* the target is a program */ - tar = _edje_program_get_byname(obj, target); - if (!tar) return EINA_FALSE; - id = tar->id; - break; + t = _alloc(sizeof(Edje_Program_Target)); + if (!t) return EINA_FALSE; - default: - return EINA_FALSE; + t->id = id; + if ((unsigned)place >= eina_list_count(epr->targets)) + epr->targets = eina_list_append(epr->targets, t); + else + { + l = eina_list_nth_list(epr->targets, place); + epr->targets = eina_list_prepend_relative_list(epr->targets, t, l); } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target) +{ + int id; + Eina_List *l; + Edje_Program_Target *t; + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + id = _program_target_id_get(obj, ed, epr->action, target); + if (id == -1) return EINA_FALSE; + EINA_LIST_FOREACH(epr->targets, l, t) if (t->id == id) break; -- 2.7.4