[ATSPI] Show the object highlighted by highlight_grab when the object is completely... 70/109470/8
authorJunsuChoi <jsuya.choi@samsung.com>
Tue, 10 Jan 2017 06:48:42 +0000 (15:48 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 23 Jan 2017 04:15:58 +0000 (20:15 -0800)
   Modified highlight_grab function of scrolling an object
   when the object is highlighted in scrollable object

   _accessible_highlight_region_show finds the scrollable parent
   and scrolls to show the highlighted object.

Change-Id: If40fbc6ce6000ace1d779d4cff86c6db00bffc12

src/lib/elm_list.c
src/lib/elm_widget.c
src/mobile_lib/elm_genlist.c

index 43f8b32f5a13ed1cc446a89fed8d2d07f19c5495..b415a25738da26ab910c69625cfdfa6a728ffe99 100644 (file)
@@ -3398,9 +3398,9 @@ _elm_list_elm_interface_atspi_selection_child_deselect(Eo *obj EINA_UNUSED, Elm_
 //TIZEN_ONLY(20160329): list: enhance accessibility scroll and highlight (02c20ee39a0ebbe67b9e1491ccfc46dd681821c9)
 static int _is_item_in_viewport(int viewport_y, int viewport_h, int obj_y, int obj_h)
 {
-    if ((obj_y + obj_h/2) < viewport_y)
+    if (obj_y + obj_h <= viewport_y)
       return 1;
-    else if ((obj_y + obj_h/2) > viewport_y + viewport_h)
+    else if (obj_y >= viewport_y + viewport_h)
       return -1;
     return 0;
 }
@@ -3497,32 +3497,15 @@ _elm_list_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, Elm_List
 EOLIAN static Eina_Bool
 _elm_list_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_List_Item_Data *it)
 {
-   Evas_Coord wy, wh, x, y, w, h, bx, by, bw, bh;
    ELM_LIST_DATA_GET_OR_RETURN_VAL(WIDGET(it), sd, EINA_FALSE);
 
-   evas_object_geometry_get(WIDGET(it), NULL, &wy, NULL, &wh);
-   evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
-   int res = _is_item_in_viewport(wy, wh, y, h);
-
-   if (res != 0)
-     {
-        evas_object_geometry_get(sd->box, &bx, &by, &bw, &bh);
-        evas_smart_objects_calculate(evas_object_evas_get(sd->box));
-        x -= bx;
-        y -= by;
-        if (res > 0)
-          {
-             y -= wh - h;
-             eo_do(WIDGET(it), elm_interface_scrollable_content_region_show(x, y, w, h));
-          }
-        else if (res < 0)
-          {
-             y += wh - h;
-             eo_do(WIDGET(it), elm_interface_scrollable_content_region_show(x, y, w, h));
-          }
-     }
-   else
-     elm_list_item_show(eo_it);
+#ifndef TIZEN_PROFILE_WEARABLE
+   //TIZEN_ONLY(20170119): Show the object highlighted by highlight_grab when the object is completely out of the scroll
+   eo_do_super(EO_OBJ(it), ELM_LIST_ITEM_CLASS, elm_interface_atspi_component_highlight_grab());
+   //
+#else
+   elm_list_item_show(eo_it);
+#endif
 
 ///TIZEN_ONLY(20170717) : expose highlight information on atspi
    elm_object_accessibility_highlight_set(eo_it, EINA_TRUE);
index 93f2f8974de40f24ba6777a276782ccf8d8cd676..e1dbf40245c2ed701a9e9fcb0339038aa12998ee 100644 (file)
@@ -6267,14 +6267,138 @@ _elm_widget_elm_interface_atspi_component_focus_grab(Eo *obj, Elm_Widget_Smart_D
    return EINA_FALSE;
 }
 
+//TIZEN_ONLY(20170119): Show the object highlighted by highlight_grab when the object is completely out of the scroll
+Eina_Bool
+_accessible_check_inside_view(Eo *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
+{
+   if(!obj) return EINA_FALSE;
+
+   Evas_Object *target = obj;
+   Evas_Object *parent = NULL;
+   Evas_Coord px, py, sx, sy, sw, sh;
+
+   if (elm_widget_is(target))
+     parent = elm_widget_parent_get(target);
+   else
+     parent = elm_widget_parent_widget_get(target);
+
+   while (parent)
+     {
+        if (eo_isa(parent, ELM_INTERFACE_SCROLLABLE_MIXIN))
+          {
+             evas_object_geometry_get(parent, &sx, &sy, &sw, &sh);
+             px = x;
+             py = y;
+             x = x > sx ? x : sx;
+             y = y > sy ? y : sy;
+             w = px + w < sx + sw ? px + w - x : sx + sw - x;
+             h = py + h < sy + sh ? py + h - y : sy + sh - y;
+          }
+        if (w <= 0 || h <= 0)
+          return EINA_FALSE;
+
+        parent = elm_widget_parent_get(parent);
+     }
+   return EINA_TRUE;
+}
+
+Eina_List *
+_accessible_scrollable_parent_list_get(Eo *obj)
+{
+   if(!obj) return NULL;
+
+   Evas_Object *parent = NULL;
+   Eina_List *plist = NULL;
+
+   if (elm_widget_is(obj))
+     parent = elm_widget_parent_get(obj);
+   else
+     parent = elm_widget_parent_widget_get(obj);
+
+   while (parent)
+     {
+        if (_elm_scrollable_is(parent))
+          plist = eina_list_append(plist, parent);
+
+        parent = elm_widget_parent_get(parent);
+   }
+   return plist;
+}
+
+void
+_accessible_highlight_region_show(Eo* obj)
+{
+   if(!obj) return ;
+
+   Evas_Object *target = obj;
+   Evas_Object *parent = NULL;
+   Evas_Object *parent_sub = NULL;
+   Eina_List *plist, *plist_sub;
+   Eina_List *l, *l2;
+
+   Evas_Coord target_x, target_y, target_w, target_h;
+
+   evas_object_geometry_get(target, &target_x, &target_y, &target_w, &target_h);
+
+   plist = _accessible_scrollable_parent_list_get(target);
+   if(!plist) return ;
+   EINA_LIST_FOREACH(plist, l, parent)
+     {
+        if(!_accessible_check_inside_view(target, target_x, target_y, target_w, target_h))
+          {
+             plist_sub = _accessible_scrollable_parent_list_get(parent);
+             plist_sub = eina_list_prepend(plist_sub, parent);
+             EINA_LIST_FOREACH(plist_sub, l2, parent_sub)
+               {
+                  Evas_Coord scroll_x, scroll_y;
+                  Evas_Coord scroll_x_back, scroll_y_back;
+                  Evas_Coord x, y, w, h;
+                  Evas_Coord px, py;
+
+                  eo_do(parent_sub, elm_interface_scrollable_content_region_get(&scroll_x_back, &scroll_y_back, NULL, NULL));
+                  evas_object_geometry_get(parent_sub, &px, &py, NULL, NULL);
+                  evas_object_geometry_get(target, &x, &y, &w, &h);
+
+                  x -= (px - scroll_x_back);
+                  y -= (py - scroll_y_back);
+                  switch (_elm_config->focus_autoscroll_mode)
+                    {
+                       case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
+                          eo_do(parent_sub, elm_interface_scrollable_content_region_show(x, y, w, h));
+                          break;
+                       case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
+                          eo_do(parent_sub, elm_interface_scrollable_region_bring_in(x, y, w, h));
+                          break;
+                       default:
+                          break;
+                    }
+                  eo_do(parent_sub, elm_interface_scrollable_content_region_get(&scroll_x, &scroll_y, NULL, NULL));
+
+                  target_x -= (scroll_x - scroll_x_back);
+                  target_y -= (scroll_y - scroll_y_back);
+
+                  if(_accessible_check_inside_view(target, target_x, target_y, target_w, target_h))
+                    break;
+               }
+             eina_list_free(plist_sub);
+          }
+     }
+
+   eina_list_free(plist);
+}
+//
+
 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods (29e253e2f7ef3c632ac3a64c489bf569df407f30)
 EOLIAN static Eina_Bool
 _elm_widget_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
 {
+   if(!obj) return EINA_FALSE;
    if(!_elm_atspi_enabled())
       return EINA_FALSE;
 
-   elm_widget_focus_region_show(obj);
+   //TIZEN_ONLY(20170119): Show the object highlighted by highlight_grab when the object is completely out of the scroll
+   _accessible_highlight_region_show(obj);
+   //
 
    elm_object_accessibility_highlight_set(obj, EINA_TRUE);
    elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
@@ -6755,40 +6879,24 @@ _elm_widget_item_elm_interface_atspi_component_focus_grab(Eo *obj EINA_UNUSED, E
 }
 
 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods
+
 EOLIAN static Eina_Bool
 _elm_widget_item_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Item_Data *sd)
 {
+   if (!sd) return EINA_FALSE;
+   if (!sd->view) return EINA_FALSE;
 
-   if (!obj) return EINA_FALSE;
-
-   Evas_Object *o = elm_object_parent_widget_get(sd->view);
-   if (_elm_scrollable_is(o))
-     {
-        Evas_Coord bx, by, bw, bh;
-        Evas_Coord x, y, w, h;
-        Evas_Object *w1 = elm_object_parent_widget_get(o);
-        evas_object_geometry_get(sd->view, &x, &y, &w, &h);
-        evas_object_geometry_get(o, &bx, &by, &bw, &bh);
-        x -= bx;
-        y -= by;
-        switch (_elm_config->focus_autoscroll_mode)
-          {
-           case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
-              eo_do(w1, elm_interface_scrollable_content_region_show(x, y, w, h));
-              break;
-           case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
-              eo_do(w1, elm_interface_scrollable_region_bring_in(x, y, w, h));
-              break;
-           default:
-              break;
-          }
-     }
+   //TIZEN_ONLY(20170119): Show the object highlighted by highlight_grab when the object is completely out of the scroll
+   _accessible_highlight_region_show(sd->view);
+   //
 
+   if (!sd->eo_obj) return EINA_FALSE;
    elm_object_accessibility_highlight_set(sd->eo_obj, EINA_TRUE);
+
+   if (!obj) return EINA_FALSE;
    elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
 
    return EINA_TRUE;
-
 }
 
 EOLIAN static Eina_Bool
index 2e66a44fd69541f7776668fa7f6de3343d5de772..86d2f5664ae7d321c53d6d85244206a3851aa790 100644 (file)
@@ -8687,6 +8687,11 @@ _elm_genlist_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Ge
 {
    ELM_GENLIST_DATA_GET(WIDGET(it), sd);
 
+#ifndef TIZEN_PROFILE_WEARABLE
+   //TIZEN_ONLY(20170119): Show the object highlighted by highlight_grab when the object is completely out of the scroll
+   eo_do_super(EO_OBJ(it), ELM_GENLIST_ITEM_CLASS, elm_interface_atspi_component_highlight_grab());
+   //
+#else
    // if item is realized check if in viewport
    if (VIEW(it))
      {
@@ -8694,24 +8699,7 @@ _elm_genlist_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Ge
         evas_object_geometry_get(WIDGET(it), NULL, &wy, NULL, &wh);
         evas_object_geometry_get(VIEW(it), NULL, &y, NULL, &h);
         //TIZEN_ONLY(20161104) : Accessibility : synchronized highlight of atspi and item align feature for wearable profile
-#ifndef TIZEN_PROFILE_WEARABLE
-        int res = _is_item_in_viewport(wy, wh, y, h);
-
-        if (res > 0)
-          {
-             // new item is above current
-             elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
-          }
-        else if (res < 0)
-          {
-             // new item is below current
-             elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
-          }
-        else
-          elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_IN);
-#else
         elm_genlist_item_bring_in(eo_it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
-#endif
         //
       }
    else // if item is not realized we should search if we are over or below viewport
@@ -8719,27 +8707,11 @@ _elm_genlist_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Ge
         Eina_List *realized = elm_genlist_realized_items_get(WIDGET(it));
         if (realized)
           {
-#ifndef TIZEN_PROFILE_WEARABLE
-             int idx, top, bottom;
-
-             // index of realized element on top of viewport
-             eo_do(eina_list_nth(realized, 0), top = elm_obj_genlist_item_index_get());
-             // index of realized element on bottom of viewport
-             eo_do(eina_list_last_data_get(realized), bottom = elm_obj_genlist_item_index_get());
-             eo_do(eo_it, idx = elm_obj_genlist_item_index_get());
-             //TIZEN_ONLY(20161104) : Accessibility : synchronized highlight of atspi and item align feature for wearable profile
-             if (idx < top)
-               elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
-             else if (idx > bottom)
-               elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_TOP);
-             else
-               elm_genlist_item_show(eo_it, ELM_GENLIST_ITEM_SCROLLTO_IN);
-#else
              elm_genlist_item_bring_in(eo_it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
-#endif
              eina_list_free(realized);
           }
      }
+#endif
 
    if (VIEW(it))
      {
@@ -8751,13 +8723,15 @@ _elm_genlist_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Ge
    else
        sd->atspi_item_to_highlight = it;//it will be highlighted when realized
 
-///TIZEN_ONLY(20170717) : expose highlight information on atspi
-        elm_interface_atspi_accessible_state_changed_signal_emit(EO_OBJ(it), ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
-///
+
+   ///TIZEN_ONLY(20170717) : expose highlight information on atspi
+   elm_interface_atspi_accessible_state_changed_signal_emit(EO_OBJ(it), ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
+   ///
 
    //TIZEN_ONLY(20161104) : Accessibility : synchronized highlight of atspi and item align feature for wearable profile
    edje_object_signal_emit(VIEW(it), SIGNAL_ITEM_HIGHLIGHTED, "elm");
    //
+
    return EINA_TRUE;
 }
 
@@ -9033,9 +9007,9 @@ _elm_genlist_elm_interface_atspi_selection_child_deselect(Eo *obj EINA_UNUSED, E
 // TIZEN only (20150914) : Accessibility: updated highlight change during genlist and list scroll
 static int _is_item_in_viewport(int viewport_y, int viewport_h, int obj_y, int obj_h)
 {
-   if ((obj_y + obj_h/2) < viewport_y)
+   if (obj_y + obj_h <= viewport_y)
      return 1;
-   else if ((obj_y + obj_h/2) > viewport_y + viewport_h)
+   else if (obj_y >= viewport_y + viewport_h)
      return -1;
    return 0;
 }