diff options
author | Bruno Dilly <bdilly@profusion.mobi> | 2016-12-14 02:58:53 -0200 |
---|---|---|
committer | Bruno Dilly <bdilly@profusion.mobi> | 2016-12-21 23:03:33 -0200 |
commit | 9bc9fde90ec75e58162e94bca4e71b62920afc73 (patch) | |
tree | cb33263d179df5ea61894c61ff8785635e1a2326 /src/lib/edje | |
parent | d57d17723e255883dda22b96b61ea5e7cd5f23f8 (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')
-rw-r--r-- | src/lib/edje/edje_embryo.c | 59 | ||||
-rw-r--r-- | src/lib/edje/edje_private.h | 1 | ||||
-rw-r--r-- | src/lib/edje/edje_program.c | 2 |
3 files changed, 61 insertions, 1 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[]) */ | ||
3778 | static 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[]) */ | ||
3808 | static 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[]) */ |
3775 | static Embryo_Cell | 3831 | static 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); |
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index f04be21a86..1a2d7dbdea 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h | |||
@@ -2491,6 +2491,7 @@ void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp); | |||
2491 | 2491 | ||
2492 | void _edje_focused_part_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp); | 2492 | void _edje_focused_part_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp); |
2493 | Edje_Real_Part *_edje_focused_part_get(Edje *ed, const char *seat_name); | 2493 | Edje_Real_Part *_edje_focused_part_get(Edje *ed, const char *seat_name); |
2494 | void _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp); | ||
2494 | 2495 | ||
2495 | Eina_Stringshare *_edje_seat_name_get(Edje *ed, Efl_Input_Device *device); | 2496 | Eina_Stringshare *_edje_seat_name_get(Edje *ed, Efl_Input_Device *device); |
2496 | Efl_Input_Device *_edje_seat_get(Edje *ed, Eina_Stringshare *name); | 2497 | Efl_Input_Device *_edje_seat_get(Edje *ed, Eina_Stringshare *name); |
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c index df74b334ec..ef4cf40d05 100644 --- a/src/lib/edje/edje_program.c +++ b/src/lib/edje/edje_program.c | |||
@@ -641,7 +641,7 @@ _edje_seat_name_emit(Edje *ed, const char *name, const char *sig, const char *sr | |||
641 | _edje_emit_full(ed, buf, src, NULL, NULL); | 641 | _edje_emit_full(ed, buf, src, NULL, NULL); |
642 | } | 642 | } |
643 | 643 | ||
644 | static void | 644 | void |
645 | _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp) | 645 | _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp) |
646 | { | 646 | { |
647 | Edje_Real_Part *focused_part; | 647 | Edje_Real_Part *focused_part; |