From 44d7ff1fb30d5fff9b8ad24de6fab973795d1fc2 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 7 Dec 2017 16:23:34 +0100 Subject: [PATCH] efl_ui_focus_manager_calc: refactor calculation logic --- src/lib/elementary/efl_ui_focus_manager_calc.c | 38 ++++++++++++-------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index 4da783a..7fec1f5 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c @@ -290,6 +290,21 @@ _distance(Eina_Rect node, Eina_Rect op, Dimension dim) } static inline void +_min_max_gen(Dimension dim, Eina_Rect rect, int *min, int *max) +{ + if (dim == DIMENSION_X) + { + *min = rect.y; + *max = eina_rectangle_max_y(&rect.rect); + } + else + { + *min = rect.x; + *max = eina_rectangle_max_x(&rect.rect); + } +} + +static inline void _calculate_node(Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *node, Dimension dim, Eina_List **pos, Eina_List **neg) { Eina_Rect rect; @@ -305,16 +320,7 @@ _calculate_node(Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *node, D *pos = NULL; *neg = NULL; - if (dim == DIMENSION_X) - { - dim_min = rect.y; - dim_max = rect.y + rect.h; - } - else - { - dim_min = rect.x; - dim_max = rect.x + rect.w; - } + _min_max_gen(dim, rect, &dim_min, &dim_max); EINA_ITERATOR_FOREACH(nodes, n) { @@ -328,17 +334,7 @@ _calculate_node(Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *node, D op_rect = efl_ui_focus_object_focus_geometry_get(op); - if (dim == DIMENSION_X) - { - min = op_rect.y; - max = eina_rectangle_max_y(&op_rect.rect); - } - else - { - min = op_rect.x; - max = eina_rectangle_max_x(&op_rect.rect); - } - + _min_max_gen(dim, op_rect, &min, &max); /* The only way the calculation does make sense is if the two number * lines are not disconnected. -- 2.7.4