diff options
author | Marcel Hollerbach <marcel@osg.samsung.com> | 2017-10-20 16:31:05 +0200 |
---|---|---|
committer | Marcel Hollerbach <marcel@osg.samsung.com> | 2017-10-20 17:21:57 +0200 |
commit | f79b1b9826fc9361c34615296165fd8aba1c97e5 (patch) | |
tree | a7fffda26f7a560c3e6db0c1201f9bea91623cbe /src/lib/elementary | |
parent | c48cde4aedfae253a14163f28477c131afc9be43 (diff) |
efl_ui_focus_manager: new api
Can be used to fetch a focusable widget that has child as parent.
Diffstat (limited to 'src/lib/elementary')
-rw-r--r-- | src/lib/elementary/efl_ui_focus_manager.eo | 12 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_focus_manager_calc.c | 65 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_focus_manager_calc.eo | 1 |
3 files changed, 61 insertions, 17 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo index 1cad0c482d..f382d55975 100644 --- a/src/lib/elementary/efl_ui_focus_manager.eo +++ b/src/lib/elementary/efl_ui_focus_manager.eo | |||
@@ -106,6 +106,18 @@ interface Efl.Ui.Focus.Manager { | |||
106 | this manager object.]] | 106 | this manager object.]] |
107 | } | 107 | } |
108 | } | 108 | } |
109 | request_subchild { | ||
110 | [[Returns a widget that can receive focus | ||
111 | |||
112 | The returned widget is in a child of the passed param. | ||
113 | Its garanteed that child will not be prepared once again, | ||
114 | so you can call this function out of a prepare call. | ||
115 | ]] | ||
116 | params { | ||
117 | child : Efl.Ui.Focus.Object; | ||
118 | } | ||
119 | return : Efl.Ui.Focus.Object; | ||
120 | } | ||
109 | fetch { | 121 | fetch { |
110 | [[This will fetch the data from a registered node. | 122 | [[This will fetch the data from a registered node. |
111 | 123 | ||
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index 24680bcd50..a254566bce 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c | |||
@@ -1097,13 +1097,10 @@ _prev_item(Node *node) | |||
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | static Node* | 1099 | static Node* |
1100 | _next(Node *node) | 1100 | _next_unprepare_node(Node *node) |
1101 | { | 1101 | { |
1102 | Node *n; | 1102 | Node *n; |
1103 | 1103 | ||
1104 | //prepare the node itself so if there are probebly no children, then they are here. | ||
1105 | efl_ui_focus_object_prepare_logical(node->focusable); | ||
1106 | |||
1107 | //Case 1 we are having children | 1104 | //Case 1 we are having children |
1108 | //But only enter the children if it does NOT have a redirect manager | 1105 | //But only enter the children if it does NOT have a redirect manager |
1109 | if (T(node).children && !node->redirect_manager) | 1106 | if (T(node).children && !node->redirect_manager) |
@@ -1145,6 +1142,15 @@ _next(Node *node) | |||
1145 | } | 1142 | } |
1146 | 1143 | ||
1147 | static Node* | 1144 | static Node* |
1145 | _next(Node *node) | ||
1146 | { | ||
1147 | //prepare the node itself so if there are probebly no children, then they are here. | ||
1148 | efl_ui_focus_object_prepare_logical(node->focusable); | ||
1149 | |||
1150 | return _next_unprepare_node(node); | ||
1151 | } | ||
1152 | |||
1153 | static Node* | ||
1148 | _prev(Node *node) | 1154 | _prev(Node *node) |
1149 | { | 1155 | { |
1150 | Node *n = NULL; | 1156 | Node *n = NULL; |
@@ -1272,7 +1278,32 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_request_move(Eo *obj EINA_UNUSED | |||
1272 | } | 1278 | } |
1273 | } | 1279 | } |
1274 | 1280 | ||
1281 | static Node* | ||
1282 | _request_subchild(Node *node) | ||
1283 | { | ||
1284 | //important! if there are no children _next would return the parent of node which will exceed the limit of children of node | ||
1285 | Node *target = NULL; | ||
1275 | 1286 | ||
1287 | if (node->tree.children) | ||
1288 | { | ||
1289 | target = node; | ||
1290 | |||
1291 | //try to find a child that is not logical or has a redirect manager | ||
1292 | while (target && target->type == NODE_TYPE_ONLY_LOGICAL && !target->redirect_manager) | ||
1293 | { | ||
1294 | if (target != node) | ||
1295 | efl_ui_focus_object_prepare_logical(target->focusable); | ||
1296 | |||
1297 | target = _next_unprepare_node(target); | ||
1298 | //abort if we are exceeding the childrens of node | ||
1299 | if (target == node) target = NULL; | ||
1300 | } | ||
1301 | |||
1302 | F_DBG("Found node %p", target); | ||
1303 | } | ||
1304 | |||
1305 | return target; | ||
1306 | } | ||
1276 | 1307 | ||
1277 | EOLIAN static void | 1308 | EOLIAN static void |
1278 | _efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *focus) | 1309 | _efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *focus) |
@@ -1296,20 +1327,8 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_ | |||
1296 | 1327 | ||
1297 | //important! if there are no children _next would return the parent of node which will exceed the limit of children of node | 1328 | //important! if there are no children _next would return the parent of node which will exceed the limit of children of node |
1298 | efl_ui_focus_object_prepare_logical(node->focusable); | 1329 | efl_ui_focus_object_prepare_logical(node->focusable); |
1299 | if (node->tree.children) | ||
1300 | { | ||
1301 | target = node; | ||
1302 | 1330 | ||
1303 | //try to find a child that is not logical or has a redirect manager | 1331 | target = _request_subchild(node); |
1304 | while (target && target->type == NODE_TYPE_ONLY_LOGICAL && !target->redirect_manager) | ||
1305 | { | ||
1306 | target = _next(target); | ||
1307 | //abort if we are exceeding the childrens of node | ||
1308 | if (target == node) target = NULL; | ||
1309 | } | ||
1310 | |||
1311 | F_DBG("Found node %p", target); | ||
1312 | } | ||
1313 | 1332 | ||
1314 | //check if we have found anything | 1333 | //check if we have found anything |
1315 | if (target) | 1334 | if (target) |
@@ -1619,5 +1638,17 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_pop_history_stack(Eo *obj EINA_U | |||
1619 | if (last) efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE); | 1638 | if (last) efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE); |
1620 | } | 1639 | } |
1621 | 1640 | ||
1641 | EOLIAN static Efl_Ui_Focus_Object* | ||
1642 | _efl_ui_focus_manager_calc_efl_ui_focus_manager_request_subchild(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *child_obj) | ||
1643 | { | ||
1644 | Node *child, *target; | ||
1645 | |||
1646 | child = node_get(obj, pd, child_obj); | ||
1647 | target = _request_subchild(child); | ||
1648 | |||
1649 | if (target) return target->focusable; | ||
1650 | return NULL; | ||
1651 | } | ||
1652 | |||
1622 | 1653 | ||
1623 | #include "efl_ui_focus_manager_calc.eo.c" | 1654 | #include "efl_ui_focus_manager_calc.eo.c" |
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.eo b/src/lib/elementary/efl_ui_focus_manager_calc.eo index d911dbfe05..0a8b4e73c5 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.eo +++ b/src/lib/elementary/efl_ui_focus_manager_calc.eo | |||
@@ -96,6 +96,7 @@ class Efl.Ui.Focus.Manager.Calc (Efl.Object, Efl.Ui.Focus.Manager) { | |||
96 | Efl.Ui.Focus.Manager.redirect {set; get;} | 96 | Efl.Ui.Focus.Manager.redirect {set; get;} |
97 | Efl.Ui.Focus.Manager.border_elements {get;} | 97 | Efl.Ui.Focus.Manager.border_elements {get;} |
98 | Efl.Ui.Focus.Manager.root {set; get;} | 98 | Efl.Ui.Focus.Manager.root {set; get;} |
99 | Efl.Ui.Focus.Manager.request_subchild; | ||
99 | Efl.Ui.Focus.Manager.fetch; | 100 | Efl.Ui.Focus.Manager.fetch; |
100 | Efl.Ui.Focus.Manager.logical_end; | 101 | Efl.Ui.Focus.Manager.logical_end; |
101 | Efl.Ui.Focus.Manager.reset_history; | 102 | Efl.Ui.Focus.Manager.reset_history; |