summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-30 15:04:50 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-12-01 14:55:39 +0900
commit42baac2b0b9676da84cc5105cfbe774db45d2094 (patch)
tree8724ea3f3014454c7cb7e3f080c08d55b3346fce
parent07db6555a9105f6365e58fa9a80ef0b7251dc5d5 (diff)
-rw-r--r--src/Makefile_Elementary.am6
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_toolbar.c125
-rw-r--r--src/lib/ecore/efl_model_item.c2
-rw-r--r--src/lib/ecore/efl_promise.c7
-rw-r--r--src/lib/elementary/Elementary.h5
-rw-r--r--src/lib/elementary/efl_ui_item.c352
-rw-r--r--src/lib/elementary/efl_ui_item.eo51
-rw-r--r--src/lib/elementary/efl_ui_item_list.c229
-rw-r--r--src/lib/elementary/efl_ui_item_list.eo26
-rw-r--r--src/lib/elementary/efl_ui_toolbar.c1676
-rw-r--r--src/lib/elementary/efl_ui_toolbar.eo182
-rw-r--r--src/lib/elementary/efl_ui_toolbar_item.eo85
-rw-r--r--src/lib/elementary/efl_ui_toolbar_private.h73
14 files changed, 834 insertions, 1987 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 2d89ee9016..3cb5c9bae3 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -72,6 +72,8 @@ elm_public_eolian_files = \
72 lib/elementary/efl_ui_progressbar_part.eo \ 72 lib/elementary/efl_ui_progressbar_part.eo \
73 lib/elementary/efl_ui_slider_part.eo \ 73 lib/elementary/efl_ui_slider_part.eo \
74 lib/elementary/efl_ui_textpath_part.eo \ 74 lib/elementary/efl_ui_textpath_part.eo \
75 lib/elementary/efl_ui_item.eo \
76 lib/elementary/efl_ui_item_list.eo \
75 lib/elementary/efl_ui_toolbar.eo \ 77 lib/elementary/efl_ui_toolbar.eo \
76 lib/elementary/efl_ui_toolbar_item.eo \ 78 lib/elementary/efl_ui_toolbar_item.eo \
77 lib/elementary/efl_ui_widget_part.eo \ 79 lib/elementary/efl_ui_widget_part.eo \
@@ -336,7 +338,6 @@ includesunstable_HEADERS = \
336 lib/elementary/elm_widget_table.h \ 338 lib/elementary/elm_widget_table.h \
337 lib/elementary/elm_widget_thumb.h \ 339 lib/elementary/elm_widget_thumb.h \
338 lib/elementary/elm_widget_toolbar.h \ 340 lib/elementary/elm_widget_toolbar.h \
339 lib/elementary/efl_ui_toolbar_private.h \
340 lib/elementary/efl_ui_video_private.h \ 341 lib/elementary/efl_ui_video_private.h \
341 lib/elementary/elm_widget_web.h \ 342 lib/elementary/elm_widget_web.h \
342 lib/elementary/efl_ui_clock.h \ 343 lib/elementary/efl_ui_clock.h \
@@ -693,6 +694,9 @@ lib_elementary_libelementary_la_SOURCES = \
693 lib/elementary/elm_theme.c \ 694 lib/elementary/elm_theme.c \
694 lib/elementary/elm_thumb.c \ 695 lib/elementary/elm_thumb.c \
695 lib/elementary/elm_toolbar.c \ 696 lib/elementary/elm_toolbar.c \
697 lib/elementary/efl_ui_item.c \
698 lib/elementary/efl_ui_item_priv.h \
699 lib/elementary/efl_ui_item_list.c \
696 lib/elementary/efl_ui_toolbar.c \ 700 lib/elementary/efl_ui_toolbar.c \
697 lib/elementary/elm_transit.c \ 701 lib/elementary/elm_transit.c \
698 lib/elementary/elm_util.c \ 702 lib/elementary/elm_util.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index ae1967d996..ae2ceadc26 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -90,6 +90,7 @@ void test_toolbar8(void *data, Evas_Object *obj, void *event_info);
90void test_toolbar_vertical(void *data, Evas_Object *obj, void *event_info); 90void test_toolbar_vertical(void *data, Evas_Object *obj, void *event_info);
91void test_toolbar_focus(void *data, Evas_Object *obj, void *event_info); 91void test_toolbar_focus(void *data, Evas_Object *obj, void *event_info);
92void test_efl_ui_toolbar(void *data, Evas_Object *obj, void *event_info); 92void test_efl_ui_toolbar(void *data, Evas_Object *obj, void *event_info);
93void test_efl_ui_toolbar_model(void *data, Evas_Object *obj, void *event_info);
93void test_hoversel(void *data, Evas_Object *obj, void *event_info); 94void test_hoversel(void *data, Evas_Object *obj, void *event_info);
94void test_hoversel_focus(void *data, Evas_Object *obj, void *event_info); 95void test_hoversel_focus(void *data, Evas_Object *obj, void *event_info);
95void test_list(void *data, Evas_Object *obj, void *event_info); 96void test_list(void *data, Evas_Object *obj, void *event_info);
@@ -898,6 +899,7 @@ add_tests:
898 ADD_TEST(NULL, "Toolbars", "Toolbar Vertical", test_toolbar_vertical); 899 ADD_TEST(NULL, "Toolbars", "Toolbar Vertical", test_toolbar_vertical);
899 ADD_TEST(NULL, "Toolbars", "Toolbar Focus", test_toolbar_focus); 900 ADD_TEST(NULL, "Toolbars", "Toolbar Focus", test_toolbar_focus);
900 ADD_TEST_EO(NULL, "Toolbars", "Efl.Ui.Toolbar", test_efl_ui_toolbar); 901 ADD_TEST_EO(NULL, "Toolbars", "Efl.Ui.Toolbar", test_efl_ui_toolbar);
902 ADD_TEST_EO(NULL, "Toolbars", "Efl.Ui.Toolbar Model", test_efl_ui_toolbar_model);
901 903
902 //------------------------------// 904 //------------------------------//
903 ADD_TEST(NULL, "Lists - List", "List", test_list); 905 ADD_TEST(NULL, "Lists - List", "List", test_list);
diff --git a/src/bin/elementary/test_toolbar.c b/src/bin/elementary/test_toolbar.c
index 259bb9a50a..c8e4f4e588 100644
--- a/src/bin/elementary/test_toolbar.c
+++ b/src/bin/elementary/test_toolbar.c
@@ -1313,74 +1313,83 @@ test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
1313 evas_object_show(win); 1313 evas_object_show(win);
1314} 1314}
1315 1315
1316static void 1316void
1317_toolbar_selected_cb(void *data EINA_UNUSED, const Efl_Event *ev) 1317test_efl_ui_toolbar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1318{ 1318{
1319 //FIXME: after defining item interface, this should be changed. 1319 Eo *win, *tb, *it;
1320 Elm_Object_Item *item = efl_ui_menu_selected_item_get(ev->object); 1320
1321 const char *str = elm_object_item_text_get(item); 1321 win = efl_add(EFL_UI_WIN_CLASS, NULL);
1322 if (str) 1322 efl_ui_win_autodel_set(win, 1);
1323 printf(" string is \"%s\"\n", str); 1323
1324 else 1324 tb = efl_add(EFL_UI_TOOLBAR_CLASS, win);
1325 printf("\n"); 1325 efl_content_set(win, tb);
1326
1327 it = efl_ui_item_list_item_add(tb, "Hello", "file");
1328 it = efl_ui_item_list_item_add(tb, "World", "file");
1329 it = efl_ui_item_list_item_add(tb, "What's going on?", "file");
1330 it = efl_ui_item_list_item_add(tb, "Eh?", "file");
1331
1332 efl_gfx_size_set(win, EINA_SIZE2D(200, 200));
1326} 1333}
1327 1334
1328void 1335static Eina_Value _eina_value_helper = EINA_VALUE_EMPTY;
1329test_efl_ui_toolbar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1336
1337#define _EINA_VALUE_HELPER_SET(name, typ, TYP) \
1338static inline const Eina_Value * \
1339_value_##name(typ v) \
1340{ \
1341 if (!_eina_value_helper.type || \
1342 eina_value_type_get(&_eina_value_helper) != TYP) \
1343 { \
1344 eina_value_flush(&_eina_value_helper); \
1345 eina_value_setup(&_eina_value_helper, TYP); \
1346 } \
1347 eina_value_set(&_eina_value_helper, v); \
1348 return &_eina_value_helper; \
1349}
1350
1351_EINA_VALUE_HELPER_SET(string, const char*, EINA_VALUE_TYPE_STRING)
1352//_EINA_VALUE_HELPER_SET(bool, Eina_Bool, EINA_VALUE_TYPE_UCHAR)
1353
1354static Efl_Model *
1355_model_create(void)
1330{ 1356{
1331 Evas_Object *win, *bx, *tb, *grd; 1357 Efl_Model *model, *child;
1332 Evas_Object *ph1, *ph2, *ph3, *ph4;
1333 char buf[PATH_MAX];
1334 1358
1335 win = efl_add(EFL_UI_WIN_CLASS, NULL, 1359 model = efl_add(EFL_MODEL_ITEM_CLASS, NULL);
1336 efl_text_set(efl_added, "Efl Ui Toolbar"),
1337 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
1338 1360
1339 bx = efl_add(EFL_UI_BOX_CLASS, win, 1361 child = efl_model_child_add(model);
1340 efl_content_set(win, efl_added)); 1362 efl_model_property_set(child, "text", _value_string("Hello"));
1363 efl_model_property_set(child, "icon", _value_string("file"));
1341 1364
1342 tb = efl_add(EFL_UI_TOOLBAR_CLASS, win, 1365 child = efl_model_child_add(model);
1343 efl_pack(bx, efl_added), 1366 efl_model_property_set(child, "text", _value_string("World!"));
1344 efl_event_callback_add(efl_added, EFL_UI_EVENT_SELECTED, _toolbar_selected_cb, NULL), 1367 efl_model_property_set(child, "icon", _value_string("user-desktop"));
1345 efl_gfx_size_hint_weight_set(efl_added, 0.0, 0.0),
1346 efl_gfx_size_hint_align_set(efl_added, -1.0, 0.0));
1347 1368
1348 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); 1369 child = efl_model_child_add(model);
1349 ph1 = efl_add(EFL_UI_IMAGE_CLASS, win, 1370 efl_model_property_set(child, "text", _value_string("What's going on?"));
1350 efl_file_set(efl_added, buf, NULL), 1371 efl_model_property_set(child, "icon", _value_string("user-bookmarks"));
1351 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(40, 40)),
1352 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5));
1353 1372
1354 ph2 = efl_add(EFL_UI_IMAGE_CLASS, win, 1373 child = efl_model_child_add(model);
1355 efl_file_set(efl_added, buf, NULL), 1374 efl_model_property_set(child, "text", _value_string("lol"));
1356 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(80, 80)), 1375 efl_model_property_set(child, "icon", _value_string("user-home"));
1357 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5));
1358 1376
1359 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get()); 1377 return model;
1360 ph3 = efl_add(EFL_UI_IMAGE_CLASS, win, 1378}
1361 efl_file_set(efl_added, buf, NULL),
1362 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(20, 20)),
1363 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5));
1364 1379
1365 snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get()); 1380void
1366 ph4 = efl_add(EFL_UI_IMAGE_CLASS, win, 1381test_efl_ui_toolbar_model(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1367 efl_file_set(efl_added, buf, NULL), 1382{
1368 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(60, 60)), 1383 Eo *win, *tb;
1369 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5)); 1384
1370 1385 win = efl_add(EFL_UI_WIN_CLASS, NULL);
1371 efl_ui_toolbar_item_append(tb, "document-print", "Hello", _tb_sel1_cb, ph1); 1386 efl_ui_win_autodel_set(win, 1);
1372 efl_ui_toolbar_item_append(tb, "folder-new", "World", _tb_sel2_cb, ph1); 1387
1373 efl_ui_toolbar_item_append(tb, "object-rotate-right", "H", _tb_sel3_cb, ph4); 1388 tb = efl_add(EFL_UI_TOOLBAR_CLASS, win);
1374 efl_ui_toolbar_item_append(tb, "mail-send", "Comes", _tb_sel4_cb, ph4); 1389 efl_content_set(win, tb);
1375 efl_ui_toolbar_item_append(tb, "clock", "Elementary", _tb_sel5_cb, ph4); 1390
1376 1391 efl_ui_item_list_model_set(tb, _model_create());
1377 grd = efl_add(EFL_UI_GRID_CLASS, win); 1392
1378 efl_pack_grid(grd, ph1, 0, 0, 1, 1); 1393 efl_gfx_size_set(win, EINA_SIZE2D(200, 200));
1379 efl_pack_grid(grd, ph2, 1, 0, 1, 1);
1380 efl_pack_grid(grd, ph3, 0, 1, 1, 1);
1381 efl_pack_grid(grd, ph4, 1, 1, 1, 1);
1382
1383 efl_pack(bx, grd);
1384 efl_gfx_size_set(win, EINA_SIZE2D(300, 300));
1385} 1394}
1386 1395
diff --git a/src/lib/ecore/efl_model_item.c b/src/lib/ecore/efl_model_item.c
index b4e286fbb4..1f35fb0fd5 100644
--- a/src/lib/ecore/efl_model_item.c
+++ b/src/lib/ecore/efl_model_item.c
@@ -72,7 +72,7 @@ _efl_model_item_efl_model_property_set(Eo *obj EINA_UNUSED, Efl_Model_Item_Data
72{ 72{
73 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get()); 73 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
74 Efl_Future* future = efl_promise_future_get(promise); 74 Efl_Future* future = efl_promise_future_get(promise);
75 Efl_Model_Property_Event evt; 75 Efl_Model_Property_Event evt = { NULL, NULL };
76 76
77 Eina_Stringshare *sshared = eina_stringshare_add(property); 77 Eina_Stringshare *sshared = eina_stringshare_add(property);
78 Eina_Value *p_v = eina_hash_find(sd->properties, sshared); 78 Eina_Value *p_v = eina_hash_find(sd->properties, sshared);
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index f95e12940e..635f880fb8 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -825,8 +825,11 @@ _efl_promise_all_die(void *data, const Efl_Event *ev EINA_UNUSED)
825 825
826 while ((fa = eina_array_pop(&all->members))) 826 while ((fa = eina_array_pop(&all->members)))
827 { 827 {
828 EINA_REFCOUNT_UNREF(fa->d) 828 if (EINA_LIKELY(fa->d != NULL))
829 _efl_promise_msg_free(fa->d); 829 {
830 EINA_REFCOUNT_UNREF(fa->d)
831 _efl_promise_msg_free(fa->d);
832 }
830 assert(fa->f == NULL); 833 assert(fa->f == NULL);
831 free(fa); 834 free(fa);
832 } 835 }
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 085d5bf3d6..aec49c2f9e 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -312,7 +312,12 @@ EAPI extern Elm_Version *elm_version;
312# include <efl_ui_spin.eo.h> 312# include <efl_ui_spin.eo.h>
313# include <efl_ui_spin_button.eo.h> 313# include <efl_ui_spin_button.eo.h>
314# include <efl_ui_image_factory.eo.h> 314# include <efl_ui_image_factory.eo.h>
315#define _EFL_UI_ITEM_LIST_EO_CLASS_TYPE
316typedef Eo Efl_Ui_Item_List;
317# include <efl_ui_item.eo.h>
318# include <efl_ui_item_list.eo.h>
315# include <efl_ui_toolbar.eo.h> 319# include <efl_ui_toolbar.eo.h>
320# include <efl_ui_toolbar_item.eo.h>
316#endif 321#endif
317 322
318/* include deprecated calls last of all */ 323/* include deprecated calls last of all */
diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c
new file mode 100644
index 0000000000..55af66b118
--- /dev/null
+++ b/src/lib/elementary/efl_ui_item.c
@@ -0,0 +1,352 @@
1#include "efl_ui_item_priv.h"
2
3#define MY_CLASS EFL_UI_ITEM_CLASS
4
5typedef struct {
6 Efl_Ui_Item *self;
7 Efl_Ui_Item_List *parent;
8 Efl_Model *model;
9
10 Eina_Stringshare *text, *icon;
11 Elm_Image *icon_obj;
12
13 Eina_List *pending_futures; // Efl_Future** (wrefs)
14
15 Eina_Bool model_owned : 1;
16 Eina_Bool selected : 1;
17} Efl_Ui_Item_Data;
18
19typedef struct {
20 Efl_Ui_Item *object;
21 Eina_Array *properties; // stringshare
22} Property_Update_Data;
23
24Eina_Value _eina_value_helper = EINA_VALUE_EMPTY;
25
26static inline Eina_Bool
27_selected_set(Eo *obj, Efl_Ui_Item_Data *pd, Eina_Bool sel)
28{
29 if (pd->selected == sel)
30 return EINA_FALSE;
31
32 pd->selected = sel;
33 if (efl_finalized_get(obj))
34 {
35 if (sel) efl_event_callback_call(obj, EFL_UI_EVENT_SELECTED, NULL);
36 else efl_event_callback_call(obj, EFL_UI_EVENT_UNSELECTED, NULL);
37 }
38 return EINA_TRUE;
39}
40
41EOLIAN static void
42_efl_ui_item_selected_set(Eo *obj, Efl_Ui_Item_Data *pd, Eina_Bool sel)
43{
44 if (_selected_set(obj, pd, !!sel))
45 efl_model_property_set(obj, "selected", _value_bool(sel));
46}
47
48EOLIAN static Eina_Bool
49_efl_ui_item_selected_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
50{
51 return pd->selected;
52}
53
54Efl_Ui_Item_List *
55_efl_ui_item_item_list_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
56{
57 return pd->parent;
58}
59
60static Eina_Bool
61_text_set(Eo *obj, Efl_Ui_Item_Data *pd, const char *text)
62{
63 if (!eina_stringshare_replace(&pd->text, text))
64 return EINA_FALSE;
65
66 efl_text_set(efl_part(efl_ui_item_view_get(obj), "elm.text"), text);
67 return EINA_TRUE;
68}
69
70EOLIAN static void
71_efl_ui_item_efl_text_text_set(Eo *obj, Efl_Ui_Item_Data *pd, const char *text)
72{
73 if (!eina_streq(text, pd->text))
74 efl_model_property_set(obj, "text", _value_string(text));
75}
76
77EOLIAN static const char *
78_efl_ui_item_efl_text_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
79{
80 return pd->text;
81}
82
83static Eina_Bool
84_icon_set(Efl_Ui_Item_Data *pd, const char *icon)
85{
86 Eo *obj = pd->self;
87
88 if (!eina_stringshare_replace(&pd->icon, icon))
89 return EINA_FALSE;
90
91 if (!icon)
92 {
93 ELM_SAFE_DEL(pd->icon_obj);
94 return EINA_TRUE;
95 }
96
97 if (!pd->icon_obj || !eina_streq(efl_ui_image_icon_get(pd->icon_obj), icon))
98 {
99 if (!pd->icon_obj)
100 {
101 Eo *view = efl_ui_item_view_get(obj);
102 pd->icon_obj = efl_add(EFL_UI_IMAGE_CLASS, view);
103 efl_content_set(efl_part(view, "elm.swallow.icon"), pd->icon_obj);
104 efl_wref_add(pd->icon_obj, &pd->icon_obj);
105 }
106 efl_ui_image_icon_set(pd->icon_obj, icon);
107 }
108
109 return EINA_TRUE;
110}
111
112EOLIAN static void
113_efl_ui_item_icon_set(Eo *obj, Efl_Ui_Item_Data *pd, const char *icon)
114{
115 if (!eina_streq(icon, pd->icon))
116 efl_model_property_set(obj, "icon", _value_string(icon));
117}
118
119EOLIAN static const char *
120_efl_ui_item_icon_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
121{
122 return pd->icon;
123}
124
125static void
126_property_update_free(Property_Update_Data *update)
127{
128 Eina_Array_Iterator it;
129 Eina_Stringshare *prop;
130 size_t k;
131
132 if (!update) return;
133 EINA_ARRAY_ITER_NEXT(update->properties, k, prop, it)
134 {
135 eina_stringshare_del(prop);
136 }
137 eina_array_free(update->properties);
138 free(update);
139}
140
141#define EINA_VALUE_CHECK(_val, _type) \
142 EINA_SAFETY_ON_FALSE_GOTO(eina_value_type_get(_val) == _type, end)
143
144static void
145_pending_future_remove(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd, Efl_Future *future)
146{
147 Efl_Future **fut;
148 Eina_List *li;
149
150 EINA_LIST_FOREACH(pd->pending_futures, li, fut)
151 if (*fut == future)
152 {
153 // WTF? where is the unuse function??
154 pd->pending_futures = eina_list_remove_list(pd->pending_futures, li);
155 efl_wref_del(*fut, fut);
156 free(future);
157 break;
158 }
159}
160
161static void
162_properties_changed_success(void *data, const Efl_Event *event)
163{
164 Efl_Future_Event_Success *ev = event->info;
165 Property_Update_Data *update = data;
166 Eina_Accessor *prop_accessor = ev->value;
167 Efl_Ui_Item_Data *pd;
168 Efl_Ui_Item *obj;
169 Eina_Array_Iterator array_itr;
170 Eina_Stringshare *prop;
171 Eina_Value *val;
172 unsigned k;
173
174 obj = update->object;
175 pd = efl_data_scope_safe_get(obj, MY_CLASS);
176 EINA_SAFETY_ON_NULL_GOTO(pd, end);
177
178 _pending_future_remove(obj, pd, event->object);
179
180 EINA_ARRAY_ITER_NEXT(update->properties, k, prop, array_itr)
181 {
182 if (!eina_accessor_data_get(prop_accessor, k, (void **) &val) || !val)
183 {
184 ERR("Invalid response from model");
185 break;
186 }
187
188 if (eina_streq(prop, "selected"))
189 {
190 EINA_VALUE_CHECK(val, EINA_VALUE_TYPE_UCHAR);
191 _selected_set(obj, pd, _value_as_bool(val));
192 }
193 else if (eina_streq(prop, "text"))
194 {
195 EINA_VALUE_CHECK(val, EINA_VALUE_TYPE_STRING);
196 _text_set(obj, pd, _value_as_string(val));
197 }
198 else if (eina_streq(prop, "icon"))
199 {
200 EINA_VALUE_CHECK(val, EINA_VALUE_TYPE_STRING);
201 _icon_set(pd, _value_as_string(val));
202 }
203 }
204
205end:
206 _property_update_free(update);
207}
208
209static void
210_properties_changed_error(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
211{
212 //Efl_Future_Event_Failure *ev = event->info;
213 Property_Update_Data *update = data;
214 Efl_Ui_Item_Data *pd;
215 Efl_Ui_Item *obj;
216
217 obj = update->object;
218 pd = efl_data_scope_safe_get(obj, MY_CLASS);
219 EINA_SAFETY_ON_NULL_GOTO(pd, end);
220
221 _pending_future_remove(obj, pd, event->object);
222
223end:
224 ERR("Model error!");
225 _property_update_free(update);
226
227}
228
229static void
230_properties_update(Eo *obj, Efl_Ui_Item_Data *pd, Eina_Array *properties)
231{
232 Property_Update_Data *update;
233 Efl_Future **futures, *all, **wfut;
234 Eina_Array_Iterator it;
235 const char *prop;
236 unsigned k, len;
237
238 if (!properties) return;
239 len = eina_array_count(properties);
240 if (!len) return;
241
242 futures = calloc(len + 1, sizeof(futures[0]));
243 update = calloc(1, sizeof(*update));
244 update->object = obj;
245 update->properties = eina_array_new(len);
246
247 EINA_ARRAY_ITER_NEXT(properties, k, prop, it)
248 {
249 Efl_Future *future = efl_model_property_get(obj, prop);
250 eina_array_push(update->properties, eina_stringshare_add(prop));
251 futures[k] = future;
252 }
253
254 all = efl_future_iterator_all(eina_carray_iterator_new((void **) futures));
255 efl_future_then(all, _properties_changed_success,
256 _properties_changed_error, NULL, update);
257 free(futures);
258
259 wfut = calloc(1, sizeof(*wfut));
260 efl_future_use(wfut, all);
261 pd->pending_futures = eina_list_append(pd->pending_futures, wfut);
262}
263
264static void
265_properties_changed_cb(void *data, const Efl_Event *event)
266{
267 Efl_Model_Property_Event *ev = event->info;
268 //Efl_Model *model = event->object;
269 Efl_Ui_Item_Data *pd;
270 Efl_Ui_Item *obj = data;
271 Eina_Array_Iterator it;
272 const char *prop;
273 unsigned k;
274
275 pd = efl_data_scope_safe_get(obj, MY_CLASS);
276 EINA_SAFETY_ON_NULL_RETURN(pd);
277
278 if (ev->invalidated_properties)
279 {
280 EINA_ARRAY_ITER_NEXT(ev->invalidated_properties, k, prop, it)
281 {
282 if (eina_streq(prop, "selected"))
283 _selected_set(obj, pd, EINA_FALSE);
284 else if (eina_streq(prop, "text"))
285 eina_stringshare_replace(&pd->text, NULL);
286 else if (eina_streq(prop, "icon"))
287 eina_stringshare_replace(&pd->icon, NULL);
288 }
289 }
290
291 _properties_update(obj, pd, ev->changed_properties);
292}
293
294EOLIAN static void
295_efl_ui_item_model_set(Eo *obj, Efl_Ui_Item_Data *pd, Efl_Model *model)
296{
297 Eina_Array *properties;
298 Efl_Future **wfut;
299
300 EINA_SAFETY_ON_NULL_RETURN(model);
301 if (pd->model == model) return;
302
303 if (pd->model)
304 {
305 efl_event_callback_del(pd->model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
306 _properties_changed_cb, obj);
307 efl_composite_detach(obj, pd->model);
308 if (pd->model_owned)
309 efl_del(pd->model);
310 }
311
312 EINA_LIST_FREE(pd->pending_futures, wfut)
313 {
314 efl_future_cancel(*wfut);
315 free(wfut);
316 }
317
318 pd->model = model;
319 pd->model_owned = EINA_FALSE;
320 if (!model) return;
321
322 efl_composite_attach(obj, pd->model);
323 efl_event_callback_add(pd->model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
324 _properties_changed_cb, obj);
325
326 properties = eina_array_new(8);
327 eina_array_push(properties, "text");
328 eina_array_push(properties, "icon");
329 eina_array_push(properties, "selected");
330 _properties_update(obj, pd, properties);
331 eina_array_free(properties);
332}
333
334EOLIAN static Efl_Model *
335_efl_ui_item_model_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd)
336{
337 return pd->model;
338}
339
340EOLIAN static Efl_Object *
341_efl_ui_item_efl_object_constructor(Eo *obj, Efl_Ui_Item_Data *pd)
342{
343 pd->self = obj;
344 obj = efl_constructor(efl_super(obj, MY_CLASS));
345
346 pd->model_owned = EINA_TRUE;
347 efl_ui_item_model_set(obj, efl_add(EFL_MODEL_ITEM_CLASS, obj));
348
349 return obj;
350}
351
352#include "efl_ui_item.eo.c"
diff --git a/src/lib/elementary/efl_ui_item.eo b/src/lib/elementary/efl_ui_item.eo
new file mode 100644
index 0000000000..ffbc410dec
--- /dev/null
+++ b/src/lib/elementary/efl_ui_item.eo
@@ -0,0 +1,51 @@
1class Efl.Ui.Item (Efl.Object, Efl.Model, Efl.Ui.Selectable, Efl.Text)
2{
3 [[A generic item for a list of items.
4
5 Emits events from Efl.Ui.Selectable:
6 - Efl.Ui.Selectable.selected
7 - Efl.Ui.Selectable.unselected
8 ]]
9 methods {
10 @property item_list {
11 [[The parent item list.]]
12 get {}
13 values {
14 list: Efl.Ui.Item_List; [[The parent list.]]
15 }
16 }
17 @property item_view @protected {
18 get @pure_virtual {}
19 values {
20 obj: Efl.Ui.Layout; [[The real object.]]
21 }
22 }
23 @property icon {
24 [[The base icon name for this item.
25
26 This is a standard icon name, as used in $Efl.Ui.Image.
27 ]]
28 get {}
29 set {}
30 values {
31 icon: string @nullable; [[An icon name.]]
32 }
33 }
34 @property selected {
35 get {}
36 set {}
37 values {
38 sel: bool(false);
39 }
40 }
41 @property model {
42 values {
43 model: Efl.Model; [[The internal model object.]]
44 }
45 }
46 }
47 implements {
48 Efl.Object.constructor;
49 Efl.Text.text { set; get; }
50 }
51}
diff --git a/src/lib/elementary/efl_ui_item_list.c b/src/lib/elementary/efl_ui_item_list.c
new file mode 100644
index 0000000000..45d43adcfc
--- /dev/null
+++ b/src/lib/elementary/efl_ui_item_list.c
@@ -0,0 +1,229 @@
1#include "efl_ui_item_priv.h"
2
3#define MY_CLASS EFL_UI_ITEM_LIST_CLASS
4
5typedef struct {
6 Eo *self;
7 Eina_List *items; /* Efl_Ui_Item* */
8 Efl_Model *model;
9
10 Eina_List *pending_futures; // Efl_Future** (wref)
11
12 Eina_Bool model_owned : 1;
13} Efl_Ui_Item_List_Data;
14
15static void
16_item_del_cb(void *data, const Efl_Event *event)
17{
18 Efl_Ui_Item_List_Data *pd = efl_data_scope_safe_get(data, MY_CLASS);
19 if (!pd) return;
20
21 pd->items = eina_list_remove(pd->items, event->object);
22}
23
24EOLIAN static Efl_Ui_Item *
25_efl_ui_item_list_item_add(Eo *obj, Efl_Ui_Item_List_Data *pd,
26 const char *text, const char *icon)
27{
28 const Efl_Class *klass;
29 Eo *item;
30
31 klass = efl_ui_item_list_item_class_get(obj);
32 EINA_SAFETY_ON_NULL_RETURN_VAL(klass, NULL);
33
34 item = efl_add(klass, obj,
35 efl_text_set(efl_added, text),
36 efl_ui_item_icon_set(efl_added, icon));
37 pd->items = eina_list_append(pd->items, item);
38 efl_event_callback_add(item, EFL_EVENT_DEL, _item_del_cb, obj);
39
40 return item;
41}
42
43static void
44_child_add_model(Eo *obj, Efl_Ui_Item_List_Data *pd, Efl_Model *model)
45{
46 const Efl_Class *klass;
47 Eo *item;
48
49 klass = efl_ui_item_list_item_class_get(obj);
50 EINA_SAFETY_ON_NULL_RETURN(klass);
51
52 item = efl_add(klass, obj, efl_ui_item_model_set(efl_added, model));
53 pd->items = eina_list_append(pd->items, item);
54 efl_event_callback_add(item, EFL_EVENT_DEL, _item_del_cb, obj);
55}
56
57static void
58_pending_future_remove(Eo *obj EINA_UNUSED, Efl_Ui_Item_List_Data *pd, Efl_Future *future)
59{
60 Efl_Future **fut;
61 Eina_List *li;
62
63 EINA_LIST_FOREACH(pd->pending_futures, li, fut)
64 if (*fut == future)
65 {
66 // WTF? where is the unuse function??
67 pd->pending_futures = eina_list_remove_list(pd->pending_futures, li);
68 efl_wref_del(*fut, fut);
69 free(future);
70 break;
71 }
72}
73
74static void
75_child_added_cb(void *data, const Efl_Event *event EINA_UNUSED)
76{
77 Efl_Model_Children_Event *cevt = event->info;
78 Efl_Ui_Item_List_Data *pd;
79 Eo *obj = data;
80
81 pd = efl_data_scope_safe_get(obj, MY_CLASS);
82 EINA_SAFETY_ON_NULL_RETURN(pd);
83
84 _pending_future_remove(obj, pd, event->object);
85 _child_add_model(obj, pd, cevt->child);
86}
87
88static void
89_child_removed_cb(void *data, const Efl_Event *event)
90{
91 Efl_Model_Children_Event *cevt = event->info;
92 Efl_Ui_Item_List_Data *pd;
93 Eina_List *li;
94 Eo *obj = data;
95 Eo *item, *model;
96
97 pd = efl_data_scope_safe_get(obj, MY_CLASS);
98 EINA_SAFETY_ON_NULL_RETURN(pd);
99
100 INF("Child removed.");
101
102 model = cevt->child;
103 _pending_future_remove(obj, pd, event->object);
104
105 EINA_LIST_FOREACH(pd->items, li, item)
106 {
107 if (model == efl_ui_item_model_get(item))
108 {
109 pd->items = eina_list_remove_list(pd->items, li);
110 efl_event_callback_add(item, EFL_EVENT_DEL, _item_del_cb, obj);
111 efl_del(item);
112 break;
113 }
114 }
115}
116
117static void
118_properties_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
119{
120 Efl_Ui_Item_List_Data *pd;
121 Eo *obj = data;
122
123 pd = efl_data_scope_safe_get(obj, MY_CLASS);
124 EINA_SAFETY_ON_NULL_RETURN(pd);
125
126 ERR("Model properties changed. Ignore.");
127}
128
129static void
130_children_slice_cb(void *data, const Efl_Event *event)
131{
132 Efl_Future_Event_Success *success = event->info;
133 Eina_Accessor *children = success->value;
134 Efl_Ui_Item_List_Data *pd;
135 Efl_Future **future;
136 Efl_Model *child;
137 Eina_List *li;
138 Eo *obj = data;
139 unsigned k;
140
141 pd = efl_data_scope_safe_get(obj, MY_CLASS);
142 EINA_SAFETY_ON_NULL_RETURN(pd);
143
144 EINA_LIST_FOREACH(pd->pending_futures, li, future)
145 if (*future == event->object)
146 {
147 // WTF? where is the unuse function??
148 pd->pending_futures = eina_list_remove_list(pd->pending_futures, li);
149 efl_wref_del(*future, future);
150 free(future);
151 break;
152 }
153
154 if (!children) return;
155 EINA_ACCESSOR_FOREACH(children, k, child)
156 _child_add_model(obj, pd, child);
157}
158
159EFL_CALLBACKS_ARRAY_DEFINE(_model_callbacks,
160{ EFL_MODEL_EVENT_PROPERTIES_CHANGED, _properties_changed_cb },
161{ EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb },
162{ EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb })
163
164EOLIAN static void
165_efl_ui_item_list_model_set(Eo *obj, Efl_Ui_Item_List_Data *pd, Efl_Model *model)
166{
167 Efl_Callback_Array_Item *cb;
168 Efl_Future **wfut, *future;
169 size_t k;
170
171 EINA_SAFETY_ON_NULL_RETURN(model);
172 if (pd->model == model) return;
173
174 if (pd->model)
175 {
176 Eo *item;
177
178 EINA_LIST_FREE(pd->items, item)
179 efl_del(item);
180
181 efl_composite_detach(obj, pd->model);
182 efl_event_callback_array_del(pd->model, _model_callbacks(), obj);
183 for (k = 0, cb = _model_callbacks(); cb->desc;
184 k++, cb = _model_callbacks() + k)
185 efl_event_callback_forwarder_del(pd->model, cb->desc, obj);
186 if (pd->model_owned)
187 efl_del(pd->model);
188 }
189
190 EINA_LIST_FREE(pd->pending_futures, wfut)
191 {
192 efl_future_cancel(*wfut);
193 free(wfut);
194 }
195
196 pd->model = model;
197 pd->model_owned = EINA_FALSE;
198 if (model)
199 {
200 efl_composite_attach(obj, pd->model);
201 efl_event_callback_array_add(pd->model, _model_callbacks(), obj);
202 for (k = 0, cb = _model_callbacks(); cb->desc;
203 k++, cb = _model_callbacks() + k)
204 efl_event_callback_forwarder_add(pd->model, cb->desc, obj);
205 future = efl_model_children_slice_get(pd->model, 0, 0);
206 efl_future_then(future, _children_slice_cb, NULL, NULL, obj);
207 pd->pending_futures = eina_list_append(pd->pending_futures, future);
208 }
209}
210
211EOLIAN static Efl_Model *
212_efl_ui_item_list_model_get(Eo *obj EINA_UNUSED, Efl_Ui_Item_List_Data *pd)
213{
214 return pd->model;
215}
216
217EOLIAN static Eo *
218_efl_ui_item_list_efl_object_constructor(Eo *obj, Efl_Ui_Item_List_Data *pd)
219{
220 pd->self = obj;
221 obj = efl_constructor(efl_super(obj, MY_CLASS));
222
223 pd->model_owned = EINA_TRUE;
224 efl_ui_item_list_model_set(obj, efl_add(EFL_MODEL_ITEM_CLASS, obj));
225
226 return obj;
227}
228
229#include "efl_ui_item_list.eo.c"
diff --git a/src/lib/elementary/efl_ui_item_list.eo b/src/lib/elementary/efl_ui_item_list.eo
new file mode 100644
index 0000000000..c5f4999446
--- /dev/null
+++ b/src/lib/elementary/efl_ui_item_list.eo
@@ -0,0 +1,26 @@
1abstract Efl.Ui.Item_List (Efl.Ui.Layout, Efl.Model.Item)
2{
3 methods {
4 @property item_class @protected {
5 get @pure_virtual {}
6 values {
7 klass: const(Efl.Class); [[Class of item objects to create.]]
8 }
9 }
10 item_add {
11 params {
12 @in text: string;
13 @in icon: string @optional;
14 }
15 return: Efl.Ui.Item; [[A newly created item, appended to this list.]]
16 }
17 @property model {
18 values {
19 model: Efl.Model; [[The internal model.]]
20 }
21 }
22 }
23 implements {
24 Efl.Object.constructor;
25 }
26}
diff --git a/src/lib/elementary/efl_ui_toolbar.c b/src/lib/elementary/efl_ui_toolbar.c
index 541b30badb..7e5b6d04a2 100644
--- a/src/lib/elementary/efl_ui_toolbar.c
+++ b/src/lib/elementary/efl_ui_toolbar.c
@@ -2,1469 +2,81 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#define EFL_UI_FOCUS_COMPOSITION_PROTECTED 5#include "efl_ui_item_priv.h"
6#define EFL_ACCESS_PROTECTED
7#define EFL_ACCESS_SELECTION_PROTECTED
8#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
9#define ELM_WIDGET_ITEM_PROTECTED
10#define EFL_UI_TRANSLATABLE_PROTECTED
11#define EFL_UI_FOCUS_OBJECT_PROTECTED
12
13#include <Elementary.h>
14#include "elm_priv.h"
15#include "efl_ui_toolbar_private.h"
16#include "efl_ui_toolbar_item.eo.h" 6#include "efl_ui_toolbar_item.eo.h"
17 7
18#define MY_CLASS EFL_UI_TOOLBAR_CLASS 8#define MY_CLASS EFL_UI_TOOLBAR_CLASS
19#define MY_CLASS_NAME "Efl.Ui.Toolbar" 9#define MY_CLASS_NAME "Efl.Ui.Toolbar"
20 10
21#define EFL_UI_TOOLBAR_ITEM_FROM_INLIST(item) \ 11typedef struct {
22 ((item) ? EINA_INLIST_CONTAINER_GET(item, Efl_Ui_Toolbar_Item_Data) : NULL) 12 Eo *self;
23 13 Eo *bx;
24static const char SIG_CLICKED[] = "clicked"; 14 Efl_Ui_Dir dir;
25static const char SIG_SELECTED[] = "selected"; 15} Efl_Ui_Toolbar_Data;
26static const char SIG_UNSELECTED[] = "unselected";
27static const char SIG_ITEM_FOCUSED[] = "item,focused";
28static const char SIG_ITEM_UNFOCUSED[] = "item,unfocused";
29static const Evas_Smart_Cb_Description _smart_callbacks[] = {
30 {SIG_CLICKED, ""},
31 {SIG_SELECTED, ""},
32 {SIG_UNSELECTED, ""},
33 {SIG_ITEM_FOCUSED, ""},
34 {SIG_ITEM_UNFOCUSED, ""},
35 {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
36 {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
37 {SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
38 {SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
39 {NULL, NULL}
40};
41
42static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
43static void _sizing_eval(Evas_Object *obj);
44
45static const Elm_Action key_actions[] = {
46 {"select", _key_action_select},
47 {NULL, NULL}
48};
49
50static void _item_select(Efl_Ui_Toolbar_Item_Data *it);
51
52static void
53_item_unselect(Efl_Ui_Toolbar_Item_Data *item)
54{
55 if ((!item) || (!item->selected)) return;
56
57 EFL_UI_TOOLBAR_DATA_GET(WIDGET(item), sd);
58
59 item->selected = EINA_FALSE;
60 sd->selected_item = NULL;
61 elm_layout_signal_emit(VIEW(item), "elm,state,unselected", "elm");
62 if (item->icon)
63 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
64 efl_event_callback_legacy_call(WIDGET(item), EFL_UI_EVENT_UNSELECTED, EO_OBJ(item));
65 if (_elm_config->atspi_mode)
66 efl_access_state_changed_signal_emit(EO_OBJ(item), EFL_ACCESS_STATE_SELECTED, EINA_FALSE);
67}
68
69static void
70_mirrored_set(Evas_Object *obj,
71 Eina_Bool mirrored)
72{
73 Efl_Ui_Toolbar_Item_Data *it;
74
75 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
76
77 EINA_INLIST_FOREACH(sd->items, it)
78 efl_ui_mirrored_set(VIEW(it), mirrored);
79}
80
81static void
82_efl_ui_toolbar_item_focused(Elm_Object_Item *eo_it)
83{
84 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it, it);
85 Evas_Object *obj = WIDGET(it);
86 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
87 const char *focus_raise;
88
89 if (!sd || (eo_it == sd->focused_item)) return;
90
91 sd->focused_item = eo_it;
92
93 if (elm_widget_focus_highlight_enabled_get(obj))
94 {
95 elm_layout_signal_emit
96 (VIEW(it), "elm,state,focused", "elm");
97 }
98 elm_layout_signal_emit
99 (VIEW(it), "elm,highlight,on", "elm");
100 focus_raise = elm_layout_data_get(VIEW(it), "focusraise");
101 if ((focus_raise) && (!strcmp(focus_raise, "on")))
102 evas_object_raise(VIEW(it));
103 efl_event_callback_legacy_call
104 (obj, EFL_UI_TOOLBAR_EVENT_ITEM_FOCUSED, EO_OBJ(it));
105 if (_elm_config->atspi_mode)
106 efl_access_state_changed_signal_emit(EO_OBJ(it), EFL_ACCESS_STATE_FOCUSED, EINA_TRUE);
107}
108
109static void
110_efl_ui_toolbar_item_unfocused(Elm_Object_Item *eo_it)
111{
112 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it, it);
113 Evas_Object *obj = WIDGET(it);
114 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
115
116 if ((!sd) || !sd->focused_item || (eo_it != sd->focused_item))
117 return;
118
119 if (elm_widget_focus_highlight_enabled_get(obj))
120 {
121 EFL_UI_TOOLBAR_ITEM_DATA_GET(sd->focused_item, focus_it);
122 elm_layout_signal_emit
123 (VIEW(focus_it), "elm,state,unfocused", "elm");
124 }
125 elm_layout_signal_emit
126 (VIEW(it), "elm,highlight,off", "elm");
127 sd->focused_item = NULL;
128 efl_event_callback_legacy_call
129 (obj, EFL_UI_TOOLBAR_EVENT_ITEM_UNFOCUSED, eo_it);
130 if (_elm_config->atspi_mode)
131 efl_access_state_changed_signal_emit(eo_it, EFL_ACCESS_STATE_FOCUSED, EINA_TRUE);
132}
133
134EOLIAN static Eina_Bool
135_efl_ui_toolbar_elm_widget_on_focus_update(Eo *obj, Efl_Ui_Toolbar_Data *sd, Elm_Object_Item *item EINA_UNUSED)
136{
137 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
138 Eina_Bool int_ret = EINA_FALSE;
139 Elm_Object_Item *eo_it = NULL;
140
141 int_ret = efl_ui_widget_on_focus_update(efl_super(obj, MY_CLASS), NULL);
142 if (!int_ret) return EINA_FALSE;
143 if (!sd->items) return EINA_FALSE;
144
145 if (elm_widget_focus_get(obj))
146 {
147 evas_object_focus_set(wd->resize_obj, EINA_TRUE);
148
149 if (sd->last_focused_item)
150 eo_it = sd->last_focused_item;
151 else if (_elm_config->first_item_focus_on_first_focus_in)
152 {
153 eo_it = efl_ui_menu_first_item_get(obj);
154 }
155 if (eo_it) _efl_ui_toolbar_item_focused(eo_it);
156 }
157 else
158 {
159 sd->last_focused_item = sd->focused_item;
160 if (sd->focused_item)
161 _efl_ui_toolbar_item_unfocused(sd->focused_item);
162 evas_object_focus_set(wd->resize_obj, EINA_FALSE);
163 }
164 return EINA_TRUE;
165}
166
167EOLIAN static void
168_efl_ui_toolbar_item_elm_widget_item_focus_set(Eo *eo_it, Efl_Ui_Toolbar_Item_Data *it, Eina_Bool focused)
169{
170 EFL_UI_TOOLBAR_ITEM_CHECK(it);
171 Evas_Object *obj = WIDGET(it);
172 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
173
174 if (focused)
175 {
176 sd->last_focused_item = eo_it;
177 if (!elm_object_focus_get(obj))
178 elm_object_focus_set(obj, EINA_TRUE);
179
180 if (!elm_object_focus_get(obj))
181 return;
182
183 if (eo_it != sd->focused_item)
184 {
185 if (sd->focused_item)
186 _efl_ui_toolbar_item_unfocused(sd->focused_item);
187 _efl_ui_toolbar_item_focused(eo_it);
188 }
189
190 }
191 else
192 {
193 if (!elm_object_focus_get(obj))
194 return;
195 if (eo_it)
196 _efl_ui_toolbar_item_unfocused(eo_it);
197 }
198
199 evas_object_focus_set(VIEW(it), focused);
200
201 _elm_widget_item_highlight_in_theme(obj, EO_OBJ(it));
202 _elm_widget_highlight_in_theme_update(obj);
203 _elm_widget_focus_highlight_start(obj);
204}
205
206EOLIAN static Eina_Bool
207_efl_ui_toolbar_item_elm_widget_item_focus_get(Eo *eo_it, Efl_Ui_Toolbar_Item_Data *it)
208{
209 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
210 Evas_Object *obj = WIDGET(it);
211 EFL_UI_TOOLBAR_CHECK(obj) EINA_FALSE;
212 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
213
214 if (eo_it == sd->focused_item)
215 return EINA_TRUE;
216 return EINA_FALSE;
217}
218
219static Eina_Bool
220_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
221{
222 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
223
224 if (!sd->items) return EINA_FALSE;
225 if (sd->focused_item)
226 {
227 EFL_UI_TOOLBAR_ITEM_DATA_GET(sd->focused_item, focus_it);
228 _item_select(focus_it);
229 }
230
231 return EINA_TRUE;
232}
233
234static void
235_resizing_eval_item(Efl_Ui_Toolbar_Item_Data *it)
236{
237 Evas_Coord mw = -1, mh = -1;
238
239 edje_object_size_min_restricted_calc(elm_layout_edje_get(VIEW(it)), &mw, &mh, mw, mh);
240 if (!it->object)
241 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
242 evas_object_size_hint_min_set(VIEW(it), mw, mh);
243 evas_object_size_hint_max_set(VIEW(it), -1, -1);
244}
245
246EOLIAN static void
247_efl_ui_toolbar_item_elm_widget_item_disable(Eo *eo_toolbar, Efl_Ui_Toolbar_Item_Data *toolbar_it)
248{
249 const char* emission;
250
251 if (elm_wdg_item_disabled_get(eo_toolbar))
252 emission = "elm,state,disabled";
253 else
254 emission = "elm,state,enabled";
255
256 elm_layout_signal_emit(VIEW(toolbar_it), emission, "elm");
257 if (toolbar_it->icon)
258 elm_widget_signal_emit(toolbar_it->icon, emission, "elm");
259}
260
261EOLIAN static void
262_efl_ui_toolbar_item_elm_widget_item_signal_emit(Eo *eo_toolbar_it EINA_UNUSED,
263 Efl_Ui_Toolbar_Item_Data *toolbar_it,
264 const char *emission,
265 const char *source)
266{
267 elm_layout_signal_emit(VIEW(toolbar_it), emission, source);
268}
269
270static Eina_Bool
271_item_icon_set(Evas_Object *icon_obj,
272 const char *type,
273 const char *icon)
274{
275 char icon_str[512];
276
277 if ((!type) || (!*type)) goto end;
278 if ((!icon) || (!*icon)) return EINA_FALSE;
279 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
280 && (elm_icon_standard_set(icon_obj, icon_str)))
281 return EINA_TRUE;
282end:
283 if (elm_icon_standard_set(icon_obj, icon))
284 return EINA_TRUE;
285
286 WRN("couldn't find icon definition for '%s'", icon);
287 return EINA_FALSE;
288}
289
290static void
291_item_select(Efl_Ui_Toolbar_Item_Data *it)
292{
293 EFL_UI_TOOLBAR_DATA_GET(WIDGET(it), sd);
294
295 if (elm_wdg_item_disabled_get(EO_OBJ(it)) || (it->object))
296 return;
297
298 if (!it->selected)
299 {
300 Elm_Object_Item *eo_it2 =
301 efl_ui_menu_selected_item_get(WIDGET(it));
302 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it2, it2);
303 _item_unselect(it2);
304
305 it->selected = EINA_TRUE;
306 sd->selected_item = EO_OBJ(it);
307
308 elm_layout_signal_emit(VIEW(it), "elm,state,selected", "elm");
309 if (it->icon)
310 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
311
312 if (it->func) it->func((void *)(WIDGET_ITEM_DATA_GET(EO_OBJ(it))), WIDGET(it), EO_OBJ(it));
313 efl_event_callback_legacy_call(WIDGET(it), EFL_UI_EVENT_SELECTED, EO_OBJ(it));
314 if (_elm_config->atspi_mode)
315 efl_access_state_changed_signal_emit(EO_OBJ(it), EFL_ACCESS_STATE_SELECTED, EINA_TRUE);
316 }
317}
318
319/* Send order signals when item is added/deleted.
320 * If the given item is on deletion, item_on_deletion should be EINA_TRUE. */
321static void
322_efl_ui_toolbar_item_order_signal_emit(Efl_Ui_Toolbar_Data *sd,
323 Efl_Ui_Toolbar_Item_Data *it,
324 Eina_List *prev_list,
325 Eina_Bool item_on_deletion)
326{
327 Efl_Ui_Toolbar_Item_Data *first_it = NULL, *last_it = NULL;
328 Evas_Object *first_it_view = NULL, *last_it_view = NULL;
329 Efl_Ui_Toolbar_Item_Data *prev_first_it = NULL, *prev_last_it = NULL;
330 Evas_Object *prev_first_it_view = NULL, *prev_last_it_view = NULL;
331 Eina_List *list = NULL;
332 Eina_Iterator *itr;
333 Evas_Object *sobj;
334
335 itr = efl_content_iterate(sd->bx);
336 EINA_ITERATOR_FOREACH(itr, sobj)
337 list = eina_list_append(list, sobj);
338
339 if (!list) return;
340
341 if (prev_list)
342 {
343 prev_first_it_view = eina_list_data_get(prev_list);
344 prev_last_it_view = eina_list_data_get(eina_list_last(prev_list));
345 prev_first_it = evas_object_data_get(prev_first_it_view, "item");
346 prev_last_it = evas_object_data_get(prev_last_it_view, "item");
347 }
348
349 first_it_view = eina_list_data_get(list);
350 last_it_view = eina_list_data_get(eina_list_last(list));
351 first_it = evas_object_data_get(first_it_view, "item");
352 last_it = evas_object_data_get(last_it_view, "item");
353
354 if (prev_first_it)
355 {
356 if ((prev_first_it != first_it) && (prev_first_it != last_it))
357 elm_layout_signal_emit(VIEW(prev_first_it), "elm,order,default,item", "elm");
358 else if (prev_first_it == last_it)
359 elm_layout_signal_emit(VIEW(prev_first_it), "elm,order,last,item", "elm");
360 }
361
362 if (prev_last_it)
363 {
364 if ((prev_last_it != last_it) && (prev_last_it != first_it))
365 elm_layout_signal_emit(VIEW(prev_last_it), "elm,order,default,item", "elm");
366 else if (prev_last_it == first_it)
367 elm_layout_signal_emit(VIEW(prev_last_it), "elm,order,first,item", "elm");
368 }
369
370 if (it)
371 {
372 if (!item_on_deletion)
373 {
374 if (first_it == last_it)
375 {
376 elm_layout_signal_emit(VIEW(it), "elm,order,first,item", "elm");
377 elm_layout_signal_emit(VIEW(it), "elm,order,last,item", "elm");
378 }
379 else if (it == first_it)
380 {
381 elm_layout_signal_emit(VIEW(it), "elm,order,first,item", "elm");
382 }
383 else if (it == last_it)
384 {
385 elm_layout_signal_emit(VIEW(it), "elm,order,last,item", "elm");
386 }
387 }
388 else if (first_it != last_it)
389 {
390 if (it == first_it)
391 {
392 Eina_List *next_l = eina_list_next(list);
393 first_it_view = eina_list_data_get(next_l);
394 first_it = evas_object_data_get(first_it_view, "item");
395
396 elm_layout_signal_emit(first_it_view, "elm,order,first,item", "elm");
397 }
398 else if (it == last_it)
399 {
400 Eina_List *prev_l = eina_list_prev(eina_list_last(list));
401 last_it_view = eina_list_data_get(prev_l);
402 last_it = evas_object_data_get(last_it_view, "item");
403
404 elm_layout_signal_emit(last_it_view, "elm,order,last,item", "elm");
405 }
406 }
407 }
408
409 eina_list_free(list);
410}
411
412static void
413_item_del(Efl_Ui_Toolbar_Item_Data *it)
414{
415 EFL_UI_TOOLBAR_DATA_GET(WIDGET(it), sd);
416
417 _item_unselect(it);
418
419 _efl_ui_toolbar_item_order_signal_emit(sd, it, NULL, EINA_TRUE);
420
421 eina_stringshare_del(it->label);
422 if (it->label)
423 elm_layout_signal_emit(VIEW(it), "elm,state,text,hidden", "elm");
424 eina_stringshare_del(it->icon_str);
425
426 if (it->icon)
427 {
428 elm_layout_signal_emit(VIEW(it), "elm,state,icon,hidden", "elm");
429 evas_object_del(it->icon);
430 }
431
432 if (sd->focused_item == EO_OBJ(it))
433 sd->focused_item = NULL;
434 if (sd->last_focused_item == EO_OBJ(it))
435 sd->last_focused_item = NULL;
436
437 evas_object_del(it->object);
438}
439
440static void
441_item_theme_hook(Evas_Object *obj,
442 Efl_Ui_Toolbar_Item_Data *it,
443 double scale)
444{
445 Evas_Coord mw = -1, mh = -1;
446 Evas_Object *view = VIEW(it);
447 const char *style;
448
449 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
450
451 style = elm_widget_style_get(obj);
452
453 efl_ui_mirrored_set(VIEW(it), efl_ui_mirrored_get(obj));
454 edje_object_scale_set(elm_layout_edje_get(view), scale);
455
456 if (!it->object)
457 {
458 if (!elm_layout_theme_set(view, "toolbar", "item", style))
459 CRI("Failed to set layout!");
460 if (it->selected)
461 {
462 elm_layout_signal_emit(view, "elm,state,selected", "elm");
463 if (it->icon)
464 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
465 }
466 if (elm_wdg_item_disabled_get(EO_OBJ(it)))
467 {
468 elm_layout_signal_emit(view, "elm,state,disabled", "elm");
469 if (it->icon)
470 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
471 }
472 if (it->icon)
473 {
474 elm_layout_content_set(view, "elm.swallow.icon", it->icon);
475 elm_layout_signal_emit
476 (view, "elm,state,icon,visible", "elm");
477 }
478 if (it->label)
479 {
480 elm_layout_text_set(view, "elm.text", it->label);
481 elm_layout_signal_emit(view, "elm,state,text,visible", "elm");
482 }
483 }
484 else
485 {
486 if (!elm_layout_theme_set(view, "toolbar", "object", style))
487 CRI("Failed to set layout!");
488 elm_layout_content_set(view, "elm.swallow.object", it->object);
489 }
490
491 //FIXME: after signal rule is fixed, this should be considered again
492 elm_layout_signal_emit(view, "elm,state,shrink,default", "elm");
493
494 if (!efl_ui_dir_is_horizontal(sd->dir, EINA_TRUE))
495 elm_layout_signal_emit(view, "elm,orient,vertical", "elm");
496 else
497 elm_layout_signal_emit(view, "elm,orient,horizontal", "elm");
498
499 edje_object_message_signal_process(elm_layout_edje_get(view));
500 if (!it->object)
501 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
502
503 if (!efl_ui_dir_is_horizontal(sd->dir, EINA_TRUE))
504 {
505 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
506 evas_object_size_hint_align_set
507 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
508 }
509 else
510 {
511 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
512 evas_object_size_hint_align_set
513 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
514 }
515
516 _resizing_eval_item(it);
517 evas_object_smart_need_recalculate_set(obj, EINA_TRUE);
518}
519
520static void
521_inform_item_number(Evas_Object *obj)
522{
523 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
524 Efl_Ui_Toolbar_Item_Data *it;
525 char buf[sizeof("elm,number,item,") + 4];
526 static int scount = 0;
527 int count = 0;
528 Evas_Coord mw, mh;
529
530 EINA_INLIST_FOREACH(sd->items, it)
531 {
532 count++;
533 }
534 if (scount != count)
535 {
536 scount = count;
537 if (snprintf(buf, sizeof(buf), "elm,number,item,%d", count) >= (int)sizeof(buf))
538 ERR("Too many items to fit signal buffer (%d)", count);
539
540 EINA_INLIST_FOREACH(sd->items, it)
541 {
542 if (!it->object)
543 {
544 elm_layout_signal_emit(VIEW(it), buf, "elm");
545 edje_object_message_signal_process(elm_layout_edje_get(VIEW(it)));
546
547 mw = mh = -1;
548 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
549
550 edje_object_size_min_restricted_calc(elm_layout_edje_get(VIEW(it)), &mw, &mh, mw, mh);
551 evas_object_size_hint_min_set(VIEW(it), mw, mh);
552 }
553 }
554 }
555}
556 16
557static void 17static void
558_sizing_eval(Evas_Object *obj) 18_sizing_calc(Efl_Ui_Toolbar_Data *pd)
559{ 19{
560 Evas_Coord minw = -1, minh = -1, minw_bx = -1, minh_bx = -1; 20 Eina_Rect r;
561 Evas_Coord w, h;
562
563 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
564 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
565
566 edje_object_size_min_calc(wd->resize_obj, &minw, &minh);
567 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
568 21
569 if (w < minw) w = minw; 22 efl_canvas_group_calculate(pd->bx);
570 if (h < minh) h = minh; 23 r.pos = efl_gfx_position_get(pd->self);
24 r.size = efl_gfx_size_hint_combined_min_get(pd->bx);
25 efl_gfx_geometry_set(pd->bx, r);
571 26
572 evas_object_resize(wd->resize_obj, w, h); 27 efl_gfx_size_hint_restricted_min_set(pd->self, r.size);
573 evas_object_size_hint_combined_min_get(sd->bx, &minw_bx, &minh_bx);
574 evas_object_size_hint_min_set(obj, minw_bx, minh_bx);
575
576 _inform_item_number(obj);
577}
578
579static void
580_efl_ui_toolbar_highlight_in_theme(Evas_Object *obj)
581{
582 const char *fh;
583 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
584
585 fh = edje_object_data_get
586 (wd->resize_obj, "focus_highlight");
587 if ((fh) && (!strcmp(fh, "on")))
588 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
589 else
590 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
591} 28}
592 29
593EOLIAN static Efl_Ui_Theme_Apply 30EOLIAN static Efl_Ui_Theme_Apply
594_efl_ui_toolbar_elm_widget_theme_apply(Eo *obj, Efl_Ui_Toolbar_Data *sd) 31_efl_ui_toolbar_elm_widget_theme_apply(Eo *obj, Efl_Ui_Toolbar_Data *sd)
595{ 32{
596 Efl_Ui_Toolbar_Item_Data *it; 33 Efl_Ui_Theme_Apply ret;
597 double scale = 0;
598 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_FAILED);
599
600 if (sd->delete_me) return EFL_UI_THEME_APPLY_SUCCESS;
601 34
602 Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED; 35 ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
603 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 36 if (!ret) return EFL_UI_THEME_APPLY_FAILED;
604 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
605 37
606 elm_widget_theme_object_set 38 elm_layout_theme_set(obj, "toolbar", "base", elm_widget_style_get(obj));
607 (obj, wd->resize_obj, "toolbar", "base",
608 elm_widget_style_get(obj));
609 if (!efl_ui_dir_is_horizontal(sd->dir, EINA_TRUE)) 39 if (!efl_ui_dir_is_horizontal(sd->dir, EINA_TRUE))
610 edje_object_signal_emit(wd->resize_obj, "elm,orient,vertical", "elm"); 40 efl_canvas_layout_signal_emit(obj, "elm,orient,vertical", "elm");
611 else
612 edje_object_signal_emit(wd->resize_obj, "elm,orient,horizontal", "elm");
613
614 _mirrored_set(obj, efl_ui_mirrored_get(obj));
615
616 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
617 EINA_INLIST_FOREACH(sd->items, it)
618 _item_theme_hook(obj, it, scale);
619
620 _efl_ui_toolbar_highlight_in_theme(obj);
621 evas_object_smart_need_recalculate_set(obj, EINA_TRUE);
622
623 return int_ret;
624}
625
626static void
627_efl_ui_toolbar_item_label_update(Efl_Ui_Toolbar_Item_Data *item)
628{
629 elm_layout_text_set(VIEW(item), "elm.text", item->label);
630 if (item->label)
631 elm_layout_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
632 else
633 elm_layout_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
634}
635
636static void
637_efl_ui_toolbar_item_label_set_cb(void *data,
638 Evas_Object *obj,
639 const char *emission,
640 const char *source)
641{
642 Efl_Ui_Toolbar_Item_Data *item = data;
643
644 _efl_ui_toolbar_item_label_update(item);
645 elm_layout_signal_callback_del
646 (obj, emission, source, _efl_ui_toolbar_item_label_set_cb);
647 elm_layout_signal_emit(VIEW(item), "elm,state,label,reset", "elm");
648}
649
650static void
651_item_label_set(Efl_Ui_Toolbar_Item_Data *item,
652 const char *label,
653 const char *sig)
654{
655 const char *s;
656
657 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
658
659 eina_stringshare_replace(&item->label, label);
660 s = elm_layout_data_get(VIEW(item), "transition_animation_on");
661 if ((s) && (atoi(s)))
662 {
663 elm_layout_text_set
664 (VIEW(item), "elm.text_new", item->label);
665 elm_layout_signal_emit(VIEW(item), sig, "elm");
666 elm_layout_signal_callback_add
667 (VIEW(item), "elm,state,label_set,done", "elm",
668 _efl_ui_toolbar_item_label_set_cb, item);
669 }
670 else 41 else
671 _efl_ui_toolbar_item_label_update(item); 42 efl_canvas_layout_signal_emit(obj, "elm,orient,horizontal", "elm");
672
673 _resizing_eval_item(item);
674}
675 43
676EOLIAN static void 44 efl_canvas_group_need_recalculate_set(obj, EINA_TRUE);
677_efl_ui_toolbar_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
678 const char *part,
679 const char *label)
680{
681 char buf[256];
682 45
683 if ((!part) || (!strcmp(part, "default")) || 46 return ret;
684 (!strcmp(part, "elm.text")))
685 {
686 _item_label_set(item, label, "elm,state,label_set");
687 }
688 else
689 {
690 if (label)
691 {
692 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
693 elm_layout_signal_emit(VIEW(item), buf, "elm");
694 }
695 else
696 {
697 snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
698 elm_layout_signal_emit(VIEW(item), buf, "elm");
699 }
700 elm_layout_text_set(VIEW(item), part, label);
701 }
702}
703
704EOLIAN static const char *
705_efl_ui_toolbar_item_elm_widget_item_part_text_get(Eo *eo_it EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it,
706 const char *part)
707{
708 char buf[256];
709
710 if (!part || !strcmp(part, "default"))
711 snprintf(buf, sizeof(buf), "elm.text");
712 else
713 snprintf(buf, sizeof(buf), "%s", part);
714
715 return elm_layout_text_get(VIEW(it), buf);
716}
717
718EOLIAN static void
719_efl_ui_toolbar_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
720 const char *part,
721 Evas_Object *content)
722{
723 Evas_Object *obj = WIDGET(item);
724 double scale;
725
726 if (part && strcmp(part, "object") && strcmp(part, "elm.swallow.object"))
727 {
728 efl_content_set(efl_part(VIEW(item), part), content);
729 return;
730 }
731 if (item->object == content) return;
732
733 evas_object_del(item->object);
734
735 item->object = content;
736 if (item->object)
737 elm_widget_sub_object_add(obj, item->object);
738
739 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
740 _item_theme_hook(obj, item, scale);
741}
742
743EOLIAN static Evas_Object *
744_efl_ui_toolbar_item_elm_widget_item_part_content_get(Eo *eo_it EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it,
745 const char *part)
746{
747 if (part && strcmp(part, "object") && strcmp(part, "elm.swallow.object"))
748 {
749 return efl_content_get(efl_part(VIEW(it), part));
750 }
751 return it->object;
752}
753
754EOLIAN static Evas_Object *
755_efl_ui_toolbar_item_elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
756 const char *part)
757{
758 Evas_Object *obj = WIDGET(item);
759 Evas_Object *o;
760 double scale;
761
762 if (part && strcmp(part, "object") && strcmp(part, "elm.swallow.object"))
763 {
764 return efl_content_unset(efl_part(VIEW(item), part));
765 }
766
767 elm_layout_content_unset(VIEW(item), "elm.swallow.object");
768 _elm_widget_sub_object_redirect_to_top(obj, item->object);
769 o = item->object;
770 item->object = NULL;
771 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
772 _item_theme_hook(obj, item, scale);
773
774 return o;
775}
776
777EOLIAN static void
778_efl_ui_toolbar_efl_ui_translatable_translation_update(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
779{
780 Efl_Ui_Toolbar_Item_Data *it;
781
782 EINA_INLIST_FOREACH(sd->items, it)
783 elm_wdg_item_translate(EO_OBJ(it));
784
785 efl_ui_translatable_translation_update(efl_super(obj, MY_CLASS));
786}
787
788static void
789_action_click_cb(void *data,
790 Evas_Object *obj EINA_UNUSED,
791 const char *emission EINA_UNUSED,
792 const char *source EINA_UNUSED)
793{
794 Efl_Ui_Toolbar_Item_Data *it = data;
795
796 if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
797 (_elm_access_2nd_click_timeout(VIEW(it))))
798 {
799 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
800 _elm_access_say(E_("Selected"));
801 _item_select(it);
802 }
803}
804
805static char *
806_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
807{
808 Efl_Ui_Toolbar_Item_Data *it = (Efl_Ui_Toolbar_Item_Data *)data;
809 const char *txt = (it->base)->access_info;
810
811 if (!txt) txt = it->label;
812 if (txt) return strdup(txt);
813
814 return NULL;
815}
816
817static char *
818_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
819{
820 Efl_Ui_Toolbar_Item_Data *it = (Efl_Ui_Toolbar_Item_Data *)data;
821
822 if (elm_wdg_item_disabled_get(EO_OBJ(it)))
823 return strdup(E_("State: Disabled"));
824 else if (it->selected)
825 return strdup(E_("State: Selected"));
826
827 return NULL;
828}
829
830EOLIAN static void
831_efl_ui_toolbar_item_efl_object_destructor(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item)
832{
833 EFL_UI_TOOLBAR_DATA_GET(WIDGET(item), sd);
834
835 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(item));
836 sd->item_count--;
837 _item_del(item);
838 efl_ui_widget_theme_apply(WIDGET(item));
839
840 efl_destructor(efl_super(eo_item, EFL_UI_TOOLBAR_ITEM_CLASS));
841}
842
843static void
844_access_activate_cb(void *data EINA_UNUSED,
845 Evas_Object *part_obj EINA_UNUSED,
846 Elm_Object_Item *item)
847{
848 EFL_UI_TOOLBAR_ITEM_DATA_GET(item, it);
849 if (elm_wdg_item_disabled_get(item)) return;
850
851 if (it->selected)
852 {
853 _elm_access_say(E_("Unselected"));
854 _item_unselect(it);
855 }
856 else
857 {
858 _elm_access_say(E_("Selected"));
859 _item_select(it);
860 }
861} 47}
862 48
863static void 49static void
864_access_widget_item_register(Efl_Ui_Toolbar_Item_Data *it) 50_box_size_cb(void *data, const Efl_Event *event EINA_UNUSED)
865{
866 Elm_Access_Info *ai;
867 _elm_access_widget_item_register(it->base);
868 ai = _elm_access_info_get(it->base->access_obj);
869
870 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Toolbar Item"));
871 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
872 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
873 _elm_access_activate_callback_set(ai, _access_activate_cb, NULL);
874}
875
876EOLIAN static Eina_Rect
877_efl_ui_toolbar_item_efl_ui_focus_object_focus_geometry_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *pd)
878{ 51{
879 Eina_Rect rect; 52 Eo *obj = data;
880 53
881 evas_object_geometry_get(VIEW(pd), &rect.x, &rect.y, &rect.w, &rect.h); 54 efl_canvas_group_need_recalculate_set(obj, EINA_TRUE);
882
883 return rect;
884} 55}
885 56
886EOLIAN static Eo * 57EOLIAN static Eo *
887_efl_ui_toolbar_item_efl_object_constructor(Eo *eo_it, Efl_Ui_Toolbar_Item_Data *it) 58_efl_ui_toolbar_efl_object_constructor(Eo *obj, Efl_Ui_Toolbar_Data *pd)
888{
889 eo_it = efl_constructor(efl_super(eo_it, EFL_UI_TOOLBAR_ITEM_CLASS));
890 it->base = efl_data_scope_get(eo_it, ELM_WIDGET_ITEM_CLASS);
891 efl_access_role_set(eo_it, EFL_ACCESS_ROLE_MENU_ITEM);
892
893 return eo_it;
894}
895
896static Efl_Ui_Toolbar_Item_Data *
897_item_new(Evas_Object *obj,
898 const char *icon,
899 const char *label,
900 Evas_Smart_Cb func,
901 const void *data)
902{
903 Evas_Object *icon_obj;
904
905 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
906
907 Eo *eo_it = efl_add(EFL_UI_TOOLBAR_ITEM_CLASS, obj);
908
909 if (!eo_it) return NULL;
910
911 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it, it);
912
913 it->label = eina_stringshare_add(label);
914 it->func = func;
915 it->object = NULL;
916 WIDGET_ITEM_DATA_SET(EO_OBJ(it), data);
917
918 VIEW(it) = elm_layout_add(obj);
919 elm_widget_tree_unfocusable_set(VIEW(it), EINA_TRUE);
920 evas_object_data_set(VIEW(it), "item", it);
921 efl_access_type_set(VIEW(it), EFL_ACCESS_TYPE_DISABLED);
922
923 icon_obj = elm_icon_add(VIEW(it));
924
925 if (_elm_config->atspi_mode)
926 if (icon_obj) efl_access_parent_set(icon_obj, eo_it);
927
928 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
929 _access_widget_item_register(it);
930
931 if (_item_icon_set(icon_obj, "toolbar/", icon))
932 {
933 it->icon = icon_obj;
934 it->icon_str = eina_stringshare_add(icon);
935 }
936 else
937 {
938 it->icon = NULL;
939 it->icon_str = NULL;
940 evas_object_del(icon_obj);
941 }
942
943 if (!elm_layout_theme_set
944 (VIEW(it), "toolbar", "item", elm_widget_style_get(obj)))
945 CRI("Failed to set layout!");
946 elm_layout_signal_callback_add
947 (VIEW(it), "elm,action,click", "elm", _action_click_cb, it);
948
949 if (it->icon)
950 {
951 elm_layout_content_set(VIEW(it), "elm.swallow.icon", it->icon);
952 elm_layout_signal_emit(VIEW(it), "elm,state,icon,visible", "elm");
953 elm_layout_signal_emit(VIEW(it), "elm,icon,visible", "elm");
954 evas_object_show(it->icon);
955 }
956 else
957 {
958 elm_layout_signal_emit(VIEW(it), "elm,state,icon,hidden", "elm");
959 elm_layout_signal_emit(VIEW(it), "elm,icon,hidden", "elm");
960 }
961
962 if (it->label)
963 {
964 elm_layout_text_set(VIEW(it), "elm.text", it->label);
965 elm_layout_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
966 elm_layout_signal_emit(VIEW(it), "elm,text,visible", "elm");
967 }
968 else
969 {
970 elm_layout_signal_emit(VIEW(it), "elm,state,text,hidden", "elm");
971 elm_layout_signal_emit(VIEW(it), "elm,text,hidden", "elm");
972 }
973
974 edje_object_message_signal_process(elm_layout_edje_get(VIEW(it)));
975
976 if (!sd->items) _item_select(it);
977
978 if (_elm_config->atspi_mode) efl_access_added(eo_it);
979
980 return it;
981}
982
983static void
984_efl_ui_toolbar_item_icon_update(Efl_Ui_Toolbar_Item_Data *item)
985{
986 Evas_Object *old_icon =
987 elm_layout_content_get(VIEW(item), "elm.swallow.icon");
988
989 _elm_widget_sub_object_redirect_to_top(WIDGET(item), old_icon);
990 elm_layout_content_unset(VIEW(item), "elm.swallow.icon");
991 elm_layout_content_set(VIEW(item), "elm.swallow.icon", item->icon);
992 if (item->icon)
993 elm_layout_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
994 else
995 elm_layout_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
996
997 evas_object_del(old_icon);
998}
999
1000static void
1001_efl_ui_toolbar_item_icon_set_cb(void *data,
1002 Evas_Object *obj,
1003 const char *emission,
1004 const char *source)
1005{
1006 Efl_Ui_Toolbar_Item_Data *item = data;
1007 _efl_ui_toolbar_item_icon_update(item);
1008 elm_layout_signal_callback_del
1009 (obj, emission, source, _efl_ui_toolbar_item_icon_set_cb);
1010 elm_layout_signal_emit(VIEW(item), "elm,state,icon,reset", "elm");
1011}
1012
1013static void
1014_efl_ui_toolbar_item_icon_obj_set(Evas_Object *obj,
1015 Efl_Ui_Toolbar_Item_Data *item,
1016 Evas_Object *icon_obj,
1017 const char *icon_str,
1018 const char *sig)
1019{
1020 Evas_Object *old_icon;
1021 const char *s;
1022
1023 if (icon_str)
1024 eina_stringshare_replace(&item->icon_str, icon_str);
1025 else
1026 {
1027 eina_stringshare_del(item->icon_str);
1028 item->icon_str = NULL;
1029 }
1030 item->icon = icon_obj;
1031
1032 if (icon_obj)
1033 {
1034 evas_object_show(item->icon);
1035 elm_widget_sub_object_add(obj, item->icon);
1036 }
1037 s = elm_layout_data_get(VIEW(item), "transition_animation_on");
1038 if ((s) && (atoi(s)))
1039 {
1040 old_icon = elm_layout_content_get
1041 (VIEW(item), "elm.swallow.icon_new");
1042 if (old_icon)
1043 {
1044 _elm_widget_sub_object_redirect_to_top(WIDGET(item), old_icon);
1045 evas_object_hide(old_icon);
1046 }
1047 elm_layout_content_set
1048 (VIEW(item), "elm.swallow.icon_new", item->icon);
1049 elm_layout_signal_emit(VIEW(item), sig, "elm");
1050 elm_layout_signal_callback_add
1051 (VIEW(item), "elm,state,icon_set,done", "elm",
1052 _efl_ui_toolbar_item_icon_set_cb, item);
1053 }
1054 else
1055 _efl_ui_toolbar_item_icon_update(item);
1056 _resizing_eval_item(item);
1057}
1058
1059EOLIAN static void
1060_efl_ui_toolbar_efl_object_destructor(Eo *obj, Efl_Ui_Toolbar_Data *sd)
1061{
1062 Efl_Ui_Toolbar_Item_Data *it, *next;
1063
1064 sd->delete_me = EINA_TRUE;
1065
1066 it = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(sd->items);
1067 while (it)
1068 {
1069 next = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1070 elm_wdg_item_del(EO_OBJ(it));
1071 it = next;
1072 }
1073 efl_destructor(efl_super(obj, MY_CLASS));
1074}
1075
1076EOLIAN static void
1077_efl_ui_toolbar_efl_gfx_position_set(Eo *obj, Efl_Ui_Toolbar_Data *sd EINA_UNUSED, Eina_Position2D pos)
1078{
1079 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
1080 return;
1081
1082 efl_gfx_position_set(efl_super(obj, MY_CLASS), pos);
1083}
1084
1085EOLIAN static void
1086_efl_ui_toolbar_efl_gfx_size_set(Eo *obj, Efl_Ui_Toolbar_Data *sd EINA_UNUSED, Eina_Size2D sz)
1087{
1088 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
1089 return;
1090
1091 efl_gfx_size_set(efl_super(obj, MY_CLASS), sz);
1092}
1093
1094static Eina_Bool _efl_ui_toolbar_smart_focus_next_enable = EINA_FALSE;
1095
1096static void
1097_access_obj_process(Efl_Ui_Toolbar_Data *sd, Eina_Bool is_access)
1098{
1099 Efl_Ui_Toolbar_Item_Data *it;
1100
1101 EINA_INLIST_FOREACH (sd->items, it)
1102 {
1103 if (is_access) _access_widget_item_register(it);
1104 else _elm_access_widget_item_unregister(it->base);
1105 }
1106}
1107
1108EOLIAN static void
1109_efl_ui_toolbar_elm_widget_on_access_update(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd, Eina_Bool acs)
1110{
1111 _efl_ui_toolbar_smart_focus_next_enable = acs;
1112 _access_obj_process(sd, _efl_ui_toolbar_smart_focus_next_enable);
1113}
1114
1115EOLIAN static void
1116_efl_ui_toolbar_item_efl_ui_focus_object_focus_set(Eo *obj, Efl_Ui_Toolbar_Item_Data *pd EINA_UNUSED, Eina_Bool focus)
1117{
1118 efl_ui_focus_object_focus_set(efl_super(obj, EFL_UI_TOOLBAR_ITEM_CLASS), focus);
1119 elm_wdg_item_focus_set(obj, focus);
1120}
1121
1122EOLIAN static Eina_Rect
1123_efl_ui_toolbar_elm_widget_focus_highlight_geometry_get(Eo *obj, Efl_Ui_Toolbar_Data *sd)
1124{
1125 Eina_Rect r = {};
1126
1127 if (sd->focused_item)
1128 {
1129 EFL_UI_TOOLBAR_ITEM_DATA_GET(sd->focused_item, focus_it);
1130
1131 evas_object_geometry_get(VIEW(focus_it), &r.x, &r.y, &r.w, &r.h);
1132 elm_widget_focus_highlight_focus_part_geometry_get(VIEW(focus_it), &r.x, &r.y, &r.w, &r.h);
1133 }
1134 else
1135 evas_object_geometry_get(obj, &r.x, &r.y, &r.w, &r.h);
1136
1137 return r;
1138}
1139
1140EOLIAN static Efl_Object *
1141_efl_ui_toolbar_efl_object_constructor(Eo *obj, Efl_Ui_Toolbar_Data *sd)
1142{ 59{
60 pd->self = obj;
1143 obj = efl_constructor(efl_super(obj, MY_CLASS)); 61 obj = efl_constructor(efl_super(obj, MY_CLASS));
1144 efl_canvas_object_type_set(obj, MY_CLASS_NAME); 62 efl_canvas_object_type_set(obj, MY_CLASS_NAME);
1145 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
1146 efl_access_role_set(obj, EFL_ACCESS_ROLE_TOOL_BAR);
1147 elm_widget_sub_object_parent_add(obj); 63 elm_widget_sub_object_parent_add(obj);
1148 64
1149 if (!elm_layout_theme_set(obj, "toolbar", "base", 65 elm_layout_theme_set(obj, "toolbar", "base", NULL);
1150 elm_object_style_get(obj))) 66 if (!efl_ui_widget_theme_apply(obj))
1151 CRI("Failed to set layout!"); 67 return NULL;
1152
1153 elm_widget_can_focus_set(obj, EINA_TRUE);
1154 68
1155 sd->dir = EFL_UI_DIR_HORIZONTAL; 69 pd->dir = EFL_UI_DIR_HORIZONTAL;
1156 sd->bx = efl_add(EFL_UI_BOX_CLASS, obj, 70 pd->bx = efl_add(EFL_UI_BOX_CLASS, obj,
1157 efl_ui_direction_set(efl_added, sd->dir), 71 efl_ui_direction_set(efl_added, pd->dir),
1158 efl_pack_align_set(efl_added, -1.0, -1.0)); 72 efl_pack_align_set(efl_added, -1.0, -1.0));
1159 73 elm_layout_content_set(obj, "elm.swallow.content", pd->bx);
1160 elm_layout_content_set(obj, "elm.swallow.content", sd->bx); 74 efl_event_callback_add(pd->bx, EFL_GFX_EVENT_CHANGE_SIZE_HINTS,
1161 _efl_ui_toolbar_highlight_in_theme(obj); 75 _box_size_cb, obj);
1162 _sizing_eval(obj);
1163 76
1164 return obj; 77 return obj;
1165} 78}
1166 79
1167EOLIAN static Elm_Object_Item*
1168_efl_ui_toolbar_item_append(Eo *obj, Efl_Ui_Toolbar_Data *sd, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1169{
1170 Efl_Ui_Toolbar_Item_Data *it;
1171 double scale;
1172 Eina_List *prev_list = NULL;
1173 Eina_Iterator *itr;
1174 Evas_Object *sobj;
1175
1176 it = _item_new(obj, icon, label, func, data);
1177 if (!it) return NULL;
1178 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
1179
1180 itr = efl_content_iterate(sd->bx);
1181 EINA_ITERATOR_FOREACH(itr, sobj)
1182 prev_list = eina_list_append(prev_list, sobj);
1183
1184 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it));
1185 efl_pack(sd->bx, VIEW(it));
1186 evas_object_show(VIEW(it));
1187
1188 _item_theme_hook(obj, it, scale);
1189 sd->item_count++;
1190
1191 _efl_ui_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
1192 eina_list_free(prev_list);
1193
1194 return EO_OBJ(it);
1195}
1196
1197EOLIAN static Elm_Object_Item*
1198_efl_ui_toolbar_item_prepend(Eo *obj, Efl_Ui_Toolbar_Data *sd, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1199{
1200 Efl_Ui_Toolbar_Item_Data *it;
1201 double scale;
1202 Eina_List *prev_list = NULL;
1203 Eina_Iterator *itr;
1204 Evas_Object *sobj;
1205
1206 it = _item_new(obj, icon, label, func, data);
1207 if (!it) return NULL;
1208 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
1209
1210 itr = efl_content_iterate(sd->bx);
1211 EINA_ITERATOR_FOREACH(itr, sobj)
1212 prev_list = eina_list_append(prev_list, sobj);
1213
1214 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
1215 efl_pack_begin(sd->bx, VIEW(it));
1216 evas_object_show(VIEW(it));
1217 _item_theme_hook(obj, it, scale);
1218 sd->item_count++;
1219
1220 _efl_ui_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
1221 eina_list_free(prev_list);
1222
1223 return EO_OBJ(it);
1224}
1225
1226EOLIAN static Elm_Object_Item*
1227_efl_ui_toolbar_item_insert_before(Eo *obj, Efl_Ui_Toolbar_Data *sd, Elm_Object_Item *eo_before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1228{
1229 Efl_Ui_Toolbar_Item_Data *it;
1230 double scale;
1231 Eina_List *prev_list = NULL;
1232 Eina_Iterator *itr;
1233 Evas_Object *sobj;
1234
1235 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL);
1236 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_before, _before);
1237 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(_before, NULL);
1238
1239 it = _item_new(obj, icon, label, func, data);
1240 if (!it) return NULL;
1241 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
1242
1243 itr = efl_content_iterate(sd->bx);
1244 EINA_ITERATOR_FOREACH(itr, sobj)
1245 prev_list = eina_list_append(prev_list, sobj);
1246
1247 sd->items = eina_inlist_prepend_relative
1248 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before));
1249
1250 efl_pack_before(sd->bx, VIEW(it), VIEW(_before));
1251 _item_theme_hook(obj, it, scale);
1252 sd->item_count++;
1253
1254 _efl_ui_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
1255 eina_list_free(prev_list);
1256
1257 return EO_OBJ(it);
1258}
1259
1260EOLIAN static Elm_Object_Item*
1261_efl_ui_toolbar_item_insert_after(Eo *obj, Efl_Ui_Toolbar_Data *sd, Elm_Object_Item *eo_after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1262{
1263 Efl_Ui_Toolbar_Item_Data *it;
1264 double scale;
1265 Eina_List *prev_list = NULL;
1266 Eina_Iterator *itr;
1267 Evas_Object *sobj;
1268
1269 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL);
1270 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_after, _after);
1271 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(_after, NULL);
1272
1273 it = _item_new(obj, icon, label, func, data);
1274 if (!it) return NULL;
1275 scale = (efl_ui_scale_get(obj) * elm_config_scale_get());
1276
1277 itr = efl_content_iterate(sd->bx);
1278 EINA_ITERATOR_FOREACH(itr, sobj)
1279 prev_list = eina_list_append(prev_list, sobj);
1280
1281 sd->items = eina_inlist_append_relative
1282 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after));
1283
1284 efl_pack_after(sd->bx, VIEW(it), VIEW(_after));
1285 _item_theme_hook(obj, it, scale);
1286 sd->item_count++;
1287
1288 _efl_ui_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
1289 eina_list_free(prev_list);
1290
1291 return EO_OBJ(it);
1292}
1293
1294EOLIAN static Elm_Object_Item*
1295_efl_ui_toolbar_efl_ui_menu_first_item_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1296{
1297 if (!sd->items) return NULL;
1298 Efl_Ui_Toolbar_Item_Data *it = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(sd->items);
1299 if (it) return EO_OBJ(it);
1300 return NULL;
1301}
1302
1303EOLIAN static Elm_Object_Item*
1304_efl_ui_toolbar_efl_ui_menu_last_item_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1305{
1306 if (!sd->items) return NULL;
1307
1308 Efl_Ui_Toolbar_Item_Data *it = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(sd->items->last);
1309 if (it) return EO_OBJ(it);
1310 return NULL;
1311}
1312
1313EOLIAN static Eina_Iterator*
1314_efl_ui_toolbar_efl_ui_menu_items_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1315{
1316 return eina_inlist_iterator_new(sd->items);
1317}
1318
1319EOLIAN static Elm_Object_Item *
1320_efl_ui_toolbar_item_efl_ui_item_next_get(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it)
1321{
1322 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
1323
1324 Efl_Ui_Toolbar_Item_Data *ret_it = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(
1325 EINA_INLIST_GET(it)->next);
1326 if (ret_it) return EO_OBJ(ret_it);
1327 else return NULL;
1328}
1329
1330EOLIAN static Elm_Object_Item *
1331_efl_ui_toolbar_item_efl_ui_item_prev_get(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it)
1332{
1333 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
1334
1335 Efl_Ui_Toolbar_Item_Data *ret_it = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(
1336 EINA_INLIST_GET(it)->prev);
1337 if (ret_it) return EO_OBJ(ret_it);
1338 else return NULL;
1339}
1340
1341EOLIAN static void
1342_efl_ui_toolbar_item_efl_ui_item_selected_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item, Eina_Bool selected)
1343{
1344 if (item->selected == selected) return;
1345 if (selected) _item_select(item);
1346 else _item_unselect(item);
1347}
1348
1349EOLIAN static Eina_Bool
1350_efl_ui_toolbar_item_efl_ui_item_selected_get(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item)
1351{
1352 return item->selected;
1353}
1354
1355EOLIAN static Elm_Object_Item*
1356_efl_ui_toolbar_efl_ui_menu_selected_item_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1357{
1358 return sd->selected_item;
1359}
1360
1361EOLIAN static void
1362_efl_ui_toolbar_item_icon_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
1363 const char *icon)
1364{
1365 Evas_Object *obj;
1366 Evas_Object *icon_obj;
1367
1368 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(item);
1369
1370 obj = WIDGET(item);
1371 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1372
1373 icon_obj = elm_icon_add(obj);
1374 if (!icon_obj) return;
1375 if (_item_icon_set(icon_obj, "toolbar/", icon))
1376 _efl_ui_toolbar_item_icon_obj_set
1377 (obj, item, icon_obj, icon, "elm,state,icon_set");
1378 else
1379 {
1380 _efl_ui_toolbar_item_icon_obj_set
1381 (obj, item, NULL, NULL, "elm,state,icon_set");
1382 evas_object_del(icon_obj);
1383 }
1384}
1385
1386EOLIAN static const char *
1387_efl_ui_toolbar_item_icon_get(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it)
1388{
1389 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
1390
1391 return it->icon_str;
1392}
1393
1394EOLIAN static Evas_Object *
1395_efl_ui_toolbar_item_icon_object_get(Eo *eo_it EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *it)
1396{
1397 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
1398
1399 return it->icon;
1400}
1401
1402EOLIAN static Eina_Bool
1403_efl_ui_toolbar_item_icon_memfile_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
1404 const void *img,
1405 size_t size,
1406 const char *format,
1407 const char *key)
1408{
1409 Evas_Object *icon_obj;
1410 Evas_Object *obj;
1411 Eina_Bool ret;
1412
1413 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
1414
1415 obj = WIDGET(item);
1416
1417 if (img && size)
1418 {
1419 icon_obj = elm_icon_add(obj);
1420 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1421 ret = elm_image_memfile_set(icon_obj, img, size, format, key);
1422 if (!ret)
1423 {
1424 evas_object_del(icon_obj);
1425 return EINA_FALSE;
1426 }
1427 _efl_ui_toolbar_item_icon_obj_set
1428 (obj, item, icon_obj, NULL, "elm,state,icon_set");
1429 }
1430 else
1431 _efl_ui_toolbar_item_icon_obj_set
1432 (obj, item, NULL, NULL, "elm,state,icon_set");
1433 return EINA_TRUE;
1434}
1435
1436EOLIAN static Eina_Bool
1437_efl_ui_toolbar_item_icon_file_set(Eo *eo_item EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *item,
1438 const char *file,
1439 const char *key)
1440{
1441 Evas_Object *icon_obj;
1442 Evas_Object *obj;
1443 Eina_Bool ret;
1444
1445 EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
1446
1447 obj = WIDGET(item);
1448
1449 if (file)
1450 {
1451 icon_obj = elm_icon_add(obj);
1452 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1453 ret = elm_image_file_set(icon_obj, file, key);
1454 if (!ret)
1455 {
1456 evas_object_del(icon_obj);
1457 return EINA_FALSE;
1458 }
1459 _efl_ui_toolbar_item_icon_obj_set
1460 (obj, item, icon_obj, NULL, "elm,state,icon_set");
1461 }
1462 else
1463 _efl_ui_toolbar_item_icon_obj_set
1464 (obj, item, NULL, NULL, "elm,state,icon_set");
1465 return EINA_TRUE;
1466}
1467
1468EOLIAN static void 80EOLIAN static void
1469_efl_ui_toolbar_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Toolbar_Data *sd, Efl_Ui_Dir dir) 81_efl_ui_toolbar_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Toolbar_Data *sd, Efl_Ui_Dir dir)
1470{ 82{
@@ -1479,7 +91,7 @@ _efl_ui_toolbar_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Toolbar_Data *sd,
1479 sd->dir = dir; 91 sd->dir = dir;
1480 efl_ui_direction_set(sd->bx, sd->dir); 92 efl_ui_direction_set(sd->bx, sd->dir);
1481 93
1482 _sizing_eval(obj); 94 evas_object_smart_changed(obj);
1483} 95}
1484 96
1485EOLIAN static Efl_Ui_Dir 97EOLIAN static Efl_Ui_Dir
@@ -1488,205 +100,75 @@ _efl_ui_toolbar_efl_ui_direction_direction_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolb
1488 return sd->dir; 100 return sd->dir;
1489} 101}
1490 102
1491EOLIAN static unsigned int 103EOLIAN void
1492_efl_ui_toolbar_items_count(const Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd) 104_efl_ui_toolbar_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd)
1493{
1494 return sd->item_count;
1495}
1496
1497EOLIAN static const char*
1498_efl_ui_toolbar_item_efl_access_name_get(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item)
1499{
1500 const char *ret;
1501 ret = efl_access_name_get(efl_super(eo_item, EFL_UI_TOOLBAR_ITEM_CLASS));
1502 if (ret) return ret;
1503 return _elm_widget_item_accessible_plain_name_get(eo_item, item->label);
1504}
1505
1506EOLIAN static Efl_Access_State_Set
1507_efl_ui_toolbar_item_efl_access_state_set_get(Eo *eo_it, Efl_Ui_Toolbar_Item_Data *item EINA_UNUSED)
1508{
1509 Efl_Access_State_Set ret;
1510 Eina_Bool sel;
1511
1512 ret = efl_access_state_set_get(efl_super(eo_it, EFL_UI_TOOLBAR_ITEM_CLASS));
1513
1514 sel = efl_ui_item_selected_get(eo_it);
1515
1516 STATE_TYPE_SET(ret, EFL_ACCESS_STATE_SELECTABLE);
1517
1518 if (sel)
1519 STATE_TYPE_SET(ret, EFL_ACCESS_STATE_SELECTED);
1520
1521 return ret;
1522}
1523
1524EOLIAN static Elm_Object_Item *
1525_efl_ui_toolbar_elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1526{
1527 return sd->focused_item;
1528}
1529
1530EOLIAN static void
1531_efl_ui_toolbar_class_constructor(Efl_Class *klass)
1532{
1533 evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
1534}
1535
1536EOLIAN static const Efl_Access_Action_Data*
1537_efl_ui_toolbar_efl_access_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd EINA_UNUSED)
1538{
1539 static Efl_Access_Action_Data atspi_actions[] = {
1540 { "select", "select", NULL, _key_action_select},
1541 { NULL, NULL, NULL, NULL }
1542 };
1543 return &atspi_actions[0];
1544}
1545
1546EOLIAN static Eina_List*
1547_efl_ui_toolbar_efl_access_children_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1548{
1549 Eina_List *ret = NULL, *ret2 = NULL;
1550 Efl_Ui_Toolbar_Item_Data *it;
1551 ret2 = efl_access_children_get(efl_super(obj, EFL_UI_TOOLBAR_CLASS));
1552
1553 EINA_INLIST_FOREACH(sd->items, it)
1554 ret = eina_list_append(ret, EO_OBJ(it));
1555
1556 return eina_list_merge(ret, ret2);
1557}
1558
1559EOLIAN static Efl_Access_State_Set
1560_efl_ui_toolbar_efl_access_state_set_get(Eo *obj, Efl_Ui_Toolbar_Data *sd EINA_UNUSED)
1561{
1562 return efl_access_state_set_get(efl_super(obj, EFL_UI_TOOLBAR_CLASS));
1563}
1564
1565EOLIAN int
1566_efl_ui_toolbar_efl_access_selection_selected_children_count_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd)
1567{
1568 return pd->selected_item ? 1 : 0;
1569}
1570
1571EOLIAN Eo*
1572_efl_ui_toolbar_efl_access_selection_selected_child_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_idx)
1573{ 105{
1574 if (child_idx != 0) 106 _sizing_calc(pd);
1575 return NULL;
1576
1577 return pd->selected_item;
1578} 107}
1579 108
1580EOLIAN Eina_Bool 109EOLIAN static const Efl_Class *
1581_efl_ui_toolbar_efl_access_selection_child_select(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index) 110_efl_ui_toolbar_efl_ui_item_list_item_class_get(Eo *obj EINA_UNUSED,
111 Efl_Ui_Toolbar_Data *pd EINA_UNUSED)
1582{ 112{
1583 Efl_Ui_Toolbar_Item_Data *item; 113 return EFL_UI_TOOLBAR_ITEM_CLASS;
1584 EINA_INLIST_FOREACH(pd->items, item)
1585 {
1586 if (child_index-- == 0)
1587 {
1588 efl_ui_item_selected_set(EO_OBJ(item), EINA_TRUE);
1589 return EINA_TRUE;
1590 }
1591 }
1592 return EINA_FALSE;
1593} 114}
1594 115
1595EOLIAN Eina_Bool 116EOLIAN static Efl_Ui_Item *
1596_efl_ui_toolbar_efl_access_selection_selected_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index) 117_efl_ui_toolbar_efl_ui_item_list_item_add(Eo *obj, Efl_Ui_Toolbar_Data *pd,
118 const char *text, const char *icon)
1597{ 119{
1598 if (child_index != 0) 120 Efl_Ui_Item *item = efl_ui_item_list_item_add(efl_super(obj, MY_CLASS), text, icon);
1599 return EINA_FALSE; 121 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
1600 122
1601 if (!pd->selected_item) 123 efl_pack(pd->bx, efl_ui_item_view_get(item));
1602 return EINA_FALSE; 124 return item;
1603
1604 efl_ui_item_selected_set(pd->selected_item, EINA_FALSE);
1605
1606 return EINA_TRUE;
1607} 125}
1608 126
1609EOLIAN Eina_Bool
1610_efl_ui_toolbar_efl_access_selection_is_child_selected(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index)
1611{
1612 Efl_Ui_Toolbar_Item_Data *item;
1613 127
1614 EINA_INLIST_FOREACH(pd->items, item) 128// ===========================================================================
1615 { 129// Toolbar Item
1616 if (child_index-- == 0) 130// ===========================================================================
1617 {
1618 return efl_ui_item_selected_get(EO_OBJ(item));
1619 }
1620 }
1621 return EINA_FALSE;
1622}
1623 131
1624EOLIAN Eina_Bool 132#undef MY_CLASS
1625_efl_ui_toolbar_efl_access_selection_all_children_select(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd EINA_UNUSED) 133#define MY_CLASS EFL_UI_TOOLBAR_ITEM_CLASS
1626{
1627 return EINA_FALSE;
1628}
1629 134
1630EOLIAN Eina_Bool 135typedef struct {
1631_efl_ui_toolbar_efl_access_selection_clear(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd) 136 Efl_Ui_Toolbar_Item *self;
1632{ 137 Efl_Ui_Toolbar *parent;
1633 if (pd->selected_item) 138 Efl_Ui_Layout *view;
1634 efl_ui_item_selected_set(pd->selected_item, EINA_FALSE); 139} Efl_Ui_Toolbar_Item_Data;
1635 return EINA_TRUE;
1636}
1637 140
1638EOLIAN Eina_Bool 141EOLIAN static Eo *
1639_efl_ui_toolbar_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index) 142_efl_ui_toolbar_item_efl_object_constructor(Eo *obj, Efl_Ui_Toolbar_Item_Data *pd)
1640{ 143{
1641 Efl_Ui_Toolbar_Item_Data *item; 144 pd->self = obj;
145 obj = efl_constructor(efl_super(obj, MY_CLASS));
146 pd->parent = efl_parent_get(obj);
1642 147
1643 EINA_INLIST_FOREACH(pd->items, item) 148 return obj;
1644 {
1645 if (child_index-- == 0)
1646 {
1647 efl_ui_item_selected_set(EO_OBJ(item), EINA_FALSE);
1648 return EINA_TRUE;
1649 }
1650 }
1651 return EINA_FALSE;
1652} 149}
1653 150
1654EOLIAN void 151EOLIAN static Eo *
1655_efl_ui_toolbar_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Toolbar_Data *pd EINA_UNUSED) 152_efl_ui_toolbar_item_efl_object_finalize(Eo *obj, Efl_Ui_Toolbar_Item_Data *pd)
1656{ 153{
1657 _sizing_eval(obj); 154 const char *style;
1658}
1659 155
1660static Eina_Bool 156 obj = efl_finalize(efl_super(obj, MY_CLASS));
1661_part_of_chain(Efl_Ui_Toolbar_Item_Data *pd)
1662{
1663 Eina_Bool want = EINA_TRUE;
1664 if (elm_wdg_item_disabled_get(pd->base->eo_obj))
1665 want = EINA_FALSE;
1666 157
1667 if (!evas_object_visible_get(VIEW(pd))) 158 // Always realized.
1668 want = EINA_FALSE; 159 style = efl_ui_widget_style_get(pd->parent);
160 pd->view = efl_add(EFL_UI_LAYOUT_CLASS, pd->parent,
161 efl_ui_widget_style_set(efl_added, style),
162 efl_ui_layout_theme_set(efl_added, "toolbar", "item", style));
1669 163
1670 return want; 164 return obj;
1671} 165}
1672 166
1673EOLIAN static void 167EOLIAN static Efl_Ui_Layout *
1674_efl_ui_toolbar_efl_ui_focus_composition_prepare(Eo *obj, Efl_Ui_Toolbar_Data *pd) 168_efl_ui_toolbar_item_efl_ui_item_item_view_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Item_Data *pd)
1675{ 169{
1676 Efl_Ui_Toolbar_Item_Data *it; 170 return pd->view;
1677 Eina_List *order = NULL;
1678
1679 EINA_INLIST_FOREACH(pd->items, it)
1680 {
1681 if (_part_of_chain(it))
1682 order = eina_list_append(order, EO_OBJ(it));
1683 }
1684
1685 efl_ui_focus_composition_elements_set(obj, order);
1686} 171}
1687 172
1688/* Standard widget overrides */
1689ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_toolbar, Efl_Ui_Toolbar_Data)
1690
1691#include "efl_ui_toolbar.eo.c" 173#include "efl_ui_toolbar.eo.c"
1692#include "efl_ui_toolbar_item.eo.c" 174#include "efl_ui_toolbar_item.eo.c"
diff --git a/src/lib/elementary/efl_ui_toolbar.eo b/src/lib/elementary/efl_ui_toolbar.eo
index 26980a3486..a2f2f8df01 100644
--- a/src/lib/elementary/efl_ui_toolbar.eo
+++ b/src/lib/elementary/efl_ui_toolbar.eo
@@ -1,188 +1,18 @@
1import elm_general; 1class Efl.Ui.Toolbar (Efl.Ui.Item_List,
2 2 Efl.Ui.Direction)
3class Efl.Ui.Toolbar (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Efl.Ui.Direction,
4 Efl.Access.Widget.Action, Efl.Access.Selection,
5 Efl.Ui.Clickable, Efl.Ui.Selectable, Efl.Ui.Menu)
6{ 3{
7 [[Toolbar widget 4 [[Toolbar widget
8 5
9 A toolbar displays a list of items inside. 6 A toolbar displays a list of items inside.
10 Among them, only one can be selected at a time. 7 Among them, only one can be selected at a time.
11 ]] 8 ]]
12 methods {
13 item_insert_before {
14 [[Insert a new item into the toolbar object before item $before.
15
16 A new item will be created and added to the toolbar. Its position in
17 this toolbar will be just before item $before.
18
19 Items created with this method can be deleted with
20 elm_object_item_del().
21
22 Associated $data can be properly freed when item is deleted if a
23 callback function is set with elm_object_item_del_cb_set().
24
25 If a function is passed as argument, it will be called every time this item
26 is selected, i.e., the user clicks over an unselected item.
27 If such function isn't needed, just passing
28 $NULL as $func is enough. The same should be done for $data.
29
30 Toolbar will load icon image from fdo or current theme.
31 This behavior can be set by elm_toolbar_icon_order_lookup_set() function.
32 If an absolute path is provided it will load it direct from a file.
33
34 Note: This function does not accept relative icon path.
35
36 See: elm_toolbar_item_icon_set()]]
37
38 return: Elm.Widget.Item; [[The created item or $NULL upon failure.]]
39 params {
40 @in before: Elm.Widget.Item; [[The toolbar item to insert before.]]
41 @in icon: string @optional; [[A string with icon name or the absolute path of an image file.]]
42 @in label: string; [[The label of the item.]]
43 @in func: Evas_Smart_Cb @optional; [[The function to call when the item is clicked.]]
44 @in data: const(void_ptr) @optional; [[The data to associate with the item for related callbacks.]]
45 }
46 }
47 item_insert_after {
48 [[Insert a new item into the toolbar object after item $after.
49
50 A new item will be created and added to the toolbar. Its position in
51 this toolbar will be just after item $after.
52
53 Items created with this method can be deleted with
54 elm_object_item_del().
55
56 Associated $data can be properly freed when item is deleted if a
57 callback function is set with elm_object_item_del_cb_set().
58
59 If a function is passed as argument, it will be called every time this item
60 is selected, i.e., the user clicks over an unselected item.
61 If such function isn't needed, just passing
62 $NULL as $func is enough. The same should be done for $data.
63
64 Toolbar will load icon image from fdo or current theme.
65 This behavior can be set by elm_toolbar_icon_order_lookup_set() function.
66 If an absolute path is provided it will load it direct from a file.
67
68 Note: This function does not accept relative icon path.
69
70 See: elm_toolbar_item_icon_set()]]
71
72 return: Elm.Widget.Item; [[The created item or $NULL upon failure.]]
73 params {
74 @in after: Elm.Widget.Item; [[The toolbar item to insert after.]]
75 @in icon: string @optional; [[A string with icon name or the absolute path of an image file.]]
76 @in label: string; [[The label of the item.]]
77 @in func: Evas_Smart_Cb @optional; [[The function to call when the item is clicked.]]
78 @in data: const(void_ptr) @optional; [[The data to associate with the item for related callbacks.]]
79 }
80 }
81 item_append {
82 [[Append item to the toolbar.
83
84 A new item will be created and appended to the toolbar, i.e., will
85 be set as last item.
86
87 Items created with this method can be deleted with
88 elm_object_item_del().
89
90 Associated $data can be properly freed when item is deleted if a
91 callback function is set with elm_object_item_del_cb_set().
92
93 If a function is passed as argument, it will be called every time this item
94 is selected, i.e., the user clicks over an unselected item.
95 If such function isn't needed, just passing
96 $NULL as $func is enough. The same should be done for $data.
97
98 Toolbar will load icon image from fdo or current theme.
99 This behavior can be set by elm_toolbar_icon_order_lookup_set() function.
100 If an absolute path is provided it will load it direct from a file.
101
102 Note: This function does not accept relative icon path.
103
104 See: elm_toolbar_item_icon_set()]]
105
106 return: Elm.Widget.Item; [[The created item or $NULL upon failure.]]
107 params {
108 @in icon: string @optional; [[A string with icon name or the absolute path of an image file.]]
109 @in label: string; [[The label of the item.]]
110 @in func: Evas_Smart_Cb @optional; [[The function to call when the item is clicked.]]
111 @in data: const(void_ptr) @optional; [[The data to associate with the item for related callbacks.]]
112 }
113 }
114 items_count @const {
115 [[Get the number of items in a toolbar]]
116 return: uint; [[The number of items in $obj toolbar]]
117 }
118 item_prepend {
119 [[Prepend item to the toolbar.
120
121 A new item will be created and prepended to the toolbar, i.e., will
122 be set as first item.
123
124 Items created with this method can be deleted with
125 elm_object_item_del().
126
127 Associated $data can be properly freed when item is deleted if a
128 callback function is set with elm_object_item_del_cb_set().
129
130 If a function is passed as argument, it will be called every time this item
131 is selected, i.e., the user clicks over an unselected item.
132 If such function isn't needed, just passing
133 $NULL as $func is enough. The same should be done for $data.
134
135 Toolbar will load icon image from fdo or current theme.
136 This behavior can be set by elm_toolbar_icon_order_lookup_set() function.
137 If an absolute path is provided it will load it direct from a file.
138
139 Note: This function does not accept relative icon path.
140
141 See: elm_toolbar_item_icon_set()]]
142
143 return: Elm.Widget.Item; [[The created item or $NULL upon failure.]]
144 params {
145 @in icon: string @optional; [[A string with icon name or the absolute path of an image file.]]
146 @in label: string; [[The label of the item.]]
147 @in func: Evas_Smart_Cb @optional; [[The function to call when the item is clicked.]]
148 @in data: const(void_ptr) @optional; [[The data to associate with the item for related callbacks.]]
149 }
150 }
151 }
152 implements { 9 implements {
153 class.constructor;
154 Efl.Object.constructor; 10 Efl.Object.constructor;
155 Efl.Object.destructor;
156 Efl.Gfx.position { set; }
157 Efl.Gfx.size { set; }
158 Efl.Canvas.Group.group_calculate; 11 Efl.Canvas.Group.group_calculate;
159 Elm.Widget.on_access_update;
160 Elm.Widget.theme_apply; 12 Elm.Widget.theme_apply;
161 Elm.Widget.on_focus_update; 13 Efl.Ui.Direction.direction { get; set; [[Only supports $vertical and
162 Efl.Ui.Translatable.translation_update; 14 $horizontal. Default is $horizontal.]] }
163 Elm.Widget.widget_event; 15 Efl.Ui.Item_List.item_add;
164 Elm.Widget.focus_highlight_geometry { get; } 16 Efl.Ui.Item_List.item_class { get; }
165 Elm.Widget.focused_item { get; }
166 Efl.Ui.Direction.direction { get; set; [[Only supports $vertical and $horizontal. Default is $horizontal.]] }
167 Efl.Access.Widget.Action.elm_actions { get; }
168 Efl.Access.children { get; }
169 Efl.Access.state_set { get; }
170 Efl.Access.Selection.selected_children_count { get; }
171 Efl.Access.Selection.selected_child { get; }
172 Efl.Access.Selection.selected_child_deselect;
173 Efl.Access.Selection.child_select;
174 Efl.Access.Selection.child_deselect;
175 Efl.Access.Selection.is_child_selected;
176 Efl.Access.Selection.all_children_select;
177 Efl.Access.Selection.clear;
178 Efl.Ui.Menu.selected_item { get; }
179 Efl.Ui.Menu.first_item { get; }
180 Efl.Ui.Menu.last_item { get; }
181 Efl.Ui.Menu.items { get; }
182 Efl.Ui.Focus.Composition.prepare;
183 }
184 events {
185 item,focused; [[Called when toolbar item got focus]]
186 item,unfocused; [[Called when toolbar item lost focus]]
187 } 17 }
188} 18}
diff --git a/src/lib/elementary/efl_ui_toolbar_item.eo b/src/lib/elementary/efl_ui_toolbar_item.eo
index 0e016b3234..04a11f9940 100644
--- a/src/lib/elementary/efl_ui_toolbar_item.eo
+++ b/src/lib/elementary/efl_ui_toolbar_item.eo
@@ -1,81 +1,8 @@
1class Efl.Ui.Toolbar.Item(Elm.Widget.Item, Efl.Ui.Item, Efl.Ui.Focus.Object) 1class Efl.Ui.Toolbar.Item (Efl.Ui.Item)
2{ 2{
3 [[Toolbar widget item class]] 3 implements {
4 methods { 4 Efl.Object.constructor;
5 @property icon { 5 Efl.Object.finalize;
6 get { 6 Efl.Ui.Item.item_view { get; }
7 [[Get the string used to set the icon of $item.]] 7 }
8 }
9 set {
10 [[Set the icon associated with $item.
11
12 Toolbar will load icon image from fdo or current theme.
13 This behavior can be set by
14 elm_toolbar_icon_order_lookup_set function.
15 If an absolute path is provided it will load it direct
16 from a file.
17
18 Note: This function does not accept relative icon path.
19 ]]
20 }
21 values {
22 icon: string; [[A string with icon name or the
23 absolute path of an image file.]]
24 }
25 }
26 @property icon_object {
27 get {
28 [[Get the icon object of $item.
29
30 See also @.icon.set, @.icon_file_set, @.icon_memfile_set.
31 ]]
32 }
33 values {
34 obj: Efl.Canvas.Object; [[The icon object.]]
35 }
36 }
37 icon_memfile_set {
38 [[Set the icon associated with $item to an image in a binary buffer.
39
40 Note: The icon image set by this function can be changed by
41 @.icon.set.
42 ]]
43 params {
44 @in img: const(void_ptr); [[The binary data that will be used as an image.]]
45 @in size: size; [[The size of binary data $img.]]
46 @in format: string; [[Optional format of $img to pass to the image loader.]]
47 @in key: string; [[Optional key of $img to pass to the image loader (eg. if $img is an edje file).]]
48 }
49 return: bool; [[$true on success, $false otherwise]]
50 }
51 icon_file_set {
52 [[Set the icon associated with $item to an image in a binary buffer.
53
54 Note: The icon image set by this function can be changed by
55 elm_toolbar_item_icon_set().
56 ]]
57 params {
58 @in file: string; [[The file that contains the image.]]
59 @in key: string; [[Optional key of $img to pass to the image loader (eg. if $img is an edje file).]]
60 }
61 return: bool; [[$true on success, $false otherwise]]
62 }
63 }
64 implements {
65 Efl.Object.constructor;
66 Efl.Object.destructor;
67 Elm.Widget.Item.disable;
68 Elm.Widget.Item.focus { get; set; }
69 Elm.Widget.Item.signal_emit;
70 Elm.Widget.Item.part_text { get; set; }
71 Elm.Widget.Item.part_content { get; set; }
72 Elm.Widget.Item.part_content_unset;
73 Efl.Ui.Focus.Object.focus_geometry { get; }
74 Efl.Ui.Focus.Object.focus { set; }
75 Efl.Access.name { get; }
76 Efl.Access.state_set { get; }
77 Efl.Ui.Item.selected { get; set; }
78 Efl.Ui.Item.prev { get; }
79 Efl.Ui.Item.next { get; }
80 }
81} 8}
diff --git a/src/lib/elementary/efl_ui_toolbar_private.h b/src/lib/elementary/efl_ui_toolbar_private.h
deleted file mode 100644
index 030c0e6b89..0000000000
--- a/src/lib/elementary/efl_ui_toolbar_private.h
+++ /dev/null
@@ -1,73 +0,0 @@
1#ifndef EFL_UI_TOOLBAR_PRIVATE_H
2#define EFL_UI_TOOLBAR_PRIVATE_H
3
4/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
5 * CODE. THIS IS EFL_UI'S INTERNAL WIDGET API (for now) AND IS NOT
6 * FINAL.
7 */
8
9/**
10 * @addtogroup Widget
11 * @{
12 *
13 * @section efl-ui-toolbar-class The Efl Ui Toolbar Class
14 *
15 */
16
17typedef struct _Efl_Ui_Toolbar_Item_Data Efl_Ui_Toolbar_Item_Data;
18
19/**
20 * Base widget smart data extended with toolbar instance data.
21 */
22typedef struct _Efl_Ui_Toolbar_Data Efl_Ui_Toolbar_Data;
23struct _Efl_Ui_Toolbar_Data
24{
25 Evas_Object *bx;
26 Eina_Inlist *items;
27 Elm_Object_Item *selected_item; /**< a selected item by mouse click, return key, api, and etc. */
28 Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
29 Elm_Object_Item *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
30 unsigned int item_count;
31 Efl_Ui_Dir dir;
32
33 Eina_Bool delete_me : 1;
34};
35
36struct _Efl_Ui_Toolbar_Item_Data
37{
38 Elm_Widget_Item_Data *base;
39 EINA_INLIST;
40
41 const char *label;
42 const char *icon_str;
43 Evas_Object *icon;
44 Evas_Object *object;
45 Evas_Smart_Cb func;
46
47 Eina_Bool selected : 1;
48};
49
50
51/**
52 * @}
53 */
54
55#define EFL_UI_TOOLBAR_DATA_GET(o, sd) \
56 Efl_Ui_Toolbar_Data * sd = efl_data_scope_get(o, EFL_UI_TOOLBAR_CLASS)
57
58#define EFL_UI_TOOLBAR_CHECK(obj) \
59 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_TOOLBAR_CLASS))) \
60 return
61
62#define EFL_UI_TOOLBAR_ITEM_CHECK(it) \
63 ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, ); \
64 EFL_UI_TOOLBAR_CHECK(it->base->widget);
65
66#define EFL_UI_TOOLBAR_ITEM_CHECK_OR_RETURN(it, ...) \
67 ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
68 EFL_UI_TOOLBAR_CHECK(it->base->widget) __VA_ARGS__;
69
70#define EFL_UI_TOOLBAR_ITEM_DATA_GET(o, sd) \
71 Efl_Ui_Toolbar_Item_Data *sd = efl_data_scope_get(o, EFL_UI_TOOLBAR_ITEM_CLASS)
72
73#endif