[atspi][elm_ctxpopup] scroll the content when highlight frame goes out of view port 07/92907/4
authorPrasoon Singh <prasoon.16@samsung.com>
Wed, 19 Oct 2016 09:46:48 +0000 (15:16 +0530)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 21 Oct 2016 08:08:18 +0000 (01:08 -0700)
Change-Id: I0522591b3bffebac6c0bcad153bba50968456dfb

src/mobile_lib/elc_ctxpopup.c
src/mobile_lib/elm_ctxpopup_item.eo

index d02ca58..4d69b81 100644 (file)
@@ -42,6 +42,10 @@ static const char ACCESS_OUTLINE_PART[] = "access.outline";
 static void _on_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
 static void _item_sizing_eval(Elm_Ctxpopup_Item_Data *item);
 static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED);
+//TIZEN ONLY(20161014) : Accessibility: scroll the content when highlight frame goes out of view port
+static void _content_move_down_cb(void *data, Evas_Object *obj, void *ev EINA_UNUSED);
+static void _content_move_up_cb(void *data, Evas_Object *obj, void *ev EINA_UNUSED);
+//
 
 EOLIAN static Eina_Bool
 _elm_ctxpopup_elm_widget_translate(Eo *obj, Elm_Ctxpopup_Data *sd)
@@ -1757,7 +1761,10 @@ _list_new(Evas_Object *obj)
      elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
 
    edje_object_part_swallow(wd->resize_obj, "elm.swallow.content", sd->scr);
-
+   //TIZEN ONLY(20161014) : Accessibility: scroll the content when highlight frame goes out of view port
+   evas_object_smart_callback_add(sd->scr, "scroll,down", _content_move_down_cb, (void*)obj);
+   evas_object_smart_callback_add(sd->scr, "scroll,up", _content_move_up_cb, (void*)obj);
+   //
    elm_object_content_set(sd->scr, sd->box);
    elm_ctxpopup_horizontal_set(obj, sd->horizontal);
 }
@@ -2385,5 +2392,179 @@ _elm_ctxpopup_item_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EIN
    return &atspi_actions[0];
 }
 
+//TIZEN ONLY(20161014) : Accessibility: scroll the content when highlight frame goes out of view port
+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)
+     return 1;
+   else if ((obj_y + obj_h/2) > viewport_y + viewport_h)
+     return -1;
+   return 0;
+}
+
+EOLIAN static Eina_Bool
+_elm_ctxpopup_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Ctxpopup_Item_Data *it)
+{
+   Evas_Coord wy, wh, x, y, w, h, bx, by;
+   ELM_CTXPOPUP_DATA_GET_OR_RETURN_VAL(WIDGET(it), sd, EINA_FALSE);
+   Eina_Bool ret;
+
+   evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
+   eo_do(sd->scr, elm_interface_scrollable_content_viewport_geometry_get(NULL, &wy, NULL, &wh));
+   int res = _is_item_in_viewport(wy, wh, y, h);
+
+   if (res != 0)
+     {
+        evas_object_geometry_get(sd->box, &bx, &by, NULL, NULL);
+        evas_smart_objects_calculate(evas_object_evas_get(sd->box));
+        x -= bx;
+        y -= by;
+        if (res > 0)
+          {
+             y -= wh - h;
+             eo_do(sd->scr, elm_interface_scrollable_content_region_show(x, y, w, h));
+          }
+        else if (res < 0)
+          {
+             y += wh - h;
+             eo_do(sd->scr, elm_interface_scrollable_content_region_show(x, y, w, h));
+          }
+     }
+
+   elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
+   eo_do_super(eo_it, ELM_CTXPOPUP_ITEM_CLASS, ret = elm_interface_atspi_component_highlight_grab());
+   return ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_ctxpopup_item_elm_interface_atspi_component_highlight_clear(Eo *eo_it, Elm_Ctxpopup_Item_Data *it)
+{
+   elm_object_accessibility_highlight_set(VIEW(it), EINA_FALSE);
+   elm_interface_atspi_accessible_state_changed_signal_emit(eo_it, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_FALSE);
+
+   return EINA_TRUE;
+}
+
+static void
+_content_move_down_cb(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
+{
+   if (!_elm_atspi_enabled())
+     return ;
+   ELM_CTXPOPUP_DATA_GET(data, pd);
+   Elm_Ctxpopup_Item_Data *it_data;
+   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;
+     }
+   // TIZEN_ONLY(20160805): set _accessibility_currently_highlighted_obj to NULL in object delete callback
+   else
+     {
+        WRN("Improper highlighted object: %p", highlighted_obj);
+        return;
+     }
+   //
+
+   if (parent)
+     {
+        int obj_x, obj_y, w, h, hx, hy, hw, hh;
+        eo_do(pd->scr, elm_interface_scrollable_content_viewport_geometry_get(&obj_x, &obj_y, &w, &h));
+        evas_object_geometry_get(highlighted_obj, &hx, &hy, &hw, &hh);
+
+        Elm_Ctxpopup_Item_Data *next_previous_item = NULL;
+        int viewport_position_result = _is_item_in_viewport(obj_y, h, hy, hh);
+        if (viewport_position_result > 0)
+          {
+             Eina_List *l = pd->items;
+             while(l)
+              {
+                 it_data = eina_list_data_get(l);
+                 next_previous_item = it_data;
+                 evas_object_geometry_get(VIEW(next_previous_item), &hx, &hy, &hw, &hh);
+
+                 if (_is_item_in_viewport(obj_y, h, hy, hh) == 0)
+                    break;
+                 next_previous_item = NULL;
+
+                 l = eina_list_next(l);
+              }
+          }
+        if (next_previous_item)
+          eo_do(EO_OBJ(next_previous_item), elm_interface_atspi_component_highlight_grab());
+     }
+
+}
+
+static void
+_content_move_up_cb(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
+{
+   if (!_elm_atspi_enabled())
+     return ;
+   ELM_CTXPOPUP_DATA_GET(data, pd);
+   Elm_Ctxpopup_Item_Data *it_data;
+   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;
+     }
+   // TIZEN_ONLY(20160805): set _accessibility_currently_highlighted_obj to NULL in object delete callback
+   else
+     {
+        WRN("Improper highlighted object: %p", highlighted_obj);
+        return;
+     }
+   //
+
+   if (parent)
+     {
+        int obj_x, obj_y, w, h, hx, hy, hw, hh;
+        eo_do(pd->scr, elm_interface_scrollable_content_viewport_geometry_get(&obj_x, &obj_y, &w, &h));
+        evas_object_geometry_get(highlighted_obj, &hx, &hy, &hw, &hh);
+
+        Elm_Ctxpopup_Item_Data *next_previous_item = NULL;
+        int viewport_position_result = _is_item_in_viewport(obj_y, h, hy, hh);
+        if (viewport_position_result < 0)
+          {
+             Eina_List *l = eina_list_last(pd->items);
+             while(l)
+              {
+                 it_data = eina_list_data_get(l);
+                 next_previous_item = it_data;
+                 evas_object_geometry_get(VIEW(next_previous_item), &hx, &hy, &hw, &hh);
+
+                 if (_is_item_in_viewport(obj_y, h, hy, hh) == 0)
+                    break;
+                 next_previous_item = NULL;
+
+                 l = eina_list_prev(l);
+              }
+          }
+        if (next_previous_item)
+          eo_do(EO_OBJ(next_previous_item), elm_interface_atspi_component_highlight_grab());
+     }
+
+}
+//
 #include "elm_ctxpopup_item.eo.c"
 #include "elm_ctxpopup.eo.c"
index 18ad2ed..1b2376d 100644 (file)
@@ -24,5 +24,9 @@ class Elm.Ctxpopup_Item(Elm.Widget_Item, Elm_Interface_Atspi_Widget_Action)
         Elm.Widget_Item.focus.get;
         Elm_Interface_Atspi_Accessible.name.get;
         Elm_Interface_Atspi_Widget_Action.elm_actions.get;
+        //TIZEN ONLY(20161014) : Accessibility: scroll the content when highlight frame goes out of view port
+        Elm_Interface_Atspi_Component.highlight_grab;
+        Elm_Interface_Atspi_Component.highlight_clear;
+        //
    }
 }