bdilly pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9bc9fde90ec75e58162e94bca4e71b62920afc73

commit 9bc9fde90ec75e58162e94bca4e71b62920afc73
Author: Bruno Dilly <bdi...@profusion.mobi>
Date:   Wed Dec 14 02:58:53 2016 -0200

    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.
---
 data/edje/include/edje.inc  |  6 +++++
 src/lib/edje/edje_embryo.c  | 59 +++++++++++++++++++++++++++++++++++++++++++++
 src/lib/edje/edje_private.h |  1 +
 src/lib/edje/edje_program.c |  2 +-
 4 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/data/edje/include/edje.inc b/data/edje/include/edje.inc
index 7807383..5fa08bf 100644
--- a/data/edje/include/edje.inc
+++ b/data/edje/include/edje.inc
@@ -141,6 +141,12 @@ native       set_mask_flags   (part_id, flags);
 native       get_mask_flags   (part_id);
 native       part_swallow     (part_id, GROUP:str[]);
 
+/* set_focus() and unset_focus() may receive an optional parameter
+   seat_name[], as set_focus(part_id, seat_name[]) and
+   unset_focus(seat_name[]) */
+native       set_focus        (part_id, ...);
+native       unset_focus      (...);
+
 native       external_param_get_int(id, param_name[]);
 native       external_param_set_int(id, param_name[], value);
 native Float:external_param_get_float(id, param_name[]);
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index bb46310..f4d49d0 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -196,6 +196,9 @@
  * set_clip(part_id, clip_part_id)
  * get_clip(part_id)
  *
+ * set_focus(part_id, seat_name[])
+ * unset_focus(seat_name[])
+ *
  * part_swallow(part_id, group_name)
  *
  * external_param_get_int(id, param_name[])
@@ -3771,6 +3774,59 @@ _edje_embryo_fn_part_swallow(Embryo_Program *ep, 
Embryo_Cell *params)
    return 0;
 }
 
+/* set_focus(part_id, seat_name[]) */
+static Embryo_Cell
+_edje_embryo_fn_set_focus(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Edje *ed;
+   int part_id;
+   Edje_Real_Part *rp;
+   char *seat_name = NULL;
+
+   if (!(HASNPARAMS(1) || HASNPARAMS(2))) return -1;
+   ed = embryo_program_data_get(ep);
+
+   part_id = params[1];
+   if (part_id < 0) return 0;
+   rp = ed->table_parts[part_id % ed->table_parts_size];
+   if (!rp) return 0;
+
+   /* if no seat name is passed, that's fine. it means
+      it should be applied to default seat */
+   if (HASNPARAMS(2))
+     {
+        GETSTR(seat_name, params[2]);
+        if (!seat_name) return 0;
+     }
+
+   _edje_part_focus_set(ed, seat_name, rp);
+
+   return 0;
+}
+
+/* unset_focus(seat_name[]) */
+static Embryo_Cell
+_edje_embryo_fn_unset_focus(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Edje *ed;
+   char *seat_name = NULL;
+
+   if (!(HASNPARAMS(0) || HASNPARAMS(1))) return -1;
+   ed = embryo_program_data_get(ep);
+
+   /* seat name is optional. no seat means
+      it should be applied to default seat */
+   if (HASNPARAMS(1))
+     {
+        GETSTR(seat_name, params[1]);
+        if (!seat_name) return 0;
+     }
+
+   _edje_part_focus_set(ed, seat_name, NULL);
+
+   return 0;
+}
+
 /* external_param_get_int(id, param_name[]) */
 static Embryo_Cell
 _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)
    embryo_program_native_call_add(ep, "set_mask_flags", 
_edje_embryo_fn_set_mask_flags);
    embryo_program_native_call_add(ep, "get_mask_flags", 
_edje_embryo_fn_get_mask_flags);
 
+   embryo_program_native_call_add(ep, "set_focus", _edje_embryo_fn_set_focus);
+   embryo_program_native_call_add(ep, "unset_focus", 
_edje_embryo_fn_unset_focus);
+
    embryo_program_native_call_add(ep, "part_swallow", 
_edje_embryo_fn_part_swallow);
 
    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 f04be21..1a2d7db 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);
 
 void _edje_focused_part_set(Edje *ed, const char *seat_name, Edje_Real_Part 
*rp);
 Edje_Real_Part *_edje_focused_part_get(Edje *ed, const char *seat_name);
+void _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp);
 
 Eina_Stringshare *_edje_seat_name_get(Edje *ed, Efl_Input_Device *device);
 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 df74b33..ef4cf40 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
    _edje_emit_full(ed, buf, src, NULL, NULL);
 }
 
-static void
+void
 _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp)
 {
    Edje_Real_Part *focused_part;

-- 


Reply via email to