summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-24 15:49:33 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-17 15:08:41 +0300
commitc38625a600d35bbe1fda95f9df7f211582bbd71e (patch)
treee797fc3b2fb83953fd5703cf62a68b4298d3d20b
parent4eadfe812c546983c50e74125c7402803882d19f (diff)
Porting to Eo: Elm Colorselector Item
-rw-r--r--src/lib/Makefile.am11
-rw-r--r--src/lib/elm_color_item.eo56
-rw-r--r--src/lib/elm_colorselector.c246
-rw-r--r--src/lib/elm_colorselector_common.h40
-rw-r--r--src/lib/elm_widget_colorselector.h24
5 files changed, 229 insertions, 148 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 251b09a61..b16d58f52 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -845,7 +845,9 @@ BUILT_SOURCES = \
845 elm_win.eo.h \ 845 elm_win.eo.h \
846 elm_win.eo.legacy.h \ 846 elm_win.eo.legacy.h \
847 elm_widget_item.eo.c \ 847 elm_widget_item.eo.c \
848 elm_widget_item.eo.h 848 elm_widget_item.eo.h \
849 elm_color_item.eo.c \
850 elm_color_item.eo.h
849 851
850elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 852elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
851elementaryeolianfiles_DATA = \ 853elementaryeolianfiles_DATA = \
@@ -940,7 +942,8 @@ elementaryeolianfiles_DATA = \
940 elm_video.eo \ 942 elm_video.eo \
941 elm_web.eo \ 943 elm_web.eo \
942 elm_win.eo \ 944 elm_win.eo \
943 elm_widget_item.eo 945 elm_widget_item.eo \
946 elm_color_item.eo
944 947
945EXTRA_DIST += ${elementaryeolianfiles_DATA} 948EXTRA_DIST += ${elementaryeolianfiles_DATA}
946 949
@@ -1037,6 +1040,7 @@ nodist_includesunstable_HEADERS = \
1037 elm_web.eo.h \ 1040 elm_web.eo.h \
1038 elm_win.eo.h \ 1041 elm_win.eo.h \
1039 elm_widget_item.eo.h \ 1042 elm_widget_item.eo.h \
1043 elm_color_item.eo.h \
1040 elm_layout.eo.legacy.h \ 1044 elm_layout.eo.legacy.h \
1041 elm_frame.eo.legacy.h \ 1045 elm_frame.eo.legacy.h \
1042 elm_hover.eo.legacy.h \ 1046 elm_hover.eo.legacy.h \
@@ -1100,7 +1104,8 @@ nodist_includesunstable_HEADERS = \
1100 elm_video.eo.legacy.h \ 1104 elm_video.eo.legacy.h \
1101 elm_web.eo.legacy.h \ 1105 elm_web.eo.legacy.h \
1102 elm_win.eo.legacy.h \ 1106 elm_win.eo.legacy.h \
1103 elm_widget_item.eo.legacy.h 1107 elm_widget_item.eo.legacy.h \
1108 elm_color_item.eo.legacy.h
1104 1109
1105if HAVE_CXX11 1110if HAVE_CXX11
1106 1111
diff --git a/src/lib/elm_color_item.eo b/src/lib/elm_color_item.eo
new file mode 100644
index 000000000..8739059f3
--- /dev/null
+++ b/src/lib/elm_color_item.eo
@@ -0,0 +1,56 @@
1class Elm_Color_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_obj_color_item;
5 properties {
6 color {
7 get {
8 /*@
9 Get Palette item's color.
10
11 @ingroup Colorselector
12 */
13 }
14 set {
15 /*@
16 Set Palette item's color.
17
18 @ingroup Colorselector
19 */
20 }
21 values {
22 int r; /*@ red-value of color */
23 int g; /*@ green-value of color */
24 int b; /*@ blue-value of color */
25 int a; /*@ alpha-value of color */
26 }
27 }
28 selected {
29 get {
30 /*@
31 Get the selected state of color palette item
32
33 @since 1.9
34 @ingroup Colorselector
35 */
36 }
37 set {
38 /*@
39 Set the selected state of color palette item
40
41 @since 1.9
42 @ingroup Colorselector
43 */
44 }
45 values {
46 Eina_Bool selected; /*@ @c EINA_TRUE if selected @c EINA_FALSE otherwise */
47 }
48 }
49 }
50 implements {
51 Eo.Base.constructor;
52 Eo.Base.destructor;
53 Elm_Widget_Item.access_register;
54 Elm_Widget_Item.signal_emit;
55 }
56}
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index 19da2a2cf..a4929af16 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -58,14 +58,13 @@ enum Palette_Box_Direction
58static void 58static void
59_items_del(Elm_Colorselector_Data *sd) 59_items_del(Elm_Colorselector_Data *sd)
60{ 60{
61 Elm_Color_Item *item; 61 Elm_Object_Item *item;
62 62
63 if (!sd->items) return; 63 if (!sd->items) return;
64 64
65 EINA_LIST_FREE(sd->items, item) 65 EINA_LIST_FREE(sd->items, item)
66 { 66 {
67 free(item->color); 67 eo_del ((Eo *)item);
68 elm_widget_item_free(item);
69 } 68 }
70 69
71 sd->items = NULL; 70 sd->items = NULL;
@@ -1082,7 +1081,7 @@ _elm_colorselector_elm_widget_theme_apply(Eo *obj, Elm_Colorselector_Data *sd)
1082{ 1081{
1083 int i; 1082 int i;
1084 Eina_List *elist; 1083 Eina_List *elist;
1085 Elm_Color_Item *item; 1084 Elm_Object_Item *eo_item;
1086 const char *hpadstr, *vpadstr; 1085 const char *hpadstr, *vpadstr;
1087 unsigned int h_pad = DEFAULT_HOR_PAD; 1086 unsigned int h_pad = DEFAULT_HOR_PAD;
1088 unsigned int v_pad = DEFAULT_VER_PAD; 1087 unsigned int v_pad = DEFAULT_VER_PAD;
@@ -1111,8 +1110,9 @@ _elm_colorselector_elm_widget_theme_apply(Eo *obj, Elm_Colorselector_Data *sd)
1111 (h_pad * elm_widget_scale_get(obj) * elm_config_scale_get()), 1110 (h_pad * elm_widget_scale_get(obj) * elm_config_scale_get()),
1112 (v_pad * elm_widget_scale_get(obj) * elm_config_scale_get())); 1111 (v_pad * elm_widget_scale_get(obj) * elm_config_scale_get()));
1113 1112
1114 EINA_LIST_FOREACH(sd->items, elist, item) 1113 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1115 { 1114 {
1115 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1116 if (!elm_layout_theme_set 1116 if (!elm_layout_theme_set
1117 (VIEW(item), "colorselector", "item", elm_widget_style_get(obj))) 1117 (VIEW(item), "colorselector", "item", elm_widget_style_get(obj)))
1118 CRI("Failed to set layout!"); 1118 CRI("Failed to set layout!");
@@ -1159,7 +1159,7 @@ _sub_obj_size_hints_set(Evas_Object *sobj,
1159} 1159}
1160 1160
1161static void 1161static void
1162_item_sizing_eval(Elm_Color_Item *item) 1162_item_sizing_eval(Elm_Color_Item_Data *item)
1163{ 1163{
1164 Evas_Coord minw = -1, minh = -1; 1164 Evas_Coord minw = -1, minh = -1;
1165 Evas_Object *edje; 1165 Evas_Object *edje;
@@ -1178,12 +1178,15 @@ static void
1178_palette_sizing_eval(Evas_Object *obj) 1178_palette_sizing_eval(Evas_Object *obj)
1179{ 1179{
1180 Eina_List *elist; 1180 Eina_List *elist;
1181 Elm_Color_Item *item; 1181 Elm_Object_Item *eo_item;
1182 1182
1183 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1183 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1184 1184
1185 EINA_LIST_FOREACH(sd->items, elist, item) 1185 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1186 _item_sizing_eval(item); 1186 {
1187 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1188 _item_sizing_eval(item);
1189 }
1187} 1190}
1188 1191
1189static void 1192static void
@@ -1277,14 +1280,14 @@ _on_resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
1277static Eina_Bool 1280static Eina_Bool
1278_on_color_long_press(void *data) 1281_on_color_long_press(void *data)
1279{ 1282{
1280 Elm_Color_Item *item = (Elm_Color_Item *)data; 1283 Elm_Color_Item_Data *item = (Elm_Color_Item_Data *)data;
1281 1284
1282 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1285 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1283 1286
1284 sd->longpress_timer = NULL; 1287 sd->longpress_timer = NULL;
1285 1288
1286 evas_object_smart_callback_call 1289 evas_object_smart_callback_call
1287 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, item); 1290 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, EO_OBJ(item));
1288 1291
1289 return ECORE_CALLBACK_CANCEL; 1292 return ECORE_CALLBACK_CANCEL;
1290} 1293}
@@ -1295,7 +1298,7 @@ _on_color_pressed(void *data,
1295 Evas_Object *obj EINA_UNUSED, 1298 Evas_Object *obj EINA_UNUSED,
1296 void *event_info EINA_UNUSED) 1299 void *event_info EINA_UNUSED)
1297{ 1300{
1298 Elm_Color_Item *item = (Elm_Color_Item *)data; 1301 Elm_Color_Item_Data *item = (Elm_Color_Item_Data *)data;
1299 Evas_Event_Mouse_Down *ev = event_info; 1302 Evas_Event_Mouse_Down *ev = event_info;
1300 1303
1301 if (!item) return; 1304 if (!item) return;
@@ -1315,9 +1318,9 @@ _on_color_released(void *data,
1315 Evas_Object *obj EINA_UNUSED, 1318 Evas_Object *obj EINA_UNUSED,
1316 void *event_info EINA_UNUSED) 1319 void *event_info EINA_UNUSED)
1317{ 1320{
1318 Elm_Color_Item *item = (Elm_Color_Item *)data; 1321 Elm_Color_Item_Data *item = (Elm_Color_Item_Data *)data;
1319 Eina_List *l; 1322 Eina_List *l;
1320 Elm_Color_Item *temp_item; 1323 Elm_Object_Item *eo_temp_item;
1321 Evas_Event_Mouse_Down *ev = event_info; 1324 Evas_Event_Mouse_Down *ev = event_info;
1322 if (!item) return; 1325 if (!item) return;
1323 1326
@@ -1330,14 +1333,20 @@ _on_color_released(void *data,
1330 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g, 1333 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
1331 item->color->b, item->color->a); 1334 item->color->b, item->color->a);
1332 evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED, 1335 evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED,
1333 item); 1336 EO_OBJ(item));
1334 1337
1335 temp_item = eina_list_data_get(sd->selected); 1338 eo_temp_item = eina_list_data_get(sd->selected);
1336 if (temp_item && (temp_item != item)) 1339 if (eo_temp_item && (eo_temp_item != EO_OBJ(item)))
1337 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm"); 1340 {
1341 ELM_COLOR_ITEM_DATA_GET(eo_temp_item, temp_item);
1342 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm");
1343 }
1338 1344
1339 EINA_LIST_FOREACH(sd->items, l, temp_item) 1345 EINA_LIST_FOREACH(sd->items, l, eo_temp_item)
1340 if (item == temp_item) sd->selected = l; 1346 {
1347 ELM_COLOR_ITEM_DATA_GET(eo_temp_item, temp_item);
1348 if (item == temp_item) sd->selected = l;
1349 }
1341 sd->focused = ELM_COLORSELECTOR_PALETTE; 1350 sd->focused = ELM_COLORSELECTOR_PALETTE;
1342} 1351}
1343 1352
@@ -1348,10 +1357,10 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1348 Eina_Strbuf *buf; 1357 Eina_Strbuf *buf;
1349 int r = 0, g = 0, b = 0 ,a = 0; 1358 int r = 0, g = 0, b = 0 ,a = 0;
1350 1359
1351 Elm_Color_Item *it = data; 1360 Elm_Color_Item_Data *it = data;
1352 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL); 1361 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL);
1353 1362
1354 elm_colorselector_palette_item_color_get((Elm_Object_Item *)it, &r, &g, &b, &a); 1363 elm_colorselector_palette_item_color_get((Elm_Object_Item *)EO_OBJ(it), &r, &g, &b, &a);
1355 1364
1356 buf = eina_strbuf_new(); 1365 buf = eina_strbuf_new();
1357 eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a); 1366 eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a);
@@ -1360,17 +1369,20 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1360 return ret; 1369 return ret;
1361} 1370}
1362 1371
1363static void 1372EOLIAN static Evas_Object*
1364_access_widget_item_register(Elm_Color_Item *it) 1373_elm_color_item_elm_widget_item_access_register(Eo *eo_it, Elm_Color_Item_Data *it)
1365{ 1374{
1366 Elm_Access_Info *ai; 1375 Elm_Access_Info *ai;
1367 1376
1368 _elm_access_widget_item_register((Elm_Widget_Item_Data *)it); 1377 Evas_Object *res;
1378 eo_do_super(eo_it, ELM_COLOR_ITEM_CLASS, res = elm_wdg_item_access_register());
1369 1379
1370 ai = _elm_access_info_get(it->base.access_obj); 1380 ai = _elm_access_info_get(it->base->access_obj);
1371 1381
1372 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("color selector palette item")); 1382 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("color selector palette item"));
1373 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it); 1383 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, eo_it);
1384
1385 return res;
1374} 1386}
1375 1387
1376static void 1388static void
@@ -1382,21 +1394,22 @@ _item_resize(void *data EINA_UNUSED,
1382 elm_layout_sizing_eval(obj); 1394 elm_layout_sizing_eval(obj);
1383} 1395}
1384 1396
1385static void 1397EOLIAN static void
1386_item_signal_emit_hook(Elm_Object_Item *it, 1398_elm_color_item_elm_widget_item_signal_emit(Eo *eo_it EINA_UNUSED, Elm_Color_Item_Data *it,
1387 const char *emission, 1399 const char *emission,
1388 const char *source) 1400 const char *source)
1389{ 1401{
1390 elm_object_signal_emit(VIEW(it), emission, source); 1402 elm_object_signal_emit(VIEW(it), emission, source);
1391} 1403}
1392 1404
1393static Elm_Color_Item * 1405EOLIAN static void
1394_item_new(Evas_Object *obj) 1406_elm_color_item_eo_base_constructor(Eo *eo_item, Elm_Color_Item_Data *item)
1395{ 1407{
1396 Elm_Color_Item *item; 1408 eo_do_super(eo_item, ELM_COLOR_ITEM_CLASS, eo_constructor());
1409 item->base = eo_data_scope_get(eo_item, ELM_WIDGET_ITEM_CLASS);
1397 1410
1398 item = elm_widget_item_new(obj, Elm_Color_Item); 1411 Evas_Object *obj;
1399 if (!item) return NULL; 1412 eo_do (eo_item, obj = eo_parent_get());
1400 1413
1401 VIEW(item) = elm_layout_add(obj); 1414 VIEW(item) = elm_layout_add(obj);
1402 if (!elm_layout_theme_set 1415 if (!elm_layout_theme_set
@@ -1422,16 +1435,19 @@ _item_new(Evas_Object *obj)
1422 (item->color_obj, EVAS_CALLBACK_MOUSE_UP, _on_color_released, item); 1435 (item->color_obj, EVAS_CALLBACK_MOUSE_UP, _on_color_released, item);
1423 elm_object_part_content_set(VIEW(item), "color_obj", item->color_obj); 1436 elm_object_part_content_set(VIEW(item), "color_obj", item->color_obj);
1424 1437
1425 elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
1426
1427 _item_sizing_eval(item); 1438 _item_sizing_eval(item);
1428 evas_object_show(VIEW(item)); 1439 evas_object_show(VIEW(item));
1429 1440
1430 // ACCESS 1441 // ACCESS
1431 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON) 1442 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
1432 _access_widget_item_register(item); 1443 eo_do(obj, elm_wdg_item_access_register());
1444}
1433 1445
1434 return item; 1446EOLIAN static void
1447_elm_color_item_eo_base_destructor(Eo *obj, Elm_Color_Item_Data *item)
1448{
1449 free(item->color);
1450 eo_do_super(obj, ELM_COLOR_ITEM_CLASS, eo_destructor());
1435} 1451}
1436 1452
1437static void 1453static void
@@ -1447,21 +1463,24 @@ static void
1447_colors_save(Evas_Object *obj) 1463_colors_save(Evas_Object *obj)
1448{ 1464{
1449 Eina_List *elist; 1465 Eina_List *elist;
1450 Elm_Color_Item *item; 1466 Elm_Object_Item *eo_item;
1451 1467
1452 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1468 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1453 1469
1454 _elm_config_colors_free(sd->palette_name); 1470 _elm_config_colors_free(sd->palette_name);
1455 EINA_LIST_FOREACH(sd->items, elist, item) 1471 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1456 _elm_config_color_set(sd->palette_name, item->color->r, item->color->g, 1472 {
1457 item->color->b, item->color->a); 1473 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1474 _elm_config_color_set(sd->palette_name, item->color->r, item->color->g,
1475 item->color->b, item->color->a);
1476 }
1458} 1477}
1459 1478
1460static void 1479static void
1461_palette_colors_load(Evas_Object *obj) 1480_palette_colors_load(Evas_Object *obj)
1462{ 1481{
1463 Eina_List *elist; 1482 Eina_List *elist;
1464 Elm_Color_Item *item; 1483 Eo *eo_item;
1465 Eina_List *color_list; 1484 Eina_List *color_list;
1466 Elm_Color_RGBA *color; 1485 Elm_Color_RGBA *color;
1467 1486
@@ -1472,8 +1491,10 @@ _palette_colors_load(Evas_Object *obj)
1472 1491
1473 EINA_LIST_FOREACH(color_list, elist, color) 1492 EINA_LIST_FOREACH(color_list, elist, color)
1474 { 1493 {
1475 item = _item_new(obj); 1494 eo_item = eo_add(ELM_COLOR_ITEM_CLASS, obj);
1476 if (!item) return; 1495 if (!eo_item) return;
1496
1497 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1477 1498
1478 item->color = ELM_NEW(Elm_Color_RGBA); 1499 item->color = ELM_NEW(Elm_Color_RGBA);
1479 if (!item->color) return; 1500 if (!item->color) return;
@@ -1489,7 +1510,7 @@ _palette_colors_load(Evas_Object *obj)
1489 (item->color->b * item->color->a) / 255, 1510 (item->color->b * item->color->a) / 255,
1490 item->color->a); 1511 item->color->a);
1491 1512
1492 sd->items = eina_list_append(sd->items, item); 1513 sd->items = eina_list_append(sd->items, EO_OBJ(item));
1493 } 1514 }
1494 1515
1495 sd->config_load = EINA_TRUE; 1516 sd->config_load = EINA_TRUE;
@@ -1618,7 +1639,7 @@ static Eina_List*
1618_palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction dir) 1639_palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction dir)
1619{ 1640{
1620 Evas_Coord basex, basey, x, y, dx, min_dx; 1641 Evas_Coord basex, basey, x, y, dx, min_dx;
1621 Elm_Color_Item *item; 1642 Elm_Object_Item *eo_item;
1622 Eina_List* l; 1643 Eina_List* l;
1623 Eina_List* res = NULL; 1644 Eina_List* res = NULL;
1624 Eina_List* (*dir_func)(const Eina_List*); 1645 Eina_List* (*dir_func)(const Eina_List*);
@@ -1637,12 +1658,14 @@ _palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction d
1637 return NULL; 1658 return NULL;
1638 } 1659 }
1639 1660
1640 item = eina_list_data_get(ref_item); 1661 eo_item = eina_list_data_get(ref_item);
1662 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1641 evas_object_geometry_get(VIEW(item), &basex, &basey, NULL, NULL); 1663 evas_object_geometry_get(VIEW(item), &basex, &basey, NULL, NULL);
1642 1664
1643 for (l = ref_item; l; l = dir_func(l)) 1665 for (l = ref_item; l; l = dir_func(l))
1644 { 1666 {
1645 item = eina_list_data_get(l); 1667 eo_item = eina_list_data_get(l);
1668 item = eo_data_scope_get((Eo *)eo_item, ELM_COLOR_ITEM_CLASS);
1646 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL); 1669 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL);
1647 if (basey != y) break; 1670 if (basey != y) break;
1648 } 1671 }
@@ -1652,7 +1675,8 @@ _palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction d
1652 1675
1653 for (; l; l = dir_func(l)) 1676 for (; l; l = dir_func(l))
1654 { 1677 {
1655 item = eina_list_data_get(l); 1678 eo_item = eina_list_data_get(l);
1679 item = eo_data_scope_get((Eo *)eo_item, ELM_COLOR_ITEM_CLASS);
1656 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL); 1680 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL);
1657 if (basey != y) break; 1681 if (basey != y) break;
1658 1682
@@ -1675,8 +1699,8 @@ static Eina_Bool
1675_key_action_move(Evas_Object *obj, const char *params) 1699_key_action_move(Evas_Object *obj, const char *params)
1676{ 1700{
1677 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1701 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1702 Elm_Object_Item *eo_item = NULL;
1678 Eina_List *cl = NULL; 1703 Eina_List *cl = NULL;
1679 Elm_Color_Item *item = NULL;
1680 char colorbar_s[128]; 1704 char colorbar_s[128];
1681 const char *dir = params; 1705 const char *dir = params;
1682 1706
@@ -1753,13 +1777,14 @@ _key_action_move(Evas_Object *obj, const char *params)
1753 1777
1754 if (cl) 1778 if (cl)
1755 { 1779 {
1756 item = eina_list_data_get(cl); 1780 eo_item = eina_list_data_get(cl);
1781 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1757 elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm"); 1782 elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm");
1758 elm_colorselector_color_set 1783 elm_colorselector_color_set
1759 (WIDGET(item), item->color->r, item->color->g, item->color->b, 1784 (WIDGET(item), item->color->r, item->color->g, item->color->b,
1760 item->color->a); 1785 item->color->a);
1761 evas_object_smart_callback_call 1786 evas_object_smart_callback_call
1762 (WIDGET(item), SIG_COLOR_ITEM_SELECTED, item); 1787 (WIDGET(item), SIG_COLOR_ITEM_SELECTED, EO_OBJ(item));
1763 sd->selected = cl; 1788 sd->selected = cl;
1764 } 1789 }
1765 else if (!cl && sd->focused == ELM_COLORSELECTOR_PALETTE) 1790 else if (!cl && sd->focused == ELM_COLORSELECTOR_PALETTE)
@@ -1805,15 +1830,18 @@ _elm_colorselector_elm_widget_focus_next(Eo *obj, Elm_Colorselector_Data *sd, El
1805{ 1830{
1806 Eina_List *items = NULL; 1831 Eina_List *items = NULL;
1807 Eina_List *l; 1832 Eina_List *l;
1808 Elm_Widget_Item_Data *item; 1833 Elm_Object_Item *eo_item;
1809 int i = 0; 1834 int i = 0;
1810 1835
1811 if (!sd) return EINA_FALSE; 1836 if (!sd) return EINA_FALSE;
1812 1837
1813 if (!sd->items) return EINA_FALSE; 1838 if (!sd->items) return EINA_FALSE;
1814 1839
1815 EINA_LIST_FOREACH(sd->items, l, item) 1840 EINA_LIST_FOREACH(sd->items, l, eo_item)
1816 items = eina_list_append(items, item->access_obj); 1841 {
1842 Elm_Widget_Item_Data *witem = eo_data_scope_get((Eo *)eo_item, ELM_WIDGET_ITEM_CLASS);
1843 items = eina_list_append(items, witem->access_obj);
1844 }
1817 1845
1818 for (i = 0; i < 4; i++) 1846 for (i = 0; i < 4; i++)
1819 { 1847 {
@@ -1830,15 +1858,15 @@ static void
1830_access_obj_process(Evas_Object *obj, Eina_Bool is_access) 1858_access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1831{ 1859{
1832 Eina_List *l; 1860 Eina_List *l;
1833 Elm_Color_Item *it; 1861 Elm_Object_Item *eo_it;
1834 int i = 0; 1862 int i = 0;
1835 1863
1836 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1864 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1837 1865
1838 if (is_access) 1866 if (is_access)
1839 { 1867 {
1840 EINA_LIST_FOREACH(sd->items, l, it) 1868 EINA_LIST_FOREACH(sd->items, l, eo_it)
1841 _access_widget_item_register(it); 1869 eo_do((Eo *)eo_it, elm_wdg_item_access_register());
1842 1870
1843 for (i = 0; i < 4; i++) 1871 for (i = 0; i < 4; i++)
1844 _access_colorbar_register(obj, sd->cb_data[i], 1872 _access_colorbar_register(obj, sd->cb_data[i],
@@ -1846,8 +1874,8 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1846 } 1874 }
1847 else 1875 else
1848 { 1876 {
1849 EINA_LIST_FOREACH(sd->items, l, it) 1877 EINA_LIST_FOREACH(sd->items, l, eo_it)
1850 _elm_access_widget_item_unregister((Elm_Widget_Item_Data *)it); 1878 eo_do((Eo *)eo_it, elm_wdg_item_access_unregister());
1851 1879
1852 //TODO: _elm_access_edje_object_part_object_unregister() ? 1880 //TODO: _elm_access_edje_object_part_object_unregister() ?
1853 } 1881 }
@@ -1984,18 +2012,21 @@ elm_colorselector_palette_item_color_get(const Elm_Object_Item *it,
1984 int *b, 2012 int *b,
1985 int *a) 2013 int *a)
1986{ 2014{
1987 Elm_Color_Item *item; 2015 eo_do((Eo *) it, elm_obj_color_item_color_get(r, g, b, a));
1988 2016}
1989 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
1990 2017
1991 item = (Elm_Color_Item *)it; 2018EOLIAN static void
1992 if (item) 2019_elm_color_item_color_get(Eo *eo_item EINA_UNUSED,
1993 { 2020 Elm_Color_Item_Data *item,
1994 if (r) *r = item->color->r; 2021 int *r,
1995 if (g) *g = item->color->g; 2022 int *g,
1996 if (b) *b = item->color->b; 2023 int *b,
1997 if (a) *a = item->color->a; 2024 int *a)
1998 } 2025{
2026 if (r) *r = item->color->r;
2027 if (g) *g = item->color->g;
2028 if (b) *b = item->color->b;
2029 if (a) *a = item->color->a;
1999} 2030}
2000 2031
2001EAPI void 2032EAPI void
@@ -2005,11 +2036,17 @@ elm_colorselector_palette_item_color_set(Elm_Object_Item *it,
2005 int b, 2036 int b,
2006 int a) 2037 int a)
2007{ 2038{
2008 Elm_Color_Item *item; 2039 eo_do((Eo *) it, elm_obj_color_item_color_set(r, g, b, a));
2009 2040}
2010 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
2011 2041
2012 item = (Elm_Color_Item *)it; 2042EOLIAN static void
2043_elm_color_item_color_set(Eo *eo_item EINA_UNUSED,
2044 Elm_Color_Item_Data *item,
2045 int r,
2046 int g,
2047 int b,
2048 int a)
2049{
2013 item->color->r = r; 2050 item->color->r = r;
2014 item->color->g = g; 2051 item->color->g = g;
2015 item->color->b = b; 2052 item->color->b = b;
@@ -2019,22 +2056,23 @@ elm_colorselector_palette_item_color_set(Elm_Object_Item *it,
2019 (item->color->g * item->color->a) / 255, 2056 (item->color->g * item->color->a) / 255,
2020 (item->color->b * item->color->a) / 255, 2057 (item->color->b * item->color->a) / 255,
2021 item->color->a); 2058 item->color->a);
2022 _colors_save(WIDGET(it)); 2059 _colors_save(WIDGET(item));
2023} 2060}
2024 2061
2025EOLIAN static Elm_Object_Item* 2062EOLIAN static Elm_Object_Item*
2026_elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r, int g, int b, int a) 2063_elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r, int g, int b, int a)
2027{ 2064{
2028 Elm_Color_Item *item; 2065 Eo *eo_item;
2029 2066
2030 if (sd->config_load) 2067 if (sd->config_load)
2031 { 2068 {
2032 _items_del(sd); 2069 _items_del(sd);
2033 sd->config_load = EINA_FALSE; 2070 sd->config_load = EINA_FALSE;
2034 } 2071 }
2035 item = _item_new(obj); 2072 eo_item = eo_add(ELM_COLOR_ITEM_CLASS, obj);
2036 if (!item) return NULL; 2073 if (!eo_item) return NULL;
2037 2074
2075 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
2038 item->color = ELM_NEW(Elm_Color_RGBA); 2076 item->color = ELM_NEW(Elm_Color_RGBA);
2039 if (!item->color) return NULL; 2077 if (!item->color) return NULL;
2040 2078
@@ -2050,11 +2088,11 @@ _elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r,
2050 (item->color->b * item->color->a) / 255, 2088 (item->color->b * item->color->a) / 255,
2051 item->color->a); 2089 item->color->a);
2052 2090
2053 sd->items = eina_list_append(sd->items, item); 2091 sd->items = eina_list_append(sd->items, eo_item);
2054 2092
2055 elm_layout_sizing_eval(obj); 2093 elm_layout_sizing_eval(obj);
2056 2094
2057 return (Elm_Object_Item *)item; 2095 return EO_OBJ(item);
2058} 2096}
2059 2097
2060EOLIAN static void 2098EOLIAN static void
@@ -2076,25 +2114,34 @@ EAPI void
2076elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, 2114elm_colorselector_palette_item_selected_set(Elm_Object_Item *it,
2077 Eina_Bool selected) 2115 Eina_Bool selected)
2078{ 2116{
2079 Elm_Color_Item *temp_item, *item; 2117 eo_do((Eo *) it, elm_obj_color_item_selected_set(selected));
2080 item = (Elm_Color_Item *)it; 2118}
2119
2120EOLIAN static void
2121_elm_color_item_selected_set(Eo *eo_item,
2122 Elm_Color_Item_Data *item,
2123 Eina_Bool selected)
2124{
2125 Eo *eo_temp_item;
2081 Eina_List *l; 2126 Eina_List *l;
2082 2127
2083 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 2128 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2084 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
2085 2129
2086 if (selected) 2130 if (selected)
2087 { 2131 {
2088 temp_item = eina_list_data_get(sd->selected); 2132 eo_temp_item = eina_list_data_get(sd->selected);
2089 if (item == temp_item) return; 2133 if (eo_item == eo_temp_item) return;
2090 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm"); 2134 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
2091 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g, 2135 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
2092 item->color->b, item->color->a); 2136 item->color->b, item->color->a);
2093 if (temp_item) 2137 if (eo_temp_item)
2094 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm"); 2138 {
2139 ELM_COLOR_ITEM_DATA_GET(eo_temp_item, temp_item);
2140 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm");
2141 }
2095 2142
2096 EINA_LIST_FOREACH(sd->items, l, temp_item) 2143 EINA_LIST_FOREACH(sd->items, l, eo_temp_item)
2097 if (item == temp_item) sd->selected = l; 2144 if (eo_item == eo_temp_item) sd->selected = l;
2098 } 2145 }
2099 else 2146 else
2100 { 2147 {
@@ -2106,13 +2153,18 @@ elm_colorselector_palette_item_selected_set(Elm_Object_Item *it,
2106EAPI Eina_Bool 2153EAPI Eina_Bool
2107elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it) 2154elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it)
2108{ 2155{
2109 Elm_Color_Item *temp_item, *item; 2156 return eo_do((Eo *) it, elm_obj_color_item_selected_get());
2110 item = (Elm_Color_Item *)it; 2157}
2111 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); 2158
2159EOLIAN static Eina_Bool
2160_elm_color_item_selected_get(Eo *eo_item EINA_UNUSED, Elm_Color_Item_Data *item)
2161{
2162 Eo *eo_temp_item;
2163
2112 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 2164 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2113 2165
2114 temp_item = eina_list_data_get(sd->selected); 2166 eo_temp_item = eina_list_data_get(sd->selected);
2115 if (item == temp_item) return EINA_TRUE; 2167 if (eo_item == eo_temp_item) return EINA_TRUE;
2116 else return EINA_FALSE; 2168 else return EINA_FALSE;
2117} 2169}
2118 2170
@@ -2163,3 +2215,5 @@ _elm_colorselector_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EIN
2163} 2215}
2164 2216
2165#include "elm_colorselector.eo.c" 2217#include "elm_colorselector.eo.c"
2218#include "elm_color_item.eo.c"
2219
diff --git a/src/lib/elm_colorselector_common.h b/src/lib/elm_colorselector_common.h
index 03935af54..00445bce5 100644
--- a/src/lib/elm_colorselector_common.h
+++ b/src/lib/elm_colorselector_common.h
@@ -30,50 +30,10 @@ typedef enum
30 ELM_COLORSELECTOR_ALL /**< all possible color selector is displayed */ 30 ELM_COLORSELECTOR_ALL /**< all possible color selector is displayed */
31} Elm_Colorselector_Mode; 31} Elm_Colorselector_Mode;
32 32
33/**
34 * Get Palette item's color.
35 *
36 * @param it The color palette item.
37 * @param r integer pointer for r-value of color
38 * @param g integer pointer for g-value of color
39 * @param b integer pointer for b-value of color
40 * @param a integer pointer for a-value of color
41 *
42 * @ingroup Colorselector
43 */
44EAPI void elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r, int *g, int *b, int *a); 33EAPI void elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r, int *g, int *b, int *a);
45 34
46/**
47 * Set palette item's color.
48 *
49 * @param it The color palette item.
50 * @param r r-value of color
51 * @param g g-value of color
52 * @param b b-value of color
53 * @param a a-value of color
54 *
55 * @ingroup Colorselector
56 */
57EAPI void elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r, int g, int b, int a); 35EAPI void elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r, int g, int b, int a);
58 36
59/**
60 * Get the selected state of color palette item.
61 *
62 * @param it The Colorpalette item
63 * @return @c EINA_TRUE if the item is selected, @c EINA_FALSE otherwise.
64 *
65 * @since 1.9
66 * @ingroup Colorselector
67 */
68EAPI Eina_Bool elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it); 37EAPI Eina_Bool elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it);
69 38
70/**
71 * Set the selected state of color palette item
72 *
73 * @param it The Colorpalette item
74 * @param selected if it's @c EINA_TRUE, select the item otherwise, unselect the item
75 *
76 * @since 1.9
77 * @ingroup Colorselector
78 */
79EAPI void elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, Eina_Bool selected); 39EAPI void elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
diff --git a/src/lib/elm_widget_colorselector.h b/src/lib/elm_widget_colorselector.h
index b55d59be0..3666fc8d9 100644
--- a/src/lib/elm_widget_colorselector.h
+++ b/src/lib/elm_widget_colorselector.h
@@ -2,6 +2,9 @@
2#define ELM_WIDGET_COLORSELECTOR_H 2#define ELM_WIDGET_COLORSELECTOR_H
3 3
4#include "Elementary.h" 4#include "Elementary.h"
5#include "elm_color_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
@@ -87,10 +90,10 @@ struct _Color_Bar_Data
87 Color_Type color_type; 90 Color_Type color_type;
88}; 91};
89 92
90typedef struct _Elm_Color_Item Elm_Color_Item; 93typedef struct _Elm_Color_Item_Data Elm_Color_Item_Data;
91struct _Elm_Color_Item 94struct _Elm_Color_Item_Data
92{ 95{
93 ELM_WIDGET_ITEM; 96 Elm_Widget_Item_Data *base;
94 97
95 Evas_Object *color_obj; 98 Evas_Object *color_obj;
96 Elm_Color_RGBA *color; 99 Elm_Color_RGBA *color;
@@ -121,16 +124,19 @@ struct _Elm_Color_Item
121 return val; \ 124 return val; \
122 } 125 }
123 126
127#define ELM_COLOR_ITEM_DATA_GET(o, sd) \
128 Elm_Color_Item_Data * sd = eo_data_scope_get((Eo *)o, ELM_COLOR_ITEM_CLASS)
129
124#define ELM_COLORSELECTOR_CHECK(obj) \ 130#define ELM_COLORSELECTOR_CHECK(obj) \
125 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLORSELECTOR_CLASS))) \ 131 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLORSELECTOR_CLASS))) \
126 return 132 return
127 133
128#define ELM_COLORSELECTOR_ITEM_CHECK(it) \ 134#define ELM_COLORSELECTOR_ITEM_CHECK(it) \
129 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \ 135 if (EINA_UNLIKELY(!eo_isa((Eo *)it->base->eo_obj, ELM_COLOR_ITEM_CLASS))) \
130 ELM_COLORSELECTOR_CHECK(it->base.widget); 136 return
131 137
132#define ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, ...) \ 138#define ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, ...) \
133 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \ 139 if (EINA_UNLIKELY(!eo_isa((Eo *)it->base->eo_obj, ELM_COLOR_ITEM_CLASS))) \
134 ELM_COLORSELECTOR_CHECK(it->base.widget) __VA_ARGS__; 140 return __VA_ARGS__;
135 141
136#endif 142#endif