summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-24 15:06:09 +0200
committerCedric BAIL <cedric.bail@free.fr>2019-07-24 12:05:08 -0700
commit59d684284b80f6ee56d39ceff34b7ad360877902 (patch)
treedc5c611aa7664fa71b85a91a59483044821898c1
parenta6543fb68f411f98eb841ed922124d411e7e2a48 (diff)
efl_ui_list: make it work with item_container
This also refactors the example a little bit. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9385
Diffstat (limited to '')
-rw-r--r--src/examples/elementary/efl_ui_list_example_1.c22
-rw-r--r--src/lib/elementary/efl_ui_list.c1010
-rw-r--r--src/lib/elementary/efl_ui_list.eo82
-rw-r--r--src/lib/elementary/efl_ui_list_private.h63
-rw-r--r--src/lib/elementary/meson.build1
5 files changed, 17 insertions, 1161 deletions
diff --git a/src/examples/elementary/efl_ui_list_example_1.c b/src/examples/elementary/efl_ui_list_example_1.c
index 7c3b1e5..dcb434f 100644
--- a/src/examples/elementary/efl_ui_list_example_1.c
+++ b/src/examples/elementary/efl_ui_list_example_1.c
@@ -30,7 +30,7 @@ _list_selected(void *data EINA_UNUSED, const Efl_Event *ev)
30 Eo *item = ev->info, *tmp; 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")); 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 32
33 Eina_Iterator *selects = efl_ui_list_selected_items_get(list); 33 Eina_Iterator *selects = efl_ui_item_container_selected_items_get(list);
34 34
35 EINA_ITERATOR_FOREACH(selects, tmp) 35 EINA_ITERATOR_FOREACH(selects, tmp)
36 printf("selected [%p:%d] ", tmp, efl_ui_item_index_get(tmp)); 36 printf("selected [%p:%d] ", tmp, efl_ui_item_index_get(tmp));
@@ -82,18 +82,18 @@ _anim_radio_changed(void *data, const Efl_Event *ev EINA_UNUSED)
82static void 82static void
83_scrl_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) 83_scrl_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
84{ 84{
85 Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list); 85 Efl_Ui_List_Item *item = efl_ui_item_container_last_selected_item_get(priv_d.list);
86 printf("show [%d:%p] [%d]\n", efl_ui_item_index_get(item), item, priv_d.anim); 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); 87 efl_ui_item_container_item_scroll(priv_d.list, item, priv_d.anim);
88} 88}
89 89
90static void 90static void
91_scrl_align_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) 91_scrl_align_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
92{ 92{
93 Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list); 93 Efl_Ui_List_Item *item = efl_ui_item_container_last_selected_item_get(priv_d.list);
94 double align = efl_ui_range_value_get(priv_d.slider); 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); 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); 96 efl_ui_item_container_item_scroll_align(priv_d.list, item, align, priv_d.anim);
97} 97}
98 98
99EAPI_MAIN int 99EAPI_MAIN int
@@ -108,10 +108,12 @@ elm_main(int argc EINA_UNUSED, char **argv)
108 char buf[256]; 108 char buf[256];
109 Eina_Bool placeholder = EINA_FALSE; 109 Eina_Bool placeholder = EINA_FALSE;
110 110
111 win = elm_win_util_standard_add("list", "list"); 111
112 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 112 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
113 elm_win_autodel_set(win, EINA_TRUE); 113 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
114 efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 800)); 114 efl_text_set(efl_added, "Efl.Ui.List"),
115 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
116
115 117
116 wbox = efl_add(EFL_UI_BOX_CLASS, win); 118 wbox = efl_add(EFL_UI_BOX_CLASS, win);
117 efl_ui_layout_orientation_set(wbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL); 119 efl_ui_layout_orientation_set(wbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
@@ -286,8 +288,10 @@ elm_main(int argc EINA_UNUSED, char **argv)
286 efl_ui_radio_state_value_set(radio, 1); 288 efl_ui_radio_state_value_set(radio, 1);
287 efl_pack_end(rbox, radio); 289 efl_pack_end(rbox, radio);
288 efl_pack_end(bbox, rbox); 290 efl_pack_end(bbox, rbox);
291 efl_ui_radio_group_selected_value_set(rbox, 0);
289 efl_event_callback_add(rbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _anim_radio_changed, rbox); 292 efl_event_callback_add(rbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _anim_radio_changed, rbox);
290 293
294
291 rbox = efl_add(EFL_UI_BOX_CLASS, bbox); 295 rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
292 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL); 296 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
293 297
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 524c969..99dd959 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -10,1028 +10,24 @@
10#include "elm_priv.h" 10#include "elm_priv.h"
11#include "efl_ui_list_item_private.h" 11#include "efl_ui_list_item_private.h"
12#include "efl_ui_item_private.h" 12#include "efl_ui_item_private.h"
13#include "efl_ui_list_private.h"
14 13
15#define MY_CLASS EFL_UI_LIST_CLASS 14#define MY_CLASS EFL_UI_LIST_CLASS
16#define MY_CLASS_PFX efl_ui_list 15#define MY_CLASS_PFX efl_ui_list
17 16
18#define MY_CLASS_NAME "Efl.Ui.List" 17#define MY_CLASS_NAME "Efl.Ui.List"
19 18
20static void 19typedef struct {
21_item_scroll_internal(Eo *obj,
22 Efl_Ui_List_Item *item,
23 double align,
24 Eina_Bool anim)
25{
26 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
27 Eina_Rect ipos, view;
28 Eina_Position2D vpos;
29
30 if (!pd->smanager) return;
31
32 ipos = efl_gfx_entity_geometry_get(item);
33 view = efl_ui_scrollable_viewport_geometry_get(pd->smanager);
34 vpos = efl_ui_scrollable_content_pos_get(pd->smanager);
35
36 ipos.x = view.x;
37 ipos.w = view.w;
38
39 // FIXME: align case will not correctly show in the position because of
40 // bar size calculation. there are no certain way to know the scroll calcuation finished.
41 if (EINA_DBL_EQ(align, -1.0))
42 {
43 ipos.y = ipos.y + vpos.y - view.y;
44 ipos.h = view.h;
45 }
46 else if ((align > 0.0 || EINA_DBL_EQ(align, 0.0)) &&
47 (align < 1.0 || EINA_DBL_EQ(align, 1.0)))
48 {
49 ipos.y = ipos.y + vpos.y - view.y - (int)((view.h - ipos.h) * align);
50 ipos.h = view.h;
51 }
52 else ERR("align (%.2lf) is not proper value. it must be the value between [0.0 , 1.0]!", align);
53
54 efl_ui_scrollable_scroll(pd->smanager, ipos, anim);
55}
56
57static void
58_efl_ui_list_bar_read_and_update(Eo *obj)
59{
60 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
61 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
62 double vx = 0.0, vy = 0.0;
63
64 edje_object_part_drag_value_get
65 (wd->resize_obj, "efl.dragable.vbar", NULL, &vy);
66
67 /* FIXME: Horizontal Scroll is not yet supported in the list.
68 edje_object_part_drag_value_get
69 (wd->resize_obj, "efl.dragable.hbar", &vx, NULL);
70 */
71
72 efl_ui_scrollbar_bar_position_set(pd->smanager, vx, vy);
73}
74
75static void
76_efl_ui_list_reload_cb(void *data,
77 Evas_Object *obj EINA_UNUSED,
78 const char *emission EINA_UNUSED,
79 const char *source EINA_UNUSED)
80{
81 Eo *list = data;
82 EFL_UI_LIST_DATA_GET_OR_RETURN(list, pd);
83
84 efl_ui_scrollbar_bar_visibility_update(pd->smanager);
85}
86
87static void
88_efl_ui_list_vbar_drag_cb(void *data,
89 Evas_Object *obj EINA_UNUSED,
90 const char *emission EINA_UNUSED,
91 const char *source EINA_UNUSED)
92{
93 _efl_ui_list_bar_read_and_update(data);
94
95 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
96 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAG, &type);
97}
98
99static void
100_efl_ui_list_vbar_press_cb(void *data,
101 Evas_Object *obj EINA_UNUSED,
102 const char *emission EINA_UNUSED,
103 const char *source EINA_UNUSED)
104{
105 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
106 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESS, &type);
107}
108
109static void
110_efl_ui_list_vbar_unpress_cb(void *data,
111 Evas_Object *obj EINA_UNUSED,
112 const char *emission EINA_UNUSED,
113 const char *source EINA_UNUSED)
114{
115 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
116 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESS, &type);
117}
118
119static void
120_efl_ui_list_edje_drag_start_cb(void *data,
121 Evas_Object *obj EINA_UNUSED,
122 const char *emission EINA_UNUSED,
123 const char *source EINA_UNUSED)
124{
125 Eo *list = data;
126 EFL_UI_LIST_DATA_GET_OR_RETURN(list, pd);
127
128 _efl_ui_list_bar_read_and_update(list);
129
130 pd->freeze_want = efl_ui_scrollable_scroll_freeze_get(pd->smanager);
131 efl_ui_scrollable_scroll_freeze_set(pd->smanager, EINA_TRUE);
132 efl_event_callback_call(list, EFL_UI_EVENT_SCROLL_DRAG_START, NULL);
133}
134
135static void
136_efl_ui_list_edje_drag_stop_cb(void *data,
137 Evas_Object *obj EINA_UNUSED,
138 const char *emission EINA_UNUSED,
139 const char *source EINA_UNUSED)
140{
141 Eo *list = data;
142 EFL_UI_LIST_DATA_GET_OR_RETURN(list, pd);
143
144 _efl_ui_list_bar_read_and_update(list);
145
146 efl_ui_scrollable_scroll_freeze_set(pd->smanager, pd->freeze_want);
147 efl_event_callback_call(list, EFL_UI_EVENT_SCROLL_DRAG_STOP, NULL);
148}
149
150static void
151_efl_ui_list_edje_drag_cb(void *data,
152 Evas_Object *obj EINA_UNUSED,
153 const char *emission EINA_UNUSED,
154 const char *source EINA_UNUSED)
155{
156 _efl_ui_list_bar_read_and_update(data);
157}
158
159/* FIXME: Horizontal Scroll is not yet supported in the list.
160 static void
161 _efl_ui_list_hbar_drag_cb(void *data,
162 Evas_Object *obj EINA_UNUSED,
163 const char *emission EINA_UNUSED,
164 const char *source EINA_UNUSED)
165 {
166 _efl_ui_list_bar_read_and_update(data);
167
168 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
169 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAG, &type);
170 }
171
172 static void
173 _efl_ui_list_hbar_press_cb(void *data,
174 Evas_Object *obj EINA_UNUSED,
175 const char *emission EINA_UNUSED,
176 const char *source EINA_UNUSED)
177 {
178 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
179 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESS, &type);
180 }
181
182 static void
183 _efl_ui_list_hbar_unpress_cb(void *data,
184 Evas_Object *obj EINA_UNUSED,
185 const char *emission EINA_UNUSED,
186 const char *source EINA_UNUSED)
187 {
188 Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
189 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESS, &type);
190 }
191 */
192
193static void
194_efl_ui_list_bar_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
195{
196 Eo *obj = data;
197 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
198 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
199
200 double width = 0.0, height = 0.0;
201
202 edje_object_calc_force(wd->resize_obj);
203 efl_ui_scrollbar_bar_size_get(pd->smanager, &width, &height);
204 edje_object_part_drag_size_set(wd->resize_obj, "efl.dragable.hbar", width, 1.0);
205 edje_object_part_drag_size_set(wd->resize_obj, "efl.dragable.vbar", 1.0, height);
206}
207
208static void
209_efl_ui_list_bar_pos_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
210{
211 Eo *obj = data;
212 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
213 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
214
215 double posx = 0.0, posy = 0.0;
216
217 efl_ui_scrollbar_bar_position_get(pd->smanager, &posx, &posy);
218 edje_object_part_drag_value_set(wd->resize_obj, "efl.dragable.hbar", posx, 0.0);
219 edje_object_part_drag_value_set(wd->resize_obj, "efl.dragable.vbar", 0.0, posy);
220}
221
222static void
223_efl_ui_list_bar_show_cb(void *data, const Efl_Event *event)
224{
225 Eo *obj = data;
226 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
227 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
228 Efl_Ui_Scrollbar_Direction type = *(Efl_Ui_Scrollbar_Direction *)(event->info);
229
230 if (type == EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL)
231 edje_object_signal_emit(wd->resize_obj, "efl,action,show,hbar", "efl");
232 else if (type == EFL_UI_SCROLLBAR_DIRECTION_VERTICAL)
233 edje_object_signal_emit(wd->resize_obj, "efl,action,show,vbar", "efl");
234}
235
236static void
237_efl_ui_list_bar_hide_cb(void *data, const Efl_Event *event)
238{
239 Eo *obj = data;
240 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
241 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
242 Efl_Ui_Scrollbar_Direction type = *(Efl_Ui_Scrollbar_Direction *)(event->info);
243
244 if (type == EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL)
245 edje_object_signal_emit(wd->resize_obj, "efl,action,hide,hbar", "efl");
246 else if (type == EFL_UI_SCROLLBAR_DIRECTION_VERTICAL)
247 edje_object_signal_emit(wd->resize_obj, "efl,action,hide,vbar", "efl");
248}
249
250static void
251_scroll_edje_object_attach(Eo *obj)
252{
253 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
254
255 efl_layout_signal_callback_add
256 (obj, "reload", "efl",
257 obj, _efl_ui_list_reload_cb, NULL);
258 efl_layout_signal_callback_add
259 (obj, "drag", "efl.dragable.vbar",
260 obj, _efl_ui_list_vbar_drag_cb, NULL);
261 efl_layout_signal_callback_add
262 (obj, "drag,set", "efl.dragable.vbar",
263 obj, _efl_ui_list_edje_drag_cb, NULL);
264 efl_layout_signal_callback_add
265 (obj, "drag,start", "efl.dragable.vbar",
266 obj, _efl_ui_list_edje_drag_start_cb, NULL);
267 efl_layout_signal_callback_add
268 (obj, "drag,stop", "efl.dragable.vbar",
269 obj, _efl_ui_list_edje_drag_stop_cb, NULL);
270 efl_layout_signal_callback_add
271 (obj, "drag,step", "efl.dragable.vbar",
272 obj, _efl_ui_list_edje_drag_cb, NULL);
273 efl_layout_signal_callback_add
274 (obj, "drag,page", "efl.dragable.vbar",
275 obj, _efl_ui_list_edje_drag_cb, NULL);
276 efl_layout_signal_callback_add
277 (obj, "efl,vbar,press", "efl",
278 obj, _efl_ui_list_vbar_press_cb, NULL);
279 efl_layout_signal_callback_add
280 (obj, "efl,vbar,unpress", "efl",
281 obj, _efl_ui_list_vbar_unpress_cb, NULL);
282
283 /* FIXME: Horizontal Scroll is not yet supported in the list.
284 efl_layout_signal_callback_add
285 (obj, "drag", "efl.dragable.hbar",
286 obj, _efl_ui_list_hbar_drag_cb, NULL);
287 efl_layout_signal_callback_add
288 (obj, "drag,set", "efl.dragable.hbar",
289 obj, _efl_ui_list_edje_drag_cb, NULL);
290 efl_layout_signal_callback_add
291 (obj, "drag,start", "efl.dragable.hbar",
292 obj, _efl_ui_list_edje_drag_start_cb, NULL);
293 efl_layout_signal_callback_add
294 (obj, "drag,stop", "efl.dragable.hbar",
295 obj, _efl_ui_list_edje_drag_stop_cb, NULL);
296 efl_layout_signal_callback_add
297 (obj, "drag,step", "efl.dragable.hbar",
298 obj, _efl_ui_list_edje_drag_cb, NULL);
299 efl_layout_signal_callback_add
300 (obj, "drag,page", "efl.dragable.hbar",
301 obj, _efl_ui_list_edje_drag_cb, NULL);
302 efl_layout_signal_callback_add
303 (obj, "efl,hbar,press", "efl",
304 obj, _efl_ui_list_hbar_press_cb, NULL);
305 efl_layout_signal_callback_add
306 (obj, "efl,hbar,unpress", "efl",
307 obj, _efl_ui_list_hbar_unpress_cb, NULL);
308 */
309}
310 20
311static void 21} Efl_Ui_List_Data;
312_scroll_edje_object_detach(Eo *obj)
313{
314 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
315
316 efl_layout_signal_callback_del
317 (obj, "reload", "efl",
318 obj, _efl_ui_list_reload_cb, NULL);
319 efl_layout_signal_callback_del
320 (obj, "drag", "efl.dragable.vbar",
321 obj, _efl_ui_list_vbar_drag_cb, NULL);
322 efl_layout_signal_callback_del
323 (obj, "drag,set", "efl.dragable.vbar",
324 obj, _efl_ui_list_edje_drag_cb, NULL);
325 efl_layout_signal_callback_del
326 (obj, "drag,start", "efl.dragable.vbar",
327 obj, _efl_ui_list_edje_drag_start_cb, NULL);
328 efl_layout_signal_callback_del
329 (obj, "drag,stop", "efl.dragable.vbar",
330 obj, _efl_ui_list_edje_drag_stop_cb, NULL);
331 efl_layout_signal_callback_del
332 (obj, "drag,step", "efl.dragable.vbar",
333 obj, _efl_ui_list_edje_drag_cb, NULL);
334 efl_layout_signal_callback_del
335 (obj, "drag,page", "efl.dragable.vbar",
336 obj, _efl_ui_list_edje_drag_cb, NULL);
337 efl_layout_signal_callback_del
338 (obj, "efl,vbar,press", "efl",
339 obj, _efl_ui_list_vbar_press_cb, NULL);
340 efl_layout_signal_callback_del
341 (obj, "efl,vbar,unpress", "efl",
342 obj, _efl_ui_list_vbar_unpress_cb, NULL);
343
344 /* FIXME: Horizontal Scroll is not yet supported in the list.
345 efl_layout_signal_callback_del
346 (obj, "drag", "efl.dragable.hbar",
347 obj, _efl_ui_list_hbar_drag_cb, NULL);
348 efl_layout_signal_callback_del
349 (obj, "drag,set", "efl.dragable.hbar",
350 obj, _efl_ui_list_edje_drag_cb, NULL);
351 efl_layout_signal_callback_del
352 (obj, "drag,start", "efl.dragable.hbar",
353 obj, _efl_ui_list_edje_drag_start_cb, NULL);
354 efl_layout_signal_callback_del
355 (obj, "drag,stop", "efl.dragable.hbar",
356 obj, _efl_ui_list_edje_drag_stop_cb, NULL);
357 efl_layout_signal_callback_del
358 (obj, "drag,step", "efl.dragable.hbar",
359 obj, _efl_ui_list_edje_drag_cb, NULL);
360 efl_layout_signal_callback_del
361 (obj, "drag,page", "efl.dragable.hbar",
362 obj, _efl_ui_list_edje_drag_cb, NULL);
363 efl_layout_signal_callback_del
364 (obj, "efl,hbar,press", "efl",
365 obj, _efl_ui_list_hbar_press_cb, NULL);
366 efl_layout_signal_callback_del
367 (obj, "efl,hbar,unpress", "efl",
368 obj, _efl_ui_list_hbar_unpress_cb, NULL);
369 */
370}
371
372static void
373_efl_ui_list_pan_resized_cb(void *data, const Efl_Event *ev EINA_UNUSED)
374{
375 Eo *obj = data;
376 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
377 if (!pd->smanager) return;
378
379 elm_layout_sizing_eval(obj);
380
381 if (!pd->pan_resized)
382 {
383 Eina_Rect view = efl_ui_scrollable_viewport_geometry_get(pd->smanager);
384 // FIXME: Below code is workaround size check
385 if (view.h > 1)
386 {
387 pd->pan_resized = EINA_TRUE;
388 if (pd->scroll.item)
389 {
390 _item_scroll_internal(obj, pd->scroll.item, pd->scroll.align, pd->scroll.anim);
391
392 pd->scroll.item = NULL;
393 pd->scroll.align = 0.0;
394 pd->scroll.anim = EINA_FALSE;
395 return;
396 }
397 }
398 }
399}
400
401static void
402_efl_ui_list_resized_cb(void *data, const Efl_Event *ev EINA_UNUSED)
403{
404 elm_layout_sizing_eval(data);
405}
406
407static void
408_efl_ui_list_size_hint_changed_cb(void *data, const Efl_Event *ev EINA_UNUSED)
409{
410 elm_layout_sizing_eval(data);
411}
412 22
413EOLIAN static Eo * 23EOLIAN static Eo *
414_efl_ui_list_efl_object_constructor(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED) 24_efl_ui_list_efl_object_constructor(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED)
415{ 25{
416 if (!elm_widget_theme_klass_get(obj))
417 elm_widget_theme_klass_set(obj, "list");
418 obj = efl_constructor(efl_super(obj, MY_CLASS)); 26 obj = efl_constructor(efl_super(obj, MY_CLASS));
419 27
420 return obj; 28 efl_ui_item_container_position_manager_set(obj, efl_new(EFL_UI_LIST_POSITION_MANAGER_CLASS));
421}
422
423EOLIAN static Eo *
424_efl_ui_list_efl_object_finalize(Eo *obj,
425 Efl_Ui_List_Data *pd)
426{
427 obj = efl_finalize(efl_super(obj, MY_CLASS));
428
429 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
430
431 pd->smanager = efl_add(EFL_UI_SCROLL_MANAGER_CLASS, obj);
432 efl_ui_mirrored_set(pd->smanager, efl_ui_mirrored_get(obj));
433 efl_composite_attach(obj, pd->smanager);
434
435 pd->pan = efl_add(EFL_UI_PAN_CLASS, obj);
436
437 efl_ui_scroll_manager_pan_set(pd->smanager, pd->pan);
438 edje_object_part_swallow(wd->resize_obj, "efl.content", pd->pan);
439
440 pd->box = efl_add(EFL_UI_BOX_CLASS, obj,
441 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
442 efl_ui_mirrored_set(pd->box, efl_ui_mirrored_get(obj));
443 efl_content_set(pd->pan, pd->box);
444
445 pd->select_mode = EFL_UI_SELECT_MODE_SINGLE;
446
447 _scroll_edje_object_attach(obj);
448
449 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
450 _efl_ui_list_bar_size_changed_cb, obj);
451 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
452 _efl_ui_list_bar_pos_changed_cb, obj);
453 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
454 _efl_ui_list_bar_show_cb, obj);
455 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
456 _efl_ui_list_bar_hide_cb, obj);
457 efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED,
458 _efl_ui_list_resized_cb, obj);
459 efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
460 _efl_ui_list_size_hint_changed_cb, obj);
461 efl_event_callback_add(pd->pan, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED,
462 _efl_ui_list_pan_resized_cb, obj);
463
464 elm_layout_sizing_eval(obj);
465 29
466 return obj; 30 return obj;
467} 31}
468 32
469EOLIAN static void
470_efl_ui_list_efl_object_invalidate(Eo *obj, Efl_Ui_List_Data *pd)
471{
472 _scroll_edje_object_detach(obj);
473
474 efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
475 _efl_ui_list_bar_size_changed_cb, obj);
476 efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
477 _efl_ui_list_bar_pos_changed_cb, obj);
478 efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
479 _efl_ui_list_bar_show_cb, obj);
480 efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
481 _efl_ui_list_bar_hide_cb, obj);
482 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED,
483 _efl_ui_list_resized_cb, obj);
484 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
485 _efl_ui_list_size_hint_changed_cb, obj);
486 efl_event_callback_del(pd->pan, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED,
487 _efl_ui_list_pan_resized_cb, obj);
488
489 efl_del(pd->box);
490 pd->box = NULL;
491
492 efl_del(pd->pan);
493 pd->pan = NULL;
494
495 efl_del(pd->smanager);
496 pd->smanager = NULL;
497
498 efl_invalidate(efl_super(obj, MY_CLASS));
499}
500
501EOLIAN static void
502_efl_ui_list_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED)
503{
504 // Need to be implemented
505 efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
506}
507
508EOLIAN static void
509_efl_ui_list_elm_layout_sizing_eval(Eo *obj, Efl_Ui_List_Data *pd)
510{
511 Eina_Size2D min = {0, 0}, max = {0, 0}, size = {-1, -1};
512 Eina_Rect view = {};
513 Evas_Coord vmw = 0, vmh = 0;
514 double xw = 0.0, yw = 0.0;
515
516 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
517
518 if (pd->box)
519 {
520 min = efl_gfx_hint_size_combined_min_get(pd->box);
521 max = efl_gfx_hint_size_max_get(pd->box);
522 efl_gfx_hint_weight_get(pd->box, &xw, &yw);
523 }
524
525 if (pd->smanager)
526 view = efl_ui_scrollable_viewport_geometry_get(pd->smanager);
527
528 if (xw > 0.0)
529 {
530 if ((min.w > 0) && (view.w < min.w))
531 view.w = min.w;
532 else if ((max.w > 0) && (view.w > max.w))
533 view.w = max.w;
534 }
535 else if (min.w > 0)
536 view.w = min.w;
537
538 if (yw > 0.0)
539 {
540 if ((min.h > 0) && (view.h < min.h))
541 view.h = min.h;
542 else if ((max.h > 0) && (view.h > max.h))
543 view.h = max.h;
544 }
545 else if (min.h > 0)
546 view.h = min.h;
547
548 if (pd->box) efl_gfx_entity_size_set(pd->box, EINA_SIZE2D(view.w, view.h));
549
550 edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh);
551
552 if (pd->match_content_w) size.w = vmw + min.w;
553 if (pd->match_content_h) size.h = vmh + min.h;
554
555 max = efl_gfx_hint_size_max_get(obj);
556 if ((max.w > 0) && (size.w > max.w)) size.w = max.w;
557 if ((max.h > 0) && (size.h > max.h)) size.h = max.h;
558
559 efl_gfx_hint_size_min_set(obj, size);
560}
561
562//FIXME: is this box related API could be improved more?
563EOLIAN static int
564_efl_ui_list_efl_container_content_count(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
565{
566 return pd->box ? efl_content_count(pd->box) : 0;
567}
568
569EOLIAN static Eina_Iterator *
570_efl_ui_list_efl_container_content_iterate(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
571{
572 return pd->box ? efl_content_iterate(pd->box) : NULL;
573}
574
575/* FIXME: Direction is not supported yet in the list
576 EOLIAN static void
577 _efl_ui_list_efl_ui_layout_orientable_orientation_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_Layout_Orientation dir)
578 {
579 switch (dir)
580 {
581 case EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL:
582 pd->dir = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
583 break;
584 case EFL_UI_LAYOUT_ORIENTATION_VERTICAL:
585 case EFL_UI_LAYOUT_ORIENTATION_DEFAULT:
586 default:
587 pd->dir = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
588 break;
589 }
590
591 efl_pack_layout_request(obj);
592 }
593 */
594
595EOLIAN static Eina_Error
596_efl_ui_list_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_List_Data *pd)
597{
598 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
599 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
600 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
601
602 efl_ui_mirrored_set(pd->smanager, efl_ui_mirrored_get(obj));
603
604 elm_layout_sizing_eval(obj);
605
606 return int_ret;
607}
608
609static void
610_list_item_pressed(void *data, const Efl_Event *event)
611{
612 Eo *obj = data;
613 Efl_Ui_List_Item *item = event->object;
614 efl_event_callback_call(obj, EFL_UI_EVENT_PRESSED, item);
615}
616
617static void
618_list_item_unpressed(void *data, const Efl_Event *event)
619{
620 Eo *obj = data;
621 Efl_Ui_List_Item *item = event->object;
622 efl_event_callback_call(obj, EFL_UI_EVENT_UNPRESSED, item);
623}
624
625static void
626_list_item_longpressed(void *data, const Efl_Event *event)
627{
628 Eo *obj = data;
629 Efl_Ui_List_Item *item = event->object;
630 efl_event_callback_call(obj, EFL_UI_EVENT_LONGPRESSED, item);
631}
632
633static void
634_list_item_selected(void *data, const Efl_Event *event)
635{
636 Eo *obj = data;
637 Efl_Ui_List_Item *item = event->object;
638 Efl_Ui_List_Item *selected;
639 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
640
641 /* Single Select */
642 if (pd->select_mode != EFL_UI_SELECT_MODE_MULTI)
643 {
644 EINA_LIST_FREE(pd->selected, selected)
645 {
646 if (selected != item)
647 efl_ui_item_selected_set(selected, EINA_FALSE);
648 }
649 }
650 pd->selected = eina_list_append(pd->selected, item);
651 pd->last_selected = item;
652
653 efl_event_callback_call(obj, EFL_UI_EVENT_ITEM_SELECTED, item);
654}
655
656static void
657_list_item_unselected(void *data, const Efl_Event *event)
658{
659 Eo *obj = data;
660 Efl_Ui_List_Item *item = event->object;
661 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
662
663 pd->selected = eina_list_remove(pd->selected, item);
664 if (pd->last_selected == item) pd->last_selected = NULL;
665
666 efl_event_callback_call(obj, EFL_UI_EVENT_ITEM_UNSELECTED, item);
667}
668
669static Eina_Bool
670_list_item_process(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED, Efl_Ui_List_Item *it)
671{
672 EFL_UI_LIST_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
673
674 efl_ui_item_container_set(it, obj);
675 efl_ui_mirrored_set(it, efl_ui_mirrored_get(obj));
676
677 efl_event_callback_add(it, EFL_UI_EVENT_PRESSED, _list_item_pressed, obj);
678 efl_event_callback_add(it, EFL_UI_EVENT_UNPRESSED, _list_item_unpressed, obj);
679 efl_event_callback_add(it, EFL_UI_EVENT_LONGPRESSED, _list_item_longpressed, obj);
680 efl_event_callback_add(it, EFL_UI_EVENT_ITEM_SELECTED, _list_item_selected, obj);
681 efl_event_callback_add(it, EFL_UI_EVENT_ITEM_UNSELECTED, _list_item_unselected, obj);
682
683 return EINA_TRUE;
684}
685
686static void
687_list_item_clear(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED, EINA_UNUSED Efl_Ui_List_Item *it)
688{
689 EFL_UI_LIST_ITEM_CHECK_OR_RETURN(it);
690 efl_ui_item_container_set(it, NULL);
691
692 efl_event_callback_del(it, EFL_UI_EVENT_PRESSED, _list_item_pressed, obj);
693 efl_event_callback_del(it, EFL_UI_EVENT_UNPRESSED, _list_item_unpressed, obj);
694 efl_event_callback_del(it, EFL_UI_EVENT_LONGPRESSED, _list_item_longpressed, obj);
695 efl_event_callback_del(it, EFL_UI_EVENT_ITEM_SELECTED, _list_item_selected, obj);
696 efl_event_callback_del(it, EFL_UI_EVENT_ITEM_UNSELECTED, _list_item_unselected, obj);
697}
698
699/* Pack APIs */
700EOLIAN static Eina_Bool
701_efl_ui_list_efl_pack_pack_clear(Eo *obj, Efl_Ui_List_Data *pd)
702{
703 Eina_Bool ret = efl_pack_clear(pd->box);
704
705 if (ret)
706 {
707 eina_list_free(pd->items);
708 eina_list_free(pd->selected);
709 pd->items = NULL;
710 pd->selected = NULL;
711 }
712
713 elm_layout_sizing_eval(obj);
714 return ret;
715}
716
717EOLIAN static Eina_Bool
718_efl_ui_list_efl_pack_unpack_all(Eo *obj, Efl_Ui_List_Data *pd)
719{
720 Eina_Bool ret = efl_pack_unpack_all(pd->box);
721
722 if (ret)
723 {
724 Efl_Ui_List_Item *it = NULL;
725 EINA_LIST_FREE(pd->items, it)
726 {
727 _list_item_clear(obj, pd, it);
728 }
729 eina_list_free(pd->selected);
730 pd->items = NULL;
731 pd->selected = NULL;
732 }
733
734 elm_layout_sizing_eval(obj);
735 return ret;
736}
737
738EOLIAN static Eina_Bool
739_efl_ui_list_efl_pack_unpack(Eo *obj, Efl_Ui_List_Data *pd, Efl_Gfx_Entity *subobj)
740{
741 Eina_Bool ret = efl_pack_unpack(pd->box, subobj);
742 Efl_Ui_List_Item *item = (Efl_Ui_List_Item *)subobj;
743
744 if (ret)
745 {
746 pd->items = eina_list_remove(pd->items, item);
747 if (efl_ui_item_selected_get(item))
748 {
749 pd->selected = eina_list_remove(pd->selected, item);
750 }
751 _list_item_clear(obj, pd, item);
752 }
753
754 elm_layout_sizing_eval(obj);
755 return ret;
756}
757
758EOLIAN static Eina_Bool
759_efl_ui_list_efl_pack_pack(Eo *obj, Efl_Ui_List_Data *pd, Efl_Gfx_Entity *subobj)
760{
761 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
762
763 Eina_Bool ret = efl_pack_end(pd->box, subobj);
764 pd->items = eina_list_append(pd->items, subobj);
765 return ret;
766}
767
768EOLIAN static Eina_Bool
769_efl_ui_list_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_List_Data *pd, Efl_Gfx_Entity *subobj)
770{
771 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
772
773 Eina_Bool ret = efl_pack_end(pd->box, subobj);
774 pd->items = eina_list_append(pd->items, subobj);
775 return ret;
776}
777
778EOLIAN static Eina_Bool
779_efl_ui_list_efl_pack_linear_pack_begin(Eo *obj, Efl_Ui_List_Data *pd, Efl_Gfx_Entity *subobj)
780{
781 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
782
783 Eina_Bool ret = efl_pack_begin(pd->box, subobj);
784 pd->items = eina_list_prepend(pd->items, subobj);
785 return ret;
786}
787
788EOLIAN static Eina_Bool
789_efl_ui_list_efl_pack_linear_pack_before(Eo *obj,
790 Efl_Ui_List_Data *pd,
791 Efl_Gfx_Entity *subobj,
792 const Efl_Gfx_Entity *existing)
793{
794 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
795 EFL_UI_LIST_ITEM_CHECK_OR_RETURN(existing, EINA_FALSE);
796
797 Eina_Bool ret = efl_pack_before(pd->box, subobj, existing);
798 pd->items = eina_list_prepend_relative(pd->items, subobj, existing);
799 return ret;
800}
801
802EOLIAN static Eina_Bool
803_efl_ui_list_efl_pack_linear_pack_after(Eo *obj,
804 Efl_Ui_List_Data *pd,
805 Efl_Gfx_Entity *subobj,
806 const Efl_Gfx_Entity *existing)
807{
808 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
809 EFL_UI_LIST_ITEM_CHECK_OR_RETURN(existing, EINA_FALSE);
810
811 Eina_Bool ret = efl_pack_after(pd->box, subobj, existing);
812 pd->items = eina_list_append_relative(pd->items, subobj, existing);
813 return ret;
814}
815
816EOLIAN static Eina_Bool
817_efl_ui_list_efl_pack_linear_pack_at(Eo *obj,
818 Efl_Ui_List_Data *pd,
819 Efl_Gfx_Entity *subobj,
820 int index)
821{
822 if (!_list_item_process(obj, pd, subobj)) return EINA_FALSE;
823 Efl_Ui_List_Item *existing = efl_pack_content_get(pd->box, index);
824
825 Eina_Bool ret = efl_pack_at(pd->box, subobj, index);
826 pd->items = eina_list_append_relative(pd->items, subobj, existing);
827 return ret;
828}
829
830EOLIAN static Efl_Gfx_Entity *
831_efl_ui_list_efl_pack_linear_pack_content_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int index)
832{
833 return efl_pack_content_get(pd->box, index);
834}
835
836EOLIAN static Efl_Gfx_Entity *
837_efl_ui_list_efl_pack_linear_pack_unpack_at(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int index)
838{
839 return efl_pack_unpack_at(pd->box, index);
840}
841
842EOLIAN static int
843_efl_ui_list_efl_pack_linear_pack_index_get(Eo *obj EINA_UNUSED,
844 Efl_Ui_List_Data *pd,
845 const Efl_Gfx_Entity *subobj)
846{
847 return efl_pack_index_get(pd->box, subobj);
848}
849
850EOLIAN static void
851_efl_ui_list_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_List_Data *pd)
852{
853 efl_pack_layout_update(pd->box);
854 elm_layout_sizing_eval(obj);
855
856 efl_event_callback_legacy_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
857}
858
859EOLIAN static void
860_efl_ui_list_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_List_Data *pd)
861{
862 efl_pack_layout_request(pd->box);
863 elm_layout_sizing_eval(obj);
864}
865
866EOLIAN static void
867_efl_ui_list_efl_gfx_arrangement_content_padding_set(Eo *obj EINA_UNUSED,
868 Efl_Ui_List_Data *pd,
869 double h,
870 double v,
871 Eina_Bool scalable)
872{
873 efl_gfx_arrangement_content_padding_set(pd->box, h, v, scalable);
874}
875
876EOLIAN static void
877_efl_ui_list_efl_gfx_arrangement_content_padding_get(const Eo *obj EINA_UNUSED,
878 Efl_Ui_List_Data *pd,
879 double *h,
880 double *v,
881 Eina_Bool *scalable)
882{
883 efl_gfx_arrangement_content_padding_get(pd->box, h, v, scalable);
884}
885
886/* FIXME: align could not work properly on the list
887 EOLIAN static void
888 _efl_ui_list_efl_gfx_arrangement_content_align_set(Eo *obj, Efl_Ui_List_Data *pd, double h, double v)
889 {
890 efl_gfx_arrangement_content_align_set(pd->box, h, v);
891 }
892
893 EOLIAN static void
894 _efl_ui_list_efl_gfx_arrangement_content_align_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, double *h, double *v)
895 {
896 efl_gfx_arrangement_content_align_get(pd->box, &h, &v);
897 }
898 */
899
900/* Scroll APIs */
901EOLIAN static void
902_efl_ui_list_efl_ui_scrollable_interactive_match_content_set(Eo *obj EINA_UNUSED,
903 Efl_Ui_List_Data *pd,
904 Eina_Bool match_content_w,
905 Eina_Bool match_content_h)
906{
907 pd->match_content_w = !!match_content_w;
908 pd->match_content_h = !!match_content_h;
909
910 efl_ui_scrollable_match_content_set(pd->smanager, match_content_w, match_content_h);
911
912 elm_layout_sizing_eval(obj);
913}
914
915EOLIAN static void
916_efl_ui_list_efl_ui_multi_selectable_select_mode_set(Eo *obj EINA_UNUSED,
917 Efl_Ui_List_Data *pd,
918 Efl_Ui_Select_Mode mode)
919{
920 Efl_Ui_List_Item *selected;
921
922 if ((pd->select_mode == EFL_UI_SELECT_MODE_MULTI &&
923 mode != EFL_UI_SELECT_MODE_MULTI) ||
924 mode == EFL_UI_SELECT_MODE_NONE)
925 {
926 Eina_List *clone = eina_list_clone(pd->selected);
927 EINA_LIST_FREE(clone, selected)
928 efl_ui_item_selected_set(selected, EINA_FALSE);
929 }
930
931 pd->select_mode = mode;
932}
933
934EOLIAN static Efl_Ui_Select_Mode
935_efl_ui_list_efl_ui_multi_selectable_select_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
936{
937 return pd->select_mode;
938}
939
940/* List APIs */
941EOLIAN static void
942_efl_ui_list_item_scroll(Eo *obj,
943 Efl_Ui_List_Data *pd,
944 Efl_Ui_List_Item *item,
945 Eina_Bool animation)
946{
947 // Need to be implemented here.
948 if (pd->pan_resized)
949 {
950 _item_scroll_internal(obj, item, -1.0, animation);
951 }
952 else
953 {
954 pd->scroll.item = item;
955 pd->scroll.align = -1.0;
956 pd->scroll.anim = animation;
957 }
958}
959
960EOLIAN static void
961_efl_ui_list_item_scroll_align(Eo *obj,
962 Efl_Ui_List_Data *pd,
963 Efl_Ui_List_Item *item,
964 double align,
965 Eina_Bool animation)
966{
967 // Need to be implemented here.
968 if (pd->pan_resized)
969 {
970 _item_scroll_internal(obj, item, align, animation);
971 }
972 else
973 {
974 pd->scroll.item = item;
975 pd->scroll.align = align;
976 pd->scroll.anim = animation;
977 }
978}
979
980EOLIAN static Efl_Ui_List_Item *
981_efl_ui_list_last_selected_item_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
982{
983 return pd->last_selected;
984}
985
986static Eina_Bool
987_list_item_iterator_next(Item_Iterator *it, void **data)
988{
989 Efl_Ui_List_Item *item;
990
991 if (!eina_iterator_next(it->real_iterator, (void **)&item))
992 return EINA_FALSE;
993
994 if (data) *data = item;
995 return EINA_TRUE;
996}
997
998static Eo *
999_list_item_iterator_get_container(Item_Iterator *it)
1000{
1001 return it->object;
1002}
1003
1004static void
1005_list_item_iterator_free(Item_Iterator *it)
1006{
1007 eina_iterator_free(it->real_iterator);
1008 eina_list_free(it->list);
1009 free(it);
1010}
1011
1012EOLIAN static Eina_Iterator *
1013_efl_ui_list_selected_items_get(Eo *obj, Efl_Ui_List_Data *pd)
1014{
1015 Item_Iterator *item;
1016
1017 item = calloc(1, sizeof(*item));
1018 if (!item) return NULL;
1019
1020 EINA_MAGIC_SET(&item->iterator, EINA_MAGIC_ITERATOR);
1021
1022 item->list = eina_list_clone(pd->selected);
1023 item->real_iterator = eina_list_iterator_new(item->list);
1024 item->iterator.version = EINA_ITERATOR_VERSION;
1025 item->iterator.next = FUNC_ITERATOR_NEXT(_list_item_iterator_next);
1026 item->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_list_item_iterator_get_container);
1027 item->iterator.free = FUNC_ITERATOR_FREE(_list_item_iterator_free);
1028 item->object = obj;
1029
1030 return &item->iterator;
1031}
1032
1033/* Internal EO APIs and hidden overrides */
1034#define EFL_UI_LIST_EXTRA_OPS \
1035 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_list)
1036
1037#include "efl_ui_list.eo.c" 33#include "efl_ui_list.eo.c"
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
index 72098a1..cf99aad 100644
--- a/src/lib/elementary/efl_ui_list.eo
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -1,89 +1,9 @@
1import efl_ui_list_item; 1import efl_ui_list_item;
2 2
3class @beta Efl.Ui.List extends Efl.Ui.Layout_Base implements 3class @beta Efl.Ui.List extends Efl.Ui.Item_Container
4 Efl.Ui.Scrollable_Interactive,
5 Efl.Ui.Scrollbar,
6 Efl.Pack_Linear, Efl.Pack_Layout,
7 Efl.Ui.Selectable,
8 Efl.Ui.Multi_Selectable,
9 Efl.Gfx.Arrangement
10{ 4{
11 [[Simple list widget with Pack interface.]] 5 [[Simple list widget with Pack interface.]]
12 methods {
13 item_scroll {
14 [[scroll move the item to show in the viewport.]]
15 params {
16 @in item: Efl.Ui.List_Item; [[Target item.]]
17 @in animation: bool; [[Boolean value for animation of scroll move.]]
18 }
19 }
20 item_scroll_align {
21 [[scroll move the item to show at the align position of the viewport.]]
22 params {
23 @in item: Efl.Ui.List_Item; [[Target item.]]
24 @in align: double; [[align value in Viewport.]]
25 @in animation: bool; [[Boolean value for animation of scroll move.]]
26 }
27 }
28 @property last_selected_item {
29 [[Property data of last selected item.]]
30 get {}
31 values {
32 return: Efl.Ui.List_Item; [[last selected item of list.]]
33 }
34 }
35 selected_items_get {
36 [[Get the selected items iterator. The iterator sequence will be decided by selection.]]
37 return: iterator<Efl.Ui.List_Item> @owned @no_unused; [[Iterator covered by selected items list.
38 user have to free the iterator after used.]]
39 }
40 }
41 implements { 6 implements {
42 //Efl.Object
43 Efl.Object.constructor; 7 Efl.Object.constructor;
44 Efl.Object.finalize;
45 Efl.Object.invalidate;
46
47 //Efl.Canvas
48 Efl.Canvas.Group.group_calculate;
49
50 //Efl.Container
51 Efl.Container.content_iterate;
52 Efl.Container.content_count;
53
54 //Efl.Ui.Layout_Orientable.orientation { get; set; } //TODO
55
56 //Efl.Ui.Widget
57 Efl.Ui.Widget.theme_apply;
58
59 //Efl.Ui.Focus
60 //Efl.Ui.Focus.Object.on_focus_update;
61
62 //Efl.Pack
63 Efl.Pack.pack_clear;
64 Efl.Pack.unpack_all;
65 Efl.Pack.unpack;
66 Efl.Pack.pack;
67 Efl.Pack_Linear.pack_begin;
68 Efl.Pack_Linear.pack_end;
69 Efl.Pack_Linear.pack_before;
70 Efl.Pack_Linear.pack_after;
71 Efl.Pack_Linear.pack_at;
72 Efl.Pack_Linear.pack_content_get;
73 Efl.Pack_Linear.pack_unpack_at;
74 Efl.Pack_Linear.pack_index_get;
75 Efl.Pack_Layout.layout_update;
76 Efl.Pack_Layout.layout_request;
77 Efl.Gfx.Arrangement.content_padding { get; set; }
78
79 //Efl.Ui.Scrollable
80 Efl.Ui.Scrollable_Interactive.match_content { set; }
81
82 //Efl.Ui.Multi_Selectable
83 Efl.Ui.Multi_Selectable.select_mode {get; set;}
84 }
85 composite {
86 Efl.Ui.Scrollable_Interactive;
87 Efl.Ui.Scrollbar;
88 } 8 }
89} 9}
diff --git a/src/lib/elementary/efl_ui_list_private.h b/src/lib/elementary/efl_ui_list_private.h
deleted file mode 100644
index 409956d..0000000
--- a/src/lib/elementary/efl_ui_list_private.h
+++ /dev/null
@@ -1,63 +0,0 @@
1#ifndef EFL_UI_LIST_PRIVATE_H
2#define EFL_UI_LIST_PRIVATE_H
3
4#include "Elementary.h"
5
6typedef struct _Efl_Ui_List_Data
7{
8 // Eo Objects
9 Eo *box; /* Internal box for Efl.Pack support */
10 Eo *pan; /* Internal pan for scroll */
11 Eo *smanager; /* Scroll Manager for support scroll with pan */
12
13 struct {
14 Efl_Ui_List_Item *item; /* Scroll target item */
15 double align; /* Item scroll aligned position.
16 -1 is for default case of scroll in */
17 Eina_Bool anim : 1; /* boolean data for animation on scroll */
18 } scroll; /* Item scroll values for deferred operation */
19
20 Eina_List *items; /* All item list for internal maintaining */
21 Eina_List *selected; /* Selected items list */
22 Efl_Ui_List_Item *last_selected; /* latest selected item */
23
24 Efl_Ui_Select_Mode select_mode; /* Select mode for items
25 with single or multiple seleciton */
26
27 // Boolean Data
28 Eina_Bool freeze_want : 1; /* Flag for Scroll freezing */
29 Eina_Bool match_content_w: 1; /* Flag for size matching on content width.
30 it will disable horizontal scroll */
31 Eina_Bool match_content_h: 1; /* Flag for size matching on content height.
32 it will disable vertical scroll */
33 Eina_Bool pan_resized : 1; /* Flag for pan resized.
34 This value is used for checking scroll is
35 calculated after initialized */
36} Efl_Ui_List_Data;
37
38typedef struct _Item_Iterator
39{
40 Eina_Iterator iterator;
41 Eina_List *list;
42 Eina_Iterator *real_iterator;
43 Eo *object;
44} Item_Iterator;
45
46
47#define EFL_UI_LIST_DATA_GET(o, pd) \
48 Efl_Ui_List_Data * pd = efl_data_scope_safe_get(o, EFL_UI_LIST_CLASS)
49
50#define EFL_UI_LIST_DATA_GET_OR_RETURN(o, ptr, ...) \
51 EFL_UI_LIST_DATA_GET(o, ptr); \
52 if (EINA_UNLIKELY(!ptr)) \
53 { \
54 ERR("No widget data for object %p (%s)", \
55 o, evas_object_type_get(o)); \
56 return __VA_ARGS__; \
57 }
58
59#define EFL_UI_LIST_CHECK(obj) \
60 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_LIST_CLASS))) \
61 return
62
63#endif
diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build
index 0764f61..47b2f4b 100644
--- a/src/lib/elementary/meson.build
+++ b/src/lib/elementary/meson.build
@@ -355,7 +355,6 @@ elementary_headers_unstable = [
355 'efl_ui_video_private.h', 355 'efl_ui_video_private.h',
356 'efl_ui_item_private.h', 356 'efl_ui_item_private.h',
357 'efl_ui_list_item_private.h', 357 'efl_ui_list_item_private.h',
358 'efl_ui_list_private.h',
359 'efl_ui_grid_item_private.h', 358 'efl_ui_grid_item_private.h',
360 'efl_ui_list_view_private.h', 359 'efl_ui_list_view_private.h',
361 'efl_ui_list_view_seg_array.h', 360 'efl_ui_list_view_seg_array.h',