[access][layout] sort focus list based on geometry value
authorShinwoo Kim <cinoo.kim@samsung.com>
Wed, 17 Apr 2013 07:08:29 +0000 (16:08 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Mon, 29 Apr 2013 11:30:04 +0000 (20:30 +0900)
src/lib/elm_layout.c

index 84800ac..ffb9ac7 100644 (file)
@@ -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