[atspi][elm_toolbar] enhance accessibility scroll and highlight on toolbar items 64/92964/3 accepted/tizen/common/20161020.173518 accepted/tizen/ivi/20161020.130334 accepted/tizen/mobile/20161020.130211 accepted/tizen/tv/20161020.130252 accepted/tizen/wearable/20161020.130315 submit/tizen/20161020.095955
authorPrasoon Singh <prasoon.16@samsung.com>
Wed, 19 Oct 2016 13:18:45 +0000 (18:48 +0530)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 20 Oct 2016 04:02:51 +0000 (21:02 -0700)
When there are multiple scrollable toolbar items. Highlight frame should change
when prevoius highlighted object goes out of viewport.

Change-Id: I3206023f843bc12574c62e6cd205fcaf775208fb

src/lib/elm_toolbar.c
src/lib/elm_toolbar.eo

index 4a926b6..eb971b3 100644 (file)
@@ -4266,6 +4266,86 @@ _elm_toolbar_evas_object_smart_calculate(Eo *obj, Elm_Toolbar_Data *pd EINA_UNUS
    _sizing_eval(obj);
 }
 
+//TIZEN_ONLY(20161019): toolbar: enhance accessibility scroll and highlight on toolbar items
+static int _is_item_in_viewport(int viewport_x, int viewport_w, int obj_x, int obj_w)
+{
+    if ((obj_x + obj_w/2) < viewport_x)
+      return 1;
+    else if ((obj_x + obj_w/2) > viewport_x + viewport_w)
+      return -1;
+    return 0;
+}
+
+EOLIAN static void
+_elm_toolbar_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, Elm_Toolbar_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig)
+{
+   if (!_elm_atspi_enabled())
+     {
+        eo_do_super(obj, MY_CLASS, elm_interface_scrollable_content_pos_set(x,y,sig));
+        return;
+     }
+
+   int old_x, old_y, delta_x;
+   eo_do_super(obj, MY_CLASS, elm_interface_scrollable_content_pos_get(&old_x,&old_y));
+   eo_do_super(obj, MY_CLASS, elm_interface_scrollable_content_pos_set(x,y,sig));
+   delta_x = old_x - x;
+   //check if highlighted item is list descendant
+   Evas_Object * highlighted_obj = _elm_object_accessibility_currently_highlighted_get();
+   Evas_Object * parent = highlighted_obj;
+   if (eo_isa(highlighted_obj, ELM_WIDGET_CLASS))
+     {
+        while ((parent = elm_widget_parent_get(parent)))
+          if (parent == obj)
+            break;
+     }
+   else if (eo_isa(highlighted_obj, EDJE_OBJECT_CLASS))
+     {
+        while ((parent = evas_object_smart_parent_get(parent)))
+          if (parent == obj)
+            break;
+     }
+   else
+     {
+        WRN("Improper highlighted object: %p", highlighted_obj);
+        return;
+     }
+
+   if (parent)
+     {
+        int obj_x, obj_y, w, h, hx, hy, hw, hh;
+        evas_object_geometry_get(obj, &obj_x, &obj_y, &w, &h);
+        evas_object_geometry_get(highlighted_obj, &hx, &hy, &hw, &hh);
+        Elm_Toolbar_Item_Data *next_previous_item = NULL;
+        int viewport_position_result = _is_item_in_viewport(obj_x, w, hx, hw);
+        //only highlight if move direction is correct
+        //sometimes highlighted item is brought in and it does not fit viewport
+        //however content goes to the viewport position so soon it will
+        //meet _is_item_in_viewport condition
+        if ((viewport_position_result < 0 && delta_x > 0) ||
+           (viewport_position_result > 0 && delta_x < 0))
+          {
+             Elm_Toolbar_Item_Data* it_data;
+             Eina_Bool traverse_direction = viewport_position_result > 0;
+             it_data = traverse_direction ? ELM_TOOLBAR_ITEM_FROM_INLIST(pd->items): ELM_TOOLBAR_ITEM_FROM_INLIST(eina_inlist_last(pd->items));
+
+             while(it_data)
+              {
+                 next_previous_item = it_data;
+                 evas_object_geometry_get(VIEW(next_previous_item), &hx, &hy, &hw, &hh);
+
+                 if (_is_item_in_viewport(obj_x, w, hx, hw) == 0)
+                    break;
+
+                 next_previous_item = NULL;
+
+                 it_data = traverse_direction ? ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it_data)->next): ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it_data)->prev);
+              }
+          }
+        if (next_previous_item)
+          eo_do(EO_OBJ(next_previous_item), elm_interface_atspi_component_highlight_grab());
+     }
+}
+//
 
 #include "elm_toolbar.eo.c"
 #include "elm_toolbar_item.eo.c"
index ffd35e7..15fa45c 100644 (file)
@@ -547,6 +547,9 @@ class Elm.Toolbar (Elm.Widget, Elm_Interface_Scrollable,
       Elm_Interface_Atspi_Selection.is_child_selected;
       Elm_Interface_Atspi_Selection.all_children_select;
       Elm_Interface_Atspi_Selection.clear;
+      //TIZEN_ONLY(20161019): toolbar: enhance accessibility scroll and highlight on toolbar items
+      Elm_Interface_Scrollable.content_pos_set;
+      //
    }
    events {
       language,changed;