From 30966e17d0aee11df4d859134a91f292bee1f33a Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Wed, 17 Apr 2013 16:08:29 +0900 Subject: [PATCH] [access][layout] sort focus list based on geometry value --- src/lib/elm_layout.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c index 84800ac..ffb9ac7 100644 --- a/src/lib/elm_layout.c +++ b/src/lib/elm_layout.c @@ -371,6 +371,38 @@ _elm_layout_smart_on_focus(Evas_Object *obj) return EINA_TRUE; } +static int +_access_focus_list_sort_cb(const void *data1, const void *data2) +{ + Evas_Coord_Point p1, p2; + Evas_Object *obj1, *obj2; + + obj1 = ((Elm_Layout_Sub_Object_Data *)data1)->obj; + obj2 = ((Elm_Layout_Sub_Object_Data *)data2)->obj; + + evas_object_geometry_get(obj1, &p1.x, &p1.y, NULL, NULL); + evas_object_geometry_get(obj2, &p2.x, &p2.y, NULL, NULL); + + if (p1.y == p2.y) + { + return p1.x - p2.x; + } + + return p1.y - p2.y; +} + +static const Eina_List * +_access_focus_list_sort(Eina_List *origin) +{ + Eina_List *l, *temp = NULL; + Elm_Layout_Sub_Object_Data *sub_d; + + EINA_LIST_FOREACH(origin, l, sub_d) + temp = eina_list_sorted_insert(temp, _access_focus_list_sort_cb, sub_d); + + return temp; +} + /* WARNING: if you're making a widget *not* supposed to have focusable * child objects, but still inheriting from elm_layout, just set its * focus_next smart function back to NULL */ @@ -392,6 +424,9 @@ _elm_layout_smart_focus_next(const Evas_Object *obj, list_data_get = _elm_layout_list_data_get; if (!items) return EINA_FALSE; + + if (_elm_config->access_mode) + items = _access_focus_list_sort((Eina_List *)items); } return elm_widget_focus_list_next_get -- 2.7.4