summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-29 13:50:05 +0300
committerYossi Kantor <yossi.kantor@samsung.com>2014-08-03 14:49:46 +0300
commitcca496aab71e470f46c64d00a86278dc42155b75 (patch)
tree7e0da50d23d5a85e60119f86b0b23744c92be8ae
parentef7289c1b78c08d8473e5cea6d2eed5ff10783a6 (diff)
Integration of Segment Control Item
-rw-r--r--src/lib/Makefile.am8
-rw-r--r--src/lib/elm_segment_control.c337
-rw-r--r--src/lib/elm_segment_control_item.eo67
-rw-r--r--src/lib/elm_widget_segment_control.h28
4 files changed, 281 insertions, 159 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 8e2fe037f..e0383874f 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -782,7 +782,9 @@ BUILT_SOURCES = \
782 elm_dayselector_item.eo.c \ 782 elm_dayselector_item.eo.c \
783 elm_dayselector_item.eo.h \ 783 elm_dayselector_item.eo.h \
784 elm_hoversel_item.eo.c \ 784 elm_hoversel_item.eo.c \
785 elm_hoversel_item.eo.h 785 elm_hoversel_item.eo.h \
786 elm_segment_control_item.eo.c \
787 elm_segment_control_item.eo.h
786 788
787elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 789elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
788elementaryeolianfiles_DATA = \ 790elementaryeolianfiles_DATA = \
@@ -878,7 +880,9 @@ elementaryeolianfiles_DATA = \
878 elm_widget_item.eo \ 880 elm_widget_item.eo \
879 elm_color_item.eo \ 881 elm_color_item.eo \
880 elm_dayselector_item.eo \ 882 elm_dayselector_item.eo \
881 elm_hoversel_item.eo 883 elm_hoversel_item.eo \
884 elm_segment_control_item.eo
885
882 886
883EXTRA_DIST += \ 887EXTRA_DIST += \
884 ${elementaryeolianfiles_DATA} 888 ${elementaryeolianfiles_DATA}
diff --git a/src/lib/elm_segment_control.c b/src/lib/elm_segment_control.c
index db129dc0f..f9513470a 100644
--- a/src/lib/elm_segment_control.c
+++ b/src/lib/elm_segment_control.c
@@ -23,11 +23,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
23EOLIAN static Eina_Bool 23EOLIAN static Eina_Bool
24_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd) 24_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
25{ 25{
26 Elm_Segment_Item *it; 26 Elm_Widobj_Item *it;
27 Eina_List *l; 27 Eina_List *l;
28 28
29 EINA_LIST_FOREACH(sd->items, l, it) 29 EINA_LIST_FOREACH(sd->items, l, it)
30 elm_widget_item_translate(it); 30 eo_do(it, elm_wdg_item_translate());
31 31
32 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate()); 32 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
33 33
@@ -59,12 +59,13 @@ _elm_segment_control_elm_layout_sizing_eval(Eo *obj, Elm_Segment_Control_Data *s
59} 59}
60 60
61static void 61static void
62_item_free(Elm_Segment_Item *it) 62_item_free(Elm_Widobj_Item *eo_item)
63{ 63{
64 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
64 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 65 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
65 66
66 if (sd->selected_item == it) sd->selected_item = NULL; 67 if (sd->selected_item == eo_item) sd->selected_item = NULL;
67 if (sd->items) sd->items = eina_list_remove(sd->items, it); 68 if (sd->items) sd->items = eina_list_remove(sd->items, eo_item);
68 69
69 evas_object_del(it->icon); 70 evas_object_del(it->icon);
70 eina_stringshare_del(it->label); 71 eina_stringshare_del(it->label);
@@ -76,7 +77,7 @@ _position_items(Elm_Segment_Control_Data *sd)
76 Eina_List *l; 77 Eina_List *l;
77 Eina_Bool rtl; 78 Eina_Bool rtl;
78 int item_count; 79 int item_count;
79 Elm_Segment_Item *it; 80 Elm_Widobj_Item *eo_item;
80 int bx, by, bw, bh, pos; 81 int bx, by, bw, bh, pos;
81 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd); 82 ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
82 83
@@ -91,8 +92,9 @@ _position_items(Elm_Segment_Control_Data *sd)
91 if (rtl) pos = bx + bw - sd->item_width; 92 if (rtl) pos = bx + bw - sd->item_width;
92 else pos = bx; 93 else pos = bx;
93 94
94 EINA_LIST_FOREACH(sd->items, l, it) 95 EINA_LIST_FOREACH(sd->items, l, eo_item)
95 { 96 {
97 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
96 evas_object_move(VIEW(it), pos, by); 98 evas_object_move(VIEW(it), pos, by);
97 evas_object_resize(VIEW(it), sd->item_width, bh); 99 evas_object_resize(VIEW(it), sd->item_width, bh);
98 if (rtl) pos -= sd->item_width; 100 if (rtl) pos -= sd->item_width;
@@ -103,9 +105,10 @@ _position_items(Elm_Segment_Control_Data *sd)
103} 105}
104 106
105static void 107static void
106_swallow_item_objects(Elm_Segment_Item *it) 108_swallow_item_objects(Elm_Widobj_Item *eo_item)
107{ 109{
108 if (!it) return; 110 if (!eo_item) return;
111 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
109 112
110 if (it->icon) 113 if (it->icon)
111 { 114 {
@@ -132,7 +135,7 @@ _update_list(Elm_Segment_Control_Data *sd)
132 Eina_List *l; 135 Eina_List *l;
133 Eina_Bool rtl; 136 Eina_Bool rtl;
134 int item_count; 137 int item_count;
135 Elm_Segment_Item *it; 138 Elm_Widobj_Item *eo_item;
136 139
137 _position_items(sd); 140 _position_items(sd);
138 141
@@ -140,14 +143,16 @@ _update_list(Elm_Segment_Control_Data *sd)
140 143
141 if (item_count == 1) 144 if (item_count == 1)
142 { 145 {
143 it = eina_list_nth(sd->items, 0); 146 eo_item = eina_list_nth(sd->items, 0);
147
148 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
144 it->seg_index = 0; 149 it->seg_index = 0;
145 150
146 //Set the segment type 151 //Set the segment type
147 edje_object_signal_emit(VIEW(it), "elm,type,segment,single", "elm"); 152 edje_object_signal_emit(VIEW(it), "elm,type,segment,single", "elm");
148 153
149 //Set the segment state 154 //Set the segment state
150 if (sd->selected_item == it) 155 if (sd->selected_item == eo_item)
151 edje_object_signal_emit 156 edje_object_signal_emit
152 (VIEW(it), "elm,state,segment,selected", "elm"); 157 (VIEW(it), "elm,state,segment,selected", "elm");
153 else 158 else
@@ -158,13 +163,14 @@ _update_list(Elm_Segment_Control_Data *sd)
158 else 163 else
159 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm"); 164 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
160 165
161 _swallow_item_objects(it); 166 _swallow_item_objects(eo_item);
162 return; 167 return;
163 } 168 }
164 169
165 rtl = elm_widget_mirrored_get(sd->obj); 170 rtl = elm_widget_mirrored_get(sd->obj);
166 EINA_LIST_FOREACH(sd->items, l, it) 171 EINA_LIST_FOREACH(sd->items, l, eo_item)
167 { 172 {
173 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
168 it->seg_index = idx; 174 it->seg_index = idx;
169 175
170 //Set the segment type 176 //Set the segment type
@@ -190,7 +196,7 @@ _update_list(Elm_Segment_Control_Data *sd)
190 edje_object_signal_emit(VIEW(it), "elm,type,segment,middle", "elm"); 196 edje_object_signal_emit(VIEW(it), "elm,type,segment,middle", "elm");
191 197
192 //Set the segment state 198 //Set the segment state
193 if (sd->selected_item == it) 199 if (sd->selected_item == eo_item)
194 edje_object_signal_emit 200 edje_object_signal_emit
195 (VIEW(it), "elm,state,segment,selected", "elm"); 201 (VIEW(it), "elm,state,segment,selected", "elm");
196 else 202 else
@@ -201,7 +207,7 @@ _update_list(Elm_Segment_Control_Data *sd)
201 else 207 else
202 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm"); 208 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
203 209
204 _swallow_item_objects(it); 210 _swallow_item_objects(eo_item);
205 idx++; 211 idx++;
206 } 212 }
207} 213}
@@ -211,7 +217,7 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
211{ 217{
212 Eina_List *l; 218 Eina_List *l;
213 Eina_Bool rtl; 219 Eina_Bool rtl;
214 Elm_Segment_Item *it; 220 Elm_Widobj_Item *eo_item;
215 221
216 Eina_Bool int_ret = EINA_FALSE; 222 Eina_Bool int_ret = EINA_FALSE;
217 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply()); 223 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
@@ -219,8 +225,9 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
219 225
220 rtl = elm_widget_mirrored_get(obj); 226 rtl = elm_widget_mirrored_get(obj);
221 227
222 EINA_LIST_FOREACH(sd->items, l, it) 228 EINA_LIST_FOREACH(sd->items, l, eo_item)
223 { 229 {
230 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
224 elm_widget_theme_object_set 231 elm_widget_theme_object_set
225 (obj, VIEW(it), "segment_control", "item", 232 (obj, VIEW(it), "segment_control", "item",
226 elm_widget_style_get(obj)); 233 elm_widget_style_get(obj));
@@ -253,10 +260,11 @@ _elm_segment_control_elm_widget_disable(Eo *obj, Elm_Segment_Control_Data *sd)
253static void * 260static void *
254_elm_list_data_get(const Eina_List *list) 261_elm_list_data_get(const Eina_List *list)
255{ 262{
256 Elm_Segment_Item *it = eina_list_data_get(list); 263 Elm_Widobj_Item *eo_item = eina_list_data_get(list);
257 264
258 if (it) return NULL; 265 if (eo_item) return NULL;
259 266
267 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
260 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm"); 268 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
261 269
262 return VIEW(it); 270 return VIEW(it);
@@ -285,28 +293,30 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
285#endif 293#endif
286 294
287static void 295static void
288_segment_off(Elm_Segment_Item *it) 296_segment_off(Elm_Widobj_Item *eo_item)
289{ 297{
298 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
290 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 299 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
291 300
292 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm"); 301 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
293 302
294 if (sd->selected_item == it) sd->selected_item = NULL; 303 if (sd->selected_item == eo_item) sd->selected_item = NULL;
295} 304}
296 305
297static void 306static void
298_segment_on(Elm_Segment_Item *it) 307_segment_on(Elm_Widobj_Item *eo_item)
299{ 308{
309 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
300 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 310 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
301 311
302 if (it == sd->selected_item) return; 312 if (eo_item == sd->selected_item) return;
303 313
304 if (sd->selected_item) _segment_off(sd->selected_item); 314 if (sd->selected_item) _segment_off(sd->selected_item);
305 315
306 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm"); 316 edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
307 317
308 sd->selected_item = it; 318 sd->selected_item = eo_item;
309 evas_object_smart_callback_call(sd->obj, SIG_CHANGED, it); 319 evas_object_smart_callback_call(sd->obj, SIG_CHANGED, eo_item);
310} 320}
311 321
312static void 322static void
@@ -325,24 +335,25 @@ _on_mouse_up(void *data,
325 Evas_Object *obj EINA_UNUSED, 335 Evas_Object *obj EINA_UNUSED,
326 void *event_info) 336 void *event_info)
327{ 337{
328 Elm_Segment_Item *it = data; 338 Elm_Widobj_Item *eo_item = data;
329 Evas_Event_Mouse_Up *ev = event_info; 339 Evas_Event_Mouse_Up *ev = event_info;
330 Evas_Coord x, y, w, h; 340 Evas_Coord x, y, w, h;
331 341
342 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
332 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 343 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
333 344
334 if (ev->button != 1) return; 345 if (ev->button != 1) return;
335 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 346 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
336 if (elm_widget_disabled_get(sd->obj)) return; 347 if (elm_widget_disabled_get(sd->obj)) return;
337 348
338 if (it == sd->selected_item) return; 349 if (eo_item == sd->selected_item) return;
339 350
340 ev = event_info; 351 ev = event_info;
341 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h); 352 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
342 353
343 if ((ev->canvas.x >= x) && (ev->output.x <= (x + w)) && (ev->canvas.y >= y) 354 if ((ev->canvas.x >= x) && (ev->output.x <= (x + w)) && (ev->canvas.y >= y)
344 && (ev->canvas.y <= (y + h))) 355 && (ev->canvas.y <= (y + h)))
345 _segment_on(it); 356 _segment_on(eo_item);
346 else 357 else
347 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm"); 358 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
348} 359}
@@ -353,39 +364,39 @@ _on_mouse_down(void *data,
353 Evas_Object *obj EINA_UNUSED, 364 Evas_Object *obj EINA_UNUSED,
354 void *event_info EINA_UNUSED) 365 void *event_info EINA_UNUSED)
355{ 366{
356 Elm_Segment_Item *it = data; 367 Elm_Widobj_Item *eo_item = data;
357 Evas_Event_Mouse_Down *ev = event_info; 368 Evas_Event_Mouse_Down *ev = event_info;
358 369
370 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
359 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 371 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
360 372
361 if (ev->button != 1) return; 373 if (ev->button != 1) return;
362 if (elm_widget_disabled_get(sd->obj)) return; 374 if (elm_widget_disabled_get(sd->obj)) return;
363 375
364 if (it == sd->selected_item) return; 376 if (eo_item == sd->selected_item) return;
365 377
366 edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm"); 378 edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm");
367} 379}
368 380
369static Elm_Segment_Item * 381static Elm_Widobj_Item *
370_item_find(const Evas_Object *obj, 382_item_find(const Evas_Object *obj,
371 int idx) 383 int idx)
372{ 384{
373 Elm_Segment_Item *it; 385 Elm_Widobj_Item *eo_item;
374 386
375 ELM_SEGMENT_CONTROL_DATA_GET(obj, sd); 387 ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
376 388
377 it = eina_list_nth(sd->items, idx); 389 eo_item = eina_list_nth(sd->items, idx);
378 return it; 390 return eo_item;
379} 391}
380 392
381static void 393EOLIAN static void
382_item_text_set_hook(Elm_Object_Item *it, 394_elm_segment_control_item_elm_widget_item_part_text_set(Eo *obj EINA_UNUSED,
383 const char *part, 395 Elm_Segment_Control_Item_Data *item,
384 const char *label) 396 const char *part,
397 const char *label)
385{ 398{
386 Elm_Segment_Item *item;
387 char buf[1024]; 399 char buf[1024];
388 item = (Elm_Segment_Item *)it;
389 400
390 if ((!part) || (!strcmp(part, "default")) || 401 if ((!part) || (!strcmp(part, "default")) ||
391 (!strcmp(part, "elm.text"))) 402 (!strcmp(part, "elm.text")))
@@ -415,9 +426,10 @@ _item_text_set_hook(Elm_Object_Item *it,
415 edje_object_part_text_escaped_set(VIEW(item), part, label); 426 edje_object_part_text_escaped_set(VIEW(item), part, label);
416} 427}
417 428
418static const char * 429EOLIAN static const char *
419_item_text_get_hook(const Elm_Object_Item *it, 430_elm_segment_control_item_elm_widget_item_part_text_get(Eo *obj EINA_UNUSED,
420 const char *part) 431 Elm_Segment_Control_Item_Data *it,
432 const char *part)
421{ 433{
422 char buf[1024]; 434 char buf[1024];
423 435
@@ -429,14 +441,13 @@ _item_text_get_hook(const Elm_Object_Item *it,
429 return edje_object_part_text_get(VIEW(it), buf); 441 return edje_object_part_text_get(VIEW(it), buf);
430} 442}
431 443
432static void 444EOLIAN static void
433_item_content_set_hook(Elm_Object_Item *it, 445_elm_segment_control_item_elm_widget_item_part_content_set(Eo *obj EINA_UNUSED,
434 const char *part, 446 Elm_Segment_Control_Item_Data *item,
435 Evas_Object *content) 447 const char *part,
448 Evas_Object *content)
436{ 449{
437 Elm_Segment_Item *item;
438 char buf[1024]; 450 char buf[1024];
439 item = (Elm_Segment_Item *)it;
440 451
441 if (!part || !strcmp("icon", part)) 452 if (!part || !strcmp("icon", part))
442 { 453 {
@@ -457,7 +468,7 @@ _item_content_set_hook(Elm_Object_Item *it,
457 { 468 {
458 if (content) 469 if (content)
459 { 470 {
460 edje_object_part_swallow(VIEW(it), part, content); 471 edje_object_part_swallow(VIEW(item), part, content);
461 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part); 472 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
462 edje_object_signal_emit(VIEW(item), buf, "elm"); 473 edje_object_signal_emit(VIEW(item), buf, "elm");
463 } 474 }
@@ -469,13 +480,11 @@ _item_content_set_hook(Elm_Object_Item *it,
469 } 480 }
470} 481}
471 482
472static Evas_Object * 483EOLIAN static Evas_Object *
473_item_content_get_hook(const Elm_Object_Item *it, 484_elm_segment_control_item_elm_widget_item_part_content_get(Eo *obj EINA_UNUSED,
474 const char *part) 485 Elm_Segment_Control_Item_Data *item,
486 const char *part)
475{ 487{
476 Elm_Segment_Item *item;
477 item = (Elm_Segment_Item *)it;
478
479 if (part && !strcmp(part, "icon")) 488 if (part && !strcmp(part, "icon"))
480 return item->icon; 489 return item->icon;
481 else 490 else
@@ -483,12 +492,11 @@ _item_content_get_hook(const Elm_Object_Item *it,
483} 492}
484 493
485static Eina_Bool 494static Eina_Bool
486_item_del_pre_hook(Elm_Object_Item *it) 495_elm_segment_control_item_elm_widget_item_del_pre(Eo *obj, Elm_Segment_Control_Item_Data *item)
487{ 496{
488 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 497 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
489 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
490 498
491 _item_free(item); 499 _item_free(obj);
492 _update_list(sd); 500 _update_list(sd);
493 501
494 return EINA_TRUE; 502 return EINA_TRUE;
@@ -498,8 +506,9 @@ static char *
498_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED) 506_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
499{ 507{
500 const char *txt = NULL; 508 const char *txt = NULL;
501 Elm_Segment_Item *it = (Elm_Segment_Item *)data; 509 Elm_Widobj_Item *eo_item = (Elm_Widobj_Item *)data;
502 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL); 510 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(eo_item, NULL);
511 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
503 512
504 if (!txt) txt = it->label; 513 if (!txt) txt = it->label;
505 if (txt) return strdup(txt); 514 if (txt) return strdup(txt);
@@ -510,59 +519,51 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
510static char * 519static char *
511_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED) 520_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
512{ 521{
513 Elm_Segment_Item *it = (Elm_Segment_Item *)data; 522 Elm_Widobj_Item *eo_item = (Elm_Widobj_Item *)data;
514 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL); 523 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(eo_item, NULL);
524
525 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
515 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd); 526 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
516 ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL); 527 ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL);
517 528
518 if (wd->disabled) 529 if (wd->disabled)
519 return strdup(E_("State: Disabled")); 530 return strdup(E_("State: Disabled"));
520 531
521 if (it == sd->selected_item) 532 if (eo_item == sd->selected_item)
522 return strdup(E_("State: Selected")); 533 return strdup(E_("State: Selected"));
523 else 534 else
524 return strdup(E_("State: Unselected")); 535 return strdup(E_("State: Unselected"));
525} 536}
526 537
527static void 538static Evas_Object*
528_access_widget_item_register(Elm_Segment_Item *it) 539_elm_segment_control_item_elm_widget_item_access_register(Eo *obj,
540 Elm_Segment_Control_Item_Data *it)
529{ 541{
530 Elm_Access_Info *ai; 542 Elm_Access_Info *ai;
543 Evas_Object *ret;
531 544
532 _elm_access_widget_item_register((Elm_Widget_Item *)it); 545 eo_do_super(obj, ELM_SEGMENT_CONTROL_ITEM_CLASS, ret = elm_wdg_item_access_register());
533 546
534 ai = _elm_access_info_get(it->base.access_obj); 547 ai = _elm_access_info_get(it->base->access_obj);
535 548
536 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Segment Control Item")); 549 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Segment Control Item"));
537 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it); 550 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, obj);
538 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it); 551 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, obj);
552
553 return ret;
539} 554}
540 555
541static Elm_Segment_Item * 556static Elm_Widobj_Item *
542_item_new(Evas_Object *obj, 557_item_new(Evas_Object *obj,
543 Evas_Object *icon, 558 Evas_Object *icon,
544 const char *label) 559 const char *label)
545{ 560{
546 Elm_Segment_Item *it; 561 Elm_Widobj_Item *eo_item;
547
548 it = elm_widget_item_new(obj, Elm_Segment_Item);
549 if (!it) return NULL;
550
551 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
552 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
553 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
554 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
555 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
556 562
557 VIEW(it) = edje_object_add(evas_object_evas_get(obj)); 563 eo_item = eo_add(ELM_SEGMENT_CONTROL_ITEM_CLASS, obj);
558 edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) * 564 if (!eo_item) return NULL;
559 elm_config_scale_get());
560 evas_object_smart_member_add(VIEW(it), obj);
561 565
562 elm_widget_sub_object_add(obj, VIEW(it)); 566 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
563 elm_widget_theme_object_set
564 (obj, VIEW(it), "segment_control", "item", elm_object_style_get(obj));
565 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
566 567
567 if (label) eina_stringshare_replace(&it->label, label); 568 if (label) eina_stringshare_replace(&it->label, label);
568 if (it->label) 569 if (it->label)
@@ -575,16 +576,36 @@ _item_new(Evas_Object *obj,
575 it->icon = icon; 576 it->icon = icon;
576 if (it->icon) elm_widget_sub_object_add(VIEW(it), it->icon); 577 if (it->icon) elm_widget_sub_object_add(VIEW(it), it->icon);
577 evas_object_event_callback_add 578 evas_object_event_callback_add
578 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, it); 579 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, eo_item);
579 evas_object_event_callback_add 580 evas_object_event_callback_add
580 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, it); 581 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, eo_item);
581 evas_object_show(VIEW(it)); 582 evas_object_show(VIEW(it));
582 583
583 // ACCESS 584 // ACCESS
584 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON) 585 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
585 _access_widget_item_register(it); 586 eo_do(eo_item, elm_wdg_item_access_register());
586 587
587 return it; 588 return eo_item;
589}
590
591EOLIAN static void
592_elm_segment_control_item_eo_base_constructor(Eo *obj, Elm_Segment_Control_Item_Data *it)
593{
594 eo_do_super(obj, ELM_SEGMENT_CONTROL_ITEM_CLASS, eo_constructor());
595 it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
596
597 Evas_Object *parent;
598 eo_do (obj, parent = eo_parent_get());
599
600 VIEW(it) = edje_object_add(evas_object_evas_get(parent));
601 edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
602 elm_config_scale_get());
603 evas_object_smart_member_add(VIEW(it), parent);
604
605 elm_widget_sub_object_add(parent, VIEW(it));
606 elm_widget_theme_object_set
607 (parent, VIEW(it), "segment_control", "item", elm_object_style_get(parent));
608 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
588} 609}
589 610
590EOLIAN static void 611EOLIAN static void
@@ -608,12 +629,12 @@ _elm_segment_control_evas_object_smart_add(Eo *obj, Elm_Segment_Control_Data *_p
608EOLIAN static void 629EOLIAN static void
609_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd) 630_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd)
610{ 631{
611 Elm_Segment_Item *it; 632 Elm_Widobj_Item *eo_item;
612 633
613 EINA_LIST_FREE(sd->items, it) 634 EINA_LIST_FREE(sd->items, eo_item)
614 { 635 {
615 _item_free(it); 636 _item_free(eo_item);
616 elm_widget_item_free(it); 637 eo_del(eo_item);
617 } 638 }
618 639
619 eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); 640 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
@@ -632,12 +653,15 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
632{ 653{
633 Eina_List *items = NULL; 654 Eina_List *items = NULL;
634 Eina_List *l; 655 Eina_List *l;
635 Elm_Segment_Item *it; 656 Elm_Widobj_Item *eo_item;
636 657
637 ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE; 658 ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE;
638 659
639 EINA_LIST_FOREACH(sd->items, l, it) 660 EINA_LIST_FOREACH(sd->items, l, eo_item)
640 items = eina_list_append(items, it->base.access_obj); 661 {
662 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
663 items = eina_list_append(items, it->base->access_obj);
664 }
641 665
642 return elm_widget_focus_list_next_get 666 return elm_widget_focus_list_next_get
643 (obj, items, eina_list_data_get, dir, next); 667 (obj, items, eina_list_data_get, dir, next);
@@ -653,13 +677,13 @@ static void
653_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access) 677_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access)
654{ 678{
655 Eina_List *l; 679 Eina_List *l;
656 Elm_Segment_Item *it; 680 Elm_Widobj_Item *eo_item;
657 681
658 EINA_LIST_FOREACH(sd->items, l, it) 682 EINA_LIST_FOREACH(sd->items, l, eo_item)
659 { 683 {
660 if (is_access) _access_widget_item_register(it); 684 if (is_access) eo_do(eo_item, elm_wdg_item_access_register());
661 else 685 else
662 _elm_access_widget_item_unregister((Elm_Widget_Item *)it); 686 eo_do(eo_item, elm_wdg_item_access_unregister());
663 } 687 }
664} 688}
665 689
@@ -693,56 +717,56 @@ _elm_segment_control_eo_base_constructor(Eo *obj, Elm_Segment_Control_Data *sd)
693EOLIAN static Elm_Object_Item* 717EOLIAN static Elm_Object_Item*
694_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label) 718_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label)
695{ 719{
696 Elm_Segment_Item *it; 720 Elm_Widobj_Item *eo_item;
697
698 721
699 it = _item_new(obj, icon, label); 722 eo_item = _item_new(obj, icon, label);
700 if (!it) return NULL; 723 if (!eo_item) return NULL;
701 724
702 sd->items = eina_list_append(sd->items, it); 725 sd->items = eina_list_append(sd->items, eo_item);
703 _update_list(sd); 726 _update_list(sd);
704 727
705 return (Elm_Object_Item *)it; 728 return (Elm_Object_Item *)eo_item;
706} 729}
707 730
708EOLIAN static Elm_Object_Item* 731EOLIAN static Elm_Object_Item*
709_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx) 732_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx)
710{ 733{
711 Elm_Segment_Item *it, *it_rel; 734 Elm_Widobj_Item *eo_item, *it_rel;
712 735
713 736
714 if (idx < 0) idx = 0; 737 if (idx < 0) idx = 0;
715 738
716 it = _item_new(obj, icon, label); 739 eo_item = _item_new(obj, icon, label);
717 if (!it) return NULL; 740 if (!eo_item) return NULL;
718 741
719 it_rel = _item_find(obj, idx); 742 it_rel = _item_find(obj, idx);
720 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, it_rel);
721 else sd->items = eina_list_append(sd->items, it); 744 else sd->items = eina_list_append(sd->items, eo_item);
722 745
723 _update_list(sd); 746 _update_list(sd);
724 747
725 return (Elm_Object_Item *)it; 748 return (Elm_Object_Item *)eo_item;
726} 749}
727 750
728EOLIAN static void 751EOLIAN static void
729_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)
730{ 753{
731 Elm_Segment_Item *it; 754 Elm_Widobj_Item *it;
732 755
733 it = _item_find(obj, idx); 756 it = _item_find(obj, idx);
734 if (!it) return; 757 if (!it) return;
735 758
736 elm_widget_item_del((Elm_Object_Item *)it); 759 eo_do(it, elm_wdg_item_del());
737} 760}
738 761
739EOLIAN static const char* 762EOLIAN static const char*
740_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)
741{ 764{
742 Elm_Segment_Item *it; 765 Elm_Widobj_Item *eo_item;
743 766
744 it = _item_find(obj, idx); 767 eo_item = _item_find(obj, idx);
745 if (it) return it->label; 768 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
769 if (eo_item) return it->label;
746 770
747 return NULL; 771 return NULL;
748} 772}
@@ -750,8 +774,9 @@ _elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_
750EOLIAN static Evas_Object* 774EOLIAN static Evas_Object*
751_elm_segment_control_item_icon_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx) 775_elm_segment_control_item_icon_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
752{ 776{
753 Elm_Segment_Item *it = _item_find(obj, idx); 777 Elm_Widobj_Item *eo_item = _item_find(obj, idx);
754 if (it) return it->icon; 778 ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
779 if (eo_item) return it->icon;
755 return NULL; 780 return NULL;
756} 781}
757 782
@@ -761,39 +786,35 @@ _elm_segment_control_item_count_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Dat
761 return eina_list_count(sd->items); 786 return eina_list_count(sd->items);
762} 787}
763 788
764EAPI Evas_Object * 789EOLIAN static Evas_Object *
765elm_segment_control_item_object_get(const Elm_Object_Item *it) 790_elm_segment_control_item_object_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
766{ 791{
767 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
768
769 return VIEW(it); 792 return VIEW(it);
770} 793}
771 794
772EOLIAN static Elm_Object_Item* 795EOLIAN static Elm_Object_Item*
773_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd) 796_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *it)
774{ 797{
775 return (Elm_Object_Item *)sd->selected_item; 798 return (Elm_Object_Item *)it->selected_item;
776} 799}
777 800
778EAPI void 801EOLIAN static void
779elm_segment_control_item_selected_set(Elm_Object_Item *it, 802_elm_segment_control_item_selected_set(Eo *it,
780 Eina_Bool selected) 803 Elm_Segment_Control_Item_Data *item,
804 Eina_Bool selected)
781{ 805{
782 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 806 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
783
784 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it);
785 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
786 807
787 if (item == sd->selected_item) 808 if (it== sd->selected_item)
788 { 809 {
789 //already in selected state. 810 //already in selected state.
790 if (selected) return; 811 if (selected) return;
791 812
792 //unselect case 813 //unselect case
793 _segment_off(item); 814 _segment_off(it);
794 } 815 }
795 else if (selected) 816 else if (selected)
796 _segment_on(item); 817 _segment_on(it);
797} 818}
798 819
799EOLIAN static Elm_Object_Item* 820EOLIAN static Elm_Object_Item*
@@ -802,12 +823,12 @@ _elm_segment_control_item_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED
802 return (Elm_Object_Item *)_item_find(obj, idx); 823 return (Elm_Object_Item *)_item_find(obj, idx);
803} 824}
804 825
805EAPI int 826EOLIAN static int
806elm_segment_control_item_index_get(const Elm_Object_Item *it) 827_elm_segment_control_item_index_get(Eo *obj, Elm_Segment_Control_Item_Data *item)
807{ 828{
808 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, -1); 829 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(obj, -1);
809 830
810 return ((Elm_Segment_Item *)it)->seg_index; 831 return item->seg_index;
811} 832}
812 833
813EOLIAN static void 834EOLIAN static void
@@ -819,4 +840,28 @@ _elm_segment_control_class_constructor(Eo_Class *klass)
819 _elm_segment_control_smart_focus_next_enable = EINA_TRUE; 840 _elm_segment_control_smart_focus_next_enable = EINA_TRUE;
820} 841}
821 842
822#include "elm_segment_control.eo.c" 843EAPI Evas_Object *
844elm_segment_control_item_object_get(const Elm_Object_Item *it)
845{
846 Evas_Object *ret = NULL;
847 eo_do((Eo*)it, ret = elm_segmentcontrol_item_object_get());
848 return ret;
849}
850
851EAPI int
852elm_segment_control_item_index_get(const Elm_Object_Item *it)
853{
854 int ret = 0;
855 eo_do((Eo*)it, ret = elm_segmentcontrol_item_index_get());
856 return ret;
857}
858
859EAPI void
860elm_segment_control_item_selected_set(Elm_Object_Item *it,
861 Eina_Bool selected)
862{
863 eo_do((Eo*)it, elm_segmentcontrol_item_selected_set(selected));
864}
865
866#include "elm_segment_control_item.eo.c"
867#include "elm_segment_control.eo.c" \ No newline at end of file
diff --git a/src/lib/elm_segment_control_item.eo b/src/lib/elm_segment_control_item.eo
new file mode 100644
index 000000000..1ed794db4
--- /dev/null
+++ b/src/lib/elm_segment_control_item.eo
@@ -0,0 +1,67 @@
1class Elm_Segment_Control_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_segmentcontrol_item;
5 methods {
6 index_get {
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 const;
20 return int;
21 }
22 object_get {
23 /*@
24 Get the real Evas(Edje) object created to implement the view of a given
25 segment_control @p item.
26
27 Base object is the @c Evas_Object that represents that item.
28
29 @return The base Edje object associated with @p it.
30
31 @ingroup SegmentControl
32 */
33 const;
34 return Evas_Object*;
35 }
36 selected_set {
37 /*@
38 Set the selected state of an item.
39
40 This sets the selected state of the given item @p it.
41 @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
42
43 If a new item is selected the previously selected will be unselected.
44 Selected item can be got with function
45 elm_segment_control_item_selected_get().
46
47 The selected item always will be highlighted on segment control.
48
49 @see elm_segment_control_item_selected_get()
50
51 @ingroup SegmentControl
52 */
53 params {
54 Eina_Bool select; /* @ The selected state. */
55 }
56 }
57 }
58 implements {
59 Eo_Base::constructor;
60 Elm_Widget_Item::access_register;
61 Elm_Widget_Item::part_text::get;
62 Elm_Widget_Item::part_text::set;
63 Elm_Widget_Item::part_content::get;
64 Elm_Widget_Item::part_content::set;
65 Elm_Widget_Item::del_pre;
66 }
67} \ No newline at end of file
diff --git a/src/lib/elm_widget_segment_control.h b/src/lib/elm_widget_segment_control.h
index 6e07b32ea..09d562da2 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/** 9/**
7 * @addtogroup Widget 10 * @addtogroup Widget
@@ -18,20 +21,20 @@
18 * Base layout smart data extended with segment control instance data. 21 * Base layout smart data extended with segment control instance data.
19 */ 22 */
20typedef struct _Elm_Segment_Control_Data Elm_Segment_Control_Data; 23typedef struct _Elm_Segment_Control_Data Elm_Segment_Control_Data;
21typedef struct _Elm_Segment_Item Elm_Segment_Item; 24typedef struct _Elm_Segment_Control_Item_Data Elm_Segment_Control_Item_Data;
22 25
23struct _Elm_Segment_Control_Data 26struct _Elm_Segment_Control_Data
24{ 27{
25 Evas_Object *obj; 28 Evas_Object *obj;
26 Eina_List *items; 29 Eina_List *items;
27 Elm_Segment_Item *selected_item; 30 Elm_Widobj_Item *selected_item;
28 31
29 int item_width; 32 int item_width;
30}; 33};
31 34
32struct _Elm_Segment_Item 35struct _Elm_Segment_Control_Item_Data
33{ 36{
34 ELM_WIDGET_ITEM; 37 Elm_Widget_Item_Data *base;
35 38
36 Evas_Object *icon; 39 Evas_Object *icon;
37 const char *label; 40 const char *label;
@@ -63,16 +66,19 @@ struct _Elm_Segment_Item
63 return val; \ 66 return val; \
64 } 67 }
65 68
66#define ELM_SEGMENT_CONTROL_CHECK(obj) \ 69#define ELM_SEGMENT_CONTROL_CHECK(obj) \
67 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_CLASS))) \ 70 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_CLASS))) \
68 return 71 return
69 72
70#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \ 73#define ELM_SEGMENT_ITEM_DATA_GET(o, sd) \
71 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \ 74 Elm_Segment_Control_Item_Data * sd = eo_data_scope_get(o, ELM_SEGMENT_CONTROL_ITEM_CLASS)
72 ELM_SEGMENT_CONTROL_CHECK(it->base.widget); 75
76#define ELM_SEGMENT_CONTROL_ITEM_CHECK(obj) \
77 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
78 return
73 79
74#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \ 80#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(obj, ...) \
75 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \ 81 if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
76 ELM_SEGMENT_CONTROL_CHECK(it->base.widget) __VA_ARGS__; 82 return __VA_ARGS__;
77 83
78#endif 84#endif