summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-24 15:49:33 +0300
committerYossi Kantor <yossi.kantor@samsung.com>2014-08-03 14:49:40 +0300
commit5e20b13e270a92c3b078147f47d7918763cd00a7 (patch)
tree8269c5a4a06648eaad49b5c765ab166d62862e4c
parentd403541dc88d87cd5e8ec94053f682a7da5caae7 (diff)
Integration of Colorselector Item
-rw-r--r--src/lib/Makefile.am9
-rw-r--r--src/lib/elm_color_item.eo56
-rw-r--r--src/lib/elm_colorselector.c306
-rw-r--r--src/lib/elm_widget_colorselector.h24
4 files changed, 258 insertions, 137 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index b7cf6a6a3..83f9a31e0 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -776,7 +776,9 @@ BUILT_SOURCES = \
776 elm_win.eo.h \ 776 elm_win.eo.h \
777 elm_win.eo.legacy.h \ 777 elm_win.eo.legacy.h \
778 elm_widget_item.eo.c \ 778 elm_widget_item.eo.c \
779 elm_widget_item.eo.h 779 elm_widget_item.eo.h \
780 elm_color_item.eo.c \
781 elm_color_item.eo.h
780 782
781elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 783elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
782elementaryeolianfiles_DATA = \ 784elementaryeolianfiles_DATA = \
@@ -869,7 +871,8 @@ elementaryeolianfiles_DATA = \
869 elm_video.eo \ 871 elm_video.eo \
870 elm_web.eo \ 872 elm_web.eo \
871 elm_win.eo \ 873 elm_win.eo \
872 elm_widget_item.eo 874 elm_widget_item.eo \
875 elm_color_item.eo
873 876
874EXTRA_DIST += \ 877EXTRA_DIST += \
875 ${elementaryeolianfiles_DATA} 878 ${elementaryeolianfiles_DATA}
@@ -1026,4 +1029,4 @@ nodist_includesunstable_HEADERS = \
1026 elm_toolbar.eo.legacy.h \ 1029 elm_toolbar.eo.legacy.h \
1027 elm_video.eo.legacy.h \ 1030 elm_video.eo.legacy.h \
1028 elm_web.eo.legacy.h \ 1031 elm_web.eo.legacy.h \
1029 elm_win.eo.legacy.h 1032 elm_win.eo.legacy.h \ No newline at end of file
diff --git a/src/lib/elm_color_item.eo b/src/lib/elm_color_item.eo
new file mode 100644
index 000000000..7092f1654
--- /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_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 @ingroup Colorselector
34 */
35 }
36 set {
37 /*@
38 Set the selected state of color palette item
39
40 @ingroup Colorselector
41 */
42 }
43 values {
44 Eina_Bool selected; /*@ EINA_TRUE if selected EINA_FALSE otherwise */
45 }
46 }
47 }
48 methods {
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} \ No newline at end of file
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index 8323d6fc8..479d5499b 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -50,14 +50,13 @@ enum Palette_Box_Direction
50static void 50static void
51_items_del(Elm_Colorselector_Data *sd) 51_items_del(Elm_Colorselector_Data *sd)
52{ 52{
53 Elm_Color_Item *item; 53 Elm_Widobj_Item *eo_item;
54 54
55 if (!sd->items) return; 55 if (!sd->items) return;
56 56
57 EINA_LIST_FREE(sd->items, item) 57 EINA_LIST_FREE(sd->items, eo_item)
58 { 58 {
59 free(item->color); 59 eo_del (eo_item);
60 elm_widget_item_free(item);
61 } 60 }
62 61
63 sd->items = NULL; 62 sd->items = NULL;
@@ -1074,7 +1073,7 @@ _elm_colorselector_elm_widget_theme_apply(Eo *obj, Elm_Colorselector_Data *sd)
1074{ 1073{
1075 int i; 1074 int i;
1076 Eina_List *elist; 1075 Eina_List *elist;
1077 Elm_Color_Item *item; 1076 Elm_Widobj_Item *eo_item;
1078 const char *hpadstr, *vpadstr; 1077 const char *hpadstr, *vpadstr;
1079 unsigned int h_pad = DEFAULT_HOR_PAD; 1078 unsigned int h_pad = DEFAULT_HOR_PAD;
1080 unsigned int v_pad = DEFAULT_VER_PAD; 1079 unsigned int v_pad = DEFAULT_VER_PAD;
@@ -1103,8 +1102,9 @@ _elm_colorselector_elm_widget_theme_apply(Eo *obj, Elm_Colorselector_Data *sd)
1103 (h_pad * elm_widget_scale_get(obj) * elm_config_scale_get()), 1102 (h_pad * elm_widget_scale_get(obj) * elm_config_scale_get()),
1104 (v_pad * elm_widget_scale_get(obj) * elm_config_scale_get())); 1103 (v_pad * elm_widget_scale_get(obj) * elm_config_scale_get()));
1105 1104
1106 EINA_LIST_FOREACH(sd->items, elist, item) 1105 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1107 { 1106 {
1107 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1108 if (!elm_layout_theme_set 1108 if (!elm_layout_theme_set
1109 (VIEW(item), "colorselector", "item", elm_widget_style_get(obj))) 1109 (VIEW(item), "colorselector", "item", elm_widget_style_get(obj)))
1110 CRI("Failed to set layout!"); 1110 CRI("Failed to set layout!");
@@ -1151,7 +1151,7 @@ _sub_obj_size_hints_set(Evas_Object *sobj,
1151} 1151}
1152 1152
1153static void 1153static void
1154_item_sizing_eval(Elm_Color_Item *item) 1154_item_sizing_eval(Elm_Color_Item_Data *item)
1155{ 1155{
1156 Evas_Coord minw = -1, minh = -1; 1156 Evas_Coord minw = -1, minh = -1;
1157 Evas_Object *edje; 1157 Evas_Object *edje;
@@ -1170,12 +1170,15 @@ static void
1170_palette_sizing_eval(Evas_Object *obj) 1170_palette_sizing_eval(Evas_Object *obj)
1171{ 1171{
1172 Eina_List *elist; 1172 Eina_List *elist;
1173 Elm_Color_Item *item; 1173 Elm_Widobj_Item *eo_item;
1174 1174
1175 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1175 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1176 1176
1177 EINA_LIST_FOREACH(sd->items, elist, item) 1177 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1178 _item_sizing_eval(item); 1178 {
1179 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1180 _item_sizing_eval(item);
1181 }
1179} 1182}
1180 1183
1181static void 1184static void
@@ -1269,14 +1272,15 @@ _on_resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
1269static Eina_Bool 1272static Eina_Bool
1270_on_color_long_press(void *data) 1273_on_color_long_press(void *data)
1271{ 1274{
1272 Elm_Color_Item *item = (Elm_Color_Item *)data; 1275 Elm_Widobj_Item *eo_item = (Elm_Widobj_Item *)data;
1276 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1273 1277
1274 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1278 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1275 1279
1276 sd->longpress_timer = NULL; 1280 sd->longpress_timer = NULL;
1277 1281
1278 evas_object_smart_callback_call 1282 evas_object_smart_callback_call
1279 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, item); 1283 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, eo_item);
1280 1284
1281 return ECORE_CALLBACK_CANCEL; 1285 return ECORE_CALLBACK_CANCEL;
1282} 1286}
@@ -1287,10 +1291,10 @@ _on_color_pressed(void *data,
1287 Evas_Object *obj EINA_UNUSED, 1291 Evas_Object *obj EINA_UNUSED,
1288 void *event_info EINA_UNUSED) 1292 void *event_info EINA_UNUSED)
1289{ 1293{
1290 Elm_Color_Item *item = (Elm_Color_Item *)data; 1294 if (!data) return;
1291 Evas_Event_Mouse_Down *ev = event_info;
1292 1295
1293 if (!item) return; 1296 ELM_COLOR_ITEM_DATA_GET((Elm_Widobj_Item *)data, item);
1297 Evas_Event_Mouse_Down *ev = event_info;
1294 1298
1295 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1299 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1296 1300
@@ -1307,12 +1311,13 @@ _on_color_released(void *data,
1307 Evas_Object *obj EINA_UNUSED, 1311 Evas_Object *obj EINA_UNUSED,
1308 void *event_info EINA_UNUSED) 1312 void *event_info EINA_UNUSED)
1309{ 1313{
1310 Elm_Color_Item *item = (Elm_Color_Item *)data; 1314 Elm_Widobj_Item *eo_item = (Elm_Widobj_Item *)data;
1311 Eina_List *l; 1315 Eina_List *l;
1312 Elm_Color_Item *temp_item; 1316 Elm_Widobj_Item *eo_temp_item;
1313 Evas_Event_Mouse_Down *ev = event_info; 1317 Evas_Event_Mouse_Down *ev = event_info;
1314 if (!item) return; 1318 if (!eo_item) return;
1315 1319
1320 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1316 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1321 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1317 1322
1318 if (ev->button != 1) return; 1323 if (ev->button != 1) return;
@@ -1322,14 +1327,17 @@ _on_color_released(void *data,
1322 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g, 1327 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
1323 item->color->b, item->color->a); 1328 item->color->b, item->color->a);
1324 evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED, 1329 evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED,
1325 item); 1330 eo_item);
1326 1331
1327 temp_item = eina_list_data_get(sd->selected); 1332 eo_temp_item = eina_list_data_get(sd->selected);
1328 if (temp_item && (temp_item != item)) 1333 if (eo_temp_item && (eo_temp_item != eo_item))
1329 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm"); 1334 {
1335 ELM_COLOR_ITEM_DATA_GET(eo_temp_item, temp_item);
1336 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm");
1337 }
1330 1338
1331 EINA_LIST_FOREACH(sd->items, l, temp_item) 1339 EINA_LIST_FOREACH(sd->items, l, eo_temp_item)
1332 if (item == temp_item) sd->selected = l; 1340 if (eo_item == eo_temp_item) sd->selected = l;
1333 sd->focused = ELM_COLORSELECTOR_PALETTE; 1341 sd->focused = ELM_COLORSELECTOR_PALETTE;
1334} 1342}
1335 1343
@@ -1340,7 +1348,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1340 Eina_Strbuf *buf; 1348 Eina_Strbuf *buf;
1341 int r = 0, g = 0, b = 0 ,a = 0; 1349 int r = 0, g = 0, b = 0 ,a = 0;
1342 1350
1343 Elm_Color_Item *it = data; 1351 Elm_Widobj_Item *it = data;
1344 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL); 1352 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL);
1345 1353
1346 elm_colorselector_palette_item_color_get((Elm_Object_Item *)it, &r, &g, &b, &a); 1354 elm_colorselector_palette_item_color_get((Elm_Object_Item *)it, &r, &g, &b, &a);
@@ -1352,17 +1360,20 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1352 return ret; 1360 return ret;
1353} 1361}
1354 1362
1355static void 1363EOLIAN static Evas_Object*
1356_access_widget_item_register(Elm_Color_Item *it) 1364_elm_color_item_elm_widget_item_access_register(Eo *obj, Elm_Color_Item_Data *_pd)
1357{ 1365{
1358 Elm_Access_Info *ai; 1366 Elm_Access_Info *ai;
1359 1367
1360 _elm_access_widget_item_register((Elm_Widget_Item *)it); 1368 Evas_Object *res;
1369 eo_do_super(obj, ELM_COLOR_ITEM_CLASS, res = elm_wdg_item_access_register());
1361 1370
1362 ai = _elm_access_info_get(it->base.access_obj); 1371 ai = _elm_access_info_get(_pd->base->access_obj);
1363 1372
1364 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("color selector palette item")); 1373 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("color selector palette item"));
1365 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it); 1374 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, obj);
1375
1376 return res;
1366} 1377}
1367 1378
1368static void 1379static void
@@ -1374,25 +1385,27 @@ _item_resize(void *data EINA_UNUSED,
1374 elm_layout_sizing_eval(obj); 1385 elm_layout_sizing_eval(obj);
1375} 1386}
1376 1387
1377static void 1388EOLIAN static void
1378_item_signal_emit_hook(Elm_Object_Item *it, 1389_elm_color_item_elm_widget_item_signal_emit(Eo *obj EINA_UNUSED,
1379 const char *emission, 1390 Elm_Color_Item_Data *_pd,
1380 const char *source) 1391 const char *emission,
1392 const char *source)
1381{ 1393{
1382 elm_object_signal_emit(VIEW(it), emission, source); 1394 elm_object_signal_emit(VIEW(_pd), emission, source);
1383} 1395}
1384 1396
1385static Elm_Color_Item * 1397EOLIAN static void
1386_item_new(Evas_Object *obj) 1398_elm_color_item_eo_base_constructor(Eo *obj, Elm_Color_Item_Data *item)
1387{ 1399{
1388 Elm_Color_Item *item; 1400 eo_do_super(obj, ELM_COLOR_ITEM_CLASS, eo_constructor());
1401 item->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
1389 1402
1390 item = elm_widget_item_new(obj, Elm_Color_Item); 1403 Evas_Object *parent;
1391 if (!item) return NULL; 1404 eo_do (obj, parent = eo_parent_get());
1392 1405
1393 VIEW(item) = elm_layout_add(obj); 1406 VIEW(item) = elm_layout_add(parent);
1394 if (!elm_layout_theme_set 1407 if (!elm_layout_theme_set
1395 (VIEW(item), "colorselector", "item", elm_widget_style_get(obj))) 1408 (VIEW(item), "colorselector", "item", elm_widget_style_get(parent)))
1396 CRI("Failed to set layout!"); 1409 CRI("Failed to set layout!");
1397 evas_object_size_hint_weight_set 1410 evas_object_size_hint_weight_set
1398 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1411 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -1400,30 +1413,33 @@ _item_new(Evas_Object *obj)
1400 evas_object_event_callback_add 1413 evas_object_event_callback_add
1401 (VIEW(item), EVAS_CALLBACK_RESIZE, _item_resize, NULL); 1414 (VIEW(item), EVAS_CALLBACK_RESIZE, _item_resize, NULL);
1402 1415
1403 item->color_obj = edje_object_add(evas_object_evas_get(obj)); 1416 item->color_obj = edje_object_add(evas_object_evas_get(parent));
1404 elm_widget_theme_object_set 1417 elm_widget_theme_object_set
1405 (obj, item->color_obj, "colorselector", "item/color", 1418 (parent, item->color_obj, "colorselector", "item/color",
1406 elm_widget_style_get(obj)); 1419 elm_widget_style_get(parent));
1407 evas_object_size_hint_weight_set 1420 evas_object_size_hint_weight_set
1408 (item->color_obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1421 (item->color_obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1409 evas_object_size_hint_align_set 1422 evas_object_size_hint_align_set
1410 (item->color_obj, EVAS_HINT_FILL, EVAS_HINT_FILL); 1423 (item->color_obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1411 evas_object_event_callback_add 1424 evas_object_event_callback_add
1412 (item->color_obj, EVAS_CALLBACK_MOUSE_DOWN, _on_color_pressed, item); 1425 (item->color_obj, EVAS_CALLBACK_MOUSE_DOWN, _on_color_pressed, obj);
1413 evas_object_event_callback_add 1426 evas_object_event_callback_add
1414 (item->color_obj, EVAS_CALLBACK_MOUSE_UP, _on_color_released, item); 1427 (item->color_obj, EVAS_CALLBACK_MOUSE_UP, _on_color_released, obj);
1415 elm_object_part_content_set(VIEW(item), "color_obj", item->color_obj); 1428 elm_object_part_content_set(VIEW(item), "color_obj", item->color_obj);
1416 1429
1417 elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
1418
1419 _item_sizing_eval(item); 1430 _item_sizing_eval(item);
1420 evas_object_show(VIEW(item)); 1431 evas_object_show(VIEW(item));
1421 1432
1422 // ACCESS 1433 // ACCESS
1423 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON) 1434 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
1424 _access_widget_item_register(item); 1435 eo_do(obj, elm_wdg_item_access_register());
1436}
1425 1437
1426 return item; 1438EOLIAN static void
1439_elm_color_item_eo_base_destructor(Eo *obj, Elm_Color_Item_Data *item)
1440{
1441 free(item->color);
1442 eo_do_super(obj, ELM_COLOR_ITEM_CLASS, eo_destructor());
1427} 1443}
1428 1444
1429static void 1445static void
@@ -1439,21 +1455,24 @@ static void
1439_colors_save(Evas_Object *obj) 1455_colors_save(Evas_Object *obj)
1440{ 1456{
1441 Eina_List *elist; 1457 Eina_List *elist;
1442 Elm_Color_Item *item; 1458 Elm_Widobj_Item *eo_item;
1443 1459
1444 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1460 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1445 1461
1446 _elm_config_colors_free(sd->palette_name); 1462 _elm_config_colors_free(sd->palette_name);
1447 EINA_LIST_FOREACH(sd->items, elist, item) 1463 EINA_LIST_FOREACH(sd->items, elist, eo_item)
1448 _elm_config_color_set(sd->palette_name, item->color->r, item->color->g, 1464 {
1465 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1466 _elm_config_color_set(sd->palette_name, item->color->r, item->color->g,
1449 item->color->b, item->color->a); 1467 item->color->b, item->color->a);
1468 }
1450} 1469}
1451 1470
1452static void 1471static void
1453_palette_colors_load(Evas_Object *obj) 1472_palette_colors_load(Evas_Object *obj)
1454{ 1473{
1455 Eina_List *elist; 1474 Eina_List *elist;
1456 Elm_Color_Item *item; 1475 Elm_Widobj_Item *eo_item;
1457 Eina_List *color_list; 1476 Eina_List *color_list;
1458 Elm_Color_RGBA *color; 1477 Elm_Color_RGBA *color;
1459 1478
@@ -1464,11 +1483,14 @@ _palette_colors_load(Evas_Object *obj)
1464 1483
1465 EINA_LIST_FOREACH(color_list, elist, color) 1484 EINA_LIST_FOREACH(color_list, elist, color)
1466 { 1485 {
1467 item = _item_new(obj); 1486 eo_item = eo_add(ELM_COLOR_ITEM_CLASS, obj);
1468 if (!item) return; 1487 if (!eo_item) return;
1488
1489 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1469 1490
1470 item->color = ELM_NEW(Elm_Color_RGBA); 1491 item->color = ELM_NEW(Elm_Color_RGBA);
1471 if (!item->color) return; 1492 if (!item->color) return;
1493
1472 item->color->r = color->r; 1494 item->color->r = color->r;
1473 item->color->g = color->g; 1495 item->color->g = color->g;
1474 item->color->b = color->b; 1496 item->color->b = color->b;
@@ -1479,9 +1501,9 @@ _palette_colors_load(Evas_Object *obj)
1479 (item->color->r * item->color->a) / 255, 1501 (item->color->r * item->color->a) / 255,
1480 (item->color->g * item->color->a) / 255, 1502 (item->color->g * item->color->a) / 255,
1481 (item->color->b * item->color->a) / 255, 1503 (item->color->b * item->color->a) / 255,
1482 item->color->a); 1504 item->color->a);
1483 1505
1484 sd->items = eina_list_append(sd->items, item); 1506 sd->items = eina_list_append(sd->items, eo_item);
1485 } 1507 }
1486 1508
1487 sd->config_load = EINA_TRUE; 1509 sd->config_load = EINA_TRUE;
@@ -1610,7 +1632,7 @@ static Eina_List*
1610_palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction dir) 1632_palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction dir)
1611{ 1633{
1612 Evas_Coord basex, basey, x, y, dx, min_dx; 1634 Evas_Coord basex, basey, x, y, dx, min_dx;
1613 Elm_Color_Item *item; 1635 Elm_Widobj_Item *eo_item;
1614 Eina_List* l; 1636 Eina_List* l;
1615 Eina_List* res = NULL; 1637 Eina_List* res = NULL;
1616 Eina_List* (*dir_func)(const Eina_List*); 1638 Eina_List* (*dir_func)(const Eina_List*);
@@ -1629,13 +1651,15 @@ _palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction d
1629 return NULL; 1651 return NULL;
1630 } 1652 }
1631 1653
1632 item = eina_list_data_get(ref_item); 1654 eo_item = eina_list_data_get(ref_item);
1655 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1633 evas_object_geometry_get(VIEW(item), &basex, &basey, NULL, NULL); 1656 evas_object_geometry_get(VIEW(item), &basex, &basey, NULL, NULL);
1634 1657
1635 for (l = ref_item; l; l = dir_func(l)) 1658 for (l = ref_item; l; l = dir_func(l))
1636 { 1659 {
1637 item = eina_list_data_get(l); 1660 eo_item = eina_list_data_get(l);
1638 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL); 1661 ELM_COLOR_ITEM_DATA_GET(eo_item, item_data2);
1662 evas_object_geometry_get(VIEW(item_data2), &x, &y, NULL, NULL);
1639 if (basey != y) break; 1663 if (basey != y) break;
1640 } 1664 }
1641 1665
@@ -1644,8 +1668,9 @@ _palette_box_vertical_item_get(Eina_List* ref_item, enum Palette_Box_Direction d
1644 1668
1645 for (; l; l = dir_func(l)) 1669 for (; l; l = dir_func(l))
1646 { 1670 {
1647 item = eina_list_data_get(l); 1671 eo_item = eina_list_data_get(l);
1648 evas_object_geometry_get(VIEW(item), &x, &y, NULL, NULL); 1672 ELM_COLOR_ITEM_DATA_GET(eo_item, item_data2);
1673 evas_object_geometry_get(VIEW(item_data2), &x, &y, NULL, NULL);
1649 if (basey != y) break; 1674 if (basey != y) break;
1650 1675
1651 dx = abs(x - basex); 1676 dx = abs(x - basex);
@@ -1668,7 +1693,7 @@ _key_action_move(Evas_Object *obj, const char *params)
1668{ 1693{
1669 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1694 ELM_COLORSELECTOR_DATA_GET(obj, sd);
1670 Eina_List *cl = NULL; 1695 Eina_List *cl = NULL;
1671 Elm_Color_Item *item = NULL; 1696 Elm_Widobj_Item *eo_item = NULL;
1672 char colorbar_s[128]; 1697 char colorbar_s[128];
1673 const char *dir = params; 1698 const char *dir = params;
1674 1699
@@ -1745,13 +1770,14 @@ _key_action_move(Evas_Object *obj, const char *params)
1745 1770
1746 if (cl) 1771 if (cl)
1747 { 1772 {
1748 item = eina_list_data_get(cl); 1773 eo_item = eina_list_data_get(cl);
1774 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
1749 elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm"); 1775 elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm");
1750 elm_colorselector_color_set 1776 elm_colorselector_color_set
1751 (WIDGET(item), item->color->r, item->color->g, item->color->b, 1777 (WIDGET(item), item->color->r, item->color->g, item->color->b,
1752 item->color->a); 1778 item->color->a);
1753 evas_object_smart_callback_call 1779 evas_object_smart_callback_call
1754 (WIDGET(item), SIG_COLOR_ITEM_SELECTED, item); 1780 (WIDGET(item), SIG_COLOR_ITEM_SELECTED, eo_item);
1755 sd->selected = cl; 1781 sd->selected = cl;
1756 } 1782 }
1757 else if (!cl && sd->focused == ELM_COLORSELECTOR_PALETTE) 1783 else if (!cl && sd->focused == ELM_COLORSELECTOR_PALETTE)
@@ -1797,15 +1823,18 @@ _elm_colorselector_elm_widget_focus_next(Eo *obj, Elm_Colorselector_Data *sd, El
1797{ 1823{
1798 Eina_List *items = NULL; 1824 Eina_List *items = NULL;
1799 Eina_List *l; 1825 Eina_List *l;
1800 Elm_Widget_Item *item; 1826 Elm_Widobj_Item *eo_item;
1801 int i = 0; 1827 int i = 0;
1802 1828
1803 if (!sd) return EINA_FALSE; 1829 if (!sd) return EINA_FALSE;
1804 1830
1805 if (!sd->items) return EINA_FALSE; 1831 if (!sd->items) return EINA_FALSE;
1806 1832
1807 EINA_LIST_FOREACH(sd->items, l, item) 1833 EINA_LIST_FOREACH(sd->items, l, eo_item)
1808 items = eina_list_append(items, item->access_obj); 1834 {
1835 Elm_Widget_Item_Data *item = eo_data_scope_get(eo_item, ELM_WIDGET_ITEM_CLASS);
1836 items = eina_list_append(items, item->access_obj);
1837 }
1809 1838
1810 for (i = 0; i < 4; i++) 1839 for (i = 0; i < 4; i++)
1811 { 1840 {
@@ -1822,7 +1851,7 @@ static void
1822_access_obj_process(Evas_Object *obj, Eina_Bool is_access) 1851_access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1823{ 1852{
1824 Eina_List *l; 1853 Eina_List *l;
1825 Elm_Color_Item *it; 1854 Elm_Widobj_Item *it;
1826 int i = 0; 1855 int i = 0;
1827 1856
1828 ELM_COLORSELECTOR_DATA_GET(obj, sd); 1857 ELM_COLORSELECTOR_DATA_GET(obj, sd);
@@ -1830,7 +1859,7 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1830 if (is_access) 1859 if (is_access)
1831 { 1860 {
1832 EINA_LIST_FOREACH(sd->items, l, it) 1861 EINA_LIST_FOREACH(sd->items, l, it)
1833 _access_widget_item_register(it); 1862 eo_do(it, elm_wdg_item_access_register());
1834 1863
1835 for (i = 0; i < 4; i++) 1864 for (i = 0; i < 4; i++)
1836 _access_colorbar_register(obj, sd->cb_data[i], 1865 _access_colorbar_register(obj, sd->cb_data[i],
@@ -1839,7 +1868,7 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1839 else 1868 else
1840 { 1869 {
1841 EINA_LIST_FOREACH(sd->items, l, it) 1870 EINA_LIST_FOREACH(sd->items, l, it)
1842 _elm_access_widget_item_unregister((Elm_Widget_Item *)it); 1871 eo_do(it, elm_wdg_item_access_unregister());
1843 1872
1844 //TODO: _elm_access_edje_object_part_object_unregister() ? 1873 //TODO: _elm_access_edje_object_part_object_unregister() ?
1845 } 1874 }
@@ -1968,39 +1997,28 @@ _elm_colorselector_mode_get(Eo *obj EINA_UNUSED, Elm_Colorselector_Data *sd)
1968 return sd->mode; 1997 return sd->mode;
1969} 1998}
1970 1999
1971EAPI void 2000EOLIAN static void
1972elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, 2001_elm_color_item_color_get(Eo *obj EINA_UNUSED,
1973 int *r, 2002 Elm_Color_Item_Data *item,
1974 int *g, 2003 int *r,
1975 int *b, 2004 int *g,
1976 int *a) 2005 int *b,
2006 int *a)
1977{ 2007{
1978 Elm_Color_Item *item; 2008 if (r) *r = item->color->r;
1979 2009 if (g) *g = item->color->g;
1980 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it); 2010 if (b) *b = item->color->b;
1981 2011 if (a) *a = item->color->a;
1982 item = (Elm_Color_Item *)it;
1983 if (item)
1984 {
1985 if (r) *r = item->color->r;
1986 if (g) *g = item->color->g;
1987 if (b) *b = item->color->b;
1988 if (a) *a = item->color->a;
1989 }
1990} 2012}
1991 2013
1992EAPI void 2014EOLIAN static void
1993elm_colorselector_palette_item_color_set(Elm_Object_Item *it, 2015_elm_color_item_color_set(Eo *obj EINA_UNUSED,
1994 int r, 2016 Elm_Color_Item_Data *item,
1995 int g, 2017 int r,
1996 int b, 2018 int g,
1997 int a) 2019 int b,
2020 int a)
1998{ 2021{
1999 Elm_Color_Item *item;
2000
2001 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
2002
2003 item = (Elm_Color_Item *)it;
2004 item->color->r = r; 2022 item->color->r = r;
2005 item->color->g = g; 2023 item->color->g = g;
2006 item->color->b = b; 2024 item->color->b = b;
@@ -2010,22 +2028,24 @@ elm_colorselector_palette_item_color_set(Elm_Object_Item *it,
2010 (item->color->g * item->color->a) / 255, 2028 (item->color->g * item->color->a) / 255,
2011 (item->color->b * item->color->a) / 255, 2029 (item->color->b * item->color->a) / 255,
2012 item->color->a); 2030 item->color->a);
2013 _colors_save(WIDGET(it)); 2031
2032 _colors_save(WIDGET(item));
2014} 2033}
2015 2034
2016EOLIAN static Elm_Object_Item* 2035EOLIAN static Elm_Object_Item*
2017_elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r, int g, int b, int a) 2036_elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r, int g, int b, int a)
2018{ 2037{
2019 Elm_Color_Item *item; 2038 Elm_Widobj_Item *eo_item;
2020 2039
2021 if (sd->config_load) 2040 if (sd->config_load)
2022 { 2041 {
2023 _items_del(sd); 2042 _items_del(sd);
2024 sd->config_load = EINA_FALSE; 2043 sd->config_load = EINA_FALSE;
2025 } 2044 }
2026 item = _item_new(obj); 2045 eo_item = eo_add(ELM_COLOR_ITEM_CLASS, obj);
2027 if (!item) return NULL; 2046 if (!eo_item) return NULL;
2028 2047
2048 ELM_COLOR_ITEM_DATA_GET(eo_item, item);
2029 item->color = ELM_NEW(Elm_Color_RGBA); 2049 item->color = ELM_NEW(Elm_Color_RGBA);
2030 if (!item->color) return NULL; 2050 if (!item->color) return NULL;
2031 2051
@@ -2039,13 +2059,13 @@ _elm_colorselector_palette_color_add(Eo *obj, Elm_Colorselector_Data *sd, int r,
2039 (item->color->r * item->color->a) / 255, 2059 (item->color->r * item->color->a) / 255,
2040 (item->color->g * item->color->a) / 255, 2060 (item->color->g * item->color->a) / 255,
2041 (item->color->b * item->color->a) / 255, 2061 (item->color->b * item->color->a) / 255,
2042 item->color->a); 2062 item->color->a);
2043 2063
2044 sd->items = eina_list_append(sd->items, item); 2064 sd->items = eina_list_append(sd->items, eo_item);
2045 2065
2046 elm_layout_sizing_eval(obj); 2066 elm_layout_sizing_eval(obj);
2047 2067
2048 return (Elm_Object_Item *)item; 2068 return (Elm_Object_Item *)eo_item;
2049} 2069}
2050 2070
2051EOLIAN static void 2071EOLIAN static void
@@ -2063,29 +2083,29 @@ _elm_colorselector_palette_items_get(Eo *obj EINA_UNUSED, Elm_Colorselector_Data
2063 return sd->items; 2083 return sd->items;
2064} 2084}
2065 2085
2066EAPI void 2086EOLIAN static void
2067elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, 2087_elm_color_item_selected_set(Eo *obj,
2068 Eina_Bool selected) 2088 Elm_Color_Item_Data *item,
2089 Eina_Bool selected)
2069{ 2090{
2070 Elm_Color_Item *temp_item, *item; 2091 Elm_Widobj_Item *temp_item;
2071 item = (Elm_Color_Item *)it;
2072 Eina_List *l; 2092 Eina_List *l;
2073 2093
2074 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 2094 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2075 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
2076 2095
2077 if (selected) 2096 if (selected)
2078 { 2097 {
2079 temp_item = eina_list_data_get(sd->selected); 2098 temp_item = eina_list_data_get(sd->selected);
2080 if (item == temp_item) return; 2099 if (obj == temp_item) return;
2100
2081 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm"); 2101 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
2082 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g, 2102 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
2083 item->color->b, item->color->a); 2103 item->color->b, item->color->a);
2084 if (temp_item) 2104 if (temp_item)
2085 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm"); 2105 elm_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
2086 2106
2087 EINA_LIST_FOREACH(sd->items, l, temp_item) 2107 EINA_LIST_FOREACH(sd->items, l, temp_item)
2088 if (item == temp_item) sd->selected = l; 2108 if (obj == temp_item) sd->selected = l;
2089 } 2109 }
2090 else 2110 else
2091 { 2111 {
@@ -2094,16 +2114,15 @@ elm_colorselector_palette_item_selected_set(Elm_Object_Item *it,
2094 } 2114 }
2095} 2115}
2096 2116
2097EAPI Eina_Bool 2117EOLIAN static Eina_Bool
2098elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it) 2118_elm_color_item_selected_get(Eo *obj, Elm_Color_Item_Data *item)
2099{ 2119{
2100 Elm_Color_Item *temp_item, *item; 2120 Elm_Widobj_Item *temp_item;
2101 item = (Elm_Color_Item *)it; 2121
2102 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2103 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 2122 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2104 2123
2105 temp_item = eina_list_data_get(sd->selected); 2124 temp_item = eina_list_data_get(sd->selected);
2106 if (item == temp_item) return EINA_TRUE; 2125 if (obj == temp_item) return EINA_TRUE;
2107 else return EINA_FALSE; 2126 else return EINA_FALSE;
2108} 2127}
2109 2128
@@ -2140,4 +2159,41 @@ _elm_colorselector_class_constructor(Eo_Class *klass)
2140 _elm_colorselector_smart_focus_next_enable = EINA_TRUE; 2159 _elm_colorselector_smart_focus_next_enable = EINA_TRUE;
2141} 2160}
2142 2161
2162EAPI void
2163elm_colorselector_palette_item_selected_set(Elm_Object_Item *it,
2164 Eina_Bool selected)
2165{
2166 eo_do((Eo *) it, elm_color_item_selected_set(selected));
2167}
2168
2169EAPI Eina_Bool
2170elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it)
2171{
2172 Eina_Bool selected = 0;
2173 eo_do((Eo *) it, selected = elm_color_item_selected_get());
2174 return selected;
2175}
2176
2177EAPI void
2178elm_colorselector_palette_item_color_get(const Elm_Object_Item *it,
2179 int *r,
2180 int *g,
2181 int *b,
2182 int *a)
2183{
2184 eo_do((Eo *) it, elm_color_item_color_get(r, g, b, a));
2185}
2186
2187EAPI void
2188elm_colorselector_palette_item_color_set(Elm_Object_Item *it,
2189 int r,
2190 int g,
2191 int b,
2192 int a)
2193{
2194 eo_do((Eo *) it, elm_color_item_color_set(r, g, b, a));
2195}
2196
2143#include "elm_colorselector.eo.c" 2197#include "elm_colorselector.eo.c"
2198#include "elm_color_item.eo.c"
2199
diff --git a/src/lib/elm_widget_colorselector.h b/src/lib/elm_widget_colorselector.h
index 1c74162f6..42d675c07 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/** 9/**
7 * @addtogroup Widget 10 * @addtogroup Widget
@@ -81,10 +84,10 @@ struct _Color_Bar_Data
81 Color_Type color_type; 84 Color_Type color_type;
82}; 85};
83 86
84typedef struct _Elm_Color_Item Elm_Color_Item; 87typedef struct _Elm_Color_Item_Data Elm_Color_Item_Data;
85struct _Elm_Color_Item 88struct _Elm_Color_Item_Data
86{ 89{
87 ELM_WIDGET_ITEM; 90 Elm_Widget_Item_Data *base;
88 91
89 Evas_Object *color_obj; 92 Evas_Object *color_obj;
90 Elm_Color_RGBA *color; 93 Elm_Color_RGBA *color;
@@ -115,16 +118,19 @@ struct _Elm_Color_Item
115 return val; \ 118 return val; \
116 } 119 }
117 120
121#define ELM_COLOR_ITEM_DATA_GET(o, sd) \
122 Elm_Color_Item_Data * sd = eo_data_scope_get(o, ELM_COLOR_ITEM_CLASS)
123
118#define ELM_COLORSELECTOR_CHECK(obj) \ 124#define ELM_COLORSELECTOR_CHECK(obj) \
119 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLORSELECTOR_CLASS))) \ 125 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLORSELECTOR_CLASS))) \
120 return 126 return
121 127
122#define ELM_COLORSELECTOR_ITEM_CHECK(it) \ 128#define ELM_COLORSELECTOR_ITEM_CHECK(obj) \
123 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \ 129 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLOR_ITEM_CLASS))) \
124 ELM_COLORSELECTOR_CHECK(it->base.widget); 130 return
125 131
126#define ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, ...) \ 132#define ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(obj, ...) \
127 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \ 133 if (EINA_UNLIKELY(!eo_isa((obj), ELM_COLOR_ITEM_CLASS))) \
128 ELM_COLORSELECTOR_CHECK(it->base.widget) __VA_ARGS__; 134 return __VA_ARGS__;
129 135
130#endif 136#endif