elementary: use Edje to enable accessibility on TEXTBLOCK.

Patch by Kim Shinwoo <kimcinoo.efl@gmail.com>.


SVN revision: 72841
This commit is contained in:
Cedric BAIL 2012-06-26 05:54:45 +00:00
parent b5e474ebb1
commit d78b70af51
7 changed files with 192 additions and 30 deletions

View File

@ -228,3 +228,6 @@
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.

View File

@ -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:

View File

@ -1,6 +1,44 @@
#include <Elementary.h>
#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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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

View File

@ -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