summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangHyeon Lee <sh10233.lee@samsung.com>2016-06-24 11:34:57 +0900
committerSangHyeon Lee <sh10233.lee@samsung.com>2016-06-24 11:34:57 +0900
commitaa349195a3959592af1659c3db1583f80fdd9105 (patch)
treea874b8a0176ec0e06d95f7ec4d5cf3701caee57c
parentd8eae1a1aac6fd29c5c6fda029f9383dbff6f2f8 (diff)
first proposal of efl_ui_list for MVC list in new efl interfacedevs/sanghyeonlee/interface
-rw-r--r--src/lib/elementary/efl_ui_list.c722
-rw-r--r--src/lib/elementary/efl_ui_list.eo80
-rw-r--r--src/lib/elementary/efl_ui_list_private.h65
-rw-r--r--src/lib/elementary/efl_ui_view.c22
-rw-r--r--src/lib/elementary/efl_ui_view.eo12
-rw-r--r--src/lib/elementary/efl_ui_view_private.h17
6 files changed, 918 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..1c95143beb
--- /dev/null
+++ b/src/lib/elementary/efl_ui_list.c
@@ -0,0 +1,722 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_PACK_LAYOUT_PROTECTED
6
7#include <Elementary.h>
8#include "elm_priv.h"
9
10#include "efl_ui_list_private.h"
11#include "efl_ui_list.eo.h"
12#include "elm_interface_scrollable.h"
13#include "elm_pan.eo.h"
14
15#define MY_CLASS EFL_UI_LIST_CLASS
16#define MY_CLASS_NAME "Efl.Ui.List"
17
18static void _list_calc(Efl_Ui_List_Pan_Data *pd);
19
20/* Custom Pan Class: overrides pan methods */
21static const Eo_Op_Description custom_pan_op_desc[] = {
22 EO_OP_CLASS_FUNC_OVERRIDE(evas_obj_smart_move, _efl_ui_list_pan_smart_move),
23 EO_OP_CLASS_FUNC_OVERRIDE(evas_obj_smart_resize, _efl_ui_list_pan_smart_resize),
24 EO_OP_CLASS_FUNC_OVERRIDE(evas_obj_smart_calculate, _efl_ui_list_pan_smart_calculate),
25 EO_OP_CLASS_FUNC_OVERRIDE(elm_pan_pos_set, _efl_ui_list_pan_pos_set),
26 EO_OP_CLASS_FUNC_OVERRIDE(elm_pan_pos_get, _efl_ui_list_pan_pos_get),
27 EO_OP_CLASS_FUNC_OVERRIDE(elm_pan_pos_min_get, _efl_ui_list_pan_pos_min_get),
28 EO_OP_CLASS_FUNC_OVERRIDE(elm_pan_pos_max_get, _efl_ui_list_pan_pos_max_get),
29 EO_OP_CLASS_FUNC_OVERRIDE(elm_pan_content_size_get, _efl_ui_list_pan_content_size_get),
30};
31
32static const Eo_Class_Description custom_pan_class_desc = {
33 EO_VERSION, "Efl.Ui.List.Pan", EO_CLASS_TYPE_REGULAR,
34 EO_CLASS_DESCRIPTION_OPS(custom_pan_op_desc), NULL,
35 sizeof(Efl_Ui_List_Pan_Data), NULL, NULL
36};
37
38EO_DEFINE_CLASS(_efl_ui_list_custom_pan_class_get, &custom_pan_class_desc,
39 ELM_PAN_CLASS, NULL)
40
41#define PAN_CLASS _efl_ui_list_custom_pan_class_get()
42
43
44/* Custom Layout Class may needs
45static const Eo_Op_Description item_laytout_op_desc[] = {
46 EO_OP_CLASS_FUNC_OVERRIDE(evas_obj_smart_calculate, _efl_ui_list_item_smart_calculate),
47};
48
49static const Eo_Class_Description item_layout_class_desc = {
50 EO_VERSION, "Efl.Ui.List.Item", EO_CLASS_TYPE_REGULAR,
51 EO_CLASS_DESCRIPTION_OPS(item_layout_op_desc), NULL,
52 sizeof(Efl_Ui_Layout_Data), NULL, NULL
53};
54
55EO_DEFINE_CLASS(_efl_ui_list_item_layout_class_get, &item_layout_class_desc,
56 EFL_LAYOUT_CLASS, NULL)
57
58#define ITEM_LAYOUT_CLASS _efl_ui_list_item_layout_class_get()
59*/
60
61
62static void
63_list_size_calc(Efl_Ui_List_Data *pd)
64{
65
66}
67
68static void
69_list_changed(Efl_Ui_List_Data *pd)
70{
71 pd->changed = EINA_TRUE;
72 if (pd->calc_job) ecore_job_del(pd->calc_job);
73 pd->calc_job = ecore_job_add(_list_size_calc, pd);
74}
75
76static List_Item *
77_list_item_new(Item_Block block, int index, Efl_Model *child)
78{
79 Efl_Ui_List_Data *pd = block->wd;
80 List_Item *item = ELM_NEW(List_Item);
81 item->index = index;
82 item->block = block;
83 item->my_model = child;
84 block->count++;
85
86 return item;
87}
88
89static void
90_list_item_calc(List_Item *item)
91{
92 if (!item->layout || !item->block) return;
93 Evas_Coord ow = 0, oh =0, mw = -1, mh = -1;
94 Item_Block *block = item->block;
95 Efl_Ui_List_Data *pd = block->wd;
96 Eo *view;
97 Elm_coords_finger_size_adjust(1, &mw, 1, &mh);
98 view = elm_layout_edje_get(item->layout);
99 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
100 if ((pd->h_scroll == EINA_FALSE) && (mw > pd->w))
101 mw = pd->w;
102
103 oh = item->h;
104 item->w = mw;
105 item->h = mh;
106
107 item->calculated = EINA_TRUE;
108
109 if (block->w < item->w) block->w = item->w;
110 block->h = block->h + item->h - ow;
111 block->changed = EINA_TRUE;
112 //_list_updated();
113}
114
115/**EOLIAN @protected??**/
116static void
117_list_item_unrealize(Eo *obj, Efl_Ui_List_Data *pd, List_Item *item, Eina_Bool calc)
118{
119 /* Caching items or */
120 evas_object_del(item->layout);
121 item->realized = EINA_FALSE;
122}
123
124static void
125_list_item_resized_cb(void *data, Eo_Event *event EINA_UNUSED)
126{
127 List_Item *item = data;
128 Efl_Ui_List_Data *pd;
129 if (!item->layout || !item->block) return;
130 pd = item->block->wd;
131
132 _list_item_calc(item);
133 if (item->calc_once)
134 _list_item_unrealize(pd->obj, item, EINA_TRUE);
135}
136
137static Eo *
138_list_item_layout_create(Eo *obj, List_Item *item, Eina_Stringshare *style)
139{
140 //Eo *layout = eo_add(ELM_LAYOUT_CLASS, obj, elm_object_style_set(style););
141 Eo *layout = eo_add(ELM_LAYOUT_CLASS, obj);
142 elm_object_style_set(style);
143 efl_gfx_position_set(layout, -9999, -9999);
144 return layout;
145}
146
147/**EOLIAN @protected??**/
148static void
149_list_item_realize(Eo *obj, Efl_Ui_List_Data *pd, List_Item *item, int index, Efl_Model *child_model, Eina_Bool calc)
150{
151 if (it->realized || !child_model) return;
152
153 Eina_Stringshare *style = efl_ui_list_item_style_get(obj, child_model, index);
154 item->layout = _layout_create(obj, item, style);
155 //
156 // state update - select, focus, disable
157 // mouse_event add
158
159 pd->event->layout = layout;
160 pd->event->child = child_model;
161 pd->event->index = index;
162 eo_event_callback_call(obj, EFL_UI_LIST_EVENT_REALIZED, pd->event);
163 eo_event_callback_add(item->layout, EVAS_OBJECT_EVENT_RESIZE, _list_item_resized_cb, item);
164}
165
166static void
167_list_item_free(List_Item *item)
168{
169 Efl_Ui_List_Data *pd = item->block->wd;
170 if (item->realized) _list_item_unrealize(pd->obj, pd, item, EINA_FALSE);
171
172 if (item->queued)
173 {
174 pd->queue = eina_list_remove(pd->queue, item);
175 item->queued = EINA_FALSE;
176 }
177 else if (item->prequeued)
178 {
179 pd->prequeue = eina_list_remove(pd->prequeue, item);
180 item->prequeued = EINA_FALSE;
181 }
182 if (!pd->queue && !pd->prequeue)
183 {
184 ecore_idle_enterer_del(pd->queue_idle_enterer);
185 pd->queue_idle_enterer = NULL;
186 }
187
188 item->block->items = eina_list_remove(item->block->items, item);
189 /*
190 * free all item index and states needs;
191 */
192 free(item);
193
194}
195
196static Item_Block
197_list_block_new(Eo* obj, Efl_Ui_List_Data *pd)
198{
199 Item_Block *block = ELM_NEW(Item_Block);
200 block->wd = pd;
201
202 return block;
203}
204
205static void
206_list_block_del(Item_Block *block)
207{
208 Efl_Ui_List_Data *pd = block->wd;
209 List_Item *item;
210 EINA_LIST_FREE(block->items, item)
211 {
212 _list_item_free(item);
213 }
214 pd->item_blocks = eina_list_remove(pd->item_blocks, block);
215 free(block);
216}
217
218static void
219_list_clear(Eo* obj, Efl_Ui_List_Data *pd)
220{
221 Eina_List *l;
222 Item_Block *block;
223 EINA_LIST_FOREACH(pd->block, l, block)
224 {
225 _list_block_del(pd, block);
226 }
227}
228
229static Eina_Bool
230_item_process(Efl_Ui_List_Data *pd, List_Item *item, unsigned index)
231{
232 Evas_Coord ow, oh;
233 if (!item->my_model) return EINA_FALSE;
234 if (pd->homogeneous)
235 {
236 Item_Size *size;
237 if (pd->size_caches)
238 {
239 Eina_Stringshare *style = efl_ui_list_item_style_get(pd->obj, item->my_model, index);
240 size = eina_hash_find(sd->size_caches, style);
241 if (size)
242 {
243 oh = item->h;
244 item->w = size->w;
245 item->h = size->h;
246 item->calculated = EINA_TRUE;
247 item->queued = EINA_FALSE;
248 item->block->h = item->block->h + item->h - oh;
249 item->block->changed;
250 //_list_updated(pd);
251 return EINA_TRUE;
252 }
253 }
254 }
255 item->calc_once = EINA_TRUE;
256 item->queued = EINA_FALSE;
257 _list_item_realize(pd->obj, item, item->my_model, index, EINA_TRUE);
258
259 return EINA_TRUE;
260}
261
262static Eina_Bool
263_queue_idle_enterer(void *data)
264{
265 EINA_SAFETY_ON_NULL_RETURN(data);
266 Efl_Ui_List_Data *pd = data;
267 List_Item *item;
268 Eina_Bool wakeup;
269 double t0, t1;
270 int n;
271
272 t0 = ecore_time_get();
273 for (n = 0; ((pd->queue) || (pd->prequeue)) && (n < (pd->block_size * 2)); n++)
274 {
275 if (pd->queue)
276 {
277 item = eina_list_data_get(pd->queue);
278 if (!_item_process(pd, item)) break;
279 pd->queue = eina_list_remove_list(pd->queue, sd->queue);
280 }
281 t1 = ecore_time_get();
282 if ((t - t0) > (ecore_animator_frametime_get())) break;
283
284 if (pd->prequeue)
285 {
286 item = eina_list_data_get(pd->prequeue);
287 if (!_item_process(pd, item)) break;
288 pd->prequeue = eina_list_remove_list(pd->prequeue, sd->queue);
289 }
290 t1 = ecore_time_get();
291 /* same as eina_inlist_count > 1 */
292 if ((t - t0) > (ecore_animator_frametime_get())) break;
293 }
294
295 if (wakeup)
296 {
297 // wake up mainloop
298 if (pd->calc_promise) efl_job_cancel(pd->calc_promise, pd->calc_promise);
299 pd->calc_promise = efl_loop_job(ds->calc_promise, pd);
300 eina_promise_then(pd->calc_promise, _list_calc, NULL, pd);
301 }
302
303 return ECORE_CALLBACK_RENEW;
304 return ECORE_CALLBACK_CANCEL;
305}
306
307
308static void
309_list_children_promise_then(Efl_Ui_List_Data *pd, Eina_Accessor **accessor)
310{
311 EINA_SAFETY_ON_NULL_RETURN(pd);
312 EINA_SAFETY_ON_NULL_RETURN(pd->model);
313 Item_Block *block;
314 int index = 0;
315 Eo *child;
316
317 block = _list_block_new(pd);
318 pd->item_blocks = eina_list_append(pd->item_blocks, block);
319
320 EINA_ACCESSOR_FOREACH(*accessor, i, child)
321 {
322 if (block->count == pd->block_size)
323 {
324 block = _list_block_new(pd);
325 pd->item_blocks = eina_list_append(pd->item_blocks, block);
326 }
327 item = _list_item_new(block, block->count, child);
328 b->items = eina_list_append(block->items, item);
329
330 if (pd->show_item =< i)
331 {
332 pd->queue = eina_list_append(pd->queue, item);
333 item->queued = EINA_TRUE;
334 }
335 else
336 {
337 pd->prequeue = eina_list_prepend(pd->prequeue, item);
338 item->prequeued = EINA_TRUE;
339 }
340 }
341
342 ecore_idle_enterer_del(pd->queue_idle_enterer);
343 pd->queue_idle_enterer = ecore_idle_enterer_add(_queue_idle_enterer, pd);
344}
345
346static void
347_list_count_promise_then(Efl_Ui_List_Data *pd, int count)
348{
349 EINA_SAFETY_ON_NULL_RETURN(pd);
350 EINA_SAFETY_ON_NULL_RETURN(pd->model);
351 if (pd->block_size =< 0) return;
352 pd->count = count;
353
354 efl_model_children_slice_get(pd->model, 0, 0, &pd->child_promise);
355 eina_promise_then(pd->child_promise, &_list_children_promise_then, NULL, pd);
356 while (count < index)
357 {
358 int size = ((pd->block_size > (count - index))?
359 (count - index) : pd->block_size);
360 itb = _list_block_new(obj, pd, size);
361 pd->item_blocks = eina_list_append(pd->item_blocks, itb);
362 index += size;
363 }
364
365 pd->count_promise = NULL;
366}
367
368static void
369_list_model_unset(Eo* obj, Efl_Ui_List_Data *pd)
370{
371 if (!pd->model) return;
372
373 _list_clear(obj, pd);
374
375 if (pd->count_promise)
376 {
377 eina_promise_cancel(pd->count_promise);
378 pd->count_promise = NULL;
379 }
380
381 pd->model = NULL;
382}
383
384static void
385_list_calc(Efl_Ui_List_Data *pd)
386{
387
388 evas_object_smart_changed();
389}
390
391EOLIAN void
392_efl_ui_list_homogeneous_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Bool homogeneous)
393{
394 pd->homogeneous = homogeneous;
395}
396
397EOLIAN Eina_Bool
398_efl_ui_list_homogeneous_get(Eo *obj, Efl_Ui_List_Data *pd)
399{
400 return pd->homogeneous;
401}
402
403EOLIAN void
404_efl_ui_list_item_style_set(Eo *obj, Efl_Ui_List_Data *pd, const char* style)
405{
406 pd->style = eina_stringshare_add(style);
407}
408
409EOLIAN Eina_Stringshare *
410_efl_ui_list_item_style_get(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model, int index)
411{
412 if (pd->style)
413 return pd->style;
414 else
415 return NULL;
416}
417
418EOLIAN void
419_efl_ui_list_scroll_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Bool h_scroll, Eina_Bool v_scroll)
420{
421 pd->h_scroll = h_scroll;
422 pd->v_scroll = v_scroll;
423}
424
425EOLIAN void
426_efl_ui_list_eo_base_destructor(Eo *obj, Efl_Ui_List_Data *pd)
427{
428 eo_destructor(eo_super(obj, MY_CLASS));
429}
430EOLIAN static void
431_efl_ui_list_pan_pos_set(Eo *obj, Efl_Ui_List_Pan_Data *pd, Evas_Coord x, Evas_Coord y)
432{
433 Efl_Ui_List_Data *wd = pd->wd;
434
435 if ((x == wd->pan_x) && (y == wd->pan_y)) return;
436 wd->pan_x = x;
437 wd->pan_y = y;
438}
439
440EOLIAN static void
441_efl_ui_list_pan_pos_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *pd, Evas_Coord *x, Evas_Coord *y)
442{
443 if (x) *x = pd->wd->pan_x;
444 if (y) *y = pd->wd->pan_y;
445}
446
447EOLIAN static void
448_efl_ui_list_pan_pos_max_get(Eo *obj, Efl_Ui_List_Pan_Data *pd, Evas_Coord *x, Evas_Coord *y)
449{
450 Evas_Coord ow, oh;
451
452 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
453 ow = pd->wd->min_w - ow;
454 if (ow < 0) ow = 0;
455 oh = pd->wd->min_h - oh;
456 if (oh < 0) oh = 0;
457
458 if (x) *x = ow;
459 if (y) *y = oh;
460}
461
462EOLIAN static void
463_efl_ui_list_pan_pos_min_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y)
464{
465 if (x) *x = 0;
466 if (y) *y = 0;
467}
468
469EOLIAN static void
470_efl_ui_list_pan_content_size_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Pan_Data *pd, Evas_Coord *w, Evas_Coord *h)
471{
472 if (w) *w = pd->wd->min_w;
473 if (h) *h = pd->wd->min_h;
474}
475
476EOLIAN static void
477_efl_ui_list_pan_smart_move(Eo *obj, Efl_Ui_List_Pan_Data *pd, Evas_Coord _gen_param2 EINA_UNUSED, Evas_Coord _gen_param3 EINA_UNUSED)
478{
479 pd->wd->pan_changed = EINA_TRUE;
480 evas_object_smart_changed(obj);
481 //ELM_SAFE_FREE(psd->wsd->calc_job, ecore_job_del);
482}
483
484static void
485_list_pan_smart_resize_job(void *data)
486{
487 EFL_UI_LIST_PAN_DATA_GET(data, pd);
488
489 elm_layout_sizing_eval(pd->wobj);
490 psd->resize_job = NULL;
491}
492
493EOLIAN static void
494_efl_ui_list_pan_smart_resize(Eo *obj, Efl_Ui_List_Pan_Data *pd, Evas_Coord w, Evas_Coord h)
495{
496 Evas_Coord ow, oh;
497
498 Efl_Ui_List_Data *wd = pd->wd;
499
500 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
501 if ((ow == w) && (oh == h)) return;
502 if ((wd->mode == EFL_UI_LIST_COMPRESS) && (ow != w))
503 {
504 /* fix me later */
505 ecore_job_del(pd->resize_job);
506 pd->resize_job =
507 ecore_job_add(_list_pan_smart_resize_job, obj);
508 }
509 wd->pan_changed = EINA_TRUE;
510 evas_object_smart_changed(obj);
511 //ecore_job_del(sd->calc_job);
512 // if the width changed we may have to resize content if scrollbar went
513 // away or appeared to queue a job to deal with it. it should settle in
514 // the end to a steady-state
515 //if (ow != w)
516 // wd->calc_job = ecore_job_add(_calc_job, pd->wobj);
517 //else
518 // wd->calc_job = NULL;
519}
520
521// ****
522EOLIAN static void
523_efl_ui_list_pan_smart_calculate(Eo *obj, Efl_Ui_List_Pan_Data *pd)
524{
525 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
526 Evas_Coord vx = 0, vy = 0, vw = 0, vh = 0;
527 Eina_List *l;
528
529 Efl_Ui_List_Data *wd = pd->wd;
530
531 evas_event_freeze(evas_object_evas_get(obj));
532 {
533 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
534 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
535
536 // Item Realize on Pan Position
537 //
538 //
539 //
540 //
541
542 elm_interface_scrollable_content_pos_get(wd->obj, &vx, &vy);
543 elm_interface_scrollable_content_viewport_geometry_get
544 (wd->obj, NULL, NULL, &vw, &vh);
545
546 }
547 evas_event_thaw(evas_object_evas_get(obj));
548 evas_event_thaw_eval(evas_object_evas_get(obj));
549
550 eo_event_callback_call
551 (pd->wobj, ELM_INTERFACE_SCROLLABLE_EVENT_CHANGED, NULL);
552}
553// ****
554
555static void
556_evas_viewport_resize_cb(void *d, Evas *e EINA_UNUSED, void *ei EINA_UNUSED)
557{
558 Efl_Ui_List_Data *pd = d;
559 evas_object_smart_changed(pd->pan_obj);
560}
561
562EOLIAN void
563_efl_ui_list_evas_object_smart_add(Eo *obj, Efl_Ui_List_Data *pd)
564{
565 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
566 Efl_Ui_List_Pan_Data *pan_data;
567 Evas_Coord minw, minh;
568 int i;
569
570 evas_obj_smart_add(eo_super(obj, MY_CLASS));
571 elm_widget_sub_object_parent_add(obj);
572
573 pd->obj = obj;
574 pd->size_caches = eina_hash_pointer_new(_size_cache_free);
575 pd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
576 evas_object_smart_member_add(pd->hit_rect, obj);
577 elm_widget_sub_object_add(obj, pd->hit_rect);
578
579 /* common scroller hit rectangle setup */
580 evas_object_color_set(pd->hit_rect, 0, 0, 0, 0);
581 evas_object_show(pd->hit_rect);
582 evas_object_repeat_events_set(pd->hit_rect, EINA_TRUE);
583
584 elm_widget_can_focus_set(obj, EINA_TRUE);
585 elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL);
586
587 // efl_ui_pack_layout
588 if (!elm_layout_theme_set
589 (obj, "list", "base", elm_widget_style_get(obj)))
590 CRI("Failed to set layout!");
591
592 elm_interface_scrollable_objects_set(obj, wd->resize_obj, pd->hit_rect);
593
594 pd->v_scroll = EINA_TRUE;
595 pd->h_scroll = EINA_FALSE;
596 pd->block_size = MAX_ITEMS_PER_BLOCK;
597
598 // Creating custom pan object
599 pd->pan = eo_add(PAN_CLASS, evas_object_evas_get(obj));
600 pan_data = eo_data_scope_get(pd->pan_obj, PAN_CLASS);
601 eo_data_ref(obj, NULL);
602 pan_data->wobj = obj;
603 pan_data->wsd = pd;
604
605 elm_interface_scrollable_extern_pan_set(obj, pd->pan);
606
607 edje_object_size_min_calc(wd->resize_obj, &minw, &minh);
608 evas_object_size_hint_min_set(obj, minw, minh);
609
610 _mirrored_set(obj, elm_widget_mirrored_get(obj));
611
612 elm_layout_sizing_eval(obj);
613
614 evas_event_callback_add(evas_object_evas_get(obj),
615 EVAS_CALLBACK_CANVAS_VIEWPORT_RESIZE,
616 _evas_viewport_resize_cb, pd);
617}
618
619EOLIAN
620void _efl_ui_list_evas_object_smart_del(Eo *obj, Efl_Ui_List_Data *pd)
621{
622 _list_clear(obj);
623 evas_event_callback_del_full(evas_object_evas_get(obj),
624 EVAS_CALLBACK_CANVAS_VIEWPORT_RESIZE,
625 _evas_viewport_resize_cb, pd);
626 ELM_SAFE_FREE(pd->pan, evas_object_del);
627 ecore_idle_enterer_del(pd->queue_idle_enterer);
628
629 evas_obj_smart_del(eo_super(obj, MY_CLASS));
630}
631
632EOLIAN
633void _efl_ui_list_evas_object_smart_member_add(Eo *obj, Efl_Ui_List_Data *pd, Evas_Object *member)
634{
635 evas_obj_smart_member_add(eo_super(obj, MY_CLASS), member);
636 if (pd->hit_rect)
637 evas_object_raise(pd->hit_rect);
638}
639
640
641EOLIAN
642void _efl_ui_list_evas_object_smart_move(Eo *obj, Efl_Ui_List_Data *pd, Evas_Coord x, Evas_Coord y)
643{
644 evas_obj_smart_move(eo_super(obj, MY_CLASS), x, y);
645 evas_object_move(pd->hit_rect, x, y);
646}
647
648EOLIAN
649void _efl_ui_list_evas_object_smart_resize(Eo *obj, Efl_Ui_List_Data *pd, Evas_Coord w, Evas_Coord h)
650{
651 evas_obj_smart_resize(eo_super(obj, MY_CLASS), w, h);
652 evas_object_resize(pd->hit_rect, w, h);
653 /*
654 if (((pd->queue) || (pd->prequeue)) &&
655 (!pd->queue_idle_enterer) && (w > 0))
656 _requeue_idle_enterer(pd);
657 */
658}
659
660/*
661 * No theme apply exist in Efl.Ui.Object
662EOLIAN
663Eina_Bool _efl_ui_list_elm_widget_theme_apply(Eo *obj, Efl_Ui_List_Data *pd)
664{
665 Eina_Bool int_ret = EINA_FALSE;
666 Eina_List *l;
667 Evas *e = evas_object_evas_get(obj);
668 Efl_Ui_List_Item *it;
669
670 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
671 if (!int_ret) return EINA_FALSE;
672
673 evas_event_freeze(e);
674 _item_cache_zero(pd);
675 _mirrored_set(obj, elm_widget_mirrored_get(obj));
676
677 eina_hash_free_buckets(pd->size_caches);
678 pd->min_w = pd->min_h = 0;
679
680 elm_layout_sizing_eval(obj);
681 evas_event_thaw(evas_object_evas_get(obj));
682 evas_event_thaw_eval(evas_object_evas_get(obj));
683
684 return EINA_TRUE;
685}
686*/
687
688
689EOLIAN
690Eina_Bool _efl_ui_list_elm_widget_sub_object_del(Eo *obj, Efl_Ui_List_Data *pd, Evas_Object *sobj)
691{
692 Eina_Bool int_ret = EINA_FALSE;
693
694 /* XXX: hack -- also skipping sizing recalculation on
695 * sub-object-del. list's crazy code paths (like groups and
696 * such) seem to issue a whole lot of deletions and Evas bitches
697 * about too many recalculations */
698 pd->on_sub_del = EINA_TRUE;
699 int_ret = elm_obj_widget_sub_object_del(eo_super(obj, MY_CLASS), sobj);
700 if (!int_ret) return EINA_FALSE;
701
702 pd->on_sub_del = EINA_FALSE;
703 return EINA_TRUE;
704}
705
706EOLIAN
707void _efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model)
708{
709 if (pd->model)
710 _list_model_unset(obj, pd);
711 pd->model = model;
712
713 efl_model_children_count_get(model, &pd->count_promise);
714 eina_promise_then(
715 pd->count_promise, (Eina_Promise_Cb)&_list_count_promise_then, NULL, pd);
716}
717
718EOLIAN
719Efl_Model * _efl_ui_list_efl_ui_view_model_get(Eo *obj, Efl_Ui_List_Data *pd)
720{
721 return pd->model;
722}
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
new file mode 100644
index 0000000000..fd36087f60
--- /dev/null
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -0,0 +1,80 @@
1struct Efl.Ui.List.Item_Event
2{
3 layout: Elm.Layout*;
4 child: Efl.Model*;
5 index: int;
6}
7
8class Efl.Ui.List (Elm.Widget, Efl.Pack, Efl.Pack_Layout, Elm.Interface_Scrollable, Efl.Ui.View)
9{
10 methods {
11 @property homogeneous {
12 set {
13 [[Enable/disable homogeneous mode.
14 ]]
15 }
16 get {
17 [[Get whether the homogeneous mode is enabled.]]
18 }
19 values {
20 homogeneous: bool; [[Assume the items within the genlist are of
21 the same height and width. Default is $false.]]
22 }
23 }
24 @property item_style {
25 set {} get {}
26 values {
27 style: Eina.Stringshare;
28 }
29 }
30 }
31 events {
32 item,realized : Efl.Ui.List.Item_Event*;
33 item,unrealized : Efl.Ui.List.Item_Event*;
34 item,focused : Efl.Ui.List.Item_Event*;
35 item,unfocused : Efl.Ui.List.Item_Event*;
36 item,highlighted : Efl.Ui.List.Item_Event*;
37 item,unhighlighted : Efl.Ui.List.Item_Event*;
38 item,selected : Efl.Ui.List.Item_Event*;
39 item,unselected : Efl.Ui.List.Item_Event*;
40 }
41
42 implements {
43 Eo.Base.constructor;
44 Eo.Base.destructor;
45
46 // Smart obj
47 Evas.Object_Smart.add;
48 Evas.Object_Smart.del;
49 Evas.Object_Smart.move;
50 Evas.Object_Smart.resize;
51 Evas.Object_Smart.calculate;
52
53 // Widget
54 Elm.Widget.theme_apply;
55 Elm.Widget.on_focus;
56 Elm.Widget.focus_direction;
57 Elm.Widget.focus_direction_manager_is;
58 Elm.Widget.focus_next;
59 Elm.Widget.focus_next_manager_is;
60 Elm.Widget.focused_item.get;
61 Elm.Widget.event;
62 Elm.Widget.sub_object_del;
63
64 // Packing interfaces
65 Efl.Pack.pack_padding.get;
66 Efl.Pack.pack_padding.set;
67 Efl.Pack.pack_align.get;
68 Efl.Pack.pack_align.set;
69
70 // Custom layouts
71 Efl.Pack_Layout.layout_update;
72 Efl.Pack_Layout.layout_request;
73 Efl.Pack_Layout.layout_engine.get;
74 Efl.Pack_Layout.layout_engine.set;
75 Efl.Pack_Layout.layout_do;
76
77 Elm.Interface_Scrollable.bounce_allow;
78 Elm.Interface_Scrollable.policy;
79 }
80}
diff --git a/src/lib/elementary/efl_ui_list_private.h b/src/lib/elementary/efl_ui_list_private.h
new file mode 100644
index 0000000000..4bdf105ca9
--- /dev/null
+++ b/src/lib/elementary/efl_ui_list_private.h
@@ -0,0 +1,65 @@
1#ifndef EFL_UI_LIST_PRIVATE_H
2#define EFL_UI_LIST_PRIVATE_H
3
4#ifdef HAVE_CONFIG_H
5# include "elementary_config.h"
6#endif
7
8#include <Elementary.h>
9#include "elm_priv.h"
10
11typedef struct _Efl_Ui_List_Data Efl_Ui_List_Data;
12typedef struct _Item_Size Item_Size;
13typedef struct _Item_Block Item_Block;
14typedef struct _Item_Private Item_Private;
15
16struct _Efl_Ui_List_Data
17{
18 Eo *obj;
19 Efl_Model *model;
20 Eina_List *item_blocks;
21 int count;
22 Eina_Promise *count_promise;
23 Eina_Promise *child_promise;
24 Evas_Coord x, y, w, h;
25 Eina_Bool v_scroll: 1;
26 Eina_Bool h_scroll: 1;
27 Eina_Bool homogeneous: 1;
28 Eina_Bool calculated: 1;
29 Eina_Bool changed: 1;
30};
31
32struct _Item_Size
33{
34 Evas_Coord w, h;
35}
36
37struct _Item_Block
38{
39 int count;
40 Evas_Coord x, y, w, h;
41 Efl_Ui_List_Data *wd;
42 Eina_List *items;
43 Eina_Bool calculated: 1;
44 Eina_Bool realized: 1;
45}
46
47struct _Item_Private;
48{
49 int index; // index from the block
50 Evas_Coord x, y; // x, y position from the block
51 Evas_Coord w, h;
52 Item_Block *block;
53 Efl_Ui_List_Data *pd;
54 Eo *layout;
55 Efl_Model *my_model;
56 Eina_Bool queued: 1;
57 Eina_Bool calc_once: 1;
58 Eina_Bool calculated: 1;
59 Eina_Bool realized: 1;
60 Eina_Bool disabled: 1;
61 Eina_Bool selected: 1;
62 Eina_Bool focused: 1;
63};
64
65#endif
diff --git a/src/lib/elementary/efl_ui_view.c b/src/lib/elementary/efl_ui_view.c
new file mode 100644
index 0000000000..40d12e1fa5
--- /dev/null
+++ b/src/lib/elementary/efl_ui_view.c
@@ -0,0 +1,22 @@
1#include "efl_ui_view_private.h"
2
3#define MY_CLASS EFL_UI_VIEW_CLASS
4#define MY_CLASS_NAME "Efl.Ui.View"
5
6static const char SIG_MODEL_CHANGED[] = "model,changed";
7static const Evas_Smart_Cb_Description _smart_callbacks[] = {
8 {SIG_MODEL_CHANGED, ""},
9 {NULL, NULL}
10};
11
12static Eo *
13_efl_ui_view_model_get(Eo* obj, Efl_Ui_View_Data)
14{
15 return pd->model;
16}
17
18static void *
19_efl_ui_view_model_set(Eo* obj, Efl_Ui_View_Data *pd, Eo *model)
20{
21 pd->model = model;
22}
diff --git a/src/lib/elementary/efl_ui_view.eo b/src/lib/elementary/efl_ui_view.eo
new file mode 100644
index 0000000000..cd3a11ea8a
--- /dev/null
+++ b/src/lib/elementary/efl_ui_view.eo
@@ -0,0 +1,12 @@
1interface Efl.Ui.View ()
2{
3 methods {
4 @property model {
5 [[Model that is/will be ]]
6 get {} set {}
7 values {
8 model: Efl.Model*;
9 }
10 }
11 }
12}
diff --git a/src/lib/elementary/efl_ui_view_private.h b/src/lib/elementary/efl_ui_view_private.h
new file mode 100644
index 0000000000..e6a3d32e58
--- /dev/null
+++ b/src/lib/elementary/efl_ui_view_private.h
@@ -0,0 +1,17 @@
1#ifndef EFL_UI_VIEW_PRIVATE_H
2#define EFL_UI_VIEW_PRIVATE_H
3
4#ifdef HAVE_CONFIG_H
5# include "elementary_config.h"
6#endif
7
8#include <Elementary.h>
9#include "elm_priv.h"
10
11typedef struct _Efl_Ui_View_Data Efl_Ui_View_Data;
12
13struct _Efl_Ui_View_Data
14{
15 Efl_Model *model;
16};
17#endif