summaryrefslogtreecommitdiff
path: root/unsorted
diff options
context:
space:
mode:
authorSangHyeon Lee <sh10233.lee@samsung.com>2018-04-23 15:13:59 +0900
committerSangHyeon Lee <sh10233.lee@samsung.com>2018-04-28 13:41:41 +0900
commitf774b7b0baab39dae5a1a6eb59ed703d70e9a63d (patch)
treec148cfebb53c724e37cd6d0704893f1037d41083 /unsorted
parenta547e82da24206e11b493797fb5fb50a08785939 (diff)
efl_ui_list : introduce new list widget for simple usage
Summary: most usage of simple list, items are very limited and loading performance is not serious. to support those requirement, this efl.ui.list will create scrollable box with efl.pack. user can create list by packing an pre-loaded item object, Efl.Ui.List.Item class. Test Plan: tested in efl_ui_list_example_1.c in examples. Reviewers: cedric, felipealmeida Subscribers: woohyun, Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5861
Diffstat (limited to 'unsorted')
-rw-r--r--unsorted/elementary/efl_ui_list_example_1.c327
-rw-r--r--unsorted/elementary/efl_ui_view_list_example_1.c2
-rw-r--r--unsorted/elementary/efl_ui_view_list_example_2.c2
-rw-r--r--unsorted/elementary/efl_ui_view_list_example_3.c4
4 files changed, 331 insertions, 4 deletions
diff --git a/unsorted/elementary/efl_ui_list_example_1.c b/unsorted/elementary/efl_ui_list_example_1.c
new file mode 100644
index 00000000..432c5862
--- /dev/null
+++ b/unsorted/elementary/efl_ui_list_example_1.c
@@ -0,0 +1,327 @@
1// gcc -o efl_ui_list_example_1 efl_ui_list_example_1.c `pkg-config --cflags --libs elementary`
2// ./efl_ui_list_example_1 item_style_name
3
4#ifdef HAVE_CONFIG_H
5# include "elementary_config.h"
6#else
7# define EFL_BETA_API_SUPPORT 1
8# define EFL_EO_API_SUPPORT 1
9#endif
10
11#include <Elementary.h>
12#include <Efl.h>
13#include <Eio.h>
14#include <stdio.h>
15
16#define NUM_ITEMS 400
17
18typedef struct _List_Scroll_Data {
19 Eo *list;
20 Eo *slider;
21 Eina_Bool anim;
22} List_Scroll_Data;
23List_Scroll_Data priv_d;
24
25
26static void
27_list_selected(void *data, const Efl_Event *ev)
28{
29 Eo *list = ev->object;
30 Eo *item = ev->info, *tmp;
31 printf("list item [%p:%d] is %s\n", item, efl_ui_item_index_get(item), (efl_ui_item_selected_get(item)? "selected" : "unselected"));
32
33 Eina_Iterator *selects = efl_ui_list_selected_items_get(list);
34
35 EINA_ITERATOR_FOREACH(selects, tmp)
36 printf("selected [%p:%d] ", tmp, efl_ui_item_index_get(tmp));
37 printf("\n");
38 eina_iterator_free(selects);
39}
40
41static void
42_list_unselected(void *data, const Efl_Event *ev)
43{
44 Eo *item = ev->info;
45 printf("list item [%p : %d] is %s\n", item, efl_ui_item_index_get(item), (efl_ui_item_selected_get(item)? "selected" : "unselected"));
46}
47
48static void
49_list_pressed(void *data, const Efl_Event *ev)
50{
51 Eo *item = ev->info;
52 printf("list item [%p : %d] is pressed\n", item, efl_ui_item_index_get(item));
53}
54
55static void
56_list_unpressed(void *data, const Efl_Event *ev)
57{
58 Eo *item = ev->info;
59 printf("list item [%p : %d] is unpressed\n", item, efl_ui_item_index_get(item));
60}
61
62static void
63_list_longpressed(void *data, const Efl_Event *ev)
64{
65 Eo *item = ev->info;
66 printf("list item [%p : %d] is longpressed\n", item, efl_ui_item_index_get(item));
67}
68
69static void
70_select_radio_changed(void *data, const Efl_Event *ev)
71{
72 Eo *list = data;
73 efl_ui_select_mode_set(list, efl_ui_radio_state_value_get(ev->object));
74}
75
76static void
77_anim_radio_changed(void *data, const Efl_Event *ev)
78{
79 priv_d.anim = efl_ui_radio_state_value_get(ev->object);
80}
81
82static void
83_scrl_btn_clicked(void *data, const Efl_Event *ev)
84{
85 Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list);
86 printf("show [%d:%p] [%d]\n", efl_ui_item_index_get(item), item, priv_d.anim);
87 efl_ui_list_item_scroll(priv_d.list, item, priv_d.anim);
88}
89
90static void
91_scrl_align_btn_clicked(void *data, const Efl_Event *ev)
92{
93 Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list);
94 double align = efl_ui_range_value_get(priv_d.slider);
95 printf("show [%d:%p] [%.2lf], [%d]\n", efl_ui_item_index_get(item), item, align, priv_d.anim);
96 efl_ui_list_item_scroll_align(priv_d.list, item, align, priv_d.anim);
97}
98
99EAPI_MAIN int
100elm_main(int argc, char **argv)
101{
102 Eo *win, *list;
103 Eo *wbox, *ibox, *bbox, *rbox;
104 Eo *item, *check, *txt;
105 Eo *radio, *select_radio, *anim_radio;
106 Eo *slider, *scrl_btn;
107 int i;
108 char buf[256];
109 Eina_Bool emptystyle = EINA_FALSE;
110
111 win = elm_win_util_standard_add("list", "list");
112 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
113 elm_win_autodel_set(win, EINA_TRUE);
114 efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 800));
115
116 wbox = efl_add(EFL_UI_BOX_CLASS, win);
117 efl_ui_direction_set(wbox, EFL_UI_DIR_VERTICAL);
118 efl_gfx_size_hint_weight_set(wbox, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND);
119 efl_gfx_size_hint_align_set(wbox, EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL);
120
121 if ((argv[1] != NULL) &&
122 (!strcmp(argv[1], "empty")))
123 emptystyle = EINA_TRUE;
124
125 priv_d.list = list = efl_add(EFL_UI_LIST_CLASS, wbox);
126 efl_gfx_size_hint_weight_set(list, EFL_GFX_SIZE_HINT_EXPAND, 0.9);
127
128 efl_event_callback_add(list, EFL_UI_EVENT_SELECTED, _list_selected, NULL);
129 efl_event_callback_add(list, EFL_UI_EVENT_UNSELECTED, _list_unselected, NULL);
130 efl_event_callback_add(list, EFL_UI_EVENT_PRESSED, _list_pressed, NULL);
131 efl_event_callback_add(list, EFL_UI_EVENT_UNPRESSED, _list_unpressed, NULL);
132 efl_event_callback_add(list, EFL_UI_EVENT_LONGPRESSED, _list_longpressed, NULL);
133
134 for (i = 0; i < NUM_ITEMS; i++)
135 {
136 if (emptystyle) item = efl_add(EFL_UI_LIST_EMPTY_ITEM_CLASS, list);
137 else item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, list);
138
139 /* disable case test */
140 if (i == 1) efl_ui_widget_disabled_set(item, EINA_TRUE);
141
142 if (emptystyle)
143 {
144 ibox = efl_add(EFL_UI_BOX_CLASS, item);
145 efl_ui_direction_set(ibox, EFL_UI_DIR_HORIZONTAL);
146
147 txt = efl_add(EFL_UI_TEXT_CLASS, ibox);
148 efl_gfx_size_hint_weight_set(txt, 0.95, EFL_GFX_SIZE_HINT_EXPAND);
149 efl_text_halign_set(txt, 0.2);
150 efl_text_interactive_selection_allowed_set(txt, EINA_FALSE);
151 snprintf(buf, sizeof(buf), "empty style item [%d]", i);
152 efl_text_set(txt, buf);
153 efl_pack_end(ibox, txt);
154
155 check = efl_add(EFL_UI_CHECK_CLASS, ibox);
156 efl_gfx_size_hint_weight_set(check, 0.05, EFL_GFX_SIZE_HINT_EXPAND);
157 efl_pack_end(ibox, check);
158
159 if (i % 2)
160 efl_content_set(item, ibox);
161 else
162 efl_content_set(efl_part(item, "content"), ibox);
163 }
164 else
165 {
166 snprintf(buf, sizeof(buf), "default style item [%d]", i);
167 if (i % 2)
168 efl_text_set(efl_part(item, "text"), buf);
169 else
170 efl_text_set(item, buf);
171
172
173 check = efl_add(EFL_UI_CHECK_CLASS, item);
174 if ((i % 3) == 0)
175 efl_content_set(efl_part(item, "end"), check);
176 else if ((i % 3) == 1)
177 efl_content_set(efl_part(item, "icon"), check);
178 else
179 efl_content_set(item, check);
180 }
181 /* Pack APIs test */
182 switch (i)
183 {
184 case 10:
185 efl_gfx_color_set(efl_part(item, "background"), 255, 0, 0, 255);
186 efl_pack_begin(list, item);
187 break;
188
189 case 20:
190 efl_gfx_color_set(efl_part(item, "background"), 0, 255, 0, 255);
191 efl_pack_before(list, item, efl_pack_content_get(list, 19));
192 break;
193
194 case 30:
195 efl_gfx_color_set(efl_part(item, "background"), 0, 0, 255, 255);
196 efl_pack_after(list, item, efl_pack_content_get(list, 29));
197 break;
198
199 case 40:
200 efl_file_set(efl_part(item, "background"), "./sky_01.jpg", NULL);
201 efl_gfx_image_scale_type_set(efl_part(item, "background"), EFL_GFX_IMAGE_SCALE_TYPE_FIT_OUTSIDE);
202 efl_pack_at(list, item, 39);
203 break;
204
205 case 50:
206 efl_file_set(efl_part(item, "background"), "./sky_01.jpg", NULL);
207 efl_gfx_image_scale_type_set(efl_part(item, "background"), EFL_GFX_IMAGE_SCALE_TYPE_TILE);
208 efl_pack(list, item);
209 break;
210
211 case 60:
212 efl_pack(list, item);
213 efl_pack_unpack(list, item);
214 efl_del(item);
215 break;
216
217 default:
218 efl_pack_end(list, item);
219 }
220 }
221
222 efl_pack_end(wbox, list);
223
224 /*select mode */
225 txt = efl_add(EFL_UI_TEXT_CLASS, wbox);
226 efl_gfx_size_hint_weight_set(txt, EFL_GFX_SIZE_HINT_EXPAND, 0.01);
227 efl_text_halign_set(txt, 0.02);
228 efl_text_interactive_selection_allowed_set(txt, EINA_FALSE);
229 efl_text_set(txt, "Select Mode");
230 efl_pack_end(wbox, txt);
231
232 bbox = efl_add(EFL_UI_BOX_CLASS, wbox);
233 efl_ui_direction_set(bbox, EFL_UI_DIR_HORIZONTAL);
234 efl_gfx_size_hint_weight_set(bbox, EFL_GFX_SIZE_HINT_EXPAND, 0.05);
235
236 select_radio = radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
237 efl_text_set(radio, "SINGLE");
238 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_SINGLE);
239 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
240 efl_pack_end(bbox, radio);
241 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
242 efl_text_set(radio, "SINGLE_ALWAYS");
243 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_SINGLE_ALWAYS);
244 efl_ui_radio_group_add(radio, select_radio);
245 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
246 efl_pack_end(bbox, radio);
247 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
248 efl_text_set(radio, "MULTI");
249 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MULTI);
250 efl_ui_radio_group_add(radio, select_radio);
251 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
252 efl_pack_end(bbox, radio);
253 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
254 efl_text_set(radio, "NONE");
255 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_NONE);
256 efl_ui_radio_group_add(radio, select_radio);
257 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
258 efl_pack_end(bbox, radio);
259 efl_pack_end(wbox, bbox);
260
261 /* scroll mode */
262 txt = efl_add(EFL_UI_TEXT_CLASS, wbox);
263 efl_gfx_size_hint_weight_set(txt, EFL_GFX_SIZE_HINT_EXPAND, 0.01);
264 efl_text_interactive_selection_allowed_set(txt, EINA_FALSE);
265 efl_text_halign_set(txt, 0.02);
266 efl_text_set(txt, "Item Scroll");
267 efl_pack_end(wbox, txt);
268
269 priv_d.slider = slider = efl_add(EFL_UI_SLIDER_CLASS, wbox);
270 efl_ui_direction_set(slider, EFL_UI_DIR_HORIZONTAL);
271 efl_gfx_size_hint_weight_set(slider, 0.0, 0.05);
272 efl_gfx_size_hint_align_set(slider, 0.5, 0.5);
273 efl_gfx_size_hint_min_set(slider, EINA_SIZE2D(380, 20));
274 efl_ui_range_min_max_set(slider, 0.0, 1.0);
275 efl_pack_end(wbox, slider);
276
277 bbox = efl_add(EFL_UI_BOX_CLASS, wbox);
278 efl_ui_direction_set(bbox, EFL_UI_DIR_HORIZONTAL);
279 efl_gfx_size_hint_weight_set(bbox, EFL_GFX_SIZE_HINT_EXPAND, 0.05);
280
281 rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
282 efl_ui_direction_set(rbox, EFL_UI_DIR_VERTICAL);
283
284 anim_radio = radio = efl_add(EFL_UI_RADIO_CLASS, rbox);
285 efl_gfx_size_hint_align_set(radio, 0.5, 0.5);
286 efl_text_set(radio, "ANIMATION OFF");
287 efl_ui_radio_state_value_set(radio, 0);
288 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _anim_radio_changed, NULL);
289 efl_pack_end(rbox, radio);
290 radio = efl_add(EFL_UI_RADIO_CLASS, rbox);
291 efl_gfx_size_hint_align_set(radio, 0.5, 0.5);
292 efl_text_set(radio, "ANIMATION ON");
293 efl_ui_radio_state_value_set(radio, 1);
294 efl_ui_radio_group_add(radio, anim_radio);
295 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _anim_radio_changed, NULL);
296 efl_pack_end(rbox, radio);
297 efl_pack_end(bbox, rbox);
298
299 rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
300 efl_ui_direction_set(rbox, EFL_UI_DIR_VERTICAL);
301
302 scrl_btn = efl_add(EFL_UI_BUTTON_CLASS, rbox);
303 efl_text_set(scrl_btn, "Scroll Item");
304 efl_gfx_size_hint_align_set(scrl_btn, 0.5, 0.5);
305 efl_gfx_size_hint_min_set(scrl_btn, EINA_SIZE2D(200, 25));
306 efl_event_callback_add(scrl_btn, EFL_UI_EVENT_CLICKED, _scrl_btn_clicked, NULL);
307 efl_pack_end(rbox, scrl_btn);
308
309 scrl_btn = efl_add(EFL_UI_BUTTON_CLASS, rbox);
310 efl_text_set(scrl_btn, "Scroll Item Align");
311 efl_gfx_size_hint_align_set(scrl_btn, 0.5, 0.5);
312 efl_gfx_size_hint_min_set(scrl_btn, EINA_SIZE2D(200, 25));
313 efl_event_callback_add(scrl_btn, EFL_UI_EVENT_CLICKED, _scrl_align_btn_clicked, NULL);
314 efl_pack_end(rbox, scrl_btn);
315
316 efl_pack_end(bbox, rbox);
317 efl_pack_end(wbox, bbox);
318
319 elm_win_resize_object_add(win, wbox);
320 //window show
321 efl_gfx_entity_visible_set(win, EINA_TRUE);
322
323 elm_run();
324
325 return 0;
326}
327ELM_MAIN() \ No newline at end of file
diff --git a/unsorted/elementary/efl_ui_view_list_example_1.c b/unsorted/elementary/efl_ui_view_list_example_1.c
index 3994fa41..621f81ee 100644
--- a/unsorted/elementary/efl_ui_view_list_example_1.c
+++ b/unsorted/elementary/efl_ui_view_list_example_1.c
@@ -85,7 +85,7 @@ elm_main(int argc, char **argv)
85 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 85 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
86 efl_ui_model_connect(factory, "signal/elm,state,%v", "odd_style"); 86 efl_ui_model_connect(factory, "signal/elm,state,%v", "odd_style");
87 efl_ui_model_connect(factory, "elm.text", "name"); 87 efl_ui_model_connect(factory, "elm.text", "name");
88 efl_ui_layout_factory_theme_config(factory, "list", "item", "default"); 88 efl_ui_layout_factory_theme_config(factory, "list_item", NULL, "default");
89 89
90 li = efl_add(EFL_UI_VIEW_LIST_CLASS, win); 90 li = efl_add(EFL_UI_VIEW_LIST_CLASS, win);
91 efl_ui_view_list_layout_factory_set(li, factory); 91 efl_ui_view_list_layout_factory_set(li, factory);
diff --git a/unsorted/elementary/efl_ui_view_list_example_2.c b/unsorted/elementary/efl_ui_view_list_example_2.c
index 6a7c0eed..fac0e5d8 100644
--- a/unsorted/elementary/efl_ui_view_list_example_2.c
+++ b/unsorted/elementary/efl_ui_view_list_example_2.c
@@ -46,7 +46,7 @@ elm_main(int argc, char **argv)
46 model = efl_add(EIO_MODEL_CLASS, efl_main_loop_get(), eio_model_path_set(efl_added, dirname)); 46 model = efl_add(EIO_MODEL_CLASS, efl_main_loop_get(), eio_model_path_set(efl_added, dirname));
47 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 47 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
48 efl_ui_model_connect(factory, "elm.text", "filename"); 48 efl_ui_model_connect(factory, "elm.text", "filename");
49 efl_ui_layout_factory_theme_config(factory, "list", "item", "default"); 49 efl_ui_layout_factory_theme_config(factory, "list_item", NULL, "default");
50 50
51 li = efl_add(EFL_UI_VIEW_LIST_CLASS, win); 51 li = efl_add(EFL_UI_VIEW_LIST_CLASS, win);
52 efl_ui_view_list_layout_factory_set(li, factory); 52 efl_ui_view_list_layout_factory_set(li, factory);
diff --git a/unsorted/elementary/efl_ui_view_list_example_3.c b/unsorted/elementary/efl_ui_view_list_example_3.c
index 53a816c6..c2e8281e 100644
--- a/unsorted/elementary/efl_ui_view_list_example_3.c
+++ b/unsorted/elementary/efl_ui_view_list_example_3.c
@@ -223,7 +223,7 @@ elm_main(int argc, char **argv)
223 priv->model = _make_model(); 223 priv->model = _make_model();
224 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 224 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
225 efl_ui_model_connect(factory, "elm.text", "filename"); 225 efl_ui_model_connect(factory, "elm.text", "filename");
226 efl_ui_layout_factory_theme_config(factory, "list", "item", "default"); 226 efl_ui_layout_factory_theme_config(factory, "list_item", NULL, "default");
227 227
228 priv->list1 = efl_add(EFL_UI_VIEW_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 228 priv->list1 = efl_add(EFL_UI_VIEW_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
229 efl_event_callback_add(priv->list1, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_1_cb, priv); 229 efl_event_callback_add(priv->list1, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_1_cb, priv);
@@ -235,7 +235,7 @@ elm_main(int argc, char **argv)
235 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 235 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
236 efl_ui_model_connect(factory, "elm.text", "filename"); 236 efl_ui_model_connect(factory, "elm.text", "filename");
237 efl_ui_model_connect(factory, "signal/elm,state,%v", "selected"); 237 efl_ui_model_connect(factory, "signal/elm,state,%v", "selected");
238 efl_ui_layout_factory_theme_config(factory, "list", "item", "default"); 238 efl_ui_layout_factory_theme_config(factory, "list_item", NULL, "default");
239 priv->list2 = efl_add(EFL_UI_VIEW_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 239 priv->list2 = efl_add(EFL_UI_VIEW_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
240 efl_event_callback_add(priv->list2, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2); 240 efl_event_callback_add(priv->list2, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2);
241 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 241 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);