From dd5b79eff6172255c34af9894f4bf622489cf36f Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Mon, 11 Oct 2010 21:26:43 +0000 Subject: [PATCH] edje: Add get_part_id() to exported Embryo functions. This allows one to calculate a part number in runtime and and use it with other functions, like get_state() and set_state(). SVN revision: 53277 --- legacy/edje/data/include/edje.inc | 1 + legacy/edje/src/lib/edje_embryo.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/legacy/edje/data/include/edje.inc b/legacy/edje/data/include/edje.inc index 74ceda5ea8..45394cb258 100644 --- a/legacy/edje/data/include/edje.inc +++ b/legacy/edje/data/include/edje.inc @@ -83,6 +83,7 @@ native cancel_anim(id); * run_program(PROGRAM:"program_name"); */ native emit (sig[], src[]); +native get_part_id (part[]); native set_state (part_id, state[], Float:state_val); native get_state (part_id, dst[], maxlen, &Float:val); native set_tween_state (part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val); diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index ceeea66821..b1687dbd14 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -798,6 +798,28 @@ _edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params) return 0; } +/* get_part_id(part[]) */ +static Embryo_Cell +_edje_embryo_fn_get_part_id(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Edje_Part_Collection *col; + Edje_Part **part; + char *p; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + GETSTR(p, params[1]); + col = ed->collection; + if (!col) return -1; + for (part = col->parts; *part; part++) + { + if (!(*part)->name) continue; + if (!strcmp((*part)->name, p)) return (*part)->id; + } + return -1; +} + /* set_state(part_id, state[], Float:state_val) */ static Embryo_Cell _edje_embryo_fn_set_state(Embryo_Program *ep, Embryo_Cell *params) @@ -2922,6 +2944,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc) embryo_program_native_call_add(ep, "cancel_anim", _edje_embryo_fn_cancel_anim); embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit); + embryo_program_native_call_add(ep, "get_part_id", _edje_embryo_fn_get_part_id); embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state); embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state); embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);