summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-06 14:47:03 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-17 15:08:42 +0300
commit32c20501438751b9a90d2cc09a77df8b16938d27 (patch)
tree36348cce2deb6f35e4a25d225a7ff0860a7eaef0
parent5a414f40619ca1fe663830dd72a4ca0457c7493a (diff)
Porting to Eo: Elm Index item
-rw-r--r--src/lib/Makefile.am11
-rw-r--r--src/lib/elm_index.c241
-rw-r--r--src/lib/elm_index_common.h19
-rw-r--r--src/lib/elm_index_item.eo47
-rw-r--r--src/lib/elm_index_legacy.h10
-rw-r--r--src/lib/elm_widget_index.h22
6 files changed, 214 insertions, 136 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 39bacbe3f..a2566cc78 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -861,7 +861,9 @@ BUILT_SOURCES = \
861 elm_menu_item.eo.c \ 861 elm_menu_item.eo.c \
862 elm_menu_item.eo.h \ 862 elm_menu_item.eo.h \
863 elm_ctxpopup_item.eo.c \ 863 elm_ctxpopup_item.eo.c \
864 elm_ctxpopup_item.eo.h 864 elm_ctxpopup_item.eo.h \
865 elm_index_item.eo.c \
866 elm_index_item.eo.h
865 867
866elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 868elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
867elementaryeolianfiles_DATA = \ 869elementaryeolianfiles_DATA = \
@@ -964,7 +966,8 @@ elementaryeolianfiles_DATA = \
964 elm_slideshow_item.eo \ 966 elm_slideshow_item.eo \
965 elm_flipselector_item.eo \ 967 elm_flipselector_item.eo \
966 elm_menu_item.eo \ 968 elm_menu_item.eo \
967 elm_ctxpopup_item.eo 969 elm_ctxpopup_item.eo \
970 elm_index_item.eo
968 971
969EXTRA_DIST += ${elementaryeolianfiles_DATA} 972EXTRA_DIST += ${elementaryeolianfiles_DATA}
970 973
@@ -1067,6 +1070,7 @@ nodist_includesunstable_HEADERS = \
1067 elm_segment_control_item.eo.h \ 1070 elm_segment_control_item.eo.h \
1068 elm_flipselector_item.eo.h \ 1071 elm_flipselector_item.eo.h \
1069 elm_menu_item.eo.h \ 1072 elm_menu_item.eo.h \
1073 elm_index_item.eo.h \
1070 elm_ctxpopup_item.eo.h \ 1074 elm_ctxpopup_item.eo.h \
1071 elm_slideshow_item.eo.h \ 1075 elm_slideshow_item.eo.h \
1072 elm_layout.eo.legacy.h \ 1076 elm_layout.eo.legacy.h \
@@ -1140,7 +1144,8 @@ nodist_includesunstable_HEADERS = \
1140 elm_slideshow_item.eo.legacy.h \ 1144 elm_slideshow_item.eo.legacy.h \
1141 elm_flipselector_item.eo.legacy.h \ 1145 elm_flipselector_item.eo.legacy.h \
1142 elm_menu_item.eo.legacy.h \ 1146 elm_menu_item.eo.legacy.h \
1143 elm_ctxpopup_item.eo.legacy.h 1147 elm_ctxpopup_item.eo.legacy.h \
1148 elm_index_item.eo.legacy.h
1144 1149
1145if HAVE_CXX11 1150if HAVE_CXX11
1146 1151
diff --git a/src/lib/elm_index.c b/src/lib/elm_index.c
index 381fcf717..ea078ea8f 100644
--- a/src/lib/elm_index.c
+++ b/src/lib/elm_index.c
@@ -2,6 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#define ELM_WIDGET_ITEM_PROTECTED
5#include <Elementary.h> 6#include <Elementary.h>
6 7
7#include "elm_priv.h" 8#include "elm_priv.h"
@@ -40,11 +41,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
40}; 41};
41 42
42static void 43static void
43_item_free(Elm_Index_Item *it) 44_item_free(Elm_Index_Item_Data *it)
44{ 45{
45 ELM_INDEX_DATA_GET(WIDGET(it), sd); 46 ELM_INDEX_DATA_GET(WIDGET(it), sd);
46 47
47 sd->items = eina_list_remove(sd->items, it); 48 sd->items = eina_list_remove(sd->items, EO_OBJ(it));
48 49
49 if (it->omitted) 50 if (it->omitted)
50 it->omitted = eina_list_free(it->omitted); 51 it->omitted = eina_list_free(it->omitted);
@@ -67,14 +68,15 @@ _index_box_clear(Evas_Object *obj,
67 int level) 68 int level)
68{ 69{
69 Eina_List *l; 70 Eina_List *l;
70 Elm_Index_Item *it; 71 Elm_Object_Item *eo_item;
71 72
72 ELM_INDEX_DATA_GET(obj, sd); 73 ELM_INDEX_DATA_GET(obj, sd);
73 74
74 if (!sd->level_active[level]) return; 75 if (!sd->level_active[level]) return;
75 76
76 EINA_LIST_FOREACH(sd->items, l, it) 77 EINA_LIST_FOREACH(sd->items, l, eo_item)
77 { 78 {
79 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
78 if (it->level != level) continue; 80 if (it->level != level) continue;
79 ELM_SAFE_FREE(VIEW(it), evas_object_del); 81 ELM_SAFE_FREE(VIEW(it), evas_object_del);
80 } 82 }
@@ -98,7 +100,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
98{ 100{
99 const char *txt = NULL; 101 const char *txt = NULL;
100 102
101 Elm_Index_Item *it = (Elm_Index_Item *)data; 103 Elm_Index_Item_Data *it = (Elm_Index_Item_Data *)data;
102 ELM_INDEX_ITEM_CHECK_OR_RETURN(it, NULL); 104 ELM_INDEX_ITEM_CHECK_OR_RETURN(it, NULL);
103 105
104 txt = elm_widget_access_info_get(obj); 106 txt = elm_widget_access_info_get(obj);
@@ -108,17 +110,20 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
108 return NULL; 110 return NULL;
109} 111}
110 112
111static void 113EOLIAN static Evas_Object*
112_access_widget_item_register(Elm_Index_Item *it) 114_elm_index_item_elm_widget_item_access_register(Eo *eo_item, Elm_Index_Item_Data *it)
113{ 115{
114 Elm_Access_Info *ai; 116 Elm_Access_Info *ai;
115 117
116 _elm_access_widget_item_register((Elm_Widget_Item_Data *)it); 118 Evas_Object *ret = NULL;
119 eo_do_super(eo_item, ELM_INDEX_ITEM_CLASS, ret = elm_wdg_item_access_register());
117 120
118 ai = _elm_access_info_get(it->base.access_obj); 121 ai = _elm_access_info_get(it->base->access_obj);
119 122
120 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Index Item")); 123 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Index Item"));
121 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it); 124 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
125
126 return ret;
122} 127}
123 128
124static void 129static void
@@ -185,7 +190,8 @@ _index_box_auto_fill(Evas_Object *obj,
185 int i = 0, max_num_of_items = 0, num_of_items = 0, g = 0, skip = 0; 190 int i = 0, max_num_of_items = 0, num_of_items = 0, g = 0, skip = 0;
186 Eina_List *l; 191 Eina_List *l;
187 Eina_Bool rtl; 192 Eina_Bool rtl;
188 Elm_Index_Item *it, *head = NULL; 193 Elm_Object_Item *eo_item;
194 Elm_Index_Item_Data *head = NULL;
189 Evas_Coord mw, mh, ih; 195 Evas_Coord mw, mh, ih;
190 Evas_Object *o; 196 Evas_Object *o;
191 Elm_Index_Omit *om; 197 Elm_Index_Omit *om;
@@ -203,8 +209,9 @@ _index_box_auto_fill(Evas_Object *obj,
203 EINA_LIST_FREE(sd->omit, om) 209 EINA_LIST_FREE(sd->omit, om)
204 free(om); 210 free(om);
205 211
206 EINA_LIST_FOREACH(sd->items, l, it) 212 EINA_LIST_FOREACH(sd->items, l, eo_item)
207 { 213 {
214 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
208 if (it->omitted) 215 if (it->omitted)
209 it->omitted = eina_list_free(it->omitted); 216 it->omitted = eina_list_free(it->omitted);
210 if (it->head) it->head = NULL; 217 if (it->head) it->head = NULL;
@@ -220,8 +227,11 @@ _index_box_auto_fill(Evas_Object *obj,
220 227
221 evas_object_del(o); 228 evas_object_del(o);
222 229
223 EINA_LIST_FOREACH(sd->items, l, it) 230 EINA_LIST_FOREACH(sd->items, l, eo_item)
224 if (it->level == level) num_of_items++; 231 {
232 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
233 if (it->level == level) num_of_items++;
234 }
225 235
226 if (mh != 0) 236 if (mh != 0)
227 max_num_of_items = ih / mh; 237 max_num_of_items = ih / mh;
@@ -230,9 +240,10 @@ _index_box_auto_fill(Evas_Object *obj,
230 } 240 }
231 241
232 om = eina_list_nth(sd->omit, g); 242 om = eina_list_nth(sd->omit, g);
233 EINA_LIST_FOREACH(sd->items, l, it) 243 EINA_LIST_FOREACH(sd->items, l, eo_item)
234 { 244 {
235 const char *stacking; 245 const char *stacking;
246 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
236 247
237 if (it->level != level) continue; 248 if (it->level != level) continue;
238 249
@@ -312,7 +323,7 @@ _index_box_auto_fill(Evas_Object *obj,
312 // ACCESS 323 // ACCESS
313 if ((it->level == 0) && 324 if ((it->level == 0) &&
314 (_elm_config->access_mode == ELM_ACCESS_MODE_ON)) 325 (_elm_config->access_mode == ELM_ACCESS_MODE_ON))
315 _access_widget_item_register(it); 326 eo_do((Eo *)eo_item, elm_wdg_item_access_register());
316 } 327 }
317 328
318 evas_object_smart_calculate(sd->bx[level]); 329 evas_object_smart_calculate(sd->bx[level]);
@@ -323,7 +334,7 @@ EOLIAN static Eina_Bool
323_elm_index_elm_widget_theme_apply(Eo *obj, Elm_Index_Data *sd) 334_elm_index_elm_widget_theme_apply(Eo *obj, Elm_Index_Data *sd)
324{ 335{
325 Evas_Coord minw = 0, minh = 0; 336 Evas_Coord minw = 0, minh = 0;
326 Elm_Index_Item *it; 337 Elm_Object_Item *eo_item;
327 338
328 Eina_Bool int_ret = EINA_FALSE; 339 Eina_Bool int_ret = EINA_FALSE;
329 340
@@ -387,9 +398,10 @@ _elm_index_elm_widget_theme_apply(Eo *obj, Elm_Index_Data *sd)
387 } 398 }
388 else elm_layout_signal_emit(obj, "elm,state,inactive", "elm"); 399 else elm_layout_signal_emit(obj, "elm,state,inactive", "elm");
389 400
390 it = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level); 401 eo_item = elm_index_selected_item_get(obj, sd->level);
391 if (it) 402 if (eo_item)
392 { 403 {
404 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
393 if (it->head) 405 if (it->head)
394 edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm"); 406 edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm");
395 else 407 else
@@ -414,51 +426,61 @@ _elm_index_elm_layout_sizing_eval(Eo *obj, Elm_Index_Data *_pd EINA_UNUSED)
414 evas_object_size_hint_max_set(obj, -1, -1); 426 evas_object_size_hint_max_set(obj, -1, -1);
415} 427}
416 428
417static Eina_Bool 429EOLIAN static Eina_Bool
418_item_del_pre_hook(Elm_Object_Item *it) 430_elm_index_item_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Index_Item_Data *it)
419{ 431{
420 ELM_INDEX_DATA_GET(WIDGET(it), sd); 432 ELM_INDEX_DATA_GET(WIDGET(it), sd);
421 433
422 _item_free((Elm_Index_Item *)it); 434 _item_free(it);
423 _index_box_clear(WIDGET(it), sd->level); 435 _index_box_clear(WIDGET(it), sd->level);
424 436
425 return EINA_TRUE; 437 return EINA_TRUE;
426} 438}
427 439
428static Elm_Index_Item * 440EOLIAN static void
441_elm_index_item_eo_base_constructor(Eo *obj, Elm_Index_Item_Data *it)
442{
443 eo_do_super(obj, ELM_INDEX_ITEM_CLASS, eo_constructor());
444 it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
445}
446
447static Elm_Object_Item *
429_item_new(Evas_Object *obj, 448_item_new(Evas_Object *obj,
430 const char *letter, 449 const char *letter,
431 Evas_Smart_Cb func, 450 Evas_Smart_Cb func,
432 const void *data) 451 const void *data)
433{ 452{
434 Elm_Index_Item *it; 453 Eo *eo_item;
435 454
436 ELM_INDEX_DATA_GET(obj, sd); 455 ELM_INDEX_DATA_GET(obj, sd);
437 456
438 it = elm_widget_item_new(obj, Elm_Index_Item); 457 eo_item = eo_add (ELM_INDEX_ITEM_CLASS, obj);
439 if (!it) return NULL; 458 if (!eo_item) return NULL;
459
460 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
440 461
441 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
442 if (letter) it->letter = eina_stringshare_add(letter); 462 if (letter) it->letter = eina_stringshare_add(letter);
443 it->func = func; 463 it->func = func;
444 it->base.data = data; 464 it->base->data = data;
445 it->level = sd->level; 465 it->level = sd->level;
446 466
447 return it; 467 return (Elm_Object_Item *)eo_item;
448} 468}
449 469
450static Elm_Index_Item * 470static Elm_Index_Item_Data *
451_item_find(Evas_Object *obj, 471_item_find(Evas_Object *obj,
452 const void *data) 472 const void *data)
453{ 473{
454 Eina_List *l; 474 Eina_List *l;
455 Elm_Index_Item *it; 475 Elm_Object_Item *eo_item;
456 476
457 ELM_INDEX_DATA_GET(obj, sd); 477 ELM_INDEX_DATA_GET(obj, sd);
458 478
459 EINA_LIST_FOREACH(sd->items, l, it) 479 EINA_LIST_FOREACH(sd->items, l, eo_item)
460 if (it->base.data == data) return it; 480 {
461 481 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
482 if (it->base->data == data) return it;
483 }
462 return NULL; 484 return NULL;
463} 485}
464 486
@@ -482,7 +504,8 @@ _sel_eval(Evas_Object *obj,
482 Evas_Coord evy) 504 Evas_Coord evy)
483{ 505{
484 Evas_Coord x, y, w, h, bx, by, bw, bh, xx, yy; 506 Evas_Coord x, y, w, h, bx, by, bw, bh, xx, yy;
485 Elm_Index_Item *it, *it_closest, *it_last, *om_closest; 507 Elm_Index_Item_Data *it, *it_closest, *it_last, *om_closest;
508 Elm_Object_Item *eo_item;
486 char *label = NULL, *last = NULL; 509 char *label = NULL, *last = NULL;
487 double cdv = 0.5; 510 double cdv = 0.5;
488 Evas_Coord dist; 511 Evas_Coord dist;
@@ -500,8 +523,9 @@ _sel_eval(Evas_Object *obj,
500 dist = 0x7fffffff; 523 dist = 0x7fffffff;
501 evas_object_geometry_get(sd->bx[i], &bx, &by, &bw, &bh); 524 evas_object_geometry_get(sd->bx[i], &bx, &by, &bw, &bh);
502 525
503 EINA_LIST_FOREACH(sd->items, l, it) 526 EINA_LIST_FOREACH(sd->items, l, eo_item)
504 { 527 {
528 it = eo_data_scope_get((Eo *)eo_item, ELM_INDEX_ITEM_CLASS);
505 if (it->level != i) continue; 529 if (it->level != i) continue;
506 if (it->level != sd->level) 530 if (it->level != sd->level)
507 { 531 {
@@ -623,16 +647,16 @@ _sel_eval(Evas_Object *obj,
623 ret = eina_strbuf_string_steal(buf); 647 ret = eina_strbuf_string_steal(buf);
624 eina_strbuf_free(buf); 648 eina_strbuf_free(buf);
625 649
626 _elm_access_highlight_set(it->base.access_obj); 650 _elm_access_highlight_set(it->base->access_obj);
627 _elm_access_say(ret); 651 _elm_access_say(ret);
628 } 652 }
629 653
630 if (om_closest) 654 if (om_closest)
631 evas_object_smart_callback_call 655 evas_object_smart_callback_call
632 (obj, SIG_CHANGED, om_closest); 656 (obj, SIG_CHANGED, EO_OBJ(om_closest));
633 else 657 else
634 evas_object_smart_callback_call 658 evas_object_smart_callback_call
635 (obj, SIG_CHANGED, it); 659 (obj, SIG_CHANGED, EO_OBJ(it));
636 ecore_timer_del(sd->delay); 660 ecore_timer_del(sd->delay);
637 sd->delay = ecore_timer_add(sd->delay_change_time, 661 sd->delay = ecore_timer_add(sd->delay_change_time,
638 _delay_change_cb, obj); 662 _delay_change_cb, obj);
@@ -713,20 +737,21 @@ _on_mouse_up(void *data,
713 void *event_info) 737 void *event_info)
714{ 738{
715 Evas_Event_Mouse_Up *ev = event_info; 739 Evas_Event_Mouse_Up *ev = event_info;
716 Elm_Object_Item *item; 740 Elm_Object_Item *eo_item;
717 Elm_Index_Item *id_item; 741 Elm_Object_Item *eo_id_item;
718 742
719 ELM_INDEX_DATA_GET(data, sd); 743 ELM_INDEX_DATA_GET(data, sd);
720 744
721 if (ev->button != 1) return; 745 if (ev->button != 1) return;
722 sd->mouse_down = EINA_FALSE; 746 sd->mouse_down = EINA_FALSE;
723 item = elm_index_selected_item_get(data, sd->level); 747 eo_item = elm_index_selected_item_get(data, sd->level);
724 if (item) 748 if (eo_item)
725 { 749 {
726 evas_object_smart_callback_call(data, SIG_SELECTED, item); 750 evas_object_smart_callback_call(data, SIG_SELECTED, eo_item);
727 id_item = (Elm_Index_Item *)item; 751 eo_id_item = eo_item;
752 ELM_INDEX_ITEM_DATA_GET(eo_id_item, id_item);
728 if (id_item->func) 753 if (id_item->func)
729 id_item->func((void *)id_item->base.data, WIDGET(id_item), id_item); 754 id_item->func((void *)id_item->base->data, WIDGET(id_item), eo_id_item);
730 } 755 }
731 if (!sd->autohide_disabled) 756 if (!sd->autohide_disabled)
732 elm_layout_signal_emit(data, "elm,state,inactive", "elm"); 757 elm_layout_signal_emit(data, "elm,state,inactive", "elm");
@@ -812,7 +837,8 @@ _on_mouse_move_access(void *data,
812{ 837{
813 838
814 Evas_Event_Mouse_Down *ev = event_info; 839 Evas_Event_Mouse_Down *ev = event_info;
815 Elm_Index_Item *it, *it_closest; 840 Elm_Object_Item *eo_item;
841 Elm_Index_Item_Data *it_closest;
816 Eina_List *l; 842 Eina_List *l;
817 Evas_Coord dist = 0; 843 Evas_Coord dist = 0;
818 Evas_Coord x, y, w, h, xx, yy; 844 Evas_Coord x, y, w, h, xx, yy;
@@ -822,8 +848,9 @@ _on_mouse_move_access(void *data,
822 it_closest = NULL; 848 it_closest = NULL;
823 dist = 0x7fffffff; 849 dist = 0x7fffffff;
824 850
825 EINA_LIST_FOREACH(sd->items, l, it) 851 EINA_LIST_FOREACH(sd->items, l, eo_item)
826 { 852 {
853 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
827 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h); 854 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
828 xx = x + (w / 2); 855 xx = x + (w / 2);
829 yy = y + (h / 2); 856 yy = y + (h / 2);
@@ -838,7 +865,7 @@ _on_mouse_move_access(void *data,
838 } 865 }
839 866
840 if (it_closest) 867 if (it_closest)
841 _elm_access_highlight_set(it_closest->base.access_obj); 868 _elm_access_highlight_set(it_closest->base->access_obj);
842} 869}
843 870
844static void 871static void
@@ -863,14 +890,15 @@ _index_resize_cb(void *data EINA_UNUSED,
863 890
864 if (!sd->omit_enabled) return; 891 if (!sd->omit_enabled) return;
865 892
866 Elm_Index_Item *it; 893 Elm_Object_Item *eo_item;
867 894
868 _index_box_clear(obj, 0); 895 _index_box_clear(obj, 0);
869 _index_box_auto_fill(obj, 0); 896 _index_box_auto_fill(obj, 0);
870 897
871 it = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level); 898 eo_item = elm_index_selected_item_get(obj, sd->level);
872 if (it) 899 if (eo_item)
873 { 900 {
901 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
874 if (it->head) 902 if (it->head)
875 edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm"); 903 edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm");
876 else 904 else
@@ -962,7 +990,7 @@ _elm_index_evas_object_smart_del(Eo *obj, Elm_Index_Data *sd)
962 Elm_Index_Omit *o; 990 Elm_Index_Omit *o;
963 991
964 while (sd->items) 992 while (sd->items)
965 elm_widget_item_del(sd->items->data); 993 eo_do (sd->items->data, elm_wdg_item_del());
966 994
967 EINA_LIST_FREE(sd->omit, o) 995 EINA_LIST_FREE(sd->omit, o)
968 free(o); 996 free(o);
@@ -993,7 +1021,7 @@ _elm_index_elm_widget_focus_next(Eo *obj, Elm_Index_Data *sd, Elm_Focus_Directio
993 1021
994 Eina_List *items = NULL; 1022 Eina_List *items = NULL;
995 Eina_List *l = NULL; 1023 Eina_List *l = NULL;
996 Elm_Index_Item *it; 1024 Elm_Object_Item *eo_item;
997 Evas_Object *ao; 1025 Evas_Object *ao;
998 Evas_Object *po; 1026 Evas_Object *po;
999 1027
@@ -1005,10 +1033,11 @@ _elm_index_elm_widget_focus_next(Eo *obj, Elm_Index_Data *sd, Elm_Focus_Directio
1005 ao = evas_object_data_get(po, "_part_access_obj"); 1033 ao = evas_object_data_get(po, "_part_access_obj");
1006 items = eina_list_append(items, ao); 1034 items = eina_list_append(items, ao);
1007 1035
1008 EINA_LIST_FOREACH(sd->items, l, it) 1036 EINA_LIST_FOREACH(sd->items, l, eo_item)
1009 { 1037 {
1038 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
1010 if (it->level != 0) continue; 1039 if (it->level != 0) continue;
1011 items = eina_list_append(items, it->base.access_obj); 1040 items = eina_list_append(items, it->base->access_obj);
1012 } 1041 }
1013 1042
1014 int_ret = elm_widget_focus_list_next_get 1043 int_ret = elm_widget_focus_list_next_get
@@ -1025,15 +1054,16 @@ static void
1025_access_obj_process(Evas_Object *obj, Eina_Bool is_access) 1054_access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1026{ 1055{
1027 Eina_List *l; 1056 Eina_List *l;
1028 Elm_Index_Item *it; 1057 Elm_Object_Item *eo_item;
1029 1058
1030 ELM_INDEX_DATA_GET(obj, sd); 1059 ELM_INDEX_DATA_GET(obj, sd);
1031 1060
1032 EINA_LIST_FOREACH(sd->items, l, it) 1061 EINA_LIST_FOREACH(sd->items, l, eo_item)
1033 { 1062 {
1063 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
1034 if (it->level != 0) continue; 1064 if (it->level != 0) continue;
1035 if (is_access) _access_widget_item_register(it); 1065 if (is_access) eo_do((Eo *)eo_item, elm_wdg_item_access_register());
1036 else _elm_access_widget_item_unregister((Elm_Widget_Item_Data *)it); 1066 else eo_do((Eo *)eo_item, elm_wdg_item_access_unregister());
1037 } 1067 }
1038 1068
1039 if (is_access) 1069 if (is_access)
@@ -1128,25 +1158,33 @@ _elm_index_item_level_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd)
1128 1158
1129//FIXME: Should update indicator based on the autohidden status & indicator visibility 1159//FIXME: Should update indicator based on the autohidden status & indicator visibility
1130EAPI void 1160EAPI void
1131elm_index_item_selected_set(Elm_Object_Item *it, 1161elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1132 Eina_Bool selected) 1162{
1163 eo_do((Eo*)it, elm_obj_index_item_selected_set(selected));
1164}
1165
1166EOLIAN static void
1167_elm_index_item_selected_set(Eo *eo_it,
1168 Elm_Index_Item_Data *it,
1169 Eina_Bool selected)
1133{ 1170{
1134 Elm_Index_Item *it_sel, *it_last, *it_inactive, *it_active; 1171 Elm_Index_Item_Data *it_sel, *it_inactive, *it_active;
1135 Evas_Object *obj = WIDGET(it); 1172 Evas_Object *obj = WIDGET(it);
1136 1173
1137 ELM_INDEX_ITEM_CHECK_OR_RETURN(it); 1174 ELM_INDEX_ITEM_CHECK_OR_RETURN(it);
1138 ELM_INDEX_DATA_GET(obj, sd); 1175 ELM_INDEX_DATA_GET(obj, sd);
1139 1176
1140 selected = !!selected; 1177 selected = !!selected;
1141 it_sel = (Elm_Index_Item *)it; 1178 it_sel = it;
1142 if (it_sel->selected == selected) return; 1179 if (it_sel->selected == selected) return;
1143 1180
1144 if (selected) 1181 if (selected)
1145 { 1182 {
1146 it_last = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level); 1183 Elm_Object_Item *eo_it_last = elm_index_selected_item_get(obj, sd->level);
1147 1184
1148 if (it_last) 1185 if (eo_it_last)
1149 { 1186 {
1187 ELM_INDEX_ITEM_DATA_GET(eo_it_last, it_last);
1150 it_last->selected = EINA_FALSE; 1188 it_last->selected = EINA_FALSE;
1151 if (it_last->head) 1189 if (it_last->head)
1152 it_inactive = it_last->head; 1190 it_inactive = it_last->head;
@@ -1168,9 +1206,9 @@ elm_index_item_selected_set(Elm_Object_Item *it,
1168 edje_object_message_signal_process(VIEW(it_active)); 1206 edje_object_message_signal_process(VIEW(it_active));
1169 1207
1170 evas_object_smart_callback_call 1208 evas_object_smart_callback_call
1171 (obj, SIG_CHANGED, it); 1209 (obj, SIG_CHANGED, eo_it);
1172 evas_object_smart_callback_call 1210 evas_object_smart_callback_call
1173 (obj, SIG_SELECTED, it); 1211 (obj, SIG_SELECTED, eo_it);
1174 ecore_timer_del(sd->delay); 1212 ecore_timer_del(sd->delay);
1175 sd->delay = ecore_timer_add(sd->delay_change_time, 1213 sd->delay = ecore_timer_add(sd->delay_change_time,
1176 _delay_change_cb, obj); 1214 _delay_change_cb, obj);
@@ -1195,13 +1233,14 @@ EOLIAN static Elm_Object_Item*
1195_elm_index_selected_item_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd, int level) 1233_elm_index_selected_item_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd, int level)
1196{ 1234{
1197 Eina_List *l; 1235 Eina_List *l;
1198 Elm_Index_Item *it; 1236 Elm_Object_Item *eo_item;
1199 1237
1200 EINA_LIST_FOREACH(sd->items, l, it) 1238 EINA_LIST_FOREACH(sd->items, l, eo_item)
1201 { 1239 {
1240 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
1202 if ((it->selected) && (it->level == level)) 1241 if ((it->selected) && (it->level == level))
1203 { 1242 {
1204 return (Elm_Object_Item *)it; 1243 return (Elm_Object_Item *)eo_item;
1205 } 1244 }
1206 } 1245 }
1207 1246
@@ -1211,8 +1250,7 @@ _elm_index_selected_item_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd, int level)
1211EOLIAN static Elm_Object_Item* 1250EOLIAN static Elm_Object_Item*
1212_elm_index_item_append(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data) 1251_elm_index_item_append(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data)
1213{ 1252{
1214 Elm_Index_Item *it; 1253 Elm_Object_Item *it;
1215
1216 1254
1217 it = _item_new(obj, letter, func, data); 1255 it = _item_new(obj, letter, func, data);
1218 if (!it) return NULL; 1256 if (!it) return NULL;
@@ -1226,7 +1264,7 @@ _elm_index_item_append(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Sma
1226EOLIAN static Elm_Object_Item* 1264EOLIAN static Elm_Object_Item*
1227_elm_index_item_prepend(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data) 1265_elm_index_item_prepend(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data)
1228{ 1266{
1229 Elm_Index_Item *it; 1267 Elm_Object_Item *it;
1230 1268
1231 it = _item_new(obj, letter, func, data); 1269 it = _item_new(obj, letter, func, data);
1232 if (!it) return NULL; 1270 if (!it) return NULL;
@@ -1250,7 +1288,7 @@ elm_index_item_prepend_relative(Evas_Object *obj,
1250EOLIAN static Elm_Object_Item* 1288EOLIAN static Elm_Object_Item*
1251_elm_index_item_insert_after(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data) 1289_elm_index_item_insert_after(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data)
1252{ 1290{
1253 Elm_Index_Item *it; 1291 Elm_Object_Item *it;
1254 1292
1255 1293
1256 if (!after) return elm_index_item_append(obj, letter, func, data); 1294 if (!after) return elm_index_item_append(obj, letter, func, data);
@@ -1267,7 +1305,7 @@ _elm_index_item_insert_after(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *after
1267EOLIAN static Elm_Object_Item* 1305EOLIAN static Elm_Object_Item*
1268_elm_index_item_insert_before(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data) 1306_elm_index_item_insert_before(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data)
1269{ 1307{
1270 Elm_Index_Item *it; 1308 Elm_Object_Item *it;
1271 1309
1272 if (!before) return elm_index_item_prepend(obj, letter, func, data); 1310 if (!before) return elm_index_item_prepend(obj, letter, func, data);
1273 1311
@@ -1283,60 +1321,64 @@ _elm_index_item_insert_before(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *befo
1283EOLIAN static Elm_Object_Item* 1321EOLIAN static Elm_Object_Item*
1284_elm_index_item_sorted_insert(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func) 1322_elm_index_item_sorted_insert(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
1285{ 1323{
1286 Elm_Index_Item *it; 1324 Elm_Object_Item *eo_item;
1287 Eina_List *lnear; 1325 Eina_List *lnear;
1288 int cmp; 1326 int cmp;
1289 1327
1290 if (!(sd->items)) return elm_index_item_append(obj, letter, func, data); 1328 if (!(sd->items)) return elm_index_item_append(obj, letter, func, data);
1291 1329
1292 it = _item_new(obj, letter, func, data); 1330 eo_item = _item_new(obj, letter, func, data);
1293 if (!it) return NULL; 1331 if (!eo_item) return NULL;
1294 1332
1295 lnear = eina_list_search_sorted_near_list(sd->items, cmp_func, it, &cmp); 1333 lnear = eina_list_search_sorted_near_list(sd->items, cmp_func, eo_item, &cmp);
1296 if (cmp < 0) 1334 if (cmp < 0)
1297 sd->items = eina_list_append_relative_list(sd->items, it, lnear); 1335 sd->items = eina_list_append_relative_list(sd->items, eo_item, lnear);
1298 else if (cmp > 0) 1336 else if (cmp > 0)
1299 sd->items = eina_list_prepend_relative_list(sd->items, it, lnear); 1337 sd->items = eina_list_prepend_relative_list(sd->items, eo_item, lnear);
1300 else 1338 else
1301 { 1339 {
1302 /* If cmp_data_func is not provided, append a duplicated item */ 1340 /* If cmp_data_func is not provided, append a duplicated item */
1303 if (!cmp_data_func) 1341 if (!cmp_data_func)
1304 sd->items = eina_list_append_relative_list(sd->items, it, lnear); 1342 sd->items = eina_list_append_relative_list(sd->items, eo_item, lnear);
1305 else 1343 else
1306 { 1344 {
1307 Elm_Index_Item *p_it = eina_list_data_get(lnear); 1345 Elm_Object_Item *eo_p_it = eina_list_data_get(lnear);
1308 if (cmp_data_func(p_it->base.data, it->base.data) >= 0) 1346 ELM_INDEX_ITEM_DATA_GET(eo_p_it, p_it);
1309 p_it->base.data = it->base.data; 1347 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
1310 elm_widget_item_del(it); 1348 if (cmp_data_func(p_it->base->data, it->base->data) >= 0)
1311 it = NULL; 1349 p_it->base->data = it->base->data;
1350 eo_do((Eo *)eo_item, elm_wdg_item_del());
1351 eo_item = NULL;
1312 } 1352 }
1313 } 1353 }
1314 _index_box_clear(obj, sd->level); 1354 _index_box_clear(obj, sd->level);
1315 1355
1316 if (!it) return NULL; 1356 if (!eo_item) return NULL;
1317 else return (Elm_Object_Item *)it; 1357 else return (Elm_Object_Item *)eo_item;
1318} 1358}
1319 1359
1320EOLIAN static Elm_Object_Item* 1360EOLIAN static Elm_Object_Item*
1321_elm_index_item_find(Eo *obj, Elm_Index_Data *_pd EINA_UNUSED, const void *data) 1361_elm_index_item_find(Eo *obj, Elm_Index_Data *_pd EINA_UNUSED, const void *data)
1322{ 1362{
1323 return (Elm_Object_Item *)_item_find(obj, data); 1363 Elm_Index_Item_Data *it = _item_find(obj, data);
1364 return it?EO_OBJ(it):NULL;
1324} 1365}
1325 1366
1326EOLIAN static void 1367EOLIAN static void
1327_elm_index_item_clear(Eo *obj, Elm_Index_Data *sd) 1368_elm_index_item_clear(Eo *obj, Elm_Index_Data *sd)
1328{ 1369{
1329 Elm_Index_Item *it; 1370 Elm_Object_Item *eo_item;
1330 Eina_List *l, *clear = NULL; 1371 Eina_List *l, *clear = NULL;
1331 1372
1332 _index_box_clear(obj, sd->level); 1373 _index_box_clear(obj, sd->level);
1333 EINA_LIST_FOREACH(sd->items, l, it) 1374 EINA_LIST_FOREACH(sd->items, l, eo_item)
1334 { 1375 {
1376 ELM_INDEX_ITEM_DATA_GET(eo_item, it);
1335 if (it->level != sd->level) continue; 1377 if (it->level != sd->level) continue;
1336 clear = eina_list_append(clear, it); 1378 clear = eina_list_append(clear, eo_item);
1337 } 1379 }
1338 EINA_LIST_FREE(clear, it) 1380 EINA_LIST_FREE(clear, eo_item)
1339 elm_widget_item_del(it); 1381 eo_do((Eo *)eo_item, elm_wdg_item_del());
1340} 1382}
1341 1383
1342EOLIAN static void 1384EOLIAN static void
@@ -1374,9 +1416,13 @@ _elm_index_indicator_disabled_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd)
1374EAPI const char * 1416EAPI const char *
1375elm_index_item_letter_get(const Elm_Object_Item *it) 1417elm_index_item_letter_get(const Elm_Object_Item *it)
1376{ 1418{
1377 ELM_INDEX_ITEM_CHECK_OR_RETURN(it, NULL); 1419 return eo_do((Eo *)it, elm_obj_index_item_letter_get());
1420}
1378 1421
1379 return ((Elm_Index_Item *)it)->letter; 1422EOLIAN static const char *
1423_elm_index_item_letter_get(Eo *item EINA_UNUSED, Elm_Index_Item_Data *it)
1424{
1425 return it->letter;
1380} 1426}
1381 1427
1382EOLIAN static void 1428EOLIAN static void
@@ -1437,4 +1483,5 @@ _elm_index_class_constructor(Eo_Class *klass)
1437 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 1483 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
1438} 1484}
1439 1485
1486#include "elm_index_item.eo.c"
1440#include "elm_index.eo.c" 1487#include "elm_index.eo.c"
diff --git a/src/lib/elm_index_common.h b/src/lib/elm_index_common.h
index ccacf184b..7c87d35fd 100644
--- a/src/lib/elm_index_common.h
+++ b/src/lib/elm_index_common.h
@@ -1,21 +1,2 @@
1/**
2 * Set the selected state of an item.
3 *
4 * @param it The index item
5 * @param selected The selected state
6 *
7 * This sets the selected state of the given item @p it.
8 * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
9 *
10 * If a new item is selected the previously selected will be unselected.
11 * Previously selected item can be get with function
12 * elm_index_selected_item_get().
13 *
14 * Selected items will be highlighted.
15 *
16 * @see elm_index_selected_item_get()
17 *
18 * @ingroup Index
19 */
20EAPI void elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected); 1EAPI void elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
21 2
diff --git a/src/lib/elm_index_item.eo b/src/lib/elm_index_item.eo
new file mode 100644
index 000000000..57f57b659
--- /dev/null
+++ b/src/lib/elm_index_item.eo
@@ -0,0 +1,47 @@
1class Elm_Index_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_obj_index_item;
5 properties {
6 selected {
7 set {
8 /*@
9 Set the selected state of an item.
10
11 This sets the selected state of the given item @p it.
12 @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
13
14 If a new item is selected the previously selected will be unselected.
15 Previously selected item can be get with function
16 elm_index_selected_item_get().
17
18 Selected items will be highlighted.
19
20 @see elm_index_selected_item_get()
21
22 @ingroup Index
23 */
24 }
25 values {
26 Eina_Bool selected; /*@ EINA_TRUE if selected EINA_FALSE otherwise */
27 }
28 }
29
30 }
31 methods {
32 letter_get @const {
33 /*@
34 Get the letter (string) set on a given index widget item.
35 @return The letter string set on @p item
36
37 @ingroup Index
38 */
39 return: const (char)*;
40 }
41 }
42 implements {
43 Eo.Base.constructor;
44 Elm_Widget_Item.access_register;
45 Elm_Widget_Item.del_pre;
46 }
47}
diff --git a/src/lib/elm_index_legacy.h b/src/lib/elm_index_legacy.h
index 5c805edf6..c78fcb829 100644
--- a/src/lib/elm_index_legacy.h
+++ b/src/lib/elm_index_legacy.h
@@ -11,14 +11,6 @@
11 */ 11 */
12EAPI Evas_Object *elm_index_add(Evas_Object *parent); 12EAPI Evas_Object *elm_index_add(Evas_Object *parent);
13 13
14/**
15 * Get the letter (string) set on a given index widget item.
16 *
17 * @param item The index item handle
18 * @return The letter string set on @p it
19 *
20 * @ingroup Index
21 */
22EAPI const char *elm_index_item_letter_get(const Elm_Object_Item *item); 14EAPI const char *elm_index_item_letter_get(const Elm_Object_Item *item);
23 15
24#include "elm_index.eo.legacy.h" \ No newline at end of file 16#include "elm_index.eo.legacy.h"
diff --git a/src/lib/elm_widget_index.h b/src/lib/elm_widget_index.h
index dd30545b9..f0fd20bee 100644
--- a/src/lib/elm_widget_index.h
+++ b/src/lib/elm_widget_index.h
@@ -2,6 +2,9 @@
2#define ELM_WIDGET_INDEX_H 2#define ELM_WIDGET_INDEX_H
3 3
4#include "Elementary.h" 4#include "Elementary.h"
5#include "elm_index_item.eo.h"
6
7#include "elm_object_item_migration_temp.h"
5 8
6/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR 9/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
7 * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT 10 * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
@@ -48,17 +51,17 @@ struct _Elm_Index_Data
48 Eina_Bool omit_enabled : 1; 51 Eina_Bool omit_enabled : 1;
49}; 52};
50 53
51typedef struct _Elm_Index_Item Elm_Index_Item; 54typedef struct _Elm_Index_Item_Data Elm_Index_Item_Data;
52struct _Elm_Index_Item 55struct _Elm_Index_Item_Data
53{ 56{
54 ELM_WIDGET_ITEM; 57 Elm_Widget_Item_Data *base;
55 58
56 const char *letter; 59 const char *letter;
57 int level; 60 int level;
58 Evas_Smart_Cb func; 61 Evas_Smart_Cb func;
59 62
60 Eina_List *omitted; 63 Eina_List *omitted;
61 Elm_Index_Item *head; 64 Elm_Index_Item_Data *head;
62 65
63 Eina_Bool selected : 1; /**< a flag that remembers an item is selected. this is set true when mouse down/move occur above an item and when elm_index_item_selected_set() API is called. */ 66 Eina_Bool selected : 1; /**< a flag that remembers an item is selected. this is set true when mouse down/move occur above an item and when elm_index_item_selected_set() API is called. */
64}; 67};
@@ -99,11 +102,14 @@ struct _Elm_Index_Omit
99 return 102 return
100 103
101#define ELM_INDEX_ITEM_CHECK(it) \ 104#define ELM_INDEX_ITEM_CHECK(it) \
102 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \ 105 if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_INDEX_ITEM_CLASS))) \
103 ELM_INDEX_CHECK(it->base.widget); 106 return
104 107
105#define ELM_INDEX_ITEM_CHECK_OR_RETURN(it, ...) \ 108#define ELM_INDEX_ITEM_CHECK_OR_RETURN(it, ...) \
106 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \ 109 if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_INDEX_ITEM_CLASS))) \
107 ELM_INDEX_CHECK(it->base.widget) __VA_ARGS__; 110 return __VA_ARGS__;
111
112#define ELM_INDEX_ITEM_DATA_GET(o, sd) \
113 Elm_Index_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_INDEX_ITEM_CLASS)
108 114
109#endif 115#endif