TizenRefApp-8352 [Apps Shorcut Widget] Implement support rotary events for Edit widge... 71/124171/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 10 Apr 2017 09:01:46 +0000 (12:01 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 10 Apr 2017 10:41:23 +0000 (13:41 +0300)
Change-Id: I3dac393ba09bfd24c72c0b41d4726ba9e53b14f0

apptray-widget-app/src/apptray_wgt_app.c

index 764552f8077904162ddc76073eb06b0a82c329ad..00a4038c6111c972b9c2d5d33011c6e89faaf058 100755 (executable)
@@ -164,6 +164,8 @@ typedef struct appdata {
 
        Evas_Object *ao_first;
        Evas_Object *ao_edit_ly;
+
+       Evas_Object *ao_cur_highlighted;
 } appdata_s;
 
 int slot_index = 0;
@@ -256,6 +258,12 @@ static Evas_Object *_edit_view_create_slot_empty_btn(Evas_Object *parent);
 static int _edit_view_get_slot_index_by_pointer(Evas_Object *slot);
 static void _edit_view_replace_slot_with_empty(Evas_Object *slot);
 
+static Eina_Bool _ao_edit_ly_action_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info);
+static void _slot_btn_highlight_cb(void *data, Evas_Object *obj, void *event_info);
+static void _slot_btn_unhighlight_cb(void *data, Evas_Object *obj, void *event_info);
+static void _manual_highlight_next();
+static void _manual_highlight_prev();
+
 /* Accessibility */
 static void _edit_view_init_ly_access_data(appdata_s *info);
 static void _edit_view_create_ly_access_obj(appdata_s *info);
@@ -406,20 +414,26 @@ static void _app_icon_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
        _ENTER;
 
+       char buff[BUF_SIZE_NORMAL] = { 0 };
+       Evas_Object *tmp = NULL;
+       int index = 0;
+
        if (!launch_flag) {
                _D("Ignore");
                return;
        }
+       index = _edit_view_get_slot_index_by_pointer(data);
 
        _edit_view_replace_slot_with_empty(data);
 
        _update_content();
 
-       char buff[BUF_SIZE_NORMAL] = { 0 };
-       snprintf(buff, sizeof(buff), "index%d", _edit_view_get_slot_index_by_pointer(data));
-       elm_atspi_component_highlight_grab(
-                       elm_object_part_content_get(
-                                       elm_object_part_content_get(g_info->edit_layout, buff), "icon"));
+       snprintf(buff, sizeof(buff), "index%d", index);
+       tmp = elm_object_part_content_get(g_info->edit_layout, buff);
+       ret_if(!tmp);
+       tmp = elm_object_part_content_get(tmp, "icon");
+       ret_if(!tmp);
+       ret_if(elm_atspi_component_highlight_grab(tmp) == EINA_FALSE);
 }
 
 static int _edit_view_get_slot_index_by_pointer(Evas_Object *slot)
@@ -786,6 +800,9 @@ static Evas_Object *_edit_view_create_slot_app_btn(Evas_Object *parent)
                        | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
        elm_atspi_accessible_description_set(eo, AO_STRING_DOUBLE_TAP_TO_REMOVE);
 
+       evas_object_smart_callback_add(eo, "atspi,highlighted", _slot_btn_highlight_cb, NULL);
+       evas_object_smart_callback_add(eo, "atspi,unhighlighted", _slot_btn_unhighlight_cb, NULL);
+
        return eo;
 }
 
@@ -814,6 +831,95 @@ static Evas_Object *_edit_view_create_slot_app_btn_del_ly(Evas_Object *parent)
        return eo;
 }
 
+
+static void _manual_highlight_next()
+{
+       Evas_Object *slot;
+       Evas_Object *btn;
+
+       if (!g_info->ao_cur_highlighted) {
+               elm_atspi_component_highlight_grab(g_info->ao_edit_ly);
+       } else if (g_info->ao_edit_ly == g_info->ao_cur_highlighted) {
+               slot = elm_object_part_content_get(g_info->edit_layout, "index1");
+               ret_if(!slot);
+               btn = elm_object_part_content_get(slot, "icon");
+               ret_if(!btn);
+               elm_atspi_component_highlight_grab(btn);
+       } else {
+               char index[BUF_SIZE_SMALL] = { 0 };
+               int i = 0;
+               for (; i < APP_SLOTS_MAX_COUNT; i++) {
+                       slot = NULL;
+                       btn = NULL;
+                       snprintf(index, sizeof(index), "index%d", i + 1);
+                       slot = elm_object_part_content_get(g_info->edit_layout, index);
+                       continue_if(!slot);
+                       btn = elm_object_part_content_get(slot, "icon");
+                       continue_if(!btn);
+
+                       if (btn == g_info->ao_cur_highlighted) {
+                               break_if(i + 1 >= APP_SLOTS_MAX_COUNT)
+                               snprintf(index, sizeof(index), "index%d", i + 2);
+                               slot = elm_object_part_content_get(g_info->edit_layout, index);
+                               ret_if(!slot);
+                               btn = elm_object_part_content_get(slot, "icon");
+                               ret_if(!btn);
+                               elm_atspi_component_highlight_grab(btn);
+                               break;
+                       }
+               }
+       }
+}
+
+static void _manual_highlight_prev()
+{
+       if (!g_info->ao_cur_highlighted) {
+               elm_atspi_component_highlight_grab(g_info->ao_edit_ly);
+       } else if (g_info->ao_edit_ly != g_info->ao_cur_highlighted) {
+               Evas_Object *slot;
+               Evas_Object *btn;
+               char index[BUF_SIZE_SMALL] = { 0 };
+               int i = 0;
+
+               for (; i < APP_SLOTS_MAX_COUNT; i++) {
+                       slot = NULL;
+                       btn = NULL;
+                       snprintf(index, sizeof(index), "index%d", i + 1);
+                       slot = elm_object_part_content_get(g_info->edit_layout, index);
+                       continue_if(!slot);
+
+                       btn = elm_object_part_content_get(slot, "icon");
+                       continue_if(!btn);
+                       if (btn == g_info->ao_cur_highlighted) {
+                               if (i - 1 < 0) {
+                                       ret_if(!g_info->ao_edit_ly);
+                                       elm_atspi_component_highlight_grab(g_info->ao_edit_ly);
+                                       return;
+                               }
+                               snprintf(index, sizeof(index), "index%d", i);
+                               slot = elm_object_part_content_get(g_info->edit_layout, index);
+                               ret_if(!slot);
+                               btn = elm_object_part_content_get(slot, "icon");
+                               ret_if(!btn);
+                               elm_atspi_component_highlight_grab(btn);
+                               return;
+                       }
+               }
+       }
+}
+
+static void _slot_btn_highlight_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       _D("Slot btn [HIGHLIGHT]");
+       g_info->ao_cur_highlighted = obj;
+}
+
+static void _slot_btn_unhighlight_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       _D("Slot btn [UNHIGHLIGHT]");
+       g_info->ao_cur_highlighted = NULL;
+}
+
 static Evas_Object *_edit_view_create_slot_empty_btn(Evas_Object *parent)
 {
        Evas_Object *eo = elm_button_add(parent);
@@ -831,6 +937,9 @@ static Evas_Object *_edit_view_create_slot_empty_btn(Evas_Object *parent)
                        | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
        elm_atspi_accessible_description_set(eo, AO_STRING_DOUBLE_TAP_TO_ADD);
 
+       evas_object_smart_callback_add(eo, "atspi,highlighted", _slot_btn_highlight_cb, NULL);
+       evas_object_smart_callback_add(eo, "atspi,unhighlighted", _slot_btn_unhighlight_cb, NULL);
+
        return eo;
 }
 
@@ -904,6 +1013,22 @@ Evas_Object *_set_app_slot(const char *appid, int pos)
        return slot;
 }
 
+static Eina_Bool _ao_edit_ly_action_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
+{
+       retv_if(!data, EINA_FALSE);
+
+       appdata_s *info = (appdata_s *)data;
+
+       if (action_info->action_type == ELM_ACCESS_ACTION_HIGHLIGHT) {
+               _D("Edit layout [HIGHLIGHT]");
+               info->ao_cur_highlighted = obj;
+       } else if (action_info->action_type == ELM_ACCESS_ACTION_HIGHLIGHT) {
+               _D("Edit layout [UNHIGHLIGHT]");
+               info->ao_cur_highlighted = NULL;
+       }
+       return EINA_FALSE;
+}
+
 static void _edit_view_create_ly_access_obj(appdata_s *info)
 {
        _ENTER;
@@ -912,6 +1037,9 @@ static void _edit_view_create_ly_access_obj(appdata_s *info)
        ret_if(!info->ao_edit_ly);
        elm_atspi_accessible_translation_domain_set(info->ao_edit_ly, APPTRAY_WIDGET_APP_DOMAIN);
        elm_atspi_accessible_reading_info_type_set(info->ao_edit_ly, ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+
+       elm_access_action_cb_set(info->ao_edit_ly, ELM_ACCESS_ACTION_HIGHLIGHT, _ao_edit_ly_action_cb, info);
+       elm_access_action_cb_set(info->ao_edit_ly, ELM_ACCESS_ACTION_UNHIGHLIGHT, _ao_edit_ly_action_cb, info);
 }
 
 static Eina_Bool _rotary_event_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *info)
@@ -919,7 +1047,11 @@ static Eina_Bool _rotary_event_cb(void *data, Evas_Object *obj, Eext_Rotary_Even
        _ENTER;
 
        if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
-               /* TODO: Need to implement logic for rotary events when Screen reader is on */
+               if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
+                       _manual_highlight_next();
+               } else {
+                       _manual_highlight_prev();
+               }
        }
 
        return EINA_FALSE;