summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/lib/elm_access.c
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2013-04-18 10:52:01 +0900
committerShinwoo Kim <cinoo.kim@samsung.com>2013-04-18 10:52:01 +0900
commit8558d80ae1ff2d8457327a0e07e3b9012a67e8ac (patch)
treed3dba6b43dffef6df5d44bf76406fcff8a2b581a /legacy/elementary/src/lib/elm_access.c
parent22841e0c11a12916a82ebd17ef0571e264b41661 (diff)
[access] add elm_access_action(), elm_access_action_cb_set()
Diffstat (limited to 'legacy/elementary/src/lib/elm_access.c')
-rw-r--r--legacy/elementary/src/lib/elm_access.c285
1 files changed, 278 insertions, 7 deletions
diff --git a/legacy/elementary/src/lib/elm_access.c b/legacy/elementary/src/lib/elm_access.c
index 06d9ca1..db4a734 100644
--- a/legacy/elementary/src/lib/elm_access.c
+++ b/legacy/elementary/src/lib/elm_access.c
@@ -5,8 +5,25 @@
5 5
6#define MY_CLASS_NAME "elm_access" 6#define MY_CLASS_NAME "elm_access"
7 7
8struct _Func_Data
9{
10 void *user_data; /* Holds user data to CB */
11 Elm_Access_Action_Cb cb;
12};
13
14typedef struct _Func_Data Func_Data;
15
16struct _Action_Info
17{
18 Evas_Object *obj;
19 Func_Data fn[ELM_ACCESS_ACTION_LAST + 1]; /* Callback for specific action */
20};
21
22typedef struct _Action_Info Action_Info;
23
8static Eina_Bool mouse_event_enable = EINA_TRUE; 24static Eina_Bool mouse_event_enable = EINA_TRUE;
9static Eina_Bool read_mode = EINA_FALSE; 25static Eina_Bool read_mode = EINA_FALSE;
26static Elm_Access_Action_Type action_by = ELM_ACCESS_ACTION_FIRST;
10 27
11static Evas_Object * _elm_access_add(Evas_Object *parent); 28static Evas_Object * _elm_access_add(Evas_Object *parent);
12 29
@@ -18,6 +35,38 @@ _elm_access_smart_add(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
18 elm_widget_can_focus_set(obj, EINA_TRUE); 35 elm_widget_can_focus_set(obj, EINA_TRUE);
19} 36}
20 37
38static Eina_Bool
39_access_action_callback_call(Evas_Object *obj,
40 Elm_Access_Action_Type type,
41 Elm_Access_Action_Info *action_info)
42{
43 Elm_Access_Action_Info *ai = NULL;
44 Action_Info *a;
45 Eina_Bool ret;
46
47 ret = EINA_FALSE;
48 a = evas_object_data_get(obj, "_elm_access_action_info");
49
50 if (!action_info)
51 {
52 ai = calloc(1, sizeof(Elm_Access_Action_Info));
53 action_info = ai;
54 }
55
56 action_info->action_type = type;
57
58 if ((type == ELM_ACCESS_ACTION_HIGHLIGHT) &&
59 (action_by != ELM_ACCESS_ACTION_FIRST))
60 action_info->action_by = action_by;
61
62 if (a && (a->fn[type].cb))
63 ret = a->fn[type].cb(a->fn[type].user_data, obj, action_info);
64
65 if (ai) free(ai);
66
67 return ret;
68}
69
21static void 70static void
22_elm_access_smart_activate(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 71_elm_access_smart_activate(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
23{ 72{
@@ -25,6 +74,53 @@ _elm_access_smart_activate(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
25 Eina_Bool *ret = va_arg(*list, Eina_Bool *); 74 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
26 if (ret) *ret = EINA_FALSE; 75 if (ret) *ret = EINA_FALSE;
27 76
77 int type = ELM_ACCESS_ACTION_FIRST;
78
79 Action_Info *a;
80 a = evas_object_data_get(obj, "_elm_access_action_info");
81
82 switch (act)
83 {
84 case ELM_ACTIVATE_DEFAULT:
85 type = ELM_ACCESS_ACTION_ACTIVATE;
86 break;
87
88 case ELM_ACTIVATE_UP:
89 type = ELM_ACCESS_ACTION_UP;
90 break;
91
92 case ELM_ACTIVATE_DOWN:
93 type = ELM_ACCESS_ACTION_DOWN;
94 break;
95
96 case ELM_ACTIVATE_RIGHT:
97 break;
98
99 case ELM_ACTIVATE_LEFT:
100 break;
101
102 case ELM_ACTIVATE_BACK:
103 type = ELM_ACCESS_ACTION_BACK;
104 break;
105
106 default:
107 break;
108 }
109
110 if (type == ELM_ACCESS_ACTION_FIRST) return;
111
112 /* if an access object has a callback, it would have the intention to do
113 something. so, check here and return EINA_TRUE. */
114 if ((a) && (type > ELM_ACCESS_ACTION_FIRST) &&
115 (type < ELM_ACCESS_ACTION_LAST) &&
116 (a->fn[type].cb))
117 {
118 _access_action_callback_call(obj, type, NULL);
119 if (ret) *ret = EINA_TRUE;
120 return;
121 }
122
123 /* TODO: deprecate below? */
28 if (act != ELM_ACTIVATE_DEFAULT) return; 124 if (act != ELM_ACTIVATE_DEFAULT) return;
29 125
30 Elm_Access_Info *ac = evas_object_data_get(obj, "_elm_access"); 126 Elm_Access_Info *ac = evas_object_data_get(obj, "_elm_access");
@@ -380,6 +476,66 @@ _elm_access_widget_item_access_order_unset(Elm_Widget_Item *item)
380 item->access_order = eina_list_remove_list(item->access_order, l); 476 item->access_order = eina_list_remove_list(item->access_order, l);
381 } 477 }
382} 478}
479
480static Eina_Bool
481_access_highlight_next_get(Evas_Object *obj, Elm_Focus_Direction dir)
482{
483 int type;
484 Evas_Object *ho, *parent, *target;
485 Elm_Widget_Smart_Data *wd;
486 Eina_Bool ret;
487
488 target = NULL;
489 ret = EINA_FALSE;
490
491 if (!elm_widget_is(obj)) return ret;
492
493 ho = _access_highlight_object_get(obj);
494 if (!ho) ho = obj;
495
496 parent = ho;
497
498 /* find highlight root */
499 do
500 {
501 wd = eo_data_get(parent, ELM_OBJ_WIDGET_CLASS);
502 if (wd->highlight_root)
503 {
504 /* change highlight root */
505 obj = parent;
506 break;
507 }
508 parent = elm_widget_parent_get(parent);
509 }
510 while (parent);
511
512 _elm_access_read_mode_set(EINA_TRUE);
513
514 ret = elm_widget_focus_next_get(obj, dir, &target);
515 if (ret && target)
516 {
517 if (dir == ELM_FOCUS_NEXT)
518 type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
519 else
520 type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
521
522 if (!_access_action_callback_call(ho, type, NULL))
523 {
524 /* this value is used in _elm_access_object_highlight();
525 to inform the target object of how to get highlight */
526 action_by = type;
527
528 _elm_access_highlight_set(target);
529
530 action_by = ELM_ACCESS_ACTION_FIRST;
531 }
532 }
533
534 _elm_access_read_mode_set(EINA_FALSE);
535
536 return ret;
537}
538
383//-------------------------------------------------------------------------// 539//-------------------------------------------------------------------------//
384EAPI void 540EAPI void
385_elm_access_highlight_set(Evas_Object* obj) 541_elm_access_highlight_set(Evas_Object* obj)
@@ -476,27 +632,43 @@ _elm_access_highlight_object_activate(Evas_Object *obj, Elm_Activate act)
476EAPI void 632EAPI void
477_elm_access_highlight_cycle(Evas_Object *obj, Elm_Focus_Direction dir) 633_elm_access_highlight_cycle(Evas_Object *obj, Elm_Focus_Direction dir)
478{ 634{
635 int type;
636 Evas_Object *ho, *parent;
479 Elm_Widget_Smart_Data *wd; 637 Elm_Widget_Smart_Data *wd;
480 Evas_Object *ho; 638
481 ho = _access_highlight_object_get(obj); 639 ho = _access_highlight_object_get(obj);
482 if (!ho) return; 640 if (!ho) return;
483 641
642 parent = ho;
643
484 /* find highlight root */ 644 /* find highlight root */
485 do 645 do
486 { 646 {
487 wd = eo_data_get(ho, ELM_OBJ_WIDGET_CLASS); 647 wd = eo_data_get(parent, ELM_OBJ_WIDGET_CLASS);
488 if (wd->highlight_root) 648 if (wd->highlight_root)
489 { 649 {
490 /* change highlight root */ 650 /* change highlight root */
491 obj = ho; 651 obj = parent;
492 break; 652 break;
493 } 653 }
494 ho = elm_widget_parent_get(ho); 654 parent = elm_widget_parent_get(parent);
495 } 655 }
496 while (ho); 656 while (parent);
497 657
498 _elm_access_read_mode_set(EINA_TRUE); 658 _elm_access_read_mode_set(EINA_TRUE);
499 elm_widget_focus_cycle(obj, dir); 659
660 if (dir == ELM_FOCUS_NEXT)
661 type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
662 else
663 type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
664
665 action_by = type;
666
667 if (!_access_action_callback_call(ho, type, NULL))
668 elm_widget_focus_cycle(obj, dir);
669
670 action_by = ELM_ACCESS_ACTION_FIRST;
671
500 _elm_access_read_mode_set(EINA_FALSE); 672 _elm_access_read_mode_set(EINA_FALSE);
501} 673}
502 674
@@ -623,7 +795,13 @@ _elm_access_object_hilight(Evas_Object *obj)
623 evas_object_geometry_get(obj, &x, &y, &w, &h); 795 evas_object_geometry_get(obj, &x, &y, &w, &h);
624 evas_object_move(o, x, y); 796 evas_object_move(o, x, y);
625 evas_object_resize(o, w, h); 797 evas_object_resize(o, w, h);
626 evas_object_show(o); 798
799 /* use callback, should an access object do below every time when
800 * a window gets a client message ECORE_X_ATOM_E_ILLMUE_ACTION_READ? */
801 if (!_access_action_callback_call(obj, ELM_ACCESS_ACTION_HIGHLIGHT, NULL))
802 evas_object_show(o);
803 else
804 evas_object_hide(o);
627} 805}
628 806
629EAPI void 807EAPI void
@@ -840,6 +1018,10 @@ _elm_access_object_unregister(Evas_Object *obj, Evas_Object *hoverobj)
840 _elm_access_clear(ac); 1018 _elm_access_clear(ac);
841 free(ac); 1019 free(ac);
842 } 1020 }
1021
1022 Action_Info *a;
1023 a = evas_object_data_get(obj, "_elm_access_action_info");
1024 if (a) free(a);
843} 1025}
844 1026
845EAPI void 1027EAPI void
@@ -1005,6 +1187,95 @@ elm_access_highlight_set(Evas_Object* obj)
1005 _elm_access_highlight_set(obj); 1187 _elm_access_highlight_set(obj);
1006} 1188}
1007 1189
1190EAPI Eina_Bool
1191elm_access_action(Evas_Object *obj, const Elm_Access_Action_Type type, Elm_Access_Action_Info *action_info)
1192{
1193 Evas *evas;
1194 Evas_Object *ho;
1195 Elm_Access_Action_Info *a;
1196
1197 a = (Elm_Access_Action_Info *) action_info;
1198
1199 switch (type)
1200 {
1201 case ELM_ACCESS_ACTION_READ:
1202 case ELM_ACCESS_ACTION_HIGHLIGHT:
1203 evas = evas_object_evas_get(obj);
1204 if (!evas) return EINA_FALSE;
1205
1206 _elm_access_mouse_event_enabled_set(EINA_TRUE);
1207
1208 evas_event_feed_mouse_in(evas, 0, NULL);
1209 evas_event_feed_mouse_move(evas, a->x, a->y, 0, NULL);
1210 _elm_access_mouse_event_enabled_set(EINA_FALSE);
1211
1212 ho = _access_highlight_object_get(obj);
1213 if (ho)
1214 _access_action_callback_call(ho, ELM_ACCESS_ACTION_READ, a);
1215 break;
1216
1217 case ELM_ACCESS_ACTION_UNHIGHLIGHT:
1218 evas = evas_object_evas_get(obj);
1219 if (!evas) return EINA_FALSE;
1220 _elm_access_object_hilight_disable(evas);
1221 break;
1222
1223 case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
1224 if (a->highlight_cycle)
1225 _elm_access_highlight_cycle(obj, ELM_FOCUS_NEXT);
1226 else
1227 return _access_highlight_next_get(obj, ELM_FOCUS_NEXT);
1228 break;
1229
1230 case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
1231 if (a->highlight_cycle)
1232 _elm_access_highlight_cycle(obj, ELM_FOCUS_PREVIOUS);
1233 else
1234 return _access_highlight_next_get(obj, ELM_FOCUS_PREVIOUS);
1235 break;
1236
1237 case ELM_ACCESS_ACTION_ACTIVATE:
1238 _elm_access_highlight_object_activate(obj, ELM_ACTIVATE_DEFAULT);
1239 break;
1240
1241 case ELM_ACCESS_ACTION_UP:
1242 _elm_access_highlight_object_activate(obj, ELM_ACTIVATE_UP);
1243 break;
1244
1245 case ELM_ACCESS_ACTION_DOWN:
1246 _elm_access_highlight_object_activate(obj, ELM_ACTIVATE_DOWN);
1247 break;
1248
1249 case ELM_ACCESS_ACTION_SCROLL:
1250 //TODO: SCROLL HIGHLIGHT OBJECT
1251 break;
1252
1253 case ELM_ACCESS_ACTION_BACK:
1254 break;
1255
1256 default:
1257 break;
1258 }
1259
1260 return EINA_TRUE;
1261}
1262
1263EAPI void
1264elm_access_action_cb_set(Evas_Object *obj, const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data)
1265{
1266 Action_Info *a;
1267 a = evas_object_data_get(obj, "_elm_access_action_info");
1268
1269 if (!a)
1270 {
1271 a = calloc(1, sizeof(Action_Info));
1272 evas_object_data_set(obj, "_elm_access_action_info", a);
1273 }
1274
1275 a->obj = obj;
1276 a->fn[type].cb = cb;
1277 a->fn[type].user_data = (void *)data;
1278}
1008EAPI void 1279EAPI void
1009elm_access_external_info_set(Evas_Object *obj, const char *text) 1280elm_access_external_info_set(Evas_Object *obj, const char *text)
1010{ 1281{