summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_list.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-12-12 22:59:48 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-12-13 14:13:09 -0200
commitfd92dec358bf6d98b4b334e938140049b6f5f12e (patch)
tree524a928aaf65e4ff25b2c2948c67885961de004f /src/lib/elementary/efl_ui_list.c
parente747e1ec2a4991ff53c854327ee66033686d7503 (diff)
elementary: Add efl_ui_list widget
Diffstat (limited to 'src/lib/elementary/efl_ui_list.c')
-rw-r--r--src/lib/elementary/efl_ui_list.c668
1 files changed, 668 insertions, 0 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
new file mode 100644
index 0000000000..4a70ab5bf4
--- /dev/null
+++ b/src/lib/elementary/efl_ui_list.c
@@ -0,0 +1,668 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#define ELM_ACCESS_PROTECTED
5#define ELM_ACCESS_WIDGET_ACTION_PROTECTED
6#define EFL_ACCESS_SELECTION_PROTECTED
7
8#include <Elementary.h>
9#include "efl_ui_list_private.h"
10#include "efl_ui_list_precise_layouter.eo.h"
11
12#include <assert.h>
13
14#define MY_CLASS EFL_UI_LIST_CLASS
15#define MY_CLASS_NAME "Efl.Ui.List"
16
17#define MY_PAN_CLASS EFL_UI_LIST_PAN_CLASS
18
19#define SIG_CHILD_ADDED "child,added"
20#define SIG_CHILD_REMOVED "child,removed"
21#define SELECTED_PROP "selected"
22
23static const Evas_Smart_Cb_Description _smart_callbacks[] = {
24 {SIG_CHILD_ADDED, ""},
25 {SIG_CHILD_REMOVED, ""},
26 {NULL, NULL}
27};
28
29void _efl_ui_list_custom_layout(Efl_Ui_List *);
30void _efl_ui_list_item_select_set(Efl_Ui_List_LayoutItem*, Eina_Bool);
31static void _layout(Efl_Ui_List_Data* pd);
32
33static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
34static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
35static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
36
37static const Elm_Action key_actions[] = {
38 {"move", _key_action_move},
39 {"select", _key_action_select},
40 {"escape", _key_action_escape},
41 {NULL, NULL}
42};
43
44EOLIAN static void
45_efl_ui_list_pan_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd)
46{
47 evas_object_smart_changed(psd->wobj);
48}
49
50
51EOLIAN static void
52_efl_ui_list_pan_elm_pan_pos_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd, Evas_Coord x, Evas_Coord y)
53{
54 if ((x == psd->x) && (y == psd->y)) return;
55
56 psd->x = x;
57 psd->y = y;
58
59 evas_object_smart_changed(psd->wobj);
60}
61
62EOLIAN static void
63_efl_ui_list_pan_elm_pan_pos_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd, Evas_Coord *x, Evas_Coord *y)
64{
65 if (x) *x = psd->x;
66 if (y) *y = psd->y;
67}
68
69EOLIAN static void
70_efl_ui_list_pan_elm_pan_pos_max_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd, Evas_Coord *x, Evas_Coord *y)
71{
72 Evas_Coord ow, oh;
73 Eina_Size2D min;
74
75 elm_interface_scrollable_content_viewport_geometry_get
76 (psd->wobj, NULL, NULL, &ow, &oh);
77
78 min = efl_ui_list_model_min_size_get(psd->wobj);
79 ow = min.w - ow;
80 if (ow < 0) ow = 0;
81 oh = min.h - oh;
82 if (oh < 0) oh = 0;
83
84 if (x) *x = ow;
85 if (y) *y = oh;
86}
87
88EOLIAN static void
89_efl_ui_list_pan_elm_pan_pos_min_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y)
90{
91 if (x) *x = 0;
92 if (y) *y = 0;
93}
94
95EOLIAN static void
96_efl_ui_list_pan_elm_pan_content_size_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *psd, Evas_Coord *w, Evas_Coord *h)
97{
98 Eina_Size2D min;
99 min = efl_ui_list_model_min_size_get(psd->wobj);
100
101 if (w) *w = min.w;
102 if (h) *h = min.h;
103}
104
105EOLIAN static void
106_efl_ui_list_pan_efl_object_destructor(Eo *obj, Efl_Ui_List_Pan_Data *psd EINA_UNUSED)
107{
108 efl_destructor(efl_super(obj, MY_PAN_CLASS));
109}
110
111#include "efl_ui_list_pan.eo.c"
112
113static Eina_Bool
114_efl_model_properties_has(Efl_Model *model, Eina_Stringshare *propfind)
115{
116 const Eina_Array *properties;
117 Eina_Array_Iterator iter_prop;
118 Eina_Stringshare *property;
119 Eina_Bool ret = EINA_FALSE;
120 unsigned i = 0;
121
122 EINA_SAFETY_ON_NULL_RETURN_VAL(model, EINA_FALSE);
123 EINA_SAFETY_ON_NULL_RETURN_VAL(propfind, EINA_FALSE);
124
125 properties = efl_model_properties_get(model);
126
127 EINA_ARRAY_ITER_NEXT(properties, i, property, iter_prop)
128 {
129 if (property == propfind)
130 {
131 ret = EINA_TRUE;
132 break;
133 }
134 }
135 return ret;
136}
137
138static void
139_on_item_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
140{
141 Evas_Event_Mouse_Down *ev = event_info;
142 Efl_Ui_List_LayoutItem *item = data;
143
144 if (ev->button != 1) return;
145 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
146
147 _efl_ui_list_item_select_set(item, EINA_TRUE);
148}
149
150static void
151_count_then(void * data, Efl_Event const* event EINA_UNUSED)
152{
153 Efl_Ui_List_Data *pd = data;
154 EINA_SAFETY_ON_NULL_RETURN(pd);
155
156 pd->count_future = NULL;
157 _layout(pd);
158}
159
160static void
161_count_error(void * data, Efl_Event const* event EINA_UNUSED)
162{
163 Efl_Ui_List_Data *pd = data;
164 EINA_SAFETY_ON_NULL_RETURN(pd);
165 pd->count_future = NULL;
166}
167
168static void
169_children_slice_error(void * data EINA_UNUSED, Efl_Event const* event EINA_UNUSED)
170{
171 Efl_Ui_List_Data *pd = data;
172 EINA_SAFETY_ON_NULL_RETURN(pd);
173 pd->slice_future = NULL;
174}
175
176static void
177_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rect r)
178{
179 elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
180}
181
182EOLIAN static void
183_efl_ui_list_select_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Elm_Object_Select_Mode mode)
184{
185 if (pd->select_mode == mode)
186 return;
187
188 pd->select_mode = mode;
189}
190
191EOLIAN static Elm_Object_Select_Mode
192_efl_ui_list_select_mode_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
193{
194 return pd->select_mode;
195}
196
197EOLIAN static void
198_efl_ui_list_default_style_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Eina_Stringshare *style)
199{
200 eina_stringshare_replace(&pd->style, style);
201}
202
203EOLIAN static Eina_Stringshare *
204_efl_ui_list_default_style_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
205{
206 return pd->style;
207}
208
209EOLIAN static void
210_efl_ui_list_homogeneous_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Eina_Bool homogeneous)
211{
212 pd->homogeneous = homogeneous;
213}
214
215EOLIAN static Eina_Bool
216_efl_ui_list_homogeneous_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
217{
218 return pd->homogeneous;
219}
220
221EOLIAN static void
222_efl_ui_list_efl_gfx_position_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Position2D p)
223{
224 int pan_x, pan_y;
225 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, p.x, p.y))
226 return;
227
228 efl_gfx_position_set(efl_super(obj, MY_CLASS), p);
229
230 elm_pan_pos_get(pd->pan_obj, &pan_x, &pan_y);
231 evas_object_move(pd->hit_rect, p.x, p.y);
232 evas_object_move(pd->pan_obj, p.x - pan_x, p.y - pan_y);
233 evas_object_smart_changed(pd->obj);
234}
235
236EOLIAN static void
237_efl_ui_list_elm_interface_scrollable_region_bring_in(Eo *obj, Efl_Ui_List_Data *pd, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
238{
239 int pan_x, pan_y;
240 elm_pan_pos_get(pd->pan_obj, &pan_x, &pan_y);
241 elm_interface_scrollable_region_bring_in(efl_super(obj, MY_CLASS), x + pan_x, y + pan_y, w, h);
242}
243
244EOLIAN static void
245_efl_ui_list_efl_gfx_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Size2D size)
246{
247 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, size.w, size.h))
248 return;
249
250 evas_object_resize(pd->hit_rect, size.w, size.h);
251 efl_gfx_size_set(efl_super(obj, MY_CLASS), size);
252
253 evas_object_smart_changed(pd->obj);
254}
255
256EOLIAN static void
257_efl_ui_list_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
258{
259 _layout(pd);
260}
261
262EOLIAN static void
263_efl_ui_list_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_List_Data *pd, Evas_Object *member)
264{
265 efl_canvas_group_member_add(efl_super(obj, MY_CLASS), member);
266
267 if (pd->hit_rect)
268 evas_object_raise(pd->hit_rect);
269}
270
271EOLIAN static void
272_efl_ui_list_efl_canvas_group_group_add(Eo *obj, Efl_Ui_List_Data *pd)
273{
274 Efl_Ui_List_Pan_Data *pan_data;
275 Evas_Coord minw, minh;
276
277 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
278
279 efl_canvas_group_add(efl_super(obj, MY_CLASS));
280 elm_widget_sub_object_parent_add(obj);
281
282 elm_widget_can_focus_set(obj, EINA_TRUE);
283
284 if (!elm_layout_theme_set(obj, "list", "base", elm_widget_style_get(obj)))
285 CRI("Failed to set layout!");
286
287 pd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
288 evas_object_data_set(pd->hit_rect, "_elm_leaveme", obj);
289 evas_object_smart_member_add(pd->hit_rect, obj);
290 elm_widget_sub_object_add(obj, pd->hit_rect);
291
292 /* common scroller hit rectangle setup */
293 evas_object_color_set(pd->hit_rect, 0, 0, 0, 0);
294 evas_object_show(pd->hit_rect);
295 evas_object_repeat_events_set(pd->hit_rect, EINA_TRUE);
296
297 elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
298
299 elm_interface_scrollable_objects_set(obj, wd->resize_obj, pd->hit_rect);
300 elm_interface_scrollable_bounce_allow_set
301 (obj, EINA_FALSE, _elm_config->thumbscroll_bounce_enable);
302
303 pd->mode = ELM_LIST_COMPRESS;
304
305 efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED);
306 pd->pan_obj = efl_add(MY_PAN_CLASS, evas_object_evas_get(obj));
307 pan_data = efl_data_scope_get(pd->pan_obj, MY_PAN_CLASS);
308 pan_data->wobj = obj;
309
310 elm_interface_scrollable_extern_pan_set(obj, pd->pan_obj);
311 evas_object_show(pd->pan_obj);
312
313 edje_object_size_min_calc(wd->resize_obj, &minw, &minh);
314 evas_object_size_hint_min_set(obj, minw, minh);
315
316 elm_layout_sizing_eval(obj);
317}
318
319EOLIAN static void
320_efl_ui_list_efl_canvas_group_group_del(Eo *obj, Efl_Ui_List_Data *pd)
321{
322 ELM_SAFE_FREE(pd->pan_obj, evas_object_del);
323 efl_canvas_group_del(efl_super(obj, MY_CLASS));
324}
325
326EOLIAN static void
327_efl_ui_list_efl_ui_focus_manager_focus_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Efl_Ui_Focus_Object *focus)
328{
329 efl_ui_focus_manager_focus_set(pd->manager, focus);
330}
331
332EOLIAN static Efl_Ui_Focus_Manager*
333_efl_ui_list_elm_widget_focus_manager_create(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root)
334{
335 if (!pd->manager)
336 pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, obj,
337 efl_ui_focus_manager_root_set(efl_added, root));
338
339 return pd->manager;
340}
341
342EOLIAN static Eo *
343_efl_ui_list_efl_object_finalize(Eo *obj, Efl_Ui_List_Data *pd)
344{
345
346 if (!pd->factory)
347 pd->factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, NULL);
348
349 if(!pd->relayout)
350 {
351 pd->relayout = efl_add(EFL_UI_LIST_PRECISE_LAYOUTER_CLASS, obj);
352 if (pd->model)
353 efl_ui_list_relayout_model_set(pd->relayout, pd->model);
354 }
355 return obj;
356}
357
358EOLIAN static Eo *
359_efl_ui_list_efl_object_constructor(Eo *obj, Efl_Ui_List_Data *pd)
360{
361 Efl_Ui_Focus_Manager *manager;
362
363 obj = efl_constructor(efl_super(obj, MY_CLASS));
364 pd->obj = obj;
365 efl_canvas_object_type_set(obj, MY_CLASS_NAME);
366 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
367 efl_access_role_set(obj, EFL_ACCESS_ROLE_LIST);
368
369 efl_ui_list_segarray_setup(&pd->segarray, 32);
370
371 manager = efl_ui_widget_focus_manager_create(obj, obj);
372 efl_composite_attach(obj, manager);
373 _efl_ui_focus_manager_redirect_events_add(manager, obj);
374
375 pd->style = eina_stringshare_add(elm_widget_style_get(obj));
376
377 pd->factory = NULL;
378 pd->orient = EFL_ORIENT_DOWN;
379 pd->align.h = 0;
380 pd->align.v = 0;
381 pd->min.w = 0;
382 pd->min.h = 0;
383
384 return obj;
385}
386
387EOLIAN static void
388_efl_ui_list_efl_object_destructor(Eo *obj, Efl_Ui_List_Data *pd)
389{
390 efl_ui_list_relayout_model_set(pd->relayout, NULL);
391
392 efl_unref(pd->model);
393 eina_stringshare_del(pd->style);
394
395 efl_ui_list_segarray_flush(&pd->segarray);
396
397 efl_destructor(efl_super(obj, MY_CLASS));
398}
399
400EOLIAN static void
401_efl_ui_list_layout_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Efl_Ui_Factory *factory)
402{
403 if (pd->factory)
404 efl_unref(pd->factory);
405
406 pd->factory = factory;
407 efl_ref(pd->factory);
408}
409
410EOLIAN static void
411_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model)
412{
413 if (pd->model == model)
414 return;
415
416 if (pd->count_future)
417 {
418 efl_future_cancel(pd->count_future);
419 pd->count_future = NULL;
420 }
421
422 if (pd->model)
423 {
424 if (pd->relayout)
425 efl_ui_list_relayout_model_set(pd->relayout, NULL);
426 efl_ui_list_segarray_flush(&pd->segarray);
427 efl_unref(pd->model);
428 pd->model = NULL;
429 }
430
431 if (model)
432 {
433 pd->model = model;
434 efl_ref(pd->model);
435 if (pd->relayout)
436 efl_ui_list_relayout_model_set(pd->relayout, model);
437 pd->count_future = efl_model_children_count_get(pd->model);
438 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd);
439 }
440
441 evas_object_smart_changed(pd->obj);
442}
443
444EOLIAN static Efl_Model *
445_efl_ui_list_efl_ui_view_model_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
446{
447 return pd->model;
448}
449
450EOLIAN int
451_efl_ui_list_efl_access_selection_selected_children_count_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
452{
453 return eina_list_count(pd->selected_items);
454}
455
456EOLIAN Eo*
457_efl_ui_list_efl_access_selection_selected_child_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int child_index)
458{
459 if(child_index < (int) eina_list_count(pd->selected_items))
460 {
461 Efl_Ui_List_Item* items = eina_list_nth(pd->selected_items, child_index);
462 return items[child_index].item.layout;
463 }
464 else
465 return NULL;
466}
467
468EOLIAN Eina_Bool
469_efl_ui_list_efl_access_selection_child_select(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
470{
471 return EINA_FALSE;
472}
473
474EOLIAN Eina_Bool
475_efl_ui_list_efl_access_selection_selected_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
476{
477 return EINA_FALSE;
478}
479
480EOLIAN Eina_Bool
481_efl_ui_list_efl_access_selection_is_child_selected(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int child_index)
482{
483 return EINA_FALSE;
484}
485
486EOLIAN Eina_Bool
487_efl_ui_list_efl_access_selection_all_children_select(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
488{
489 return EINA_TRUE;
490}
491
492EOLIAN Eina_Bool
493_efl_ui_list_efl_access_selection_clear(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
494{
495 return EINA_TRUE;
496}
497
498EOLIAN Eina_Bool
499_efl_ui_list_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
500{
501 return EINA_FALSE;
502}
503
504static Eina_Bool
505_key_action_move(Evas_Object *obj, const char *params)
506{
507 return EINA_FALSE;
508}
509
510static Eina_Bool
511_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
512{
513 return EINA_FALSE;
514}
515
516static Eina_Bool
517_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
518{
519 efl_ui_focus_manager_reset_history(obj);
520 return EINA_TRUE;
521}
522
523ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_list, Efl_Ui_List_Data)
524
525void
526_efl_ui_list_item_select_set(Efl_Ui_List_LayoutItem *item, Eina_Bool selected)
527{
528 Eina_Stringshare *sprop;
529 assert(item != NULL);
530 assert(item->children != NULL);
531
532 selected = !!selected;
533
534 sprop = eina_stringshare_add(SELECTED_PROP);
535
536 if (_efl_model_properties_has(item->children, sprop))
537 {
538 Eina_Value v;
539 eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR);
540 eina_value_set(&v, selected);
541 efl_model_property_set(item->children, sprop, &v);
542 eina_value_flush(&v);
543 }
544 eina_stringshare_del(sprop);
545}
546
547static void
548_efl_ui_list_relayout_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED, Efl_Ui_List_Relayout *object)
549{
550 if(pd->relayout)
551 efl_unref(pd->relayout);
552
553 pd->relayout = object;
554 efl_ref(pd->relayout);
555}
556
557static Efl_Ui_List_Relayout *
558_efl_ui_list_relayout_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED)
559{
560 return pd->relayout;
561}
562
563static void
564_layout(Efl_Ui_List_Data *pd)
565{
566 if (!pd->model)
567 return;
568
569 efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first, &pd->segarray);
570}
571
572static void
573_children_slice_then(void * data, Efl_Event const* event)
574{
575 Efl_Ui_List_Data *pd = data;
576 Eina_Accessor *acc = (Eina_Accessor*)((Efl_Future_Event_Success*)event->info)->value;
577
578 efl_ui_list_segarray_insert_accessor(&pd->segarray, pd->outstanding_slice.slice_start, acc);
579
580 pd->segarray_first = pd->outstanding_slice.slice_start;
581 pd->outstanding_slice.slice_start = pd->outstanding_slice.slice_count = 0;
582 pd->slice_future = NULL;
583}
584
585/* EFL UI LIST MODEL INTERFACE */
586EOLIAN static Eina_Size2D
587_efl_ui_list_efl_ui_list_model_min_size_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
588{
589 return pd->min;
590}
591
592EOLIAN static void
593_efl_ui_list_efl_ui_list_model_min_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Size2D min)
594{
595 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
596
597 pd->min.w = min.w;
598 pd->min.h = min.h;
599
600 evas_object_size_hint_min_set(wd->resize_obj, pd->min.w, pd->min.h);
601 efl_event_callback_legacy_call(pd->pan_obj, ELM_PAN_EVENT_CHANGED, NULL);
602}
603
604EOLIAN static Efl_Ui_List_LayoutItem *
605_efl_ui_list_efl_ui_list_model_realize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
606{
607 Efl_Ui_List_Item_Event evt;
608 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
609
610 item->layout = efl_ui_factory_create(pd->factory, item->children, obj);
611 evas_object_smart_member_add(item->layout, pd->pan_obj);
612 evas_object_event_callback_add(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item);
613
614 evt.child = item->children;
615 evt.layout = item->layout;
616 evt.index = efl_ui_list_item_index_get((Efl_Ui_List_Item *)item);
617 efl_event_callback_call(obj, EFL_UI_LIST_EVENT_ITEM_REALIZED, &evt);
618
619 evas_object_show(item->layout);
620 return item;
621}
622
623EOLIAN static void
624_efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
625{
626 Efl_Ui_List_Item_Event evt;
627 EINA_SAFETY_ON_NULL_RETURN(item->layout);
628
629 evas_object_event_callback_del_full(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item);
630 evas_object_hide(item->layout);
631 evas_object_move(item->layout, -9999, -9999);
632
633 evt.child = item->children;
634 evt.layout = item->layout;
635 evt.index = efl_ui_list_item_index_get((Efl_Ui_List_Item *)item);
636 efl_event_callback_call(obj, EFL_UI_LIST_EVENT_ITEM_UNREALIZED, &evt);
637
638 evas_object_smart_member_del(item->layout);
639 efl_ui_factory_release(pd->factory, item->layout);
640 item->layout = NULL;
641}
642
643EOLIAN static void
644_efl_ui_list_efl_ui_list_model_load_range_set(Eo* obj EINA_UNUSED, Efl_Ui_List_Data* pd, int first, int count)
645{
646 if(!pd->slice_future)
647 {
648 pd->slice_future = efl_model_children_slice_get(pd->model, first, count);
649 pd->outstanding_slice.slice_start = first;
650 pd->outstanding_slice.slice_count = count;
651 efl_future_then(pd->slice_future, &_children_slice_then, &_children_slice_error, NULL, pd);
652 }
653}
654
655EOLIAN static int
656_efl_ui_list_efl_ui_list_model_size_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
657{
658 return pd->item_count;
659}
660
661/* Internal EO APIs and hidden overrides */
662
663#define EFL_UI_LIST_EXTRA_OPS \
664 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_list)
665
666#include "efl_ui_list.eo.c"
667#include "efl_ui_list_relayout.eo.c"
668#include "efl_ui_list_model.eo.c"