summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-29 13:50:05 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-17 15:08:41 +0300
commitd344d99974c724b5a849d2668479fef96b27b6a0 (patch)
tree4fdc36565847715cda6a9a19f22bd1915e6bc7f1
parent58e69ee199a11545c994a6b395a199b70b927398 (diff)
Porting to Eo: Elm Segment Control Item
-rw-r--r--src/lib/Makefile.am12
-rw-r--r--src/lib/elm_segment_control.c251
-rw-r--r--src/lib/elm_segment_control_common.h43
-rw-r--r--src/lib/elm_segment_control_item.eo65
-rw-r--r--src/lib/elm_widget_segment_control.h24
5 files changed, 233 insertions, 162 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 06e8f2ea8..95647172e 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -851,7 +851,9 @@ BUILT_SOURCES = \
851 elm_dayselector_item.eo.c \ 851 elm_dayselector_item.eo.c \
852 elm_dayselector_item.eo.h \ 852 elm_dayselector_item.eo.h \
853 elm_hoversel_item.eo.c \ 853 elm_hoversel_item.eo.c \
854 elm_hoversel_item.eo.h 854 elm_hoversel_item.eo.h \
855 elm_segment_control_item.eo.c \
856 elm_segment_control_item.eo.h
855 857
856elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 858elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
857elementaryeolianfiles_DATA = \ 859elementaryeolianfiles_DATA = \
@@ -949,7 +951,9 @@ elementaryeolianfiles_DATA = \
949 elm_widget_item.eo \ 951 elm_widget_item.eo \
950 elm_color_item.eo \ 952 elm_color_item.eo \
951 elm_dayselector_item.eo \ 953 elm_dayselector_item.eo \
952 elm_hoversel_item.eo 954 elm_hoversel_item.eo \
955 elm_segment_control_item.eo
956
953 957
954EXTRA_DIST += ${elementaryeolianfiles_DATA} 958EXTRA_DIST += ${elementaryeolianfiles_DATA}
955 959
@@ -1049,6 +1053,7 @@ nodist_includesunstable_HEADERS = \
1049 elm_color_item.eo.h \ 1053 elm_color_item.eo.h \
1050 elm_dayselector_item.eo.h \ 1054 elm_dayselector_item.eo.h \
1051 elm_hoversel_item.eo.h \ 1055 elm_hoversel_item.eo.h \
1056 elm_segment_control_item.eo.h \
1052 elm_layout.eo.legacy.h \ 1057 elm_layout.eo.legacy.h \
1053 elm_frame.eo.legacy.h \ 1058 elm_frame.eo.legacy.h \
1054 elm_hover.eo.legacy.h \ 1059 elm_hover.eo.legacy.h \
@@ -1115,7 +1120,8 @@ nodist_includesunstable_HEADERS = \
1115 elm_widget_item.eo.legacy.h \ 1120 elm_widget_item.eo.legacy.h \
1116 elm_color_item.eo.legacy.h \ 1121 elm_color_item.eo.legacy.h \
1117 elm_dayselector_item.eo.legacy.h \ 1122 elm_dayselector_item.eo.legacy.h \
1118 elm_hoversel_item.eo.legacy.h 1123 elm_hoversel_item.eo.legacy.h \
1124 elm_segment_control_item.eo.legacy.h
1119 1125
1120if HAVE_CXX11 1126if HAVE_CXX11
1121 1127
diff --git a/src/lib/elm_segment_control.c b/src/lib/elm_segment_control.c
index dff899fb0..13668d2cf 100644
--- a/src/lib/elm_segment_control.c
+++ b/src/lib/elm_segment_control.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"
@@ -27,11 +28,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
27EOLIAN static Eina_Bool 28EOLIAN static Eina_Bool
28_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd) 29_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
29{ 30{
30 Elm_Segment_Item *it; 31 Elm_Object_Item *it;
31 Eina_List *l; 32 Eina_List *l;
32 33
33 EINA_LIST_FOREACH(sd->items, l, it) 34 EINA_LIST_FOREACH(sd->items, l, it)
34 elm_widget_item_translate(it); 35 eo_do((Eo *)it, elm_wdg_item_translate());
35 36
36 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate()); 37 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
37 38
@@ -63,12 +64,12 @@ _elm_segment_control_elm_layout_sizing_eval(Eo *obj, Elm_Segment_Control_Data *s
63} 64}
64 65
65static void 66static void
66_item_free(Elm_Segment_Item *it) 67_item_free(Elm_Segment_Control_Item_Data *it)
67{ 68{
68 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 69 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
69 70
70 if (sd->selected_item == it) sd->selected_item = NULL; 71 if (sd->selected_item == it) sd->selected_item = NULL;
71 if (sd->items) sd->items = eina_list_remove(sd->items, it); 72 if (sd->items) sd->items = eina_list_remove(sd->items, EO_OBJ(it));
72 73
73 evas_object_del(it->icon); 74 evas_object_del(it->icon);
74 eina_stringshare_del(it->label); 75 eina_stringshare_del(it->label);
@@ -80,7 +81,7 @@ _position_items(Elm_Segment_Control_Data *sd)
80 Eina_List *l; 81 Eina_List *l;
81 Eina_Bool rtl; 82 Eina_Bool rtl;
82 int item_count; 83 int item_count;
83 Elm_Segment_Item *it; 84 Elm_Object_Item *eo_item;
84 int bx, by, bw, bh, pos; 85 int bx, by, bw, bh, pos;
85 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd); 86 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
86 87
@@ -95,8 +96,9 @@ _position_items(Elm_Segment_Control_Data *sd)
95 if (rtl) pos = bx + bw - sd->item_width; 96 if (rtl) pos = bx + bw - sd->item_width;
96 else pos = bx; 97 else pos = bx;
97 98
98 EINA_LIST_FOREACH(sd->items, l, it) 99 EINA_LIST_FOREACH(sd->items, l, eo_item)
99 { 100 {
101 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
100 evas_object_move(VIEW(it), pos, by); 102 evas_object_move(VIEW(it), pos, by);
101 evas_object_resize(VIEW(it), sd->item_width, bh); 103 evas_object_resize(VIEW(it), sd->item_width, bh);
102 if (rtl) pos -= sd->item_width; 104 if (rtl) pos -= sd->item_width;
@@ -107,7 +109,7 @@ _position_items(Elm_Segment_Control_Data *sd)
107} 109}
108 110
109static void 111static void
110_swallow_item_objects(Elm_Segment_Item *it) 112_swallow_item_objects(Elm_Segment_Control_Item_Data *it)
111{ 113{
112 if (!it) return; 114 if (!it) return;
113 115
@@ -136,7 +138,7 @@ _update_list(Elm_Segment_Control_Data *sd)
136 Eina_List *l; 138 Eina_List *l;
137 Eina_Bool rtl; 139 Eina_Bool rtl;
138 int item_count; 140 int item_count;
139 Elm_Segment_Item *it; 141 Elm_Object_Item *eo_it;
140 142
141 _position_items(sd); 143 _position_items(sd);
142 144
@@ -144,7 +146,9 @@ _update_list(Elm_Segment_Control_Data *sd)
144 146
145 if (item_count == 1) 147 if (item_count == 1)
146 { 148 {
147 it = eina_list_nth(sd->items, 0); 149 eo_it = eina_list_nth(sd->items, 0);
150 ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
151
148 it->seg_index = 0; 152 it->seg_index = 0;
149 153
150 //Set the segment type 154 //Set the segment type
@@ -167,8 +171,9 @@ _update_list(Elm_Segment_Control_Data *sd)
167 } 171 }
168 172
169 rtl = elm_widget_mirrored_get(sd->obj); 173 rtl = elm_widget_mirrored_get(sd->obj);
170 EINA_LIST_FOREACH(sd->items, l, it) 174 EINA_LIST_FOREACH(sd->items, l, eo_it)
171 { 175 {
176 ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
172 it->seg_index = idx; 177 it->seg_index = idx;
173 178
174 //Set the segment type 179 //Set the segment type
@@ -215,7 +220,7 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
215{ 220{
216 Eina_List *l; 221 Eina_List *l;
217 Eina_Bool rtl; 222 Eina_Bool rtl;
218 Elm_Segment_Item *it; 223 Elm_Object_Item *eo_item;
219 224
220 Eina_Bool int_ret = EINA_FALSE; 225 Eina_Bool int_ret = EINA_FALSE;
221 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply()); 226 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
@@ -223,8 +228,9 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
223 228
224 rtl = elm_widget_mirrored_get(obj); 229 rtl = elm_widget_mirrored_get(obj);
225 230
226 EINA_LIST_FOREACH(sd->items, l, it) 231 EINA_LIST_FOREACH(sd->items, l, eo_item)
227 { 232 {
233 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
228 elm_widget_theme_object_set 234 elm_widget_theme_object_set
229 (obj, VIEW(it), "segment_control", "item", 235 (obj, VIEW(it), "segment_control", "item",
230 elm_widget_style_get(obj)); 236 elm_widget_style_get(obj));
@@ -257,10 +263,11 @@ _elm_segment_control_elm_widget_disable(Eo *obj, Elm_Segment_Control_Data *sd)
257static void * 263static void *
258_elm_list_data_get(const Eina_List *list) 264_elm_list_data_get(const Eina_List *list)
259{ 265{
260 Elm_Segment_Item *it = eina_list_data_get(list); 266 Elm_Object_Item *eo_item = eina_list_data_get(list);
261 267
262 if (it) return NULL; 268 if (eo_item) return NULL;
263 269
270 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
264 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm"); 271 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
265 272
266 return VIEW(it); 273 return VIEW(it);
@@ -289,7 +296,7 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
289#endif 296#endif
290 297
291static void 298static void
292_segment_off(Elm_Segment_Item *it) 299_segment_off(Elm_Segment_Control_Item_Data *it)
293{ 300{
294 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 301 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
295 302
@@ -299,7 +306,7 @@ _segment_off(Elm_Segment_Item *it)
299} 306}
300 307
301static void 308static void
302_segment_on(Elm_Segment_Item *it) 309_segment_on(Elm_Segment_Control_Item_Data *it)
303{ 310{
304 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 311 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
305 312
@@ -310,7 +317,7 @@ _segment_on(Elm_Segment_Item *it)
310 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm"); 317 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
311 318
312 sd->selected_item = it; 319 sd->selected_item = it;
313 evas_object_smart_callback_call(sd->obj, SIG_CHANGED, it); 320 evas_object_smart_callback_call(sd->obj, SIG_CHANGED, EO_OBJ(it));
314} 321}
315 322
316static void 323static void
@@ -329,7 +336,7 @@ _on_mouse_up(void *data,
329 Evas_Object *obj EINA_UNUSED, 336 Evas_Object *obj EINA_UNUSED,
330 void *event_info) 337 void *event_info)
331{ 338{
332 Elm_Segment_Item *it = data; 339 Elm_Segment_Control_Item_Data *it = data;
333 Evas_Event_Mouse_Up *ev = event_info; 340 Evas_Event_Mouse_Up *ev = event_info;
334 Evas_Coord x, y, w, h; 341 Evas_Coord x, y, w, h;
335 342
@@ -357,7 +364,7 @@ _on_mouse_down(void *data,
357 Evas_Object *obj EINA_UNUSED, 364 Evas_Object *obj EINA_UNUSED,
358 void *event_info EINA_UNUSED) 365 void *event_info EINA_UNUSED)
359{ 366{
360 Elm_Segment_Item *it = data; 367 Elm_Segment_Control_Item_Data *it = data;
361 Evas_Event_Mouse_Down *ev = event_info; 368 Evas_Event_Mouse_Down *ev = event_info;
362 369
363 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 370 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
@@ -370,26 +377,26 @@ _on_mouse_down(void *data,
370 edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm"); 377 edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm");
371} 378}
372 379
373static Elm_Segment_Item * 380static Elm_Segment_Control_Item_Data *
374_item_find(const Evas_Object *obj, 381_item_find(const Evas_Object *obj,
375 int idx) 382 int idx)
376{ 383{
377 Elm_Segment_Item *it; 384 Elm_Object_Item *eo_it;
378 385
379 ELM_SEGMENT_CONTROL_DATA_GET(obj, sd); 386 ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
380 387
381 it = eina_list_nth(sd->items, idx); 388 eo_it = eina_list_nth(sd->items, idx);
389 ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
382 return it; 390 return it;
383} 391}
384 392
385static void 393EOLIAN static void
386_item_text_set_hook(Elm_Object_Item *it, 394_elm_segment_control_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
387 const char *part, 395 Elm_Segment_Control_Item_Data *item,
388 const char *label) 396 const char *part,
397 const char *label)
389{ 398{
390 Elm_Segment_Item *item;
391 char buf[1024]; 399 char buf[1024];
392 item = (Elm_Segment_Item *)it;
393 400
394 if ((!part) || (!strcmp(part, "default")) || 401 if ((!part) || (!strcmp(part, "default")) ||
395 (!strcmp(part, "elm.text"))) 402 (!strcmp(part, "elm.text")))
@@ -419,9 +426,10 @@ _item_text_set_hook(Elm_Object_Item *it,
419 edje_object_part_text_escaped_set(VIEW(item), part, label); 426 edje_object_part_text_escaped_set(VIEW(item), part, label);
420} 427}
421 428
422static const char * 429EOLIAN static const char *
423_item_text_get_hook(const Elm_Object_Item *it, 430_elm_segment_control_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
424 const char *part) 431 Elm_Segment_Control_Item_Data *it,
432 const char *part)
425{ 433{
426 char buf[1024]; 434 char buf[1024];
427 435
@@ -433,14 +441,13 @@ _item_text_get_hook(const Elm_Object_Item *it,
433 return edje_object_part_text_get(VIEW(it), buf); 441 return edje_object_part_text_get(VIEW(it), buf);
434} 442}
435 443
436static void 444EOLIAN static void
437_item_content_set_hook(Elm_Object_Item *it, 445_elm_segment_control_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
438 const char *part, 446 Elm_Segment_Control_Item_Data *item,
439 Evas_Object *content) 447 const char *part,
448 Evas_Object *content)
440{ 449{
441 Elm_Segment_Item *item;
442 char buf[1024]; 450 char buf[1024];
443 item = (Elm_Segment_Item *)it;
444 451
445 if (!part || !strcmp("icon", part)) 452 if (!part || !strcmp("icon", part))
446 { 453 {
@@ -461,7 +468,7 @@ _item_content_set_hook(Elm_Object_Item *it,
461 { 468 {
462 if (content) 469 if (content)
463 { 470 {
464 edje_object_part_swallow(VIEW(it), part, content); 471 edje_object_part_swallow(VIEW(item), part, content);
465 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part); 472 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
466 edje_object_signal_emit(VIEW(item), buf, "elm"); 473 edje_object_signal_emit(VIEW(item), buf, "elm");
467 } 474 }
@@ -473,13 +480,11 @@ _item_content_set_hook(Elm_Object_Item *it,
473 } 480 }
474} 481}
475 482
476static Evas_Object * 483EOLIAN static Evas_Object *
477_item_content_get_hook(const Elm_Object_Item *it, 484_elm_segment_control_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
478 const char *part) 485 Elm_Segment_Control_Item_Data *item,
486 const char *part)
479{ 487{
480 Elm_Segment_Item *item;
481 item = (Elm_Segment_Item *)it;
482
483 if (part && !strcmp(part, "icon")) 488 if (part && !strcmp(part, "icon"))
484 return item->icon; 489 return item->icon;
485 else 490 else
@@ -487,10 +492,9 @@ _item_content_get_hook(const Elm_Object_Item *it,
487} 492}
488 493
489static Eina_Bool 494static Eina_Bool
490_item_del_pre_hook(Elm_Object_Item *it) 495_elm_segment_control_item_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Segment_Control_Item_Data *item)
491{ 496{
492 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 497 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
493 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
494 498
495 _item_free(item); 499 _item_free(item);
496 _update_list(sd); 500 _update_list(sd);
@@ -502,7 +506,7 @@ static char *
502_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED) 506_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
503{ 507{
504 const char *txt = NULL; 508 const char *txt = NULL;
505 Elm_Segment_Item *it = (Elm_Segment_Item *)data; 509 Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
506 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL); 510 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
507 511
508 if (!txt) txt = it->label; 512 if (!txt) txt = it->label;
@@ -514,7 +518,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
514static char * 518static char *
515_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED) 519_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
516{ 520{
517 Elm_Segment_Item *it = (Elm_Segment_Item *)data; 521 Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
518 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL); 522 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
519 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 523 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
520 ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL); 524 ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL);
@@ -528,45 +532,35 @@ _access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
528 return strdup(E_("State: Unselected")); 532 return strdup(E_("State: Unselected"));
529} 533}
530 534
531static void 535static Evas_Object*
532_access_widget_item_register(Elm_Segment_Item *it) 536_elm_segment_control_item_elm_widget_item_access_register(Eo *eo_it EINA_UNUSED,
537 Elm_Segment_Control_Item_Data *it)
533{ 538{
534 Elm_Access_Info *ai; 539 Elm_Access_Info *ai;
540 Evas_Object *ret;
535 541
536 _elm_access_widget_item_register((Elm_Widget_Item_Data *)it); 542 eo_do_super(eo_it, ELM_SEGMENT_CONTROL_ITEM_CLASS, ret = elm_wdg_item_access_register());
537 543
538 ai = _elm_access_info_get(it->base.access_obj); 544 ai = _elm_access_info_get(it->base->access_obj);
539 545
540 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Segment Control Item")); 546 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Segment Control Item"));
541 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it); 547 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
542 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it); 548 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
549
550 return ret;
543} 551}
544 552
545static Elm_Segment_Item * 553static Elm_Object_Item *
546_item_new(Evas_Object *obj, 554_item_new(Evas_Object *obj,
547 Evas_Object *icon, 555 Evas_Object *icon,
548 const char *label) 556 const char *label)
549{ 557{
550 Elm_Segment_Item *it; 558 Eo *eo_item;
551 559
552 it = elm_widget_item_new(obj, Elm_Segment_Item); 560 eo_item = eo_add(ELM_SEGMENT_CONTROL_ITEM_CLASS, obj);
553 if (!it) return NULL; 561 if (!eo_item) return NULL;
554 562
555 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); 563 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
556 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
557 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
558 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
559 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
560
561 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
562 edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
563 elm_config_scale_get());
564 evas_object_smart_member_add(VIEW(it), obj);
565
566 elm_widget_sub_object_add(obj, VIEW(it));
567 elm_widget_theme_object_set
568 (obj, VIEW(it), "segment_control", "item", elm_object_style_get(obj));
569 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
570 564
571 if (label) eina_stringshare_replace(&it->label, label); 565 if (label) eina_stringshare_replace(&it->label, label);
572 if (it->label) 566 if (it->label)
@@ -586,9 +580,29 @@ _item_new(Evas_Object *obj,
586 580
587 // ACCESS 581 // ACCESS
588 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON) 582 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
589 _access_widget_item_register(it); 583 eo_do(eo_item, elm_wdg_item_access_register());
590 584
591 return it; 585 return (Elm_Object_Item *)eo_item;
586}
587
588EOLIAN static void
589_elm_segment_control_item_eo_base_constructor(Eo *obj, Elm_Segment_Control_Item_Data *it)
590{
591 eo_do_super(obj, ELM_SEGMENT_CONTROL_ITEM_CLASS, eo_constructor());
592 it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
593
594 Evas_Object *parent;
595 eo_do (obj, parent = eo_parent_get());
596
597 VIEW(it) = edje_object_add(evas_object_evas_get(parent));
598 edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
599 elm_config_scale_get());
600 evas_object_smart_member_add(VIEW(it), parent);
601
602 elm_widget_sub_object_add(parent, VIEW(it));
603 elm_widget_theme_object_set
604 (parent, VIEW(it), "segment_control", "item", elm_object_style_get(parent));
605 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
592} 606}
593 607
594EOLIAN static void 608EOLIAN static void
@@ -612,12 +626,13 @@ _elm_segment_control_evas_object_smart_add(Eo *obj, Elm_Segment_Control_Data *_p
612EOLIAN static void 626EOLIAN static void
613_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd) 627_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd)
614{ 628{
615 Elm_Segment_Item *it; 629 Elm_Object_Item *eo_it;
616 630
617 EINA_LIST_FREE(sd->items, it) 631 EINA_LIST_FREE(sd->items, eo_it)
618 { 632 {
633 ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
619 _item_free(it); 634 _item_free(it);
620 elm_widget_item_free(it); 635 eo_del((Eo *)eo_it);
621 } 636 }
622 637
623 eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); 638 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
@@ -636,12 +651,15 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
636{ 651{
637 Eina_List *items = NULL; 652 Eina_List *items = NULL;
638 Eina_List *l; 653 Eina_List *l;
639 Elm_Segment_Item *it; 654 Elm_Object_Item *eo_item;
640 655
641 ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE; 656 ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE;
642 657
643 EINA_LIST_FOREACH(sd->items, l, it) 658 EINA_LIST_FOREACH(sd->items, l, eo_item)
644 items = eina_list_append(items, it->base.access_obj); 659 {
660 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
661 items = eina_list_append(items, it->base->access_obj);
662 }
645 663
646 return elm_widget_focus_list_next_get 664 return elm_widget_focus_list_next_get
647 (obj, items, eina_list_data_get, dir, next); 665 (obj, items, eina_list_data_get, dir, next);
@@ -657,13 +675,13 @@ static void
657_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access) 675_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access)
658{ 676{
659 Eina_List *l; 677 Eina_List *l;
660 Elm_Segment_Item *it; 678 Eo *eo_item;
661 679
662 EINA_LIST_FOREACH(sd->items, l, it) 680 EINA_LIST_FOREACH(sd->items, l, eo_item)
663 { 681 {
664 if (is_access) _access_widget_item_register(it); 682 if (is_access) eo_do(eo_item, elm_wdg_item_access_register());
665 else 683 else
666 _elm_access_widget_item_unregister((Elm_Widget_Item_Data *)it); 684 eo_do(eo_item, elm_wdg_item_access_unregister());
667 } 685 }
668} 686}
669 687
@@ -698,53 +716,53 @@ _elm_segment_control_eo_base_constructor(Eo *obj, Elm_Segment_Control_Data *sd)
698EOLIAN static Elm_Object_Item* 716EOLIAN static Elm_Object_Item*
699_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label) 717_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label)
700{ 718{
701 Elm_Segment_Item *it; 719 Elm_Object_Item *eo_item;
702
703 720
704 it = _item_new(obj, icon, label); 721 eo_item = _item_new(obj, icon, label);
705 if (!it) return NULL; 722 if (!eo_item) return NULL;
706 723
707 sd->items = eina_list_append(sd->items, it); 724 sd->items = eina_list_append(sd->items, eo_item);
708 _update_list(sd); 725 _update_list(sd);
709 726
710 return (Elm_Object_Item *)it; 727 return (Elm_Object_Item *)eo_item;
711} 728}
712 729
713EOLIAN static Elm_Object_Item* 730EOLIAN static Elm_Object_Item*
714_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx) 731_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx)
715{ 732{
716 Elm_Segment_Item *it, *it_rel; 733 Elm_Object_Item *eo_item;
734 Elm_Segment_Control_Item_Data *it_rel;
717 735
718 736
719 if (idx < 0) idx = 0; 737 if (idx < 0) idx = 0;
720 738
721 it = _item_new(obj, icon, label); 739 eo_item = _item_new(obj, icon, label);
722 if (!it) return NULL; 740 if (!eo_item) return NULL;
723 741
724 it_rel = _item_find(obj, idx); 742 it_rel = _item_find(obj, idx);
725 if (it_rel) sd->items = eina_list_prepend_relative(sd->items, it, it_rel); 743 if (it_rel) sd->items = eina_list_prepend_relative(sd->items, eo_item, EO_OBJ(it_rel));
726 else sd->items = eina_list_append(sd->items, it); 744 else sd->items = eina_list_append(sd->items, eo_item);
727 745
728 _update_list(sd); 746 _update_list(sd);
729 747
730 return (Elm_Object_Item *)it; 748 return (Elm_Object_Item *)eo_item;
731} 749}
732 750
733EOLIAN static void 751EOLIAN static void
734_elm_segment_control_item_del_at(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx) 752_elm_segment_control_item_del_at(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
735{ 753{
736 Elm_Segment_Item *it; 754 Elm_Segment_Control_Item_Data *it;
737 755
738 it = _item_find(obj, idx); 756 it = _item_find(obj, idx);
739 if (!it) return; 757 if (!it) return;
740 758
741 elm_widget_item_del((Elm_Object_Item *)it); 759 eo_do((Eo *)EO_OBJ(it), elm_wdg_item_del());
742} 760}
743 761
744EOLIAN static const char* 762EOLIAN static const char*
745_elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx) 763_elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
746{ 764{
747 Elm_Segment_Item *it; 765 Elm_Segment_Control_Item_Data *it;
748 766
749 it = _item_find(obj, idx); 767 it = _item_find(obj, idx);
750 if (it) return it->label; 768 if (it) return it->label;
@@ -755,7 +773,7 @@ _elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_
755EOLIAN static Evas_Object* 773EOLIAN static Evas_Object*
756_elm_segment_control_item_icon_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx) 774_elm_segment_control_item_icon_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
757{ 775{
758 Elm_Segment_Item *it = _item_find(obj, idx); 776 Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
759 if (it) return it->icon; 777 if (it) return it->icon;
760 return NULL; 778 return NULL;
761} 779}
@@ -769,25 +787,36 @@ _elm_segment_control_item_count_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Dat
769EAPI Evas_Object * 787EAPI Evas_Object *
770elm_segment_control_item_object_get(const Elm_Object_Item *it) 788elm_segment_control_item_object_get(const Elm_Object_Item *it)
771{ 789{
772 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL); 790 return eo_do((Eo*)it, elm_obj_segment_control_item_object_get());
791}
773 792
793EOLIAN static Evas_Object *
794_elm_segment_control_item_object_get(Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
795{
774 return VIEW(it); 796 return VIEW(it);
775} 797}
776 798
777EOLIAN static Elm_Object_Item* 799EOLIAN static Elm_Object_Item*
778_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd) 800_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
779{ 801{
780 return (Elm_Object_Item *)sd->selected_item; 802 Elm_Segment_Control_Item_Data *it = sd->selected_item;
803 return it?(Elm_Object_Item *)EO_OBJ(it):NULL;
781} 804}
782 805
783EAPI void 806EAPI void
784elm_segment_control_item_selected_set(Elm_Object_Item *it, 807elm_segment_control_item_selected_set(Elm_Object_Item *it,
785 Eina_Bool selected) 808 Eina_Bool selected)
786{ 809{
787 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 810 eo_do((Eo*)it, elm_obj_segment_control_item_selected_set(selected));
811}
788 812
789 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it); 813EOLIAN static void
790 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 814_elm_segment_control_item_selected_set(Eo *eo_item EINA_UNUSED,
815 Elm_Segment_Control_Item_Data *item,
816 Eina_Bool selected)
817{
818 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(item);
819 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
791 820
792 if (item == sd->selected_item) 821 if (item == sd->selected_item)
793 { 822 {
@@ -804,15 +833,22 @@ elm_segment_control_item_selected_set(Elm_Object_Item *it,
804EOLIAN static Elm_Object_Item* 833EOLIAN static Elm_Object_Item*
805_elm_segment_control_item_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx) 834_elm_segment_control_item_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
806{ 835{
807 return (Elm_Object_Item *)_item_find(obj, idx); 836 Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
837 return it?(Elm_Object_Item *)EO_OBJ(it):NULL;
808} 838}
809 839
810EAPI int 840EAPI int
811elm_segment_control_item_index_get(const Elm_Object_Item *it) 841elm_segment_control_item_index_get(const Elm_Object_Item *it)
812{ 842{
843 return eo_do((Eo*)it, elm_obj_segment_control_item_index_get());
844}
845
846EOLIAN static int
847_elm_segment_control_item_index_get(Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
848{
813 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, -1); 849 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, -1);
814 850
815 return ((Elm_Segment_Item *)it)->seg_index; 851 return it->seg_index;
816} 852}
817 853
818EOLIAN static void 854EOLIAN static void
@@ -824,4 +860,5 @@ _elm_segment_control_class_constructor(Eo_Class *klass)
824 _elm_segment_control_smart_focus_next_enable = EINA_TRUE; 860 _elm_segment_control_smart_focus_next_enable = EINA_TRUE;
825} 861}
826 862
863#include "elm_segment_control_item.eo.c"
827#include "elm_segment_control.eo.c" 864#include "elm_segment_control.eo.c"
diff --git a/src/lib/elm_segment_control_common.h b/src/lib/elm_segment_control_common.h
index 6b586ec3d..026836cd9 100644
--- a/src/lib/elm_segment_control_common.h
+++ b/src/lib/elm_segment_control_common.h
@@ -1,49 +1,6 @@
1/**
2 * Get the index of an item.
3 *
4 * @param it The segment control item.
5 * @return The position of item in segment control widget.
6 *
7 * Index is the position of an item in segment control widget. Its
8 * range is from @c 0 to <tt> count - 1 </tt>.
9 * Count is the number of items, that can be get with
10 * elm_segment_control_item_count_get().
11 *
12 * @ingroup SegmentControl
13 */
14EAPI int elm_segment_control_item_index_get(const Elm_Object_Item *it); 1EAPI int elm_segment_control_item_index_get(const Elm_Object_Item *it);
15 2
16/**
17 * Get the real Evas(Edje) object created to implement the view of a given
18 * segment_control @p item.
19 *
20 * @param it The segment control item.
21 * @return The base Edje object associated with @p it.
22 *
23 * Base object is the @c Evas_Object that represents that item.
24 *
25 * @ingroup SegmentControl
26 */
27EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Object_Item *it); 3EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Object_Item *it);
28 4
29/**
30 * Set the selected state of an item.
31 *
32 * @param it The segment control item
33 * @param select The selected state
34 *
35 * This sets the selected state of the given item @p it.
36 * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
37 *
38 * If a new item is selected the previously selected will be unselected.
39 * Selected item can be got with function
40 * elm_segment_control_item_selected_get().
41 *
42 * The selected item always will be highlighted on segment control.
43 *
44 * @see elm_segment_control_item_selected_get()
45 *
46 * @ingroup SegmentControl
47 */
48EAPI void elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select); 5EAPI void elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);
49 6
diff --git a/src/lib/elm_segment_control_item.eo b/src/lib/elm_segment_control_item.eo
new file mode 100644
index 000000000..9d2396578
--- /dev/null
+++ b/src/lib/elm_segment_control_item.eo
@@ -0,0 +1,65 @@
1class Elm_Segment_Control_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_obj_segment_control_item;
5 methods {
6 index_get @const {
7 /*@
8 Get the index of an item.
9
10 Index is the position of an item in segment control widget. Its
11 range is from @c 0 to <tt> count - 1 </tt>.
12 Count is the number of items, that can be get with
13 elm_segment_control_item_count_get().
14
15 @return The position of item in segment control widget.
16
17 @ingroup SegmentControl
18 */
19 return: int;
20 }
21 object_get @const {
22 /*@
23 Get the real Evas(Edje) object created to implement the view of a given
24 segment_control @p item.
25
26 Base object is the @c Evas_Object that represents that item.
27
28 @return The base Edje object associated with @p it.
29
30 @ingroup SegmentControl
31 */
32 return: Evas_Object*;
33 }
34 selected_set {
35 /*@
36 Set the selected state of an item.
37
38 This sets the selected state of the given item @p it.
39 @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
40
41 If a new item is selected the previously selected will be unselected.
42 Selected item can be got with function
43 elm_segment_control_item_selected_get().
44
45 The selected item always will be highlighted on segment control.
46
47 @see elm_segment_control_item_selected_get()
48
49 @ingroup SegmentControl
50 */
51 params {
52 Eina_Bool select; /* @ The selected state. */
53 }
54 }
55 }
56 implements {
57 Eo.Base.constructor;
58 Elm_Widget_Item.access_register;
59 Elm_Widget_Item.part_text.get;
60 Elm_Widget_Item.part_text.set;
61 Elm_Widget_Item.part_content.get;
62 Elm_Widget_Item.part_content.set;
63 Elm_Widget_Item.del_pre;
64 }
65}
diff --git a/src/lib/elm_widget_segment_control.h b/src/lib/elm_widget_segment_control.h
index 1ef7fe14e..c3225513d 100644
--- a/src/lib/elm_widget_segment_control.h
+++ b/src/lib/elm_widget_segment_control.h
@@ -2,6 +2,9 @@
2#define ELM_WIDGET_SEGMENT_CONTROL_H 2#define ELM_WIDGET_SEGMENT_CONTROL_H
3 3
4#include "Elementary.h" 4#include "Elementary.h"
5#include "elm_segment_control_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
@@ -24,20 +27,20 @@
24 * Base layout smart data extended with segment control instance data. 27 * Base layout smart data extended with segment control instance data.
25 */ 28 */
26typedef struct _Elm_Segment_Control_Data Elm_Segment_Control_Data; 29typedef struct _Elm_Segment_Control_Data Elm_Segment_Control_Data;
27typedef struct _Elm_Segment_Item Elm_Segment_Item; 30typedef struct _Elm_Segment_Control_Item_Data Elm_Segment_Control_Item_Data;
28 31
29struct _Elm_Segment_Control_Data 32struct _Elm_Segment_Control_Data
30{ 33{
31 Evas_Object *obj; 34 Evas_Object *obj;
32 Eina_List *items; 35 Eina_List *items;
33 Elm_Segment_Item *selected_item; 36 Elm_Segment_Control_Item_Data *selected_item;
34 37
35 int item_width; 38 int item_width;
36}; 39};
37 40
38struct _Elm_Segment_Item 41struct _Elm_Segment_Control_Item_Data
39{ 42{
40 ELM_WIDGET_ITEM; 43 Elm_Widget_Item_Data *base;
41 44
42 Evas_Object *icon; 45 Evas_Object *icon;
43 const char *label; 46 const char *label;
@@ -73,12 +76,15 @@ struct _Elm_Segment_Item
73 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_CLASS))) \ 76 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_CLASS))) \
74 return 77 return
75 78
79#define ELM_SEGMENT_ITEM_DATA_GET(o, sd) \
80 Elm_Segment_Control_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_SEGMENT_CONTROL_ITEM_CLASS)
81
76#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \ 82#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \
77 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \ 83 if (EINA_UNLIKELY(!eo_isa((it)->base->eo_obj, ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
78 ELM_SEGMENT_CONTROL_CHECK(it->base.widget); 84 return
79 85
80#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \ 86#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \
81 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \ 87 if (EINA_UNLIKELY(!eo_isa((it)->base->eo_obj, ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
82 ELM_SEGMENT_CONTROL_CHECK(it->base.widget) __VA_ARGS__; 88 return __VA_ARGS__;
83 89
84#endif 90#endif