From 8453ebfe4ef7f74730b2f3769c9ddad127fbe949 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 16 Aug 2017 15:56:57 +0200 Subject: [PATCH] elm: move the focus direction definition to general and remove the old definition --- src/lib/elementary/efl_ui_focus_layer.c | 2 +- src/lib/elementary/efl_ui_focus_manager.eo | 15 +------- .../elementary/efl_ui_focus_manager_calc.c | 34 ++++++++++--------- src/lib/elementary/efl_ui_win.c | 4 +-- src/lib/elementary/elm_general.eot | 16 ++++----- src/lib/elementary/elm_general.h | 8 +++++ src/lib/elementary/elm_widget_item.eo | 8 ++--- src/tests/elementary/elm_test_focus.c | 2 +- 8 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/lib/elementary/efl_ui_focus_layer.c b/src/lib/elementary/efl_ui_focus_layer.c index c708d8356d..70b2ee180d 100644 --- a/src/lib/elementary/efl_ui_focus_layer.c +++ b/src/lib/elementary/efl_ui_focus_layer.c @@ -46,7 +46,7 @@ _efl_ui_focus_layer_efl_ui_focus_manager_move(Eo *obj, Efl_Ui_Focus_Layer_Data * if (!pd->cycle) return NULL; - if ((direction == EFL_UI_FOCUS_DIRECTION_PREV) || (direction == EFL_UI_FOCUS_DIRECTION_NEXT)) + if ((direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS ) || (direction == EFL_UI_FOCUS_DIRECTION_NEXT)) efl_ui_focus_manager_focus_set(pd->manager, obj); return efl_ui_focus_manager_focus_get(obj); diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo index aeb762713b..2cac733e7c 100644 --- a/src/lib/elementary/efl_ui_focus_manager.eo +++ b/src/lib/elementary/efl_ui_focus_manager.eo @@ -1,17 +1,4 @@ -enum Efl.Ui.Focus.Direction { - [[Those values are describing a direction from the position of view from - one item. - - @since 1.20 - ]] - right = 0, [[Coordinate-wise the next element on the right-hand side]] - left = 1, [[Coordinate-wise the next element on the left-hand side]] - down = 2, [[Coordinate-wise the next element downward]] - up = 3, [[Coorinate-wise the next element upwards]] - next = 4, [[Logically-wise the next item in the logical tree]] - prev = 5, [[Logically-wise the prev item in the logical tree]] - last = 6 [[Last value for this enum, do not use]] -} +import elm_general; struct Efl.Ui.Focus.Relations { [[Structure holding the graph of relations between focussable objects. diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index b55798d649..58566c4410 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c @@ -11,7 +11,7 @@ #define DIM_EFL_UI_FOCUS_DIRECTION(dim,neg) dim*2+neg #define NODE_DIRECTIONS_COUNT 4 -#define DIRECTION_CHECK(dir) (dir >= 0 && dir < EFL_UI_FOCUS_DIRECTION_LAST) +#define DIRECTION_CHECK(dir) (dir >= EFL_UI_FOCUS_DIRECTION_PREVIOUS && dir < EFL_UI_FOCUS_DIRECTION_LAST) //#define CALC_DEBUG #define DEBUG_TUPLE(obj) efl_name_get(obj), efl_class_name_get(obj) @@ -24,6 +24,8 @@ static int _focus_log_domain = -1; #define F_INF(...) EINA_LOG_DOM_INFO(_focus_log_domain, __VA_ARGS__) #define F_DBG(...) EINA_LOG_DOM_DBG(_focus_log_domain, __VA_ARGS__) +#define DIRECTION_ACCESS(V, ID) ((V)->graph.directions[(ID) - 2]) + typedef struct { Eina_Bool positive; Efl_Ui_Focus_Object *anchor; @@ -85,7 +87,7 @@ _complement(Efl_Ui_Focus_Direction dir) COMP(EFL_UI_FOCUS_DIRECTION_RIGHT, EFL_UI_FOCUS_DIRECTION_LEFT) COMP(EFL_UI_FOCUS_DIRECTION_UP, EFL_UI_FOCUS_DIRECTION_DOWN) - COMP(EFL_UI_FOCUS_DIRECTION_PREV, EFL_UI_FOCUS_DIRECTION_NEXT) + COMP(EFL_UI_FOCUS_DIRECTION_PREVIOUS, EFL_UI_FOCUS_DIRECTION_NEXT) #undef COMP @@ -101,11 +103,11 @@ border_partners_set(Node *node, Efl_Ui_Focus_Direction direction, Eina_List *lis { Node *partner; Eina_List *lnode; - Border *border = &G(node).directions[direction]; + Border *border = &DIRECTION_ACCESS(node, direction); EINA_LIST_FREE(border->partners, partner) { - Border *comp_border = &G(partner).directions[_complement(direction)]; + Border *comp_border = &DIRECTION_ACCESS(partner, _complement(direction)); comp_border->partners = eina_list_remove(comp_border->partners, node); } @@ -114,7 +116,7 @@ border_partners_set(Node *node, Efl_Ui_Focus_Direction direction, Eina_List *lis EINA_LIST_FOREACH(border->partners, lnode, partner) { - Border *comp_border = &G(partner).directions[_complement(direction)]; + Border *comp_border = &DIRECTION_ACCESS(partner,_complement(direction)); comp_border->partners = eina_list_append(comp_border->partners, node); } @@ -164,7 +166,7 @@ node_item_free(Node *item) Node *n; Eina_List *l; //free the graph items - for(int i = 0;i < NODE_DIRECTIONS_COUNT; i++) + for(int i = EFL_UI_FOCUS_DIRECTION_UP;i < NODE_DIRECTIONS_COUNT; i++) { border_partners_set(item, i, NULL); } @@ -373,7 +375,7 @@ _debug_node(Node *node) printf("NODE %s-%s\n", DEBUG_TUPLE(node->focusable)); -#define DIR_LIST(dir) G(node).directions[dir].partners +#define DIR_LIST(dir) DIRECTION_ACCESS(node,dir).partners #define DIR_OUT(dir)\ tmp = DIR_LIST(dir); \ @@ -791,12 +793,12 @@ _efl_ui_focus_manager_calc_unregister(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_ pd->focus_stack = eina_list_remove(pd->focus_stack, node); //add all neighbors of the node to the dirty list - for(int i = 0; i < 4; i++) + for(int i = EFL_UI_FOCUS_DIRECTION_UP; i < NODE_DIRECTIONS_COUNT; i++) { Node *partner; Eina_List *n; - EINA_LIST_FOREACH(node->graph.directions[i].partners, n, partner) + EINA_LIST_FOREACH(DIRECTION_ACCESS(node, i).partners, n, partner) { dirty_add(obj, pd, partner); } @@ -895,10 +897,10 @@ _iterator_next(Border_Elements_Iterator *it, void **data) EINA_ITERATOR_FOREACH(it->real_iterator, node) { - for(int i = 0 ;i < NODE_DIRECTIONS_COUNT; i++) + for(int i = EFL_UI_FOCUS_DIRECTION_UP ;i < NODE_DIRECTIONS_COUNT; i++) { if (node->type != NODE_TYPE_ONLY_LOGICAL && - !node->graph.directions[i].partners) + !DIRECTION_ACCESS(node, i).partners) { *data = node->focusable; return EINA_TRUE; @@ -984,7 +986,7 @@ _coords_movement(Efl_Ui_Focus_Manager_Calc_Data *pd, Node *upper, Efl_Ui_Focus_D //we are searching which of the partners is lower to the history EINA_LIST_REVERSE_FOREACH(pd->focus_stack, node_list, candidate) { - if (eina_list_data_find(G(upper).directions[direction].partners, candidate)) + if (eina_list_data_find(DIRECTION_ACCESS(upper, direction).partners, candidate)) { //this is the next accessable part return candidate; @@ -993,7 +995,7 @@ _coords_movement(Efl_Ui_Focus_Manager_Calc_Data *pd, Node *upper, Efl_Ui_Focus_D //if we haven't found anything in the history, use the widget with the smallest distance { - Eina_List *lst = G(upper).directions[direction].partners; + Eina_List *lst = DIRECTION_ACCESS(upper, direction).partners; Eina_List *n; Node *node, *min = NULL; Eina_Vector2 elem, other; @@ -1157,7 +1159,7 @@ _request_move(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Fo dirty_flush(obj, pd, upper); - if (direction == EFL_UI_FOCUS_DIRECTION_PREV + if (direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS || direction == EFL_UI_FOCUS_DIRECTION_NEXT) dir = _logical_movement(pd, upper, direction); else @@ -1337,7 +1339,7 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_move(Eo *obj EINA_UNUSED, Efl_Ui n = eina_hash_find(pd->node_hash, &old_candidate); if (direction == EFL_UI_FOCUS_DIRECTION_NEXT || - direction == EFL_UI_FOCUS_DIRECTION_PREV) + direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS) { if (n) { @@ -1458,7 +1460,7 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_fetch(Eo *obj, Efl_Ui_Focus_Mana dirty_flush(obj, pd, n); -#define DIR_CLONE(dir) _convert(G(n).directions[dir].partners); +#define DIR_CLONE(dir) _convert(DIRECTION_ACCESS(n,dir).partners); res->right = DIR_CLONE(EFL_UI_FOCUS_DIRECTION_RIGHT); res->left = DIR_CLONE(EFL_UI_FOCUS_DIRECTION_LEFT); diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 1b341ffe01..d3ef9f3ede 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -1656,7 +1656,7 @@ _key_action_move(Evas_Object *obj, const char *params) Efl_Ui_Focus_Object *o; if (!strcmp(dir, "previous")) - focus_dir = EFL_UI_FOCUS_DIRECTION_PREV; + focus_dir = EFL_UI_FOCUS_DIRECTION_PREVIOUS; else if (!strcmp(dir, "next")) focus_dir = EFL_UI_FOCUS_DIRECTION_NEXT; else if (!strcmp(dir, "left")) @@ -1679,7 +1679,7 @@ _key_action_move(Evas_Object *obj, const char *params) efl_ui_focus_manager_focus_set(obj, root); } - if (!o && focus_dir == EFL_UI_FOCUS_DIRECTION_PREV) + if (!o && focus_dir == EFL_UI_FOCUS_DIRECTION_PREVIOUS) { Efl_Ui_Focus_Manager_Logical_End_Detail last; Efl_Ui_Focus_Manager *rec_manager = obj; diff --git a/src/lib/elementary/elm_general.eot b/src/lib/elementary/elm_general.eot index b4b05552b2..43f1dece60 100644 --- a/src/lib/elementary/elm_general.eot +++ b/src/lib/elementary/elm_general.eot @@ -129,16 +129,16 @@ enum Elm.Wrap.Type last [[Sentinel value to indicate last enum field during iteration]] } -enum Elm.Focus_Direction +enum Efl.Ui.Focus.Direction { [[ Focus directions. ]] - legacy: elm_focus; - previous, [[ previous direction ]] - next, [[ next direction ]] - up, [[ up direction ]] - down, [[ down direction ]] - right, [[ right direction ]] - left, [[ left direction ]] + previous = 0, [[ previous direction ]] + next = 1, [[ next direction ]] + up = 2, [[ up direction ]] + down = 3, [[ down direction ]] + right = 4, [[ right direction ]] + left = 5, [[ left direction ]] + last = 6 } enum Elm.Focus.Region.Show_Mode diff --git a/src/lib/elementary/elm_general.h b/src/lib/elementary/elm_general.h index c56b181528..35701cfe47 100644 --- a/src/lib/elementary/elm_general.h +++ b/src/lib/elementary/elm_general.h @@ -20,6 +20,14 @@ #include "elm_general.eot.h" +#define ELM_FOCUS_PREVIOUS EFL_UI_FOCUS_DIRECTION_PREVIOUS +#define ELM_FOCUS_NEXT EFL_UI_FOCUS_DIRECTION_NEXT +#define ELM_FOCUS_UP EFL_UI_FOCUS_DIRECTION_UP +#define ELM_FOCUS_DOWN EFL_UI_FOCUS_DIRECTION_DOWN +#define ELM_FOCUS_RIGHT EFL_UI_FOCUS_DIRECTION_RIGHT +#define ELM_FOCUS_LEFT EFL_UI_FOCUS_DIRECTION_LEFT +typedef Efl_Ui_Focus_Direction Elm_Focus_Direction; + /** * Defines couple of standard Evas_Object layers to be used * with evas_object_layer_set(). diff --git a/src/lib/elementary/elm_widget_item.eo b/src/lib/elementary/elm_widget_item.eo index e1778dd620..eb0b4a8b76 100644 --- a/src/lib/elementary/elm_widget_item.eo +++ b/src/lib/elementary/elm_widget_item.eo @@ -501,7 +501,7 @@ class Elm.Widget.Item(Efl.Object, Elm.Interface.Atspi_Accessible, @since 1.16]] params { - dir: Elm.Focus_Direction; [[Focus direction]] + dir: Efl.Ui.Focus.Direction; [[Focus direction]] } return: Efl.Canvas.Object; [[Focus next object]] } @@ -511,7 +511,7 @@ class Elm.Widget.Item(Efl.Object, Elm.Interface.Atspi_Accessible, @since 1.16]] params { next: Efl.Canvas.Object @nullable; [[Focus next object]] - dir: Elm.Focus_Direction; [[Focus direction]] + dir: Efl.Ui.Focus.Direction; [[Focus direction]] } } focus_next_item_get @const { @@ -519,7 +519,7 @@ class Elm.Widget.Item(Efl.Object, Elm.Interface.Atspi_Accessible, @since 1.16]] params { - dir: Elm.Focus_Direction; [[Focus direction]] + dir: Efl.Ui.Focus.Direction; [[Focus direction]] } return: Elm.Widget.Item; [[Focus next object item]] } @@ -529,7 +529,7 @@ class Elm.Widget.Item(Efl.Object, Elm.Interface.Atspi_Accessible, @since 1.16]] params { next_item: Elm.Widget.Item @nullable; [[Focus next object item]] - dir: Elm.Focus_Direction; [[Focus direction]] + dir: Efl.Ui.Focus.Direction; [[Focus direction]] } } } diff --git a/src/tests/elementary/elm_test_focus.c b/src/tests/elementary/elm_test_focus.c index 8eb732b33f..c4e08361b6 100644 --- a/src/tests/elementary/elm_test_focus.c +++ b/src/tests/elementary/elm_test_focus.c @@ -216,7 +216,7 @@ START_TEST(logical_chain) i-= 2; for (; i > 0; --i) { - ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREV)); + ck_assert_ptr_eq(logical_chain[i], efl_ui_focus_manager_move(m, EFL_UI_FOCUS_DIRECTION_PREVIOUS)); } elm_shutdown(); }