summaryrefslogtreecommitdiff
path: root/src/examples/elementary
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2019-09-19 11:19:56 -0700
committerCedric Bail <cedric.bail@free.fr>2019-09-24 11:12:44 -0700
commit78b69d45b57ce43ac0373a4f10ac548a3a458dbf (patch)
tree5438b8750b4e5b1fabc73dd775d842210b785f40 /src/examples/elementary
parent2e1317baedb844a490e96b574fcec3c1ef52c6d9 (diff)
elementary: migrate Efl.Ui.List_View to use Efl.Ui.Collection_View.
Differential Revision: https://phab.enlightenment.org/D10035
Diffstat (limited to 'src/examples/elementary')
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_1.c38
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_2.c3
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_3.c54
3 files changed, 27 insertions, 68 deletions
diff --git a/src/examples/elementary/efl_ui_list_view_example_1.c b/src/examples/elementary/efl_ui_list_view_example_1.c
index 757082a..5c1f4f5 100644
--- a/src/examples/elementary/efl_ui_list_view_example_1.c
+++ b/src/examples/elementary/efl_ui_list_view_example_1.c
@@ -14,39 +14,20 @@
14 14
15#define NUM_ITEMS 400 15#define NUM_ITEMS 400
16 16
17const char *styles[] = {
18 "odd",
19 "even"
20 };
21
22char edj_path[PATH_MAX];
23
24static void 17static void
25_realized_cb(void *data EINA_UNUSED, const Efl_Event *event) 18_realized_cb(void *data EINA_UNUSED, const Efl_Event *event)
26{ 19{
27 Efl_Ui_List_View_Item_Event *ie = event->info; 20 Efl_Gfx_Entity *layout = event->info;
28 if (!ie->layout) return;
29 21
30 Efl_Ui_Layout *layout = ie->layout;
31 elm_object_focus_allow_set(layout, EINA_TRUE); 22 elm_object_focus_allow_set(layout, EINA_TRUE);
32} 23}
33 24
34/*
35static void
36_unrealized_cb(void *data EINA_UNUSED, const Efl_Event *event)
37{
38 Efl_Ui_List_View_Item_Event *ie = event->info;
39
40 efl_ui_view_model_set(ie->layout, NULL);
41 efl_del(ie->layout);
42}
43*/
44static Efl_Model* 25static Efl_Model*
45_make_model(Evas_Object *win) 26_make_model(Evas_Object *win)
46{ 27{
47 Eina_Value vtext; 28 Eina_Value vtext;
48 Efl_Generic_Model *model, *child; 29 Efl_Generic_Model *model, *child;
49 unsigned int i, s; 30 unsigned int i;
50 char buf[256]; 31 char buf[256];
51 32
52 model = efl_add(EFL_GENERIC_MODEL_CLASS, win); 33 model = efl_add(EFL_GENERIC_MODEL_CLASS, win);
@@ -54,10 +35,7 @@ _make_model(Evas_Object *win)
54 35
55 for (i = 0; i < (NUM_ITEMS); i++) 36 for (i = 0; i < (NUM_ITEMS); i++)
56 { 37 {
57 s = i%2;
58 child = efl_model_child_add(model); 38 child = efl_model_child_add(model);
59 eina_value_set(&vtext, styles[s]);
60 efl_model_property_set(child, "odd_style", &vtext);
61 39
62 snprintf(buf, sizeof(buf), "Item # %i", i); 40 snprintf(buf, sizeof(buf), "Item # %i", i);
63 eina_value_set(&vtext, buf); 41 eina_value_set(&vtext, buf);
@@ -88,17 +66,13 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
88 66
89 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 67 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
90 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 68 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
91 efl_ui_property_bind(factory, "signal/efl,state,%v", "odd_style");
92 efl_ui_property_bind(factory, "signal/efl,state,%{selected;unselected}", "selected");
93 efl_ui_property_bind(factory, "efl.text", "title"); 69 efl_ui_property_bind(factory, "efl.text", "title");
94 70
95 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win 71 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win,
96 , efl_ui_list_view_layout_factory_set(efl_added, factory) 72 efl_ui_collection_view_factory_set(efl_added, factory),
97 , efl_ui_view_model_set(efl_added, selmodel) 73 efl_ui_view_model_set(efl_added, selmodel));
98 );
99 74
100 efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_cb, NULL); 75 efl_event_callback_add(li, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_cb, NULL);
101// efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_UNREALIZED, _unrealized_cb, NULL);
102 76
103 elm_win_resize_object_add(win, li); 77 elm_win_resize_object_add(win, li);
104 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 78 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
diff --git a/src/examples/elementary/efl_ui_list_view_example_2.c b/src/examples/elementary/efl_ui_list_view_example_2.c
index 5a4d680..3464af5 100644
--- a/src/examples/elementary/efl_ui_list_view_example_2.c
+++ b/src/examples/elementary/efl_ui_list_view_example_2.c
@@ -37,13 +37,12 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
37 efl_ui_property_bind(factory, "efl.text", "filename"); 37 efl_ui_property_bind(factory, "efl.text", "filename");
38 38
39 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win); 39 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win);
40 efl_ui_list_view_layout_factory_set(li, factory); 40 efl_ui_collection_view_factory_set(li, factory);
41 efl_ui_view_model_set(li, model); 41 efl_ui_view_model_set(li, model);
42 42
43 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 43 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
44 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); 44 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
45 45
46
47 imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win); 46 imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
48 efl_ui_property_bind(imgf, "", "path"); //connect to "path" property 47 efl_ui_property_bind(imgf, "", "path"); //connect to "path" property
49 efl_ui_factory_bind(factory, "efl.icon", imgf); 48 efl_ui_factory_bind(factory, "efl.icon", imgf);
diff --git a/src/examples/elementary/efl_ui_list_view_example_3.c b/src/examples/elementary/efl_ui_list_view_example_3.c
index 5a233b3..ca839bc 100644
--- a/src/examples/elementary/efl_ui_list_view_example_3.c
+++ b/src/examples/elementary/efl_ui_list_view_example_3.c
@@ -52,17 +52,15 @@ static void
52_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 52_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{ 53{
54 Priv_Data *priv = (Priv_Data*)data; 54 Priv_Data *priv = (Priv_Data*)data;
55 efl_unref(priv->model); 55 efl_del(priv->model);
56} 56}
57 57
58static void 58static void
59_focused(void *data, const Efl_Event *event) 59_selected(void *data, const Efl_Event *event)
60{ 60{
61 Priv_Data *priv = (Priv_Data*)data; 61 Priv_Data *priv = (Priv_Data*)data;
62 Evas_Object *focused = efl_ui_focus_manager_focus_get(event->object);
63 62
64 if (focused) 63 priv->selected = efl_ui_single_selectable_last_selected_get(event->object);
65 priv->selected = focused;
66} 64}
67 65
68static void 66static void
@@ -77,7 +75,7 @@ _bt_add_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
77 child = efl_model_child_add(priv->model); 75 child = efl_model_child_add(priv->model);
78 76
79 eina_value_set(&vtext, elm_object_text_get(priv->e_name)); 77 eina_value_set(&vtext, elm_object_text_get(priv->e_name));
80 efl_model_property_set(child, "name", &vtext); 78 efl_model_property_set(child, "filename", &vtext);
81 79
82 eina_value_set(&vtext, elm_object_text_get(priv->e_occ)); 80 eina_value_set(&vtext, elm_object_text_get(priv->e_occ));
83 efl_model_property_set(child, "occupation", &vtext); 81 efl_model_property_set(child, "occupation", &vtext);
@@ -95,7 +93,6 @@ _bt_del_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
95 Priv_Data *priv = (Priv_Data*)data; 93 Priv_Data *priv = (Priv_Data*)data;
96 Eo *child = NULL; 94 Eo *child = NULL;
97 95
98 //l = efl_ui_focus_manager_focus_get(priv->list1);
99 if(priv->selected) 96 if(priv->selected)
100 { 97 {
101 printf("focused %p\n", priv->selected); 98 printf("focused %p\n", priv->selected);
@@ -113,21 +110,21 @@ static void
113_bt_none_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 110_bt_none_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
114{ 111{
115 Evas_Object *li = data; 112 Evas_Object *li = data;
116 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_NONE); 113 efl_ui_multi_selectable_async_select_mode_set(li, EFL_UI_SELECT_MODE_NONE);
117} 114}
118 115
119static void 116static void
120_bt_donly_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 117_bt_donly_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
121{ 118{
122 Evas_Object *li = data; 119 /* Evas_Object *li = data; */
123 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); 120 /* efl_ui_multi_selectable_async_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); */
124} 121}
125 122
126static void 123static void
127_bt_default_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 124_bt_default_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
128{ 125{
129 Evas_Object *li = data; 126 Evas_Object *li = data;
130 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DEFAULT); 127 efl_ui_multi_selectable_async_select_mode_set(li, EFL_UI_SELECT_MODE_SINGLE);
131} 128}
132 129
133static void 130static void
@@ -146,28 +143,21 @@ _bt_unset_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
146static void 143static void
147_realized_1_cb(void *data EINA_UNUSED, const Efl_Event *event) 144_realized_1_cb(void *data EINA_UNUSED, const Efl_Event *event)
148{ 145{
149 Efl_Ui_List_View_Item_Event *ie = event->info; 146 Efl_Gfx_Entity *layout = event->info;
150 147
151 evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0); 148 efl_ui_property_bind(layout, "efl.text", "filename");
152 evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
153 efl_ui_property_bind(ie->layout, "efl.text", "name");
154 efl_ui_property_bind(ie->layout, "signal/efl,state,%v", "odd_style");
155} 149}
156 150
157static void 151static void
158_realized_2_cb(void *data EINA_UNUSED, const Efl_Event *event) 152_realized_2_cb(void *data EINA_UNUSED, const Efl_Event *event)
159{ 153{
160 Efl_Ui_List_View_Item_Event *ie = event->info; 154 Efl_Gfx_Entity *layout = event->info;
161 printf("relized 2\n");
162 155
163 elm_object_focus_allow_set(ie->layout, EINA_TRUE); 156 efl_ui_property_bind(layout, "efl.text", "occupation");
164 evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
165 evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
166 efl_ui_property_bind(ie->layout, "efl.text", "occupation");
167} 157}
168 158
169static Efl_Model* 159static Efl_Model*
170_make_model() 160_make_model(void)
171{ 161{
172 Eina_Value vtext, value; 162 Eina_Value vtext, value;
173 Efl_Generic_Model *model, *child; 163 Efl_Generic_Model *model, *child;
@@ -182,11 +172,8 @@ _make_model()
182 { 172 {
183 child = efl_model_child_add(model); 173 child = efl_model_child_add(model);
184 174
185 i%2 ? eina_value_set(&vtext, "even") : eina_value_set(&vtext, "odd");
186 efl_model_property_set(child, "odd_style", &vtext);
187
188 eina_value_set(&vtext, texts[(i % len)]); 175 eina_value_set(&vtext, texts[(i % len)]);
189 efl_model_property_set(child, "name", &vtext); 176 efl_model_property_set(child, "filename", &vtext);
190 177
191 eina_value_set(&vtext, subtexts[(i % len)]); 178 eina_value_set(&vtext, subtexts[(i % len)]);
192 efl_model_property_set(child, "occupation", &vtext); 179 efl_model_property_set(child, "occupation", &vtext);
@@ -226,21 +213,20 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
226 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 213 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
227 214
228 priv->list1 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 215 priv->list1 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
229 efl_event_callback_add(priv->list1, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_1_cb, priv); 216 efl_event_callback_add(priv->list1, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_1_cb, priv);
230 evas_object_size_hint_weight_set(priv->list1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 217 evas_object_size_hint_weight_set(priv->list1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
231 evas_object_size_hint_align_set(priv->list1, EVAS_HINT_FILL, EVAS_HINT_FILL); 218 evas_object_size_hint_align_set(priv->list1, EVAS_HINT_FILL, EVAS_HINT_FILL);
232 elm_box_pack_end(bx, priv->list1); 219 elm_box_pack_end(bx, priv->list1);
233 efl_ui_list_view_layout_factory_set(priv->list1, factory); 220 efl_ui_collection_view_factory_set(priv->list1, factory);
234 221
235 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 222 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
236 efl_ui_property_bind(factory, "efl.text", "filename"); 223 efl_ui_property_bind(factory, "efl.text", "filename");
237 efl_ui_property_bind(factory, "signal/efl,state,%v", "selected");
238 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 224 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
239 priv->list2 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 225 priv->list2 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
240 efl_event_callback_add(priv->list2, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2); 226 efl_event_callback_add(priv->list2, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2);
241 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 227 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_size_hint_align_set(priv->list2, EVAS_HINT_FILL, EVAS_HINT_FILL); 228 evas_object_size_hint_align_set(priv->list2, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 efl_ui_list_view_layout_factory_set(priv->list2, factory); 229 efl_ui_collection_view_factory_set(priv->list2, factory);
244 230
245 vbx = elm_box_add(win); 231 vbx = elm_box_add(win);
246 elm_box_pack_end(bx, vbx); 232 elm_box_pack_end(bx, vbx);
@@ -313,7 +299,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
313 elm_box_pack_end(vbx, bt); 299 elm_box_pack_end(vbx, bt);
314 300
315 elm_box_pack_end(bx, priv->list2); 301 elm_box_pack_end(bx, priv->list2);
316 efl_event_callback_add(priv->list2, EFL_UI_FOCUS_MANAGER_EVENT_MANAGER_FOCUS_CHANGED, _focused ,priv); 302 efl_event_callback_add(priv->list2, EFL_UI_SINGLE_SELECTABLE_EVENT_SELECTION_CHANGED, _selected, priv);
317 303
318 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv); 304 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv);
319 305