summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_embryo.c
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-14 02:58:53 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-21 23:03:33 -0200
commit9bc9fde90ec75e58162e94bca4e71b62920afc73 (patch)
treecb33263d179df5ea61894c61ff8785635e1a2326 /src/lib/edje/edje_embryo.c
parentd57d17723e255883dda22b96b61ea5e7cd5f23f8 (diff)
edje: add function on embryo to control focus
Add set_focus(part_id) and unset_focus(). Both functions accept an optional argument "seat_name". If not provided default seat will be assumed.
Diffstat (limited to 'src/lib/edje/edje_embryo.c')
-rw-r--r--src/lib/edje/edje_embryo.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index bb46310ca8..f4d49d079e 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -196,6 +196,9 @@
196 * set_clip(part_id, clip_part_id) 196 * set_clip(part_id, clip_part_id)
197 * get_clip(part_id) 197 * get_clip(part_id)
198 * 198 *
199 * set_focus(part_id, seat_name[])
200 * unset_focus(seat_name[])
201 *
199 * part_swallow(part_id, group_name) 202 * part_swallow(part_id, group_name)
200 * 203 *
201 * external_param_get_int(id, param_name[]) 204 * external_param_get_int(id, param_name[])
@@ -3771,6 +3774,59 @@ _edje_embryo_fn_part_swallow(Embryo_Program *ep, Embryo_Cell *params)
3771 return 0; 3774 return 0;
3772} 3775}
3773 3776
3777/* set_focus(part_id, seat_name[]) */
3778static Embryo_Cell
3779_edje_embryo_fn_set_focus(Embryo_Program *ep, Embryo_Cell *params)
3780{
3781 Edje *ed;
3782 int part_id;
3783 Edje_Real_Part *rp;
3784 char *seat_name = NULL;
3785
3786 if (!(HASNPARAMS(1) || HASNPARAMS(2))) return -1;
3787 ed = embryo_program_data_get(ep);
3788
3789 part_id = params[1];
3790 if (part_id < 0) return 0;
3791 rp = ed->table_parts[part_id % ed->table_parts_size];
3792 if (!rp) return 0;
3793
3794 /* if no seat name is passed, that's fine. it means
3795 it should be applied to default seat */
3796 if (HASNPARAMS(2))
3797 {
3798 GETSTR(seat_name, params[2]);
3799 if (!seat_name) return 0;
3800 }
3801
3802 _edje_part_focus_set(ed, seat_name, rp);
3803
3804 return 0;
3805}
3806
3807/* unset_focus(seat_name[]) */
3808static Embryo_Cell
3809_edje_embryo_fn_unset_focus(Embryo_Program *ep, Embryo_Cell *params)
3810{
3811 Edje *ed;
3812 char *seat_name = NULL;
3813
3814 if (!(HASNPARAMS(0) || HASNPARAMS(1))) return -1;
3815 ed = embryo_program_data_get(ep);
3816
3817 /* seat name is optional. no seat means
3818 it should be applied to default seat */
3819 if (HASNPARAMS(1))
3820 {
3821 GETSTR(seat_name, params[1]);
3822 if (!seat_name) return 0;
3823 }
3824
3825 _edje_part_focus_set(ed, seat_name, NULL);
3826
3827 return 0;
3828}
3829
3774/* external_param_get_int(id, param_name[]) */ 3830/* external_param_get_int(id, param_name[]) */
3775static Embryo_Cell 3831static Embryo_Cell
3776_edje_embryo_fn_external_param_get_int(Embryo_Program *ep, Embryo_Cell *params) 3832_edje_embryo_fn_external_param_get_int(Embryo_Program *ep, Embryo_Cell *params)
@@ -4510,6 +4566,9 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
4510 embryo_program_native_call_add(ep, "set_mask_flags", _edje_embryo_fn_set_mask_flags); 4566 embryo_program_native_call_add(ep, "set_mask_flags", _edje_embryo_fn_set_mask_flags);
4511 embryo_program_native_call_add(ep, "get_mask_flags", _edje_embryo_fn_get_mask_flags); 4567 embryo_program_native_call_add(ep, "get_mask_flags", _edje_embryo_fn_get_mask_flags);
4512 4568
4569 embryo_program_native_call_add(ep, "set_focus", _edje_embryo_fn_set_focus);
4570 embryo_program_native_call_add(ep, "unset_focus", _edje_embryo_fn_unset_focus);
4571
4513 embryo_program_native_call_add(ep, "part_swallow", _edje_embryo_fn_part_swallow); 4572 embryo_program_native_call_add(ep, "part_swallow", _edje_embryo_fn_part_swallow);
4514 4573
4515 embryo_program_native_call_add(ep, "external_param_get_int", _edje_embryo_fn_external_param_get_int); 4574 embryo_program_native_call_add(ep, "external_param_get_int", _edje_embryo_fn_external_param_get_int);