From d78b70af51461cd22e3627ffe3b4ed65c6f4d3e2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 26 Jun 2012 05:54:45 +0000 Subject: [PATCH] elementary: use Edje to enable accessibility on TEXTBLOCK. Patch by Kim Shinwoo . SVN revision: 72841 --- legacy/elementary/ChangeLog | 61 +++++----- legacy/elementary/NEWS | 1 + legacy/elementary/src/lib/elm_access.c | 148 ++++++++++++++++++++++++ legacy/elementary/src/lib/elm_layout.c | 4 + legacy/elementary/src/lib/elm_toolbar.c | 3 +- legacy/elementary/src/lib/elm_widget.c | 3 + legacy/elementary/src/lib/elm_widget.h | 2 + 7 files changed, 192 insertions(+), 30 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index 181c7202ec..3757214527 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -84,7 +84,7 @@ the items over max number are located in more panel. The APIs are added for this feature.(elm_toolbar_more_item_get, elm_toolbar_items_max_set/get) -2012-05-22 Carsten Haitzler (The Rasterman) +2012-05-22 Carsten Haitzler (The Rasterman) * Add skeleton for handling remote commands access controls. @@ -92,46 +92,46 @@ * Map: Add elm_map_overlays_get & elm_map_overlay_visible_get functions. -2012-05-24 Michal Pakula vel Rutka +2012-05-24 Michal Pakula vel Rutka * Add ability to use cnp helper code on non-elm widget objects by falling back to ecore-evas to get the window id. -2012-05-24 Tae-Hwan Kim (Bluezery) +2012-05-24 Tae-Hwan Kim (Bluezery) * Add "loaded" signal for elm_map. -2012-05-25 Rob Bradford +2012-05-25 Rob Bradford * Refactor X11 specific code to use ecore_evas_*_window_get functions so that the driver for the Ecore_Evas will be checked. -2012-05-28 Mike Blumenkrantz +2012-05-28 Mike Blumenkrantz * Fix sizing calc error in list item homogenizing -2012-05-28 Carsten Haitzler (The Rasterman) +2012-05-28 Carsten Haitzler (The Rasterman) * Made elm_object_focus_set() fall back to evbas_object_focus_set() if the object is not an elm widget. -2012-05-29 Mike Blumenkrantz +2012-05-29 Mike Blumenkrantz * Prepending items to a genlist no longer causes the selected item to scroll out of the viewport * Collapsing tree items in genlist now animate properly -2012-05-29 Rob Bradford +2012-05-29 Rob Bradford * Move X related window items into their own substruct of _Elm_Win_Smart_Data to allow grouping based on engine. -2012-05-29 Rob Bradford +2012-05-29 Rob Bradford * Move X related cursor items into their own substruct of Elm_Cursor to make supporting cursors on other platforms cleaner. -2012-05-30 Rob Bradford +2012-05-30 Rob Bradford * Add support for setting the cursor under Wayland: * Introduce a configure option and #define to as per other engines @@ -140,91 +140,94 @@ * Call into Ecore to set the cursor when the mouse enters the desired widget. -2012-05-30 Mike Blumenkrantz +2012-05-30 Mike Blumenkrantz * Fix even/odd signals for genlist items -2012-05-30 Thiep Ha +2012-05-30 Thiep Ha * Entry: Add 3 APIs which are elm_entry_text_style_user_push/pop/peek and test functions for these APIs. -2012-05-31 WooHyun Jung +2012-05-31 WooHyun Jung * child_can_focus should be EINA_FALSE only when all children in the object tree are not focusable. Before this fix, it was EINA_FALSE when all sub objects were not focusable. (i.e. didn't check whole object tree) -2012-06-01 Mike Blumenkrantz +2012-06-01 Mike Blumenkrantz * Re-setting the current mirrored mode state no longer causes a full recalc -2012-06-07 Jaehwan Kim +2012-06-07 Jaehwan Kim * Toolbar: Remove the APIs elm_toolbar_items_max_set/get. Instead of them, add the APIs elm_toolbar_standard_priority_set/get. The items which are lower than standard priority are located in more menu or panel. -2012-06-08 Jaehwan Kim +2012-06-08 Jaehwan Kim - * Add elm_object_scroll_hold/freeze_get. + * Add elm_object_scroll_hold/freeze_get. -2012-06-12 ChunEon Park(Hermet) +2012-06-12 ChunEon Park (Hermet) * Fixed Transit wipe effect flickering. -2012-06-12 Carsten Haitzler (The Rasterman) +2012-06-12 Carsten Haitzler (The Rasterman) * Add elm_win_size_base_set/get, elm_win_size_step_set/get for hinting sizing of windows. Useful for terminals. -2012-06-12 Mike Blumenkrantz +2012-06-12 Mike Blumenkrantz * Map no longer saves its files to directories outside of the user's home directory -2012-06-14 Seunggyun Kim +2012-06-14 Seunggyun Kim * Fix elm_config_font_overlay_apply() to also apply rescaling properly. -2012-06-14 Jaehwan Kim +2012-06-14 Jaehwan Kim * Toolbar : Add the reorder feature when the more panel is shown. After the item is long-pressed, it can be moved. -2012-06-14 Michael Bouchaud +2012-06-14 Michael Bouchaud * Add an enum to Elm_Calendar_Mark_Repeat_Type: ELM_CALENDAR_LAST_DAY_OF_MONTH -2012-06-15 Michael Bouchaud +2012-06-15 Michael Bouchaud * elm_progressbar: elm_progressbar_format_function_set to add a callback function to format the unit string. -2012-06-16 Davide Andreoli +2012-06-16 Davide Andreoli * elm_map: add elm_map_overlay_del_cb_set to be notify when an overlay is deleted. -2012-06-21 Daniel Juyung Seo (SeoZ) +2012-06-21 Daniel Juyung Seo (SeoZ) * Genlist: Fixed a bug with decorate all mode + tree effect. Delete tree effect animator and set the effect mode to none when decorate all mode is set. -2012-06-23 Daniel Willmann +2012-06-23 Daniel Willmann * elm_progressbar: Add "changed" signal to be emitted when the value is changed. -2012-06-25 Daniel Juyung Seo (SeoZ) +2012-06-25 Daniel Juyung Seo (SeoZ) * Genlist: Fixed tree expand bug. Check item type when an item is requested to be expanded/contracted. -2012-06-25 Carsten Haitzler (The Rasterman) +2012-06-25 Carsten Haitzler (The Rasterman) * add elm_cnp_selection_loss_callback_set() so you know when you lose a selection as a client * improve robustness of cnp to track target object deletions. +2012-06-26 Shinwoo Kim (kimcinoo) + + * Use Edje to enable accessibility on TEXTBLOCK. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 4fa906fa8e..1534bb2a6f 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -15,6 +15,7 @@ Additions: * Add elm_progressbar_format_function_set API function * Add elm_map_overlay_del_cb_set API function * Add "changed" signal to the progressbar widgets + * Use Edje to enable accessibility on TEXTBLOCK. Fixes: diff --git a/legacy/elementary/src/lib/elm_access.c b/legacy/elementary/src/lib/elm_access.c index 4ea5582883..eb7605dba3 100644 --- a/legacy/elementary/src/lib/elm_access.c +++ b/legacy/elementary/src/lib/elm_access.c @@ -1,6 +1,44 @@ #include #include "elm_priv.h" +static const char ACCESS_SMART_NAME[] = "elm_access"; + +EVAS_SMART_SUBCLASS_NEW + (ACCESS_SMART_NAME, _elm_access, Elm_Widget_Smart_Class, + Elm_Widget_Smart_Class, elm_widget_smart_class_get, NULL); + +static Evas_Object * _elm_access_add(Evas_Object *parent); + +static void +_elm_access_smart_add(Evas_Object *obj) +{ + EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data); + ELM_WIDGET_CLASS(_elm_access_parent_sc)->base.add(obj); + + elm_widget_can_focus_set(obj, EINA_TRUE); +} + +static Eina_Bool +_elm_access_smart_on_focus(Evas_Object *obj) +{ + evas_object_focus_set(obj, elm_widget_focus_get(obj)); + + return EINA_TRUE; +} + +static void +_elm_access_smart_set_user(Elm_Widget_Smart_Class *sc) +{ + sc->base.add = _elm_access_smart_add; + + /* not a 'focus chain manager' */ + sc->focus_next = NULL; + sc->focus_direction = NULL; + sc->on_focus = _elm_access_smart_on_focus; + + return; +} + typedef struct _Mod_Api Mod_Api; struct _Mod_Api @@ -197,6 +235,11 @@ _access_obj_hilight_resize_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Ob //-------------------------------------------------------------------------// +EAPI void +_elm_access_highlight_set(Evas_Object* obj) +{ + _access_obj_over_timeout_cb(obj); +} EAPI void _elm_access_clear(Elm_Access_Info *ac) @@ -383,6 +426,92 @@ _elm_access_object_unhilight(Evas_Object *obj) } } +static void +_content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, + void *event_info __UNUSED__) +{ + Evas_Object *accessobj; + Evas_Coord w, h; + + accessobj = data; + if (!accessobj) return; + + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + evas_object_resize(accessobj, w, h); +} + +static void +_content_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, + void *event_info __UNUSED__) +{ + Evas_Object *accessobj; + Evas_Coord x, y; + + accessobj = data; + if (!accessobj) return; + + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + evas_object_move(accessobj, x, y); +} + +static char * +_part_access_info_cb(void *data, Evas_Object *obj, + Elm_Widget_Item *item __UNUSED__) +{ + Evas_Object *eobj = data; + if (!eobj) return NULL; + + const char *part = evas_object_data_get(obj, "_elm_access_part"); + const char *txt = edje_object_part_text_get(eobj, part); + if (txt) return strdup(txt); + return NULL; +} + +static void +_access_obj_del(void *data __UNUSED__, Evas *e __UNUSED__, + Evas_Object *obj, void *event_info __UNUSED__) +{ + char *part = evas_object_data_get(obj, "_elm_access_part"); + evas_object_data_del(obj, "_elm_access_part"); + if (part) free(part); +} + +EAPI Evas_Object * +_elm_access_edje_object_part_object_register(Evas_Object* obj, + const Evas_Object *eobj, + const char* part) +{ + Evas_Object *ao; + Evas_Object *po = (Evas_Object *)edje_object_part_object_get(eobj, part); + Evas_Coord x, y, w, h; + + if (!obj || !po) return NULL; + + // create access object + ao = _elm_access_add(obj); + evas_object_event_callback_add(po, EVAS_CALLBACK_RESIZE, + _content_resize, ao); + evas_object_event_callback_add(po, EVAS_CALLBACK_MOVE, + _content_move, ao); + + evas_object_geometry_get(po, &x, &y, &w, &h); + evas_object_move(ao, x, y); + evas_object_resize(ao, w, h); + evas_object_show(ao); + + // register access object + _elm_access_object_register(ao, po); + _elm_access_text_set(_elm_access_object_get(ao), + ELM_ACCESS_TYPE, evas_object_type_get(po)); + evas_object_data_set(ao, "_elm_access_part", strdup(part)); + evas_object_event_callback_add(ao, EVAS_CALLBACK_DEL, + _access_obj_del, NULL); + _elm_access_callback_set(_elm_access_object_get(ao), + ELM_ACCESS_INFO, + _part_access_info_cb, eobj); + return ao; +} + EAPI void _elm_access_object_hilight_disable(Evas *e) { @@ -534,3 +663,22 @@ _elm_access_2nd_click_timeout(Evas_Object *obj) _access_2nd_click_del_cb, NULL); return EINA_FALSE; } + +static Evas_Object * +_elm_access_add(Evas_Object *parent) +{ + Evas *e; + Evas_Object *obj; + + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + + e = evas_object_evas_get(parent); + if (!e) return NULL; + + obj = evas_object_smart_add(e, _elm_access_smart_class_new()); + + if (!elm_widget_sub_object_add(parent, obj)) + ERR("could not add %p as sub object of %p", obj, parent); + + return obj; +} diff --git a/legacy/elementary/src/lib/elm_layout.c b/legacy/elementary/src/lib/elm_layout.c index bdde401358..63279b6c71 100644 --- a/legacy/elementary/src/lib/elm_layout.c +++ b/legacy/elementary/src/lib/elm_layout.c @@ -657,6 +657,10 @@ _elm_layout_smart_text_set(Evas_Object *obj, ELM_LAYOUT_CLASS(ELM_WIDGET_DATA(sd)->api)->sizing_eval(obj); + if (_elm_config->access_mode == ELM_ACCESS_MODE_ON && !(sub_d->obj)) + sub_d->obj = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), part); + return EINA_TRUE; } diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c index a0d3fe5ed6..c0a279f7ad 100644 --- a/legacy/elementary/src/lib/elm_toolbar.c +++ b/legacy/elementary/src/lib/elm_toolbar.c @@ -1425,8 +1425,9 @@ _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item) Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item), "elm.swallow.icon"); elm_widget_sub_object_del(VIEW(item), old_icon); - evas_object_hide(old_icon); + /* edje_object_part_unswallow(VIEW(item), old_icon); */ edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon); + evas_object_hide(old_icon); elm_coords_finger_size_adjust(1, &mw, 1, &mh); edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh); elm_coords_finger_size_adjust(1, &mw, 1, &mh); diff --git a/legacy/elementary/src/lib/elm_widget.c b/legacy/elementary/src/lib/elm_widget.c index 8bd0fe917a..f2a3ea8ede 100644 --- a/legacy/elementary/src/lib/elm_widget.c +++ b/legacy/elementary/src/lib/elm_widget.c @@ -839,6 +839,9 @@ _parent_focus(Evas_Object *obj) _elm_widget_focus_region_show(obj); } sd->focus_order_on_calc = EINA_FALSE; + + if (_elm_config->access_mode == ELM_ACCESS_MODE_ON) + _elm_access_highlight_set(obj); } static void diff --git a/legacy/elementary/src/lib/elm_widget.h b/legacy/elementary/src/lib/elm_widget.h index 24609f507a..7ad3d417a8 100644 --- a/legacy/elementary/src/lib/elm_widget.h +++ b/legacy/elementary/src/lib/elm_widget.h @@ -551,6 +551,8 @@ EAPI void _elm_access_object_register(Evas_Object *obj, Evas_Object EAPI void _elm_access_item_unregister(Elm_Widget_Item *item); EAPI void _elm_access_item_register(Elm_Widget_Item *item, Evas_Object *hoverobj); EAPI Eina_Bool _elm_access_2nd_click_timeout(Evas_Object *obj); +EAPI void _elm_access_highlight_set(Evas_Object* obj); +EAPI Evas_Object * _elm_access_edje_object_part_object_register(Evas_Object *obj, const Evas_Object *partobj, const char* part); /**< put this as the first member in your widget item struct */ #define ELM_WIDGET_ITEM Elm_Widget_Item base