summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2019-09-19 11:19:56 -0700
committerCedric Bail <cedric.bail@free.fr>2019-09-24 11:12:44 -0700
commit78b69d45b57ce43ac0373a4f10ac548a3a458dbf (patch)
tree5438b8750b4e5b1fabc73dd775d842210b785f40
parent2e1317baedb844a490e96b574fcec3c1ef52c6d9 (diff)
elementary: migrate Efl.Ui.List_View to use Efl.Ui.Collection_View.
Differential Revision: https://phab.enlightenment.org/D10035
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_1.c38
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_2.c3
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_3.c54
-rw-r--r--src/lib/elementary/Efl_Ui.h1
-rw-r--r--src/lib/elementary/efl_ui_list_view.c1031
-rw-r--r--src/lib/elementary/efl_ui_list_view.eo102
-rw-r--r--src/lib/elementary/efl_ui_list_view_model.eo41
-rw-r--r--src/lib/elementary/efl_ui_list_view_pan.eo12
-rw-r--r--src/lib/elementary/efl_ui_list_view_precise_layouter.c728
-rw-r--r--src/lib/elementary/efl_ui_list_view_precise_layouter.eo10
-rw-r--r--src/lib/elementary/efl_ui_list_view_private.h78
-rw-r--r--src/lib/elementary/efl_ui_list_view_relayout.eo30
-rw-r--r--src/lib/elementary/efl_ui_list_view_seg_array.c477
-rw-r--r--src/lib/elementary/efl_ui_list_view_seg_array.h42
-rw-r--r--src/lib/elementary/efl_ui_list_view_types.eot12
-rw-r--r--src/lib/elementary/meson.build9
16 files changed, 45 insertions, 2623 deletions
diff --git a/src/examples/elementary/efl_ui_list_view_example_1.c b/src/examples/elementary/efl_ui_list_view_example_1.c
index 757082aa9d..5c1f4f5fe1 100644
--- a/src/examples/elementary/efl_ui_list_view_example_1.c
+++ b/src/examples/elementary/efl_ui_list_view_example_1.c
@@ -14,39 +14,20 @@
14 14
15#define NUM_ITEMS 400 15#define NUM_ITEMS 400
16 16
17const char *styles[] = {
18 "odd",
19 "even"
20 };
21
22char edj_path[PATH_MAX];
23
24static void 17static void
25_realized_cb(void *data EINA_UNUSED, const Efl_Event *event) 18_realized_cb(void *data EINA_UNUSED, const Efl_Event *event)
26{ 19{
27 Efl_Ui_List_View_Item_Event *ie = event->info; 20 Efl_Gfx_Entity *layout = event->info;
28 if (!ie->layout) return;
29 21
30 Efl_Ui_Layout *layout = ie->layout;
31 elm_object_focus_allow_set(layout, EINA_TRUE); 22 elm_object_focus_allow_set(layout, EINA_TRUE);
32} 23}
33 24
34/*
35static void
36_unrealized_cb(void *data EINA_UNUSED, const Efl_Event *event)
37{
38 Efl_Ui_List_View_Item_Event *ie = event->info;
39
40 efl_ui_view_model_set(ie->layout, NULL);
41 efl_del(ie->layout);
42}
43*/
44static Efl_Model* 25static Efl_Model*
45_make_model(Evas_Object *win) 26_make_model(Evas_Object *win)
46{ 27{
47 Eina_Value vtext; 28 Eina_Value vtext;
48 Efl_Generic_Model *model, *child; 29 Efl_Generic_Model *model, *child;
49 unsigned int i, s; 30 unsigned int i;
50 char buf[256]; 31 char buf[256];
51 32
52 model = efl_add(EFL_GENERIC_MODEL_CLASS, win); 33 model = efl_add(EFL_GENERIC_MODEL_CLASS, win);
@@ -54,10 +35,7 @@ _make_model(Evas_Object *win)
54 35
55 for (i = 0; i < (NUM_ITEMS); i++) 36 for (i = 0; i < (NUM_ITEMS); i++)
56 { 37 {
57 s = i%2;
58 child = efl_model_child_add(model); 38 child = efl_model_child_add(model);
59 eina_value_set(&vtext, styles[s]);
60 efl_model_property_set(child, "odd_style", &vtext);
61 39
62 snprintf(buf, sizeof(buf), "Item # %i", i); 40 snprintf(buf, sizeof(buf), "Item # %i", i);
63 eina_value_set(&vtext, buf); 41 eina_value_set(&vtext, buf);
@@ -88,17 +66,13 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
88 66
89 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 67 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
90 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 68 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
91 efl_ui_property_bind(factory, "signal/efl,state,%v", "odd_style");
92 efl_ui_property_bind(factory, "signal/efl,state,%{selected;unselected}", "selected");
93 efl_ui_property_bind(factory, "efl.text", "title"); 69 efl_ui_property_bind(factory, "efl.text", "title");
94 70
95 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win 71 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win,
96 , efl_ui_list_view_layout_factory_set(efl_added, factory) 72 efl_ui_collection_view_factory_set(efl_added, factory),
97 , efl_ui_view_model_set(efl_added, selmodel) 73 efl_ui_view_model_set(efl_added, selmodel));
98 );
99 74
100 efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_cb, NULL); 75 efl_event_callback_add(li, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_cb, NULL);
101// efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_UNREALIZED, _unrealized_cb, NULL);
102 76
103 elm_win_resize_object_add(win, li); 77 elm_win_resize_object_add(win, li);
104 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 78 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
diff --git a/src/examples/elementary/efl_ui_list_view_example_2.c b/src/examples/elementary/efl_ui_list_view_example_2.c
index 5a4d680614..3464af5841 100644
--- a/src/examples/elementary/efl_ui_list_view_example_2.c
+++ b/src/examples/elementary/efl_ui_list_view_example_2.c
@@ -37,13 +37,12 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
37 efl_ui_property_bind(factory, "efl.text", "filename"); 37 efl_ui_property_bind(factory, "efl.text", "filename");
38 38
39 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win); 39 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win);
40 efl_ui_list_view_layout_factory_set(li, factory); 40 efl_ui_collection_view_factory_set(li, factory);
41 efl_ui_view_model_set(li, model); 41 efl_ui_view_model_set(li, model);
42 42
43 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 43 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
44 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); 44 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
45 45
46
47 imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win); 46 imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
48 efl_ui_property_bind(imgf, "", "path"); //connect to "path" property 47 efl_ui_property_bind(imgf, "", "path"); //connect to "path" property
49 efl_ui_factory_bind(factory, "efl.icon", imgf); 48 efl_ui_factory_bind(factory, "efl.icon", imgf);
diff --git a/src/examples/elementary/efl_ui_list_view_example_3.c b/src/examples/elementary/efl_ui_list_view_example_3.c
index 5a233b3430..ca839bcf59 100644
--- a/src/examples/elementary/efl_ui_list_view_example_3.c
+++ b/src/examples/elementary/efl_ui_list_view_example_3.c
@@ -52,17 +52,15 @@ static void
52_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 52_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{ 53{
54 Priv_Data *priv = (Priv_Data*)data; 54 Priv_Data *priv = (Priv_Data*)data;
55 efl_unref(priv->model); 55 efl_del(priv->model);
56} 56}
57 57
58static void 58static void
59_focused(void *data, const Efl_Event *event) 59_selected(void *data, const Efl_Event *event)
60{ 60{
61 Priv_Data *priv = (Priv_Data*)data; 61 Priv_Data *priv = (Priv_Data*)data;
62 Evas_Object *focused = efl_ui_focus_manager_focus_get(event->object);
63 62
64 if (focused) 63 priv->selected = efl_ui_single_selectable_last_selected_get(event->object);
65 priv->selected = focused;
66} 64}
67 65
68static void 66static void
@@ -77,7 +75,7 @@ _bt_add_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
77 child = efl_model_child_add(priv->model); 75 child = efl_model_child_add(priv->model);
78 76
79 eina_value_set(&vtext, elm_object_text_get(priv->e_name)); 77 eina_value_set(&vtext, elm_object_text_get(priv->e_name));
80 efl_model_property_set(child, "name", &vtext); 78 efl_model_property_set(child, "filename", &vtext);
81 79
82 eina_value_set(&vtext, elm_object_text_get(priv->e_occ)); 80 eina_value_set(&vtext, elm_object_text_get(priv->e_occ));
83 efl_model_property_set(child, "occupation", &vtext); 81 efl_model_property_set(child, "occupation", &vtext);
@@ -95,7 +93,6 @@ _bt_del_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
95 Priv_Data *priv = (Priv_Data*)data; 93 Priv_Data *priv = (Priv_Data*)data;
96 Eo *child = NULL; 94 Eo *child = NULL;
97 95
98 //l = efl_ui_focus_manager_focus_get(priv->list1);
99 if(priv->selected) 96 if(priv->selected)
100 { 97 {
101 printf("focused %p\n", priv->selected); 98 printf("focused %p\n", priv->selected);
@@ -113,21 +110,21 @@ static void
113_bt_none_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 110_bt_none_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
114{ 111{
115 Evas_Object *li = data; 112 Evas_Object *li = data;
116 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_NONE); 113 efl_ui_multi_selectable_async_select_mode_set(li, EFL_UI_SELECT_MODE_NONE);
117} 114}
118 115
119static void 116static void
120_bt_donly_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 117_bt_donly_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
121{ 118{
122 Evas_Object *li = data; 119 /* Evas_Object *li = data; */
123 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); 120 /* efl_ui_multi_selectable_async_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); */
124} 121}
125 122
126static void 123static void
127_bt_default_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 124_bt_default_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
128{ 125{
129 Evas_Object *li = data; 126 Evas_Object *li = data;
130 efl_ui_list_view_select_mode_set(li, ELM_OBJECT_SELECT_MODE_DEFAULT); 127 efl_ui_multi_selectable_async_select_mode_set(li, EFL_UI_SELECT_MODE_SINGLE);
131} 128}
132 129
133static void 130static void
@@ -146,28 +143,21 @@ _bt_unset_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
146static void 143static void
147_realized_1_cb(void *data EINA_UNUSED, const Efl_Event *event) 144_realized_1_cb(void *data EINA_UNUSED, const Efl_Event *event)
148{ 145{
149 Efl_Ui_List_View_Item_Event *ie = event->info; 146 Efl_Gfx_Entity *layout = event->info;
150 147
151 evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0); 148 efl_ui_property_bind(layout, "efl.text", "filename");
152 evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
153 efl_ui_property_bind(ie->layout, "efl.text", "name");
154 efl_ui_property_bind(ie->layout, "signal/efl,state,%v", "odd_style");
155} 149}
156 150
157static void 151static void
158_realized_2_cb(void *data EINA_UNUSED, const Efl_Event *event) 152_realized_2_cb(void *data EINA_UNUSED, const Efl_Event *event)
159{ 153{
160 Efl_Ui_List_View_Item_Event *ie = event->info; 154 Efl_Gfx_Entity *layout = event->info;
161 printf("relized 2\n");
162 155
163 elm_object_focus_allow_set(ie->layout, EINA_TRUE); 156 efl_ui_property_bind(layout, "efl.text", "occupation");
164 evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
165 evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
166 efl_ui_property_bind(ie->layout, "efl.text", "occupation");
167} 157}
168 158
169static Efl_Model* 159static Efl_Model*
170_make_model() 160_make_model(void)
171{ 161{
172 Eina_Value vtext, value; 162 Eina_Value vtext, value;
173 Efl_Generic_Model *model, *child; 163 Efl_Generic_Model *model, *child;
@@ -182,11 +172,8 @@ _make_model()
182 { 172 {
183 child = efl_model_child_add(model); 173 child = efl_model_child_add(model);
184 174
185 i%2 ? eina_value_set(&vtext, "even") : eina_value_set(&vtext, "odd");
186 efl_model_property_set(child, "odd_style", &vtext);
187
188 eina_value_set(&vtext, texts[(i % len)]); 175 eina_value_set(&vtext, texts[(i % len)]);
189 efl_model_property_set(child, "name", &vtext); 176 efl_model_property_set(child, "filename", &vtext);
190 177
191 eina_value_set(&vtext, subtexts[(i % len)]); 178 eina_value_set(&vtext, subtexts[(i % len)]);
192 efl_model_property_set(child, "occupation", &vtext); 179 efl_model_property_set(child, "occupation", &vtext);
@@ -226,21 +213,20 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
226 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 213 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
227 214
228 priv->list1 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 215 priv->list1 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
229 efl_event_callback_add(priv->list1, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_1_cb, priv); 216 efl_event_callback_add(priv->list1, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_1_cb, priv);
230 evas_object_size_hint_weight_set(priv->list1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 217 evas_object_size_hint_weight_set(priv->list1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
231 evas_object_size_hint_align_set(priv->list1, EVAS_HINT_FILL, EVAS_HINT_FILL); 218 evas_object_size_hint_align_set(priv->list1, EVAS_HINT_FILL, EVAS_HINT_FILL);
232 elm_box_pack_end(bx, priv->list1); 219 elm_box_pack_end(bx, priv->list1);
233 efl_ui_list_view_layout_factory_set(priv->list1, factory); 220 efl_ui_collection_view_factory_set(priv->list1, factory);
234 221
235 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 222 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
236 efl_ui_property_bind(factory, "efl.text", "filename"); 223 efl_ui_property_bind(factory, "efl.text", "filename");
237 efl_ui_property_bind(factory, "signal/efl,state,%v", "selected");
238 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 224 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
239 priv->list2 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model)); 225 priv->list2 = efl_add(EFL_UI_LIST_VIEW_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
240 efl_event_callback_add(priv->list2, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2); 226 efl_event_callback_add(priv->list2, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2);
241 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 227 evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_size_hint_align_set(priv->list2, EVAS_HINT_FILL, EVAS_HINT_FILL); 228 evas_object_size_hint_align_set(priv->list2, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 efl_ui_list_view_layout_factory_set(priv->list2, factory); 229 efl_ui_collection_view_factory_set(priv->list2, factory);
244 230
245 vbx = elm_box_add(win); 231 vbx = elm_box_add(win);
246 elm_box_pack_end(bx, vbx); 232 elm_box_pack_end(bx, vbx);
@@ -313,7 +299,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
313 elm_box_pack_end(vbx, bt); 299 elm_box_pack_end(vbx, bt);
314 300
315 elm_box_pack_end(bx, priv->list2); 301 elm_box_pack_end(bx, priv->list2);
316 efl_event_callback_add(priv->list2, EFL_UI_FOCUS_MANAGER_EVENT_MANAGER_FOCUS_CHANGED, _focused ,priv); 302 efl_event_callback_add(priv->list2, EFL_UI_SINGLE_SELECTABLE_EVENT_SELECTION_CHANGED, _selected, priv);
317 303
318 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv); 304 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv);
319 305
diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h
index baa945c24b..7f0c2ab4e9 100644
--- a/src/lib/elementary/Efl_Ui.h
+++ b/src/lib/elementary/Efl_Ui.h
@@ -334,6 +334,7 @@ typedef Eo Efl_Ui_Spotlight_Indicator;
334# include <efl_ui_list_view_model.eo.h> 334# include <efl_ui_list_view_model.eo.h>
335# include <efl_ui_view_model.eo.h> 335# include <efl_ui_view_model.eo.h>
336# include <efl_ui_collection_view.eo.h> 336# include <efl_ui_collection_view.eo.h>
337# include <efl_ui_list_view.eo.h>
337 338
338# include <efl_ui_scroller.eo.h> 339# include <efl_ui_scroller.eo.h>
339# include <efl_ui_pan.eo.h> 340# include <efl_ui_pan.eo.h>
diff --git a/src/lib/elementary/efl_ui_list_view.c b/src/lib/elementary/efl_ui_list_view.c
index cee52e1132..efc3dfe50e 100644
--- a/src/lib/elementary/efl_ui_list_view.c
+++ b/src/lib/elementary/efl_ui_list_view.c
@@ -1,1041 +1,22 @@
1#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4#define EFL_ACCESS_OBJECT_PROTECTED
5#define EFL_ACCESS_SELECTION_PROTECTED
6#define EFL_UI_SCROLL_MANAGER_PROTECTED
7#define EFL_UI_SCROLLBAR_PROTECTED
8#define EFL_UI_FOCUS_COMPOSITION_PROTECTED
9#define EFL_UI_WIDGET_FOCUS_MANAGER_PROTECTED
10 4
11#include "elm_priv.h" 5#include <Efl_Ui.h>
12#include "efl_ui_list_view_private.h"
13#include "efl_ui_list_view_precise_layouter.eo.h"
14 6
15#include <assert.h> 7#define MY_CLASS EFL_UI_LIST_VIEW_CLASS
8#define MY_CLASS_PFX efl_ui_list_view
16 9
17#define MY_CLASS EFL_UI_LIST_VIEW_CLASS
18#define MY_CLASS_NAME "Efl.Ui.List_View" 10#define MY_CLASS_NAME "Efl.Ui.List_View"
19 11
20#define MY_PAN_CLASS EFL_UI_LIST_VIEW_PAN_CLASS 12static Eo *
21 13_efl_ui_list_view_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
22#define SIG_CHILD_ADDED "child,added"
23#define SIG_CHILD_REMOVED "child,removed"
24#define SELECTED_PROP "selected"
25
26static const Evas_Smart_Cb_Description _smart_callbacks[] = {
27 {SIG_CHILD_ADDED, ""},
28 {SIG_CHILD_REMOVED, ""},
29 {NULL, NULL}
30};
31
32void _efl_ui_list_view_custom_layout(Efl_Ui_List_View *);
33void _efl_ui_list_view_item_select_set(Efl_Ui_List_View_Layout_Item*, Eina_Bool);
34
35static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
36static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
37static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
38
39static const Elm_Action key_actions[] = {
40 {"move", _key_action_move},
41 {"select", _key_action_select},
42 {"escape", _key_action_escape},
43 {NULL, NULL}
44};
45
46EOLIAN static void
47_efl_ui_list_view_pan_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd)
48{
49 efl_canvas_group_need_recalculate_set(obj, EINA_FALSE);
50 evas_object_smart_changed(psd->wobj);
51}
52
53
54EOLIAN static void
55_efl_ui_list_view_pan_efl_ui_pan_pan_position_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd, Eina_Position2D pos)
56{
57 if ((pos.x == psd->gmt.x) && (pos.y == psd->gmt.y)) return;
58
59 psd->gmt.x = pos.x;
60 psd->gmt.y = pos.y;
61
62 efl_event_callback_call(obj, EFL_UI_PAN_EVENT_PAN_CONTENT_POSITION_CHANGED, &pos);
63 evas_object_smart_changed(psd->wobj);
64}
65
66EOLIAN static Eina_Position2D
67_efl_ui_list_view_pan_efl_ui_pan_pan_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd)
68{
69 return psd->gmt.pos;
70}
71
72EOLIAN static Eina_Position2D
73_efl_ui_list_view_pan_efl_ui_pan_pan_position_max_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd)
74{
75 EFL_UI_LIST_VIEW_DATA_GET(psd->wobj, pd);
76 Eina_Rect vgmt = {};
77 Eina_Size2D min = {};
78
79 vgmt = efl_ui_scrollable_viewport_geometry_get(pd->scrl_mgr);
80 min = efl_ui_list_view_model_min_size_get(psd->wobj);
81
82 min.w = min.w - vgmt.w;
83 if (min.w < 0) min.w = 0;
84 min.h = min.h - vgmt.h;
85 if (min.h < 0) min.h = 0;
86
87 return EINA_POSITION2D(min.w, min.h);
88}
89
90EOLIAN static Eina_Position2D
91_efl_ui_list_view_pan_efl_ui_pan_pan_position_min_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd EINA_UNUSED)
92{
93 return EINA_POSITION2D(0, 0);
94}
95
96EOLIAN static Eina_Size2D
97_efl_ui_list_view_pan_efl_ui_pan_content_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Pan_Data *psd)
98{
99 Eina_Size2D min = {};
100 min = efl_ui_list_view_model_min_size_get(psd->wobj);
101
102 return min;
103}
104
105EOLIAN static void
106_efl_ui_list_view_pan_efl_object_destructor(Eo *obj, Efl_Ui_List_View_Pan_Data *psd EINA_UNUSED)
107{
108 efl_destructor(efl_super(obj, MY_PAN_CLASS));
109}
110
111#include "efl_ui_list_view_pan.eo.c"
112
113static Eina_Bool
114_efl_model_properties_has(Efl_Model *model, Eina_Stringshare *propfind)
115{
116 Eina_Iterator *properties;
117 const char *property;
118 Eina_Bool ret = EINA_FALSE;
119
120 EINA_SAFETY_ON_NULL_RETURN_VAL(model, EINA_FALSE);
121 EINA_SAFETY_ON_NULL_RETURN_VAL(propfind, EINA_FALSE);
122
123 properties = efl_model_properties_get(model);
124 EINA_ITERATOR_FOREACH(properties, property)
125 {
126 if (property == propfind ||
127 !strcmp(property, propfind))
128 {
129 ret = EINA_TRUE;
130 break;
131 }
132 }
133 eina_iterator_free(properties);
134
135 return ret;
136}
137
138static void
139_list_element_focused(void *data EINA_UNUSED, const Efl_Event *ev)
140{
141 Eina_Rect geom;
142 Eina_Position2D pos;
143 Efl_Ui_Focus_Object *focused = efl_ui_focus_manager_focus_get(ev->object);
144
145 if (!focused) return;
146
147 EFL_UI_LIST_VIEW_DATA_GET(ev->object, pd);
148 geom = efl_ui_focus_object_focus_geometry_get(focused);
149 pos = efl_ui_scrollable_content_pos_get(pd->scrl_mgr);
150
151 geom.x += pos.x;
152 geom.y += pos.y;
153 efl_ui_scrollable_scroll(pd->scrl_mgr, geom, EINA_TRUE);
154}
155
156static void
157_on_item_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
158{
159 Evas_Event_Mouse_Down *ev = event_info;
160 Efl_Ui_List_View_Layout_Item *item = data;
161 Eina_Value *v;
162 Eina_Bool select;
163
164 if (ev->button != 1) return;
165 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
166
167 v = efl_model_property_get(item->children, SELECTED_PROP);
168 if (!eina_value_get(v, &select))
169 {
170 WRN("Could not get the select value");
171 eina_value_free(v);
172 return;
173 }
174 _efl_ui_list_view_item_select_set(item, !select);
175 eina_value_free(v);
176}
177
178EOLIAN static void
179_efl_ui_list_view_select_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, Elm_Object_Select_Mode mode)
180{
181 if (pd->select_mode == mode)
182 return;
183
184 pd->select_mode = mode;
185}
186
187EOLIAN static Elm_Object_Select_Mode
188_efl_ui_list_view_select_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
189{
190 return pd->select_mode;
191}
192
193EOLIAN static void
194_efl_ui_list_view_default_style_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, Eina_Stringshare *style)
195{
196 eina_stringshare_replace(&pd->style, style);
197}
198
199EOLIAN static Eina_Stringshare *
200_efl_ui_list_view_default_style_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
201{
202 return pd->style;
203}
204
205EOLIAN static void
206_efl_ui_list_view_homogeneous_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, Eina_Bool homogeneous)
207{
208 pd->homogeneous = homogeneous;
209}
210
211EOLIAN static Eina_Bool
212_efl_ui_list_view_homogeneous_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
213{
214 return pd->homogeneous;
215}
216
217EOLIAN static void
218_efl_ui_list_view_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_List_View_Data *pd, Eina_Position2D pos)
219{
220 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
221 return;
222
223 efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
224 evas_object_smart_changed(pd->obj);
225}
226
227EOLIAN static void
228_efl_ui_list_view_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_List_View_Data *pd, Eina_Size2D size)
229{
230 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, size.w, size.h))
231 return;
232
233 efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), size);
234
235 evas_object_smart_changed(pd->obj);
236}
237
238EOLIAN static void
239_efl_ui_list_view_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
240{
241 if (!pd->model)
242 return;
243
244 efl_ui_list_view_relayout_layout_do(pd->relayout, pd->obj, pd->seg_array_first, pd->seg_array);
245
246}
247
248EOLIAN static void
249_efl_ui_list_view_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_List_View_Data *pd EINA_UNUSED, Evas_Object *member)
250{
251 efl_canvas_group_member_add(efl_super(obj, MY_CLASS), member);
252}
253
254//Scrollable Implement
255static void
256_efl_ui_list_view_bar_read_and_update(Eo *obj)
257{
258 EFL_UI_LIST_VIEW_DATA_GET(obj, pd);
259 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
260 double vx, vy;
261
262 edje_object_part_drag_value_get
263 (wd->resize_obj, "efl.dragable.vbar", NULL, &vy);
264 edje_object_part_drag_value_get
265 (wd->resize_obj, "efl.dragable.hbar", &vx, NULL);
266
267 efl_ui_scrollbar_bar_position_set(pd->scrl_mgr, vx, vy);
268
269 efl_canvas_group_change(pd->pan_obj);
270}
271
272static void
273_efl_ui_list_view_reload_cb(void *data,
274 Evas_Object *obj EINA_UNUSED,
275 const char *emission EINA_UNUSED,
276 const char *source EINA_UNUSED)
277{
278 EFL_UI_LIST_VIEW_DATA_GET(data, pd);
279
280 efl_ui_scrollbar_bar_visibility_update(pd->scrl_mgr);
281}
282
283static void
284_efl_ui_list_view_vbar_drag_cb(void *data,
285 Evas_Object *obj EINA_UNUSED,
286 const char *emission EINA_UNUSED,
287 const char *source EINA_UNUSED)
288{
289 _efl_ui_list_view_bar_read_and_update(data);
290
291 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
292 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAGGED, &type);
293}
294
295static void
296_efl_ui_list_view_vbar_press_cb(void *data,
297 Evas_Object *obj EINA_UNUSED,
298 const char *emission EINA_UNUSED,
299 const char *source EINA_UNUSED)
300{
301 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
302 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESSED, &type);
303}
304
305static void
306_efl_ui_list_view_vbar_unpress_cb(void *data,
307 Evas_Object *obj EINA_UNUSED,
308 const char *emission EINA_UNUSED,
309 const char *source EINA_UNUSED)
310{
311 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
312 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESSED, &type);
313}
314
315static void
316_efl_ui_list_view_edje_drag_start_cb(void *data,
317 Evas_Object *obj EINA_UNUSED,
318 const char *emission EINA_UNUSED,
319 const char *source EINA_UNUSED)
320{
321 EFL_UI_LIST_VIEW_DATA_GET(data, pd);
322
323 _efl_ui_list_view_bar_read_and_update(data);
324
325 pd->scrl_freeze = efl_ui_scrollable_scroll_freeze_get(pd->scrl_mgr);
326 efl_ui_scrollable_scroll_freeze_set(pd->scrl_mgr, EINA_TRUE);
327 efl_event_callback_call(data, EFL_UI_EVENT_SCROLL_DRAG_STARTED, NULL);
328}
329
330static void
331_efl_ui_list_view_edje_drag_stop_cb(void *data,
332 Evas_Object *obj EINA_UNUSED,
333 const char *emission EINA_UNUSED,
334 const char *source EINA_UNUSED)
335{
336 EFL_UI_LIST_VIEW_DATA_GET(data, pd);
337
338 _efl_ui_list_view_bar_read_and_update(data);
339
340 efl_ui_scrollable_scroll_freeze_set(pd->scrl_mgr, pd->scrl_freeze);
341 efl_event_callback_call(data, EFL_UI_EVENT_SCROLL_DRAG_FINISHED, NULL);
342}
343
344static void
345_efl_ui_list_view_edje_drag_cb(void *data,
346 Evas_Object *obj EINA_UNUSED,
347 const char *emission EINA_UNUSED,
348 const char *source EINA_UNUSED)
349{
350 _efl_ui_list_view_bar_read_and_update(data);
351}
352
353static void
354_efl_ui_list_view_hbar_drag_cb(void *data,
355 Evas_Object *obj EINA_UNUSED,
356 const char *emission EINA_UNUSED,
357 const char *source EINA_UNUSED)
358{
359 _efl_ui_list_view_bar_read_and_update(data);
360
361 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
362 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAGGED, &type);
363}
364
365static void
366_efl_ui_list_view_hbar_press_cb(void *data,
367 Evas_Object *obj EINA_UNUSED,
368 const char *emission EINA_UNUSED,
369 const char *source EINA_UNUSED)
370{
371 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
372 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESSED, &type);
373}
374
375static void
376_efl_ui_list_view_hbar_unpress_cb(void *data,
377 Evas_Object *obj EINA_UNUSED,
378 const char *emission EINA_UNUSED,
379 const char *source EINA_UNUSED)
380{
381 Efl_Ui_Layout_Orientation type = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
382 efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESSED, &type);
383}
384
385static void
386_efl_ui_list_view_bar_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
387{
388 Eo *obj = data;
389 EFL_UI_LIST_VIEW_DATA_GET(obj, pd);
390 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
391
392 double width = 0.0, height = 0.0;
393
394 efl_ui_scrollbar_bar_size_get(pd->scrl_mgr, &width, &height);
395
396 edje_object_part_drag_size_set(wd->resize_obj, "efl.dragable.hbar", width, 1.0);
397 edje_object_part_drag_size_set(wd->resize_obj, "efl.dragable.vbar", 1.0, height);
398}
399
400static void
401_efl_ui_list_view_bar_pos_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
402{
403 Eo *obj = data;
404 EFL_UI_LIST_VIEW_DATA_GET(obj, pd);
405 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
406
407 double posx = 0.0, posy = 0.0;
408
409 efl_ui_scrollbar_bar_position_get(pd->scrl_mgr, &posx, &posy);
410
411 edje_object_part_drag_value_set(wd->resize_obj, "efl.dragable.hbar", posx, 0.0);
412 edje_object_part_drag_value_set(wd->resize_obj, "efl.dragable.vbar", 0.0, posy);
413}
414
415static void
416_efl_ui_list_view_bar_show_cb(void *data, const Efl_Event *event)
417{
418 Eo *obj = data;
419 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
420 Efl_Ui_Layout_Orientation type = *(Efl_Ui_Layout_Orientation *)(event->info);
421
422 if (type == EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL)
423 edje_object_signal_emit(wd->resize_obj, "efl,action,show,hbar", "efl");
424 else if (type == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
425 edje_object_signal_emit(wd->resize_obj, "efl,action,show,vbar", "efl");
426}
427
428static void
429_efl_ui_list_view_bar_hide_cb(void *data, const Efl_Event *event)
430{
431 Eo *obj = data;
432 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
433 Efl_Ui_Layout_Orientation type = *(Efl_Ui_Layout_Orientation *)(event->info);
434
435 if (type == EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL)
436 edje_object_signal_emit(wd->resize_obj, "efl,action,hide,hbar", "efl");
437 else if (type == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
438 edje_object_signal_emit(wd->resize_obj, "efl,action,hide,vbar", "efl");
439}
440
441static Eina_Bool
442_efl_ui_list_view_efl_layout_signal_signal_callback_add(Eo *obj, Efl_Ui_List_View_Data *pd EINA_UNUSED, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
443{
444 Eina_Bool ok;
445 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
446
447 ok = efl_layout_signal_callback_add(wd->resize_obj, emission, source, func_data, func, func_free_cb);
448
449 return ok;
450}
451
452static Eina_Bool
453_efl_ui_list_view_efl_layout_signal_signal_callback_del(Eo *obj, Efl_Ui_List_View_Data *pd EINA_UNUSED, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
454{
455 Eina_Bool ok;
456 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
457
458 ok = efl_layout_signal_callback_del(wd->resize_obj, emission, source, func_data, func, func_free_cb);
459
460 return ok;
461}
462
463static void
464_efl_ui_list_view_edje_object_attach(Eo *obj)
465{
466 efl_layout_signal_callback_add
467 (obj, "reload", "efl",
468 obj, _efl_ui_list_view_reload_cb, NULL);
469 //Vertical bar
470 efl_layout_signal_callback_add
471 (obj, "drag", "efl.dragable.vbar",
472 obj, _efl_ui_list_view_vbar_drag_cb, NULL);
473 efl_layout_signal_callback_add
474 (obj, "drag,set", "efl.dragable.vbar",
475 obj, _efl_ui_list_view_edje_drag_cb, NULL);
476 efl_layout_signal_callback_add
477 (obj, "drag,start", "efl.dragable.vbar",
478 obj, _efl_ui_list_view_edje_drag_start_cb, NULL);
479 efl_layout_signal_callback_add
480 (obj, "drag,stop", "efl.dragable.vbar",
481 obj, _efl_ui_list_view_edje_drag_stop_cb, NULL);
482 efl_layout_signal_callback_add
483 (obj, "drag,step", "efl.dragable.vbar",
484 obj, _efl_ui_list_view_edje_drag_cb, NULL);
485 efl_layout_signal_callback_add
486 (obj, "drag,page", "efl.dragable.vbar",
487 obj, _efl_ui_list_view_edje_drag_cb, NULL);
488 efl_layout_signal_callback_add
489 (obj, "efl,vbar,press", "efl",
490 obj, _efl_ui_list_view_vbar_press_cb, NULL);
491 efl_layout_signal_callback_add
492 (obj, "efl,vbar,unpress", "efl",
493 obj, _efl_ui_list_view_vbar_unpress_cb, NULL);
494
495 //Horizontal bar
496 efl_layout_signal_callback_add
497 (obj, "drag", "efl.dragable.hbar",
498 obj, _efl_ui_list_view_hbar_drag_cb, NULL);
499 efl_layout_signal_callback_add
500 (obj, "drag,set", "efl.dragable.hbar",
501 obj, _efl_ui_list_view_edje_drag_cb, NULL);
502 efl_layout_signal_callback_add
503 (obj, "drag,start", "efl.dragable.hbar",
504 obj, _efl_ui_list_view_edje_drag_start_cb, NULL);
505 efl_layout_signal_callback_add
506 (obj, "drag,stop", "efl.dragable.hbar",
507 obj, _efl_ui_list_view_edje_drag_stop_cb, NULL);
508 efl_layout_signal_callback_add
509 (obj, "drag,step", "efl.dragable.hbar",
510 obj, _efl_ui_list_view_edje_drag_cb, NULL);
511 efl_layout_signal_callback_add
512 (obj, "drag,page", "efl.dragable.hbar",
513 obj, _efl_ui_list_view_edje_drag_cb, NULL);
514 efl_layout_signal_callback_add
515 (obj, "efl,hbar,press", "efl",
516 obj, _efl_ui_list_view_hbar_press_cb, NULL);
517 efl_layout_signal_callback_add
518 (obj, "efl,hbar,unpress", "efl",
519 obj, _efl_ui_list_view_hbar_unpress_cb, NULL);
520}
521
522static void
523_efl_ui_list_view_edje_object_detach(Evas_Object *obj)
524{
525 efl_layout_signal_callback_del
526 (obj, "reload", "efl",
527 obj, _efl_ui_list_view_reload_cb, NULL);
528 //Vertical bar
529 efl_layout_signal_callback_del
530 (obj, "drag", "efl.dragable.vbar",
531 obj, _efl_ui_list_view_vbar_drag_cb, NULL);
532 efl_layout_signal_callback_del
533 (obj, "drag,set", "efl.dragable.vbar",
534 obj, _efl_ui_list_view_edje_drag_cb, NULL);
535 efl_layout_signal_callback_del
536 (obj, "drag,start", "efl.dragable.vbar",
537 obj, _efl_ui_list_view_edje_drag_start_cb, NULL);
538 efl_layout_signal_callback_del
539 (obj, "drag,stop", "efl.dragable.vbar",
540 obj, _efl_ui_list_view_edje_drag_stop_cb, NULL);
541 efl_layout_signal_callback_del
542 (obj, "drag,step", "efl.dragable.vbar",
543 obj, _efl_ui_list_view_edje_drag_cb, NULL);
544 efl_layout_signal_callback_del
545 (obj, "drag,page", "efl.dragable.vbar",
546 obj, _efl_ui_list_view_edje_drag_cb, NULL);
547 efl_layout_signal_callback_del
548 (obj, "efl,vbar,press", "efl",
549 obj, _efl_ui_list_view_vbar_press_cb, NULL);
550 efl_layout_signal_callback_del
551 (obj, "efl,vbar,unpress", "efl",
552 obj, _efl_ui_list_view_vbar_unpress_cb, NULL);
553
554 //Horizontal bar
555 efl_layout_signal_callback_del
556 (obj, "drag", "efl.dragable.hbar",
557 obj, _efl_ui_list_view_hbar_drag_cb, NULL);
558 efl_layout_signal_callback_del
559 (obj, "drag,set", "efl.dragable.hbar",
560 obj, _efl_ui_list_view_edje_drag_cb, NULL);
561 efl_layout_signal_callback_del
562 (obj, "drag,start", "efl.dragable.hbar",
563 obj, _efl_ui_list_view_edje_drag_start_cb, NULL);
564 efl_layout_signal_callback_del
565 (obj, "drag,stop", "efl.dragable.hbar",
566 obj, _efl_ui_list_view_edje_drag_stop_cb, NULL);
567 efl_layout_signal_callback_del
568 (obj, "drag,step", "efl.dragable.hbar",
569 obj, _efl_ui_list_view_edje_drag_cb, NULL);
570 efl_layout_signal_callback_del
571 (obj, "drag,page", "efl.dragable.hbar",
572 obj, _efl_ui_list_view_edje_drag_cb, NULL);
573 efl_layout_signal_callback_del
574 (obj, "efl,hbar,press", "efl",
575 obj, _efl_ui_list_view_hbar_press_cb, NULL);
576 efl_layout_signal_callback_del
577 (obj, "efl,hbar,unpress", "efl",
578 obj, _efl_ui_list_view_hbar_unpress_cb, NULL);
579}
580
581EOLIAN static void
582_efl_ui_list_view_efl_canvas_group_group_add(Eo *obj, Efl_Ui_List_View_Data *pd)
583{
584 Efl_Ui_List_View_Pan_Data *pan_data;
585 Eina_Size2D min = {};
586 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
587 Evas_Object *o;
588
589 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
590
591 efl_canvas_group_add(efl_super(obj, MY_CLASS));
592
593 elm_widget_can_focus_set(obj, EINA_TRUE);
594
595 if (!elm_layout_theme_set(obj, "list_view", "base", elm_widget_style_get(obj)))
596 CRI("Failed to set layout!");
597
598 pd->scrl_mgr = efl_add(EFL_UI_SCROLL_MANAGER_CLASS, obj,
599 efl_ui_mirrored_set(efl_added, efl_ui_mirrored_get(obj)));
600 efl_composite_attach(obj, pd->scrl_mgr);
601 pd->pan_obj = efl_add(MY_PAN_CLASS, obj);
602 pan_data = efl_data_scope_get(pd->pan_obj, MY_PAN_CLASS);
603 pan_data->wobj = obj;
604
605 efl_ui_scroll_manager_pan_set(pd->scrl_mgr, pd->pan_obj);
606 efl_ui_scrollable_bounce_enabled_set(pd->scrl_mgr, bounce, bounce);
607
608 edje_object_part_swallow(wd->resize_obj, "efl.content", pd->pan_obj);
609 edje_object_freeze(wd->resize_obj);
610 o = (Evas_Object *)edje_object_part_object_get(wd->resize_obj, "efl.dragable.vbar");
611 edje_object_thaw(wd->resize_obj);
612 efl_gfx_stack_raise_to_top((Eo *)o);
613
614 efl_gfx_entity_visible_set(pd->pan_obj, EINA_TRUE);
615 efl_access_object_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED);
616
617 edje_object_size_min_calc(wd->resize_obj, &min.w, &min.h);
618 efl_gfx_hint_size_restricted_min_set(obj, min);
619
620 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
621 _efl_ui_list_view_bar_size_changed_cb, obj);
622 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
623 _efl_ui_list_view_bar_pos_changed_cb, obj);
624 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
625 _efl_ui_list_view_bar_show_cb, obj);
626 efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
627 _efl_ui_list_view_bar_hide_cb, obj);
628
629 _efl_ui_list_view_edje_object_attach(obj);
630}
631
632EOLIAN static void
633_efl_ui_list_view_efl_canvas_group_group_del(Eo *obj, Efl_Ui_List_View_Data *pd)
634{
635 efl_ui_list_view_relayout_model_set(pd->relayout, NULL);
636
637 ELM_SAFE_FREE(pd->pan_obj, efl_del);
638 efl_canvas_group_del(efl_super(obj, MY_CLASS));
639}
640
641EOLIAN static Efl_Ui_Focus_Manager*
642_efl_ui_list_view_efl_ui_widget_focus_manager_focus_manager_create(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root)
643{
644 if (!pd->manager)
645 pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, obj,
646 efl_ui_focus_manager_root_set(efl_added, root));
647
648 return pd->manager;
649}
650
651EOLIAN static Eo *
652_efl_ui_list_view_efl_object_finalize(Eo *obj, Efl_Ui_List_View_Data *pd)
653{
654 if (!pd->factory)
655 {
656 pd->factory = efl_new(EFL_UI_LAYOUT_FACTORY_CLASS);
657 efl_ui_layout_factory_theme_config(pd->factory, "list_item", NULL, "default");
658 }
659
660 if(!pd->relayout)
661 {
662 pd->relayout = efl_new(EFL_UI_LIST_VIEW_PRECISE_LAYOUTER_CLASS);
663 efl_ui_list_view_relayout_model_set(pd->relayout, pd->model);
664 }
665 return obj;
666}
667
668EOLIAN static Eo *
669_efl_ui_list_view_efl_object_constructor(Eo *obj, Efl_Ui_List_View_Data *pd)
670{ 14{
671 obj = efl_constructor(efl_super(obj, MY_CLASS)); 15 obj = efl_constructor(efl_super(obj, MY_CLASS));
672 pd->obj = obj;
673 efl_canvas_object_type_set(obj, MY_CLASS_NAME);
674 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
675 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_LIST);
676
677 pd->seg_array = efl_ui_list_view_seg_array_setup(32);
678
679 efl_event_callback_add(obj, EFL_UI_FOCUS_MANAGER_EVENT_MANAGER_FOCUS_CHANGED, _list_element_focused, NULL);
680
681 efl_ui_focus_composition_logical_mode_set(obj, EINA_TRUE);
682
683 pd->style = eina_stringshare_add(elm_widget_style_get(obj));
684 16
685 pd->factory = NULL; 17 efl_ui_collection_view_position_manager_set(obj, efl_new(EFL_UI_POSITION_MANAGER_LIST_CLASS));
686 pd->min.w = 0;
687 pd->min.h = 0;
688 18
689 return obj; 19 return obj;
690} 20}
691 21
692EOLIAN static void
693_efl_ui_list_view_efl_object_destructor(Eo *obj, Efl_Ui_List_View_Data *pd)
694{
695 efl_event_callback_del(obj, EFL_UI_FOCUS_MANAGER_EVENT_MANAGER_FOCUS_CHANGED,
696 _list_element_focused, NULL);
697
698 _efl_ui_list_view_edje_object_detach(obj);
699
700 efl_replace(&pd->model, NULL);
701 efl_replace(&pd->relayout, NULL);
702 efl_replace(&pd->factory, NULL);
703
704 efl_ui_list_view_seg_array_free(pd->seg_array);
705
706 eina_stringshare_del(pd->style);
707 efl_destructor(efl_super(obj, MY_CLASS));
708}
709
710EOLIAN static void
711_efl_ui_list_view_layout_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, Efl_Ui_Factory *factory)
712{
713 efl_replace(&pd->factory, factory);
714}
715
716EOLIAN static void
717_efl_ui_list_view_efl_ui_view_model_set(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, Efl_Model *model)
718{
719 if (!efl_replace(&pd->model, model))
720 return;
721
722 efl_ui_list_view_seg_array_flush(pd->seg_array);
723
724 if (pd->relayout)
725 efl_ui_list_view_relayout_model_set(pd->relayout, pd->model);
726
727 evas_object_smart_changed(pd->obj);
728}
729
730EOLIAN static Efl_Model *
731_efl_ui_list_view_efl_ui_view_model_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
732{
733 return pd->model;
734}
735
736EOLIAN int
737_efl_ui_list_view_efl_access_selection_selected_children_count_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
738{
739 return eina_list_count(pd->selected_items);
740}
741
742EOLIAN Eo*
743_efl_ui_list_view_efl_access_selection_selected_child_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd, int child_index)
744{
745 if(child_index < (int) eina_list_count(pd->selected_items))
746 {
747 Efl_Ui_List_View_Layout_Item* items = eina_list_nth(pd->selected_items, child_index);
748 return items[child_index].layout;
749 }
750 else
751 return NULL;
752}
753
754EOLIAN Eina_Bool
755_efl_ui_list_view_efl_access_selection_child_select(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
756{
757 return EINA_FALSE;
758}
759
760EOLIAN Eina_Bool
761_efl_ui_list_view_efl_access_selection_selected_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
762{
763 return EINA_FALSE;
764}
765
766EOLIAN Eina_Bool
767_efl_ui_list_view_efl_access_selection_is_child_selected(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
768{
769 return EINA_FALSE;
770}
771
772EOLIAN Eina_Bool
773_efl_ui_list_view_efl_access_selection_all_children_select(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED)
774{
775 return EINA_TRUE;
776}
777
778EOLIAN Eina_Bool
779_efl_ui_list_view_efl_access_selection_access_selection_clear(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED)
780{
781 return EINA_TRUE;
782}
783
784EOLIAN Eina_Bool
785_efl_ui_list_view_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd EINA_UNUSED, int child_index EINA_UNUSED)
786{
787 return EINA_FALSE;
788}
789
790static Eina_Bool
791_key_action_move(Evas_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
792{
793 return EINA_FALSE;
794}
795
796static Eina_Bool
797_key_action_select(Evas_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
798{
799 return EINA_FALSE;
800}
801
802static Eina_Bool
803_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
804{
805 efl_ui_focus_manager_reset_history(obj);
806 return EINA_TRUE;
807}
808
809void
810_efl_ui_list_view_item_select_set(Efl_Ui_List_View_Layout_Item *item, Eina_Bool selected)
811{
812 Eina_Stringshare *sprop;
813 assert(item != NULL);
814 assert(item->children != NULL);
815
816 selected = !!selected;
817
818 sprop = eina_stringshare_add(SELECTED_PROP);
819
820 if (_efl_model_properties_has(item->children, sprop))
821 {
822 Eina_Value v;
823 eina_value_setup(&v, EINA_VALUE_TYPE_BOOL);
824 eina_value_set(&v, selected);
825 efl_model_property_set(item->children, sprop, &v);
826 eina_value_flush(&v);
827 }
828 eina_stringshare_del(sprop);
829}
830
831static Eina_Value
832_children_slice_then(void * data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
833{
834 Efl_Ui_List_View_Data *pd = data;
835
836 if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR)
837 goto on_error;
838
839 efl_ui_list_view_seg_array_insert_value(pd->seg_array, pd->slice.start, v);
840
841 pd->seg_array_first = pd->slice.start;
842 pd->slice.start = pd->slice.count = 0;
843 pd->slice.future = NULL;
844
845 efl_ui_list_view_relayout_layout_do(pd->relayout, pd->obj, pd->seg_array_first, pd->seg_array);
846 on_error:
847 return v;
848}
849
850/* EFL UI LIST MODEL INTERFACE */
851EOLIAN static Eina_Size2D
852_efl_ui_list_view_efl_ui_list_view_model_min_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
853{
854 return pd->min;
855}
856
857EOLIAN static void
858_efl_ui_list_view_efl_ui_list_view_model_min_size_set(Eo *obj, Efl_Ui_List_View_Data *pd, Eina_Size2D min)
859{
860 Eina_Size2D sz;
861 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
862
863 pd->min.w = min.w;
864 pd->min.h = min.h;
865
866 efl_gfx_hint_size_min_set(wd->resize_obj, EINA_SIZE2D(pd->min.w, pd->min.h));
867 sz = pd->min;
868 efl_event_callback_call(pd->pan_obj, EFL_UI_PAN_EVENT_PAN_CONTENT_SIZE_CHANGED, &sz);
869}
870
871EOLIAN static void
872_efl_ui_list_view_efl_ui_focus_composition_prepare(Eo *obj, Efl_Ui_List_View_Data *pd)
873{
874 Eina_List *order = efl_ui_list_view_relayout_elements_get(pd->relayout);
875 efl_ui_focus_composition_elements_set(obj, order);
876}
877
878EOLIAN Eina_List*
879_efl_ui_list_view_efl_access_object_access_children_get(const Eo *obj, Efl_Ui_List_View_Data *pd)
880{
881 Eina_List *ret = NULL, *ret2 = NULL;
882
883 ret = efl_ui_list_view_relayout_elements_get(pd->relayout);
884 ret2 = efl_access_object_access_children_get(efl_super(obj, EFL_UI_LIST_VIEW_CLASS));
885
886 return eina_list_merge(ret, ret2);
887}
888
889EOLIAN static Eina_Bool
890_efl_ui_list_view_efl_ui_widget_focus_state_apply(Eo *obj, Efl_Ui_List_View_Data *pd EINA_UNUSED, Efl_Ui_Widget_Focus_State current_state, Efl_Ui_Widget_Focus_State *configured_state, Efl_Ui_Widget *redirect EINA_UNUSED)
891{
892 return efl_ui_widget_focus_state_apply(efl_super(obj, MY_CLASS), current_state, configured_state, obj);
893}
894
895typedef struct _Efl_Ui_List_Vuew_Layout_Item_Tracking Efl_Ui_List_View_Layout_Item_Tracking;
896struct _Efl_Ui_List_Vuew_Layout_Item_Tracking
897{
898 Efl_Ui_List_View_Layout_Item *item;
899 Efl_Ui_List_View_Data *pd;
900};
901
902static Eina_Value
903_content_created(Eo *obj, void *data, const Eina_Value value)
904{
905 Efl_Ui_List_View_Layout_Item_Tracking *tracking = data;
906 Efl_Ui_List_View_Layout_Item *item = tracking->item;
907 Efl_Ui_List_View_Item_Event evt;
908
909 if (eina_value_array_count(&value) != 1) return eina_value_error_init(EINVAL);
910 eina_value_array_get(&value, 0, &item->layout);
911
912 efl_canvas_group_member_add(tracking->pd->pan_obj, item->layout);
913 evas_object_event_callback_add(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item);
914
915 if (_elm_config->atspi_mode)
916 {
917 efl_access_added(item->layout);
918 efl_access_children_changed_added_signal_emit(obj, item->layout);
919 }
920
921 evt.child = item->children;
922 evt.layout = item->layout;
923 evt.index = efl_ui_list_view_item_index_get(item);
924 efl_event_callback_call(obj, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, &evt);
925
926 tracking->item->layout_request = NULL;
927 efl_ui_list_view_relayout_content_created(tracking->pd->relayout, item);
928
929 efl_ui_focus_composition_dirty(obj);
930 evas_object_show(item->layout);
931
932 return value;
933}
934
935static void
936_clean_request(Eo *obj EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
937{
938 Efl_Ui_List_View_Layout_Item_Tracking *tracking = data;
939
940 tracking->item->layout_request = NULL;
941 free(tracking);
942}
943
944EOLIAN static Efl_Ui_List_View_Layout_Item *
945_efl_ui_list_view_efl_ui_list_view_model_realize(Eo *obj, Efl_Ui_List_View_Data *pd, Efl_Ui_List_View_Layout_Item *item)
946{
947 Efl_Ui_List_View_Layout_Item_Tracking *tracking;
948 Efl_Model *childrens[1];
949 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
950
951 if (!item->children) return item;
952
953 if (item->layout_request) eina_future_cancel(item->layout_request);
954
955 tracking = calloc(1, sizeof (Efl_Ui_List_View_Layout_Item_Tracking));
956 if (!tracking) return item;
957
958 tracking->item = item;
959 tracking->pd = pd;
960 childrens[0] = item->children;
961
962 item->layout_request = efl_ui_view_factory_create_with_event(pd->factory, EINA_C_ARRAY_ITERATOR_NEW(childrens));
963 item->layout_request = efl_future_then(obj, item->layout_request,
964 .success = _content_created,
965 .success_type = EINA_VALUE_TYPE_ARRAY,
966 .data = tracking,
967 .free = _clean_request);
968
969 return item;
970}
971
972EOLIAN static void
973_efl_ui_list_view_efl_ui_list_view_model_unrealize(Eo *obj, Efl_Ui_List_View_Data *pd, Efl_Ui_List_View_Layout_Item *item)
974{
975 Efl_Ui_List_View_Item_Event evt;
976 Efl_Gfx_Entity *entities[1];
977 EINA_SAFETY_ON_NULL_RETURN(item);
978
979 if (!item->layout)
980 return;
981
982 // First check if the item has been fully realized
983 if (item->layout_request)
984 {
985 eina_future_cancel(item->layout_request);
986 return ;
987 }
988
989 evas_object_event_callback_del_full(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item);
990 if (elm_object_focus_allow_get(item->layout))
991 {
992 if (efl_ui_focus_object_focus_get(item->layout))
993 efl_ui_focus_object_focus_set(item->layout, EINA_FALSE);
994 efl_ui_focus_manager_calc_unregister(obj, item->layout);
995 }
996 evas_object_hide(item->layout);
997 evas_object_move(item->layout, -9999, -9999);
998
999 evt.child = item->children;
1000 evt.layout = item->layout;
1001 evt.index = efl_ui_list_view_item_index_get(item);
1002 efl_event_callback_call(obj, EFL_UI_LIST_VIEW_EVENT_ITEM_UNREALIZED, &evt);
1003
1004 efl_canvas_group_member_remove(obj, pd->pan_obj);
1005 entities[0] = item->layout;
1006 efl_ui_factory_release(pd->factory, EINA_C_ARRAY_ITERATOR_NEW(entities));
1007 item->layout = NULL;
1008}
1009
1010EOLIAN static void
1011_efl_ui_list_view_efl_ui_list_view_model_load_range_set(Eo* obj, Efl_Ui_List_View_Data* pd, int first, int count)
1012{
1013 if (pd->slice.future) return ;
1014
1015 pd->slice.start = first;
1016 pd->slice.count = count;
1017
1018 if (efl_model_children_count_get(pd->model))
1019 {
1020 Eina_Future *f = efl_model_children_slice_get(pd->model, first, count);
1021 f = eina_future_then(f, _children_slice_then, pd, NULL);
1022 pd->slice.future = efl_future_then(obj, f);
1023 }
1024}
1025
1026EOLIAN static int
1027_efl_ui_list_view_efl_ui_list_view_model_model_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Data *pd)
1028{
1029 return efl_model_children_count_get(pd->model);
1030}
1031
1032ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_list_view, Efl_Ui_List_View_Data)
1033
1034/* Internal EO APIs and hidden overrides */
1035
1036#define EFL_UI_LIST_VIEW_EXTRA_OPS \
1037 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_list_view)
1038
1039#include "efl_ui_list_view.eo.c" 22#include "efl_ui_list_view.eo.c"
1040#include "efl_ui_list_view_relayout.eo.c"
1041#include "efl_ui_list_view_model.eo.c"
diff --git a/src/lib/elementary/efl_ui_list_view.eo b/src/lib/elementary/efl_ui_list_view.eo
index d552ce4793..c4de87da5a 100644
--- a/src/lib/elementary/efl_ui_list_view.eo
+++ b/src/lib/elementary/efl_ui_list_view.eo
@@ -1,97 +1,17 @@
1import elm_general; 1class @beta Efl.Ui.List_View extends Efl.Ui.Collection_View
2
3struct @beta Efl.Ui.List_View_Item_Event
4{
5 [[Information related to item events.]] // TODO: This needs to be filled in.
6 layout: Efl.Ui.Layout; [[TBD]]
7 child: Efl.Model; [[TBD]]
8 index: int; [[TBD]]
9}
10class @beta Efl.Ui.List_View extends Efl.Ui.Layout_Base implements
11 Efl.Access.Widget.Action, Efl.Access.Selection,
12 Efl.Ui.Focus.Composition, Efl.Ui.Focus.Manager_Sub,
13 Efl.Ui.Container_Selectable, Efl.Ui.List_View_Model,
14 Efl.Ui.Widget_Focus_Manager
15 composites
16 Efl.Ui.Scrollable, Efl.Ui.Scrollbar
17{ 2{
18 methods { 3 [[A scrollable list of @Efl.Ui.Item objects, typically @Efl.Ui.List_Default_Item objects.
19 @property homogeneous {
20 [[When in homogeneous mode, all items have the same height and width.
21 Otherwise, each item's size is respected.
22 ]]
23 get {
24 }
25 set {
26 }
27 values {
28 homogeneous: bool; [[Homogeneous mode setting. Default is $false.]]
29 }
30 }
31 @property select_mode {
32 [[Listview select mode.]]
33 get {}
34 set {}
35 values {
36 mode: Elm.Object.Select_Mode(Elm.Object.Select_Mode.max); [[The select mode.]]
37 }
38 }
39 @property default_style {
40 [[TBD]] // TODO: This needs to be filled in. Does not seem to be in use.
41 values {
42 style: stringshare; [[TBD]]
43 }
44 }
45 @property layout_factory {
46 [[Listview layout factory set.]]
47 set {}
48 values {
49 factory: Efl.Ui.Factory; [[The factory.]]
50 }
51 }
52 }
53 events {
54 item,realized : Efl.Ui.List_View_Item_Event;
55 item,unrealized : Efl.Ui.List_View_Item_Event;
56 item,focused : Efl.Ui.List_View_Item_Event;
57 item,unfocused : Efl.Ui.List_View_Item_Event;
58 item,highlighted : Efl.Ui.List_View_Item_Event;
59 item,unhighlighted : Efl.Ui.List_View_Item_Event;
60 }
61 4
62 implements { 5 Items are added asynchronously by an @Efl.Ui.Factory from the definition of an @Efl.Model.
63 Efl.Object.constructor;
64 Efl.Object.finalize;
65 Efl.Object.destructor;
66 Efl.Gfx.Entity.position { set; }
67 Efl.Gfx.Entity.size { set; }
68 // Smart obj
69 Efl.Canvas.Group.group_member_add;
70 Efl.Canvas.Group.group_calculate;
71
72 Efl.Ui.List_View_Model.load_range { set;}
73 Efl.Ui.List_View_Model.realize;
74 Efl.Ui.List_View_Model.unrealize;
75 Efl.Ui.List_View_Model.model_size { get; }
76 Efl.Ui.List_View_Model.min_size { get; set; }
77 6
78 // Widget 7 The orientation (vertical or horizontal) of the list can be set with
79 Efl.Ui.Widget_Focus_Manager.focus_manager_create; 8 @Efl.Ui.Layout_Orientable.orientation.
80 Efl.Ui.Widget.widget_input_event_handler;
81 Efl.Ui.Widget.focus_state_apply;
82 Efl.Ui.Focus.Composition.prepare;
83 Efl.Ui.View.model { get; set; }
84 9
85 Efl.Layout.Signal.signal_callback_add; 10 Items inside this widget can be selected according to the @Efl.Ui.Multi_Selectable_Async.select_mode
86 Efl.Layout.Signal.signal_callback_del; 11 policy, and the selection can be retrieved with @Efl.Ui.Multi_Selectable_Async.selected_iterator_new.
87 Efl.Access.Object.access_children { get; } 12 ]]
88 Efl.Access.Selection.selected_children_count { get; } 13 data: null;
89 Efl.Access.Selection.selected_child { get; } 14 implements {
90 Efl.Access.Selection.selected_child_deselect; 15 Efl.Object.constructor;
91 Efl.Access.Selection.child_select;
92 Efl.Access.Selection.child_deselect;
93 Efl.Access.Selection.is_child_selected;
94 Efl.Access.Selection.all_children_select;
95 Efl.Access.Selection.access_selection_clear;
96 } 16 }
97} 17}
diff --git a/src/lib/elementary/efl_ui_list_view_model.eo b/src/lib/elementary/efl_ui_list_view_model.eo
deleted file mode 100644
index cf4780ed5f..0000000000
--- a/src/lib/elementary/efl_ui_list_view_model.eo
+++ /dev/null
@@ -1,41 +0,0 @@
1import efl_ui_list_view_types;
2
3interface @beta Efl.Ui.List_View_Model
4{
5 methods {
6 @property load_range {
7 set {}
8 values {
9 first: int;
10 count: int;
11 }
12 }
13 realize {
14 params {
15 item: ptr(Efl.Ui.List_View_Layout_Item);
16 }
17 return: ptr(Efl.Ui.List_View_Layout_Item);
18 }
19 unrealize {
20 params {
21 item: ptr(Efl.Ui.List_View_Layout_Item);
22 }
23 }
24 @property model_size {
25 get {}
26 values {
27 s: int;
28 }
29 }
30 @property min_size {
31 [[Minimal content size.]]
32 set {}
33 get {}
34 values {
35 min: Eina.Size2D;
36 }
37 }
38
39
40 }
41}
diff --git a/src/lib/elementary/efl_ui_list_view_pan.eo b/src/lib/elementary/efl_ui_list_view_pan.eo
deleted file mode 100644
index 1bd72a8300..0000000000
--- a/src/lib/elementary/efl_ui_list_view_pan.eo
+++ /dev/null
@@ -1,12 +0,0 @@
1class @beta Efl.Ui.List_View_Pan extends Efl.Ui.Pan
2{
3 [[Elementary Efl_Ui_List_View pan class]]
4 implements {
5 Efl.Object.destructor;
6 Efl.Ui.Pan.content_size { get; }
7 Efl.Ui.Pan.pan_position { get; set; }
8 Efl.Ui.Pan.pan_position_min { get; }
9 Efl.Ui.Pan.pan_position_max { get; }
10 Efl.Canvas.Group.group_calculate;
11 }
12}
diff --git a/src/lib/elementary/efl_ui_list_view_precise_layouter.c b/src/lib/elementary/efl_ui_list_view_precise_layouter.c
deleted file mode 100644
index a7ee6ec102..0000000000
--- a/src/lib/elementary/efl_ui_list_view_precise_layouter.c
+++ /dev/null
@@ -1,728 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include <assert.h>
8
9#include "elm_priv.h"
10#include "efl_ui_list_view_relayout.eo.h"
11#include "efl_ui_list_view_seg_array.h"
12
13#define MY_CLASS EFL_UI_LIST_VIEW_PRECISE_LAYOUTER_CLASS
14
15typedef struct _Efl_Ui_List_View_Precise_Layouter_Data
16{
17 Efl_Model* model;
18 Efl_Ui_List_View_Model *modeler;
19 Ecore_Job *calc_job;
20 Efl_Ui_List_View_Seg_Array *seg_array;
21
22 Eina_Size2D min;
23
24 unsigned int calc_progress;
25
26 int count_total;
27
28 Eina_Bool initialized : 1;
29 Eina_Bool recalc : 1;
30 Eina_Bool resize : 1;
31} Efl_Ui_List_View_Precise_Layouter_Data;
32
33typedef struct _Efl_Ui_List_View_Precise_Layouter_Node_Data
34{
35 Eina_Size2D min;
36 Eina_Size2D size;
37
38 Eina_Bool realized;
39} Efl_Ui_List_View_Precise_Layouter_Node_Data;
40
41typedef struct _Efl_Ui_List_View_Precise_Layouter_Callback_Data
42{
43 Efl_Ui_List_View_Precise_Layouter_Data *pd;
44 Efl_Ui_List_View_Layout_Item *item;
45} Efl_Ui_List_View_Precise_Layouter_Callback_Data;
46
47#include "efl_ui_list_view_precise_layouter.eo.h"
48
49static void _efl_ui_list_view_relayout_layout_do(Efl_Ui_List_View_Precise_Layouter_Data *);
50static Eina_Bool _initilize(Eo *, Efl_Ui_List_View_Precise_Layouter_Data*, Efl_Ui_List_View_Model*, Efl_Ui_List_View_Seg_Array*);
51static void _finalize(Eo *, Efl_Ui_List_View_Precise_Layouter_Data*);
52static void _node_realize(Efl_Ui_List_View_Precise_Layouter_Data*, Efl_Ui_List_View_Seg_Array_Node*);
53static void _node_unrealize(Efl_Ui_List_View_Precise_Layouter_Data*, Efl_Ui_List_View_Seg_Array_Node*);
54
55static void
56_item_size_calc(Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Layout_Item* item)
57{
58 int boxx, boxy, boxw, boxh, boxl, boxr, boxt, boxb, pad[4];
59 double align[2];
60 Eina_Bool fill[2];
61 Eina_Size2D max;
62
63 efl_gfx_hint_margin_get(item->layout, &pad[0], &pad[1], &pad[2], &pad[3]);
64 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh);
65 efl_gfx_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb);
66 efl_gfx_hint_align_get(item->layout, &align[0], &align[1]);
67 efl_gfx_hint_fill_get(item->layout, &fill[0], &fill[1]);
68 max = efl_gfx_hint_size_combined_max_get(item->layout);
69
70 // box outer margin
71 boxw -= boxl + boxr;
72 boxh -= boxt + boxb;
73 boxx += boxl;
74 boxy += boxt;
75
76 if (EINA_DBL_EQ(align[0], -1))
77 {
78 align[0] = 0.5;
79 fill[0] = EINA_TRUE;
80 }
81 else if (align[0] < 0)
82 {
83 align[0] = 0;
84 }
85 if (EINA_DBL_EQ(align[1], -1))
86 {
87 align[1] = 0.5;
88 fill[1] = EINA_TRUE;
89 }
90 else if (align[1] < 0)
91 {
92 align[1] = 0;
93 }
94
95 if (align[0] > 1) align[0] = 1;
96 if (align[1] > 1) align[1] = 1;
97
98 if (max.w <= 0) max.w = INT_MAX;
99 if (max.h <= 0) max.h = INT_MAX;
100 if (max.w < item->min.w) max.w = item->min.w;
101 if (max.h < item->min.h) max.h = item->min.h;
102
103 // horizontally
104 if (max.w < INT_MAX)
105 {
106 item->size.w = MIN(MAX(item->min.w - pad[0] - pad[1], max.w), boxw);
107 item->pos.x = boxx + pad[0];
108 }
109 else if (fill[0])
110 {
111 // fill x
112 item->size.w = boxw - pad[0] - pad[1];
113 item->pos.x = boxx + pad[0];
114 }
115 else
116 {
117 item->size.w = item->min.w - pad[0] - pad[1];
118 item->pos.x = boxx + ((boxw - item->size.w) * align[0]) + pad[0];
119 }
120
121 // vertically
122 if (max.h < INT_MAX)
123 {
124 item->size.h = MIN(MAX(item->min.h - pad[2] - pad[3], max.h), boxh);
125 item->pos.y = boxy + pad[2];
126 }
127 else if (fill[1])
128 {
129 // fill y
130 item->size.h = item->min.h - pad[2] - pad[3];
131 item->pos.y = boxy + pad[2];
132 }
133 else
134 {
135 item->size.h = item->min.h - pad[2] - pad[3];
136 item->pos.y = boxy + ((item->min.h - item->size.h) * align[1]) + pad[2];
137 }
138}
139
140static Eina_Size2D
141_item_min_calc(Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Layout_Item* item)
142{
143 Efl_Ui_List_View_Seg_Array_Node *itemnode = item->tree_node;
144 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata;
145 Efl_Ui_List_View_Layout_Item *layout_item;
146 int i, pad[4];
147
148 Eina_Size2D min = efl_gfx_hint_size_combined_min_get(item->layout);
149
150 efl_gfx_hint_margin_get(item->layout, &pad[0], &pad[1], &pad[2], &pad[3]);
151 min.w += pad[0] + pad[1];
152 min.h += pad[2] + pad[3];
153
154 if (item->min.h == min.h && item->min.w == min.w)
155 return min;
156
157 EINA_SAFETY_ON_NULL_RETURN_VAL(itemnode, min);
158 EINA_SAFETY_ON_NULL_RETURN_VAL(itemnode->layout_data, min);
159 nodedata = itemnode->layout_data;
160
161 pd->min.h += min.h - item->min.h;
162 nodedata->min.h += min.h - item->min.h;
163
164 if (nodedata->min.w <= min.w)
165 nodedata->min.w = min.w;
166 else if (nodedata->min.w == item->min.w)
167 {
168 nodedata->min.w = 0;
169 for (i = 0; i != itemnode->length; ++i)
170 {
171 layout_item = (Efl_Ui_List_View_Layout_Item *)itemnode->pointers[i];
172 if (nodedata->min.w < layout_item->min.w)
173 nodedata->min.w = layout_item->min.w;
174
175 if (item->min.w == layout_item->min.w)
176 break;
177 }
178 }
179
180 if (pd->min.w <= min.w)
181 pd->min.w = min.w;
182 else if (pd->min.w == item->min.w)
183 {
184 Efl_Ui_List_View_Seg_Array_Node *node2;
185 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
186 pd->min.w = min.w;
187
188 EINA_ACCESSOR_FOREACH(nodes, i, node2)
189 {
190 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata2 = node2->layout_data;
191 if (pd->min.w < nodedata2->min.w)
192 pd->min.w = nodedata2->min.w;
193
194 if (item->min.w == nodedata2->min.w)
195 break;
196 }
197 eina_accessor_free(nodes);
198 }
199
200 item->min.w = min.w;
201 item->min.h = min.h;
202 return item->min;
203}
204
205static void
206_on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
207 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
208{
209 Efl_Ui_List_View_Precise_Layouter_Callback_Data *cb_data = data;
210 Efl_Ui_List_View_Precise_Layouter_Data *pd = cb_data->pd;
211 Efl_Ui_List_View_Layout_Item *item = cb_data->item;;
212 Efl_Ui_List_View_Seg_Array_Node *node = item->tree_node;
213 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = node->layout_data;
214
215 _item_min_calc(pd, item);
216 if (!nodedata->realized)
217 {
218 free(evas_object_event_callback_del(item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change));
219 efl_ui_list_view_model_unrealize(pd->modeler, item);
220 }
221}
222
223static void
224_on_modeler_resize(void *data, Evas *e EINA_UNUSED,
225 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
226{
227 Efl_Ui_List_View_Precise_Layouter_Data *pd = data;
228 pd->resize = EINA_TRUE;
229}
230
231typedef struct _Request Request;
232struct _Request
233{
234 Efl_Ui_List_View_Precise_Layouter_Data *pd;
235 unsigned int index;
236};
237
238static Eina_Value
239_children_get(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
240{
241 Request *r = data;
242
243 if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR)
244 goto on_error;
245
246 efl_ui_list_view_seg_array_insert_value(r->pd->seg_array, r->index, v);
247 r->pd->recalc = EINA_TRUE;
248 evas_object_smart_changed(r->pd->modeler);
249
250 on_error:
251 free(r);
252 return v;
253}
254
255static void
256_child_added_cb(void *data, const Efl_Event *event)
257{
258 Efl_Model_Children_Event* evt = event->info;
259 Efl_Ui_List_View_Precise_Layouter_Data *pd = data;
260 Eina_Future *f;
261 Request *r;
262
263 r = calloc(1, sizeof (Request));
264 if (!r) return;
265
266 r->index = evt->index;
267 r->pd = pd;
268
269 f = efl_model_children_slice_get(pd->model, evt->index, 1);
270 f = eina_future_then(f, _children_get, r, NULL);
271}
272
273static void
274_child_removed_cb(void *data, const Efl_Event *event)
275{
276 Efl_Model_Children_Event* evt = event->info;
277 Efl_Ui_List_View_Precise_Layouter_Data *pd = data;
278 Efl_Ui_List_View_Layout_Item *layout_item, *litem;
279 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata;
280 Efl_Ui_List_View_Seg_Array_Node *itemnode;
281 int i;
282
283 litem = efl_ui_list_view_seg_array_remove(pd->seg_array, evt->index);
284 if (!litem) return;
285
286 itemnode = litem->tree_node;
287 nodedata = itemnode->layout_data;
288
289 free(evas_object_event_callback_del(litem->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change));
290
291 pd->min.h -= litem->min.h;
292 nodedata->min.h -= litem->min.h;
293
294 if (nodedata->min.w == litem->min.w)
295 nodedata->min.w = 0;
296
297 for (i = 0; i != itemnode->length; ++i)
298 {
299 layout_item = (Efl_Ui_List_View_Layout_Item *)itemnode->pointers[i];
300 if (nodedata->min.w < layout_item->min.w)
301 nodedata->min.w = layout_item->min.w;
302
303 if (litem->min.w == layout_item->min.w)
304 {
305 nodedata->min.w = layout_item->min.w;
306 break;
307 }
308 }
309
310 if (pd->min.w == litem->min.w)
311 {
312 Efl_Ui_List_View_Seg_Array_Node *node2;
313 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
314 pd->min.w = 0;
315
316 EINA_ACCESSOR_FOREACH(nodes, i, node2)
317 {
318 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata2 = node2->layout_data;
319 if (pd->min.w < nodedata2->min.w)
320 pd->min.w = nodedata2->min.w;
321
322 if (litem->min.w == nodedata2->min.w)
323 break;
324 }
325 eina_accessor_free(nodes);
326 }
327 efl_ui_list_view_model_unrealize(pd->modeler, litem);
328
329 free(litem);
330 pd->recalc = EINA_TRUE;
331 evas_object_smart_changed(pd->modeler);
332}
333
334static void
335_child_count_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
336{
337 Efl_Ui_List_View_Precise_Layouter_Data *pd = data;
338 pd->count_total = efl_model_children_count_get(pd->model);
339 if (pd->count_total)
340 efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _child_count_changed_cb, pd);
341}
342
343static Eina_Bool
344_initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Model *modeler, Efl_Ui_List_View_Seg_Array *seg_array)
345{
346 if(pd->initialized)
347 return EINA_TRUE;
348
349 efl_replace(&pd->modeler, modeler);
350
351 if(!pd->model || !pd->modeler)
352 return EINA_FALSE;
353
354 pd->recalc = EINA_TRUE;
355 pd->initialized = EINA_TRUE;
356
357 pd->seg_array = seg_array;
358
359 efl_ui_list_view_model_load_range_set(pd->modeler, 0, pd->count_total); // load all
360 efl_event_callback_add(pd->model, EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb, pd);
361 efl_event_callback_add(pd->model, EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb, pd);
362
363 evas_object_event_callback_add(modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd);
364 pd->min.w = 0;
365 pd->min.h = 0;
366
367 return EINA_TRUE;
368}
369
370static void
371_finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Precise_Layouter_Data *pd)
372{
373 Efl_Ui_List_View_Seg_Array_Node* node;
374 int i = 0;
375
376 if (pd->model)
377 {
378 efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb, pd);
379 efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb, pd);
380 pd->count_total = 0;
381 }
382
383 if (pd->seg_array)
384 {
385 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
386 EINA_ACCESSOR_FOREACH(nodes, i, node)
387 {
388 _node_unrealize(pd, node);
389 free(node->layout_data);
390 }
391
392 eina_accessor_free(nodes);
393 }
394
395 pd->min.w = 0;
396 pd->min.h = 0;
397
398 if (pd->modeler)
399 {
400 evas_object_event_callback_del_full(pd->modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd);
401 efl_ui_list_view_model_min_size_set(pd->modeler, pd->min);
402 }
403
404 pd->seg_array = NULL;
405 efl_replace(&pd->modeler, NULL);
406
407 pd->initialized = EINA_FALSE;
408 pd->recalc = EINA_TRUE;
409}
410
411static void
412_node_realize(Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Seg_Array_Node *node)
413{
414 Efl_Ui_List_View_Layout_Item* layout_item;
415 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = node->layout_data;
416 int i;
417
418 EINA_SAFETY_ON_NULL_RETURN(nodedata);
419 if (nodedata->realized)
420 return;
421
422 nodedata->realized = EINA_TRUE;
423
424 for (i = 0; i != node->length; ++i)
425 {
426 layout_item = (Efl_Ui_List_View_Layout_Item *)node->pointers[i];
427 efl_ui_list_view_model_realize(pd->modeler, layout_item);
428 }
429}
430
431static void
432_node_unrealize(Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Seg_Array_Node *node)
433{
434 Efl_Ui_List_View_Layout_Item* layout_item;
435 Efl_Ui_List_View_Precise_Layouter_Callback_Data *cb_data;
436 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = node->layout_data;
437 int i;
438
439 EINA_SAFETY_ON_NULL_RETURN(nodedata);
440 if (!nodedata->realized)
441 return;
442
443 nodedata->realized = EINA_FALSE;
444
445 for (i = 0; i != node->length; ++i)
446 {
447 layout_item = (Efl_Ui_List_View_Layout_Item *)node->pointers[i];
448 if (layout_item->layout)
449 {
450 cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
451 free(cb_data);
452 efl_ui_list_view_model_unrealize(pd->modeler, layout_item);
453 }
454 }
455}
456
457static void
458_calc_range(Efl_Ui_List_View_Precise_Layouter_Data *pd)
459{
460 Efl_Ui_List_View_Seg_Array_Node *node;
461 Evas_Coord ch, ny;
462 Eina_Rect vgmt;
463 Eina_Position2D spos;
464 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata;
465 int i;
466
467 vgmt = efl_ui_scrollable_viewport_geometry_get(pd->modeler);
468 spos = efl_ui_scrollable_content_pos_get(pd->modeler);
469
470 ny = spos.y - (vgmt.h / 2);
471 if (ny < 0) spos.y = 0;
472 else spos.y = ny;
473 vgmt.h *= 2;
474
475 ch = 0;
476 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
477 EINA_ACCESSOR_FOREACH(nodes, i, node)
478 {
479 nodedata = node->layout_data;
480 if (!nodedata || !nodedata->min.h)
481 continue;
482
483 if ((ch > spos.y || nodedata->min.h + ch > spos.y) && (ch < (spos.y + vgmt.h) || nodedata->min.h + ch < spos.y + vgmt.h))
484 _node_realize(pd, node);
485 else
486 _node_unrealize(pd, node);
487
488 ch += nodedata->min.h;
489 }
490 eina_accessor_free(nodes);
491}
492
493static void
494_calc_size_job(void *data)
495{
496 Efl_Ui_List_View_Precise_Layouter_Data *pd;
497 Efl_Ui_List_View_Seg_Array_Node *node;
498 Efl_Ui_List_View_Layout_Item *layout_item;
499 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata;
500 Eo *obj = data;
501 int i;
502 double start_time = ecore_time_get();
503
504 EINA_SAFETY_ON_NULL_RETURN(data);
505 pd = efl_data_scope_get(obj, MY_CLASS);
506 if (EINA_UNLIKELY(!pd)) return;
507
508 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
509 while (eina_accessor_data_get(nodes, pd->calc_progress, (void **)&node))
510 {
511 pd->calc_progress++;
512 if (!node->layout_data)
513 node->layout_data = calloc(1, sizeof(Efl_Ui_List_View_Precise_Layouter_Node_Data));
514
515 nodedata = node->layout_data;
516 if (pd->calc_progress == 1)
517 nodedata->realized = EINA_TRUE;
518
519 for (i = 0; i != node->length; ++i)
520 {
521 layout_item = (Efl_Ui_List_View_Layout_Item *)node->pointers[i];
522 EINA_SAFETY_ON_NULL_RETURN(layout_item);
523
524 // cache size of new items
525 if ((layout_item->min.w == 0) && (layout_item->min.h == 0) && (!layout_item->layout))
526 efl_ui_list_view_model_realize(pd->modeler, layout_item);
527 }
528
529 if ( (ecore_time_get() - start_time ) > 0.01 )
530 {
531 ecore_job_del(pd->calc_job);
532 pd->calc_job = ecore_job_add(_calc_size_job, obj);
533 eina_accessor_free(nodes);
534 return;
535 }
536 }
537 eina_accessor_free(nodes);
538 pd->calc_progress = 0;
539 pd->calc_job = NULL;
540 pd->recalc = EINA_FALSE;
541}
542
543EOLIAN static Efl_Object *
544_efl_ui_list_view_precise_layouter_efl_object_constructor(Eo *obj, Efl_Ui_List_View_Precise_Layouter_Data *pd)
545{
546 obj = efl_constructor(efl_super(obj, MY_CLASS));
547 pd->initialized = EINA_FALSE;
548
549 return obj;
550}
551
552EOLIAN static void
553_efl_ui_list_view_precise_layouter_efl_ui_list_view_relayout_content_created(Eo *obj EINA_UNUSED, Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Ui_List_View_Layout_Item *item)
554{
555 Efl_Ui_List_View_Precise_Layouter_Callback_Data *cb_data;
556 EINA_SAFETY_ON_NULL_RETURN(item);
557 EINA_SAFETY_ON_NULL_RETURN(item->layout);
558 Efl_Ui_List_View_Seg_Array_Node *node = item->tree_node;
559 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = node->layout_data;
560
561 Eina_Size2D min = _item_min_calc(pd, item);
562
563 if (min.w && min.h && !nodedata->realized)
564 {
565 efl_ui_list_view_model_unrealize(pd->modeler, item);
566 return;
567 }
568
569 cb_data = calloc(1, sizeof(Efl_Ui_List_View_Precise_Layouter_Callback_Data));
570 if (!cb_data) return;
571 cb_data->pd = pd;
572 cb_data->item = item;
573 evas_object_event_callback_add(item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
574
575 _item_size_calc(pd, item);
576}
577
578EOLIAN static Eina_List *
579_efl_ui_list_view_precise_layouter_efl_ui_list_view_relayout_elements_get(const Eo *obj EINA_UNUSED, Efl_Ui_List_View_Precise_Layouter_Data *pd)
580{
581 Eina_List *elements_order = NULL;
582 Efl_Ui_List_View_Layout_Item* layout_item;
583 Efl_Ui_List_View_Seg_Array_Node *items_node;
584 int i, j = 0;
585
586 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
587 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
588 {
589 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
590 if (!nodedata || !nodedata->realized)
591 continue;
592
593 for (j = 0; j != items_node->length;++j)
594 {
595 layout_item = (Efl_Ui_List_View_Layout_Item *)items_node->pointers[j];
596 if (layout_item->layout)
597 elements_order = eina_list_append(elements_order, layout_item->layout);
598 }
599 }
600
601 eina_accessor_free(nodes);
602 return elements_order;
603}
604
605EOLIAN static void
606_efl_ui_list_view_precise_layouter_efl_ui_list_view_relayout_model_set(Eo *obj, Efl_Ui_List_View_Precise_Layouter_Data *pd, Efl_Model *model)
607{
608 _finalize(obj, pd);
609
610 efl_replace(&pd->model, model);
611
612 if (pd->model)
613 {
614 pd->count_total = efl_model_children_count_get(pd->model);
615 if (pd->count_total && pd->modeler)
616 efl_ui_list_view_model_load_range_set(pd->modeler, 0, pd->count_total); // load all
617 else
618 efl_event_callback_add(pd->model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _child_count_changed_cb, pd);
619 }
620}
621
622static void
623_efl_ui_list_view_relayout_layout_do(Efl_Ui_List_View_Precise_Layouter_Data *pd)
624{
625 Eina_Rect vgmt;
626 Eina_Position2D spos;
627 double cur_pos = 0;
628 Efl_Ui_List_View_Layout_Item* layout_item;
629 Efl_Ui_List_View_Seg_Array_Node *items_node;
630 int i, j = 0;
631 int boxx, boxy, boxw, boxh, extra = 0, rounding = 0;
632 int boxl = 0, boxr = 0, boxt = 0, boxb = 0;
633
634 _calc_range(pd);
635
636 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh);
637 efl_gfx_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb);
638
639 // box outer margin
640 boxw -= boxl + boxr;
641 boxh -= boxt + boxb;
642 boxx += boxl;
643 boxy += boxt;
644
645 // available space. if <0 we overflow
646 extra = boxh - pd->min.h;
647 if (extra < 0) extra = 0;
648
649 efl_ui_list_view_model_min_size_set(pd->modeler, pd->min);
650
651 vgmt = efl_ui_scrollable_viewport_geometry_get(pd->modeler);
652 spos = efl_ui_scrollable_content_pos_get(pd->modeler);
653
654 Eina_Accessor *nodes = efl_ui_list_view_seg_array_node_accessor_get(pd->seg_array);
655 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
656 {
657 Efl_Ui_List_View_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
658 if (!items_node->layout_data)
659 continue;
660
661 if (!nodedata->realized)
662 {
663 cur_pos += nodedata->min.h;
664 continue;
665 }
666
667 for (j = 0; j != items_node->length;++j)
668 {
669 layout_item = (Efl_Ui_List_View_Layout_Item *)items_node->pointers[j];
670 double x, y, w, h;
671 double weight_x, weight_y;
672 if (!(layout_item->min.w && layout_item->min.h))
673 continue;
674
675 // extra rounding up (compensate cumulative error)
676 if ((i == (pd->count_total - 1)) && (cur_pos - floor(cur_pos) >= 0.5))
677 rounding = 1;
678
679 if (layout_item->layout)
680 {
681 if (pd->resize)
682 _item_size_calc(pd, layout_item);
683
684 efl_gfx_hint_weight_get(layout_item->layout, &weight_x, &weight_y);
685 }
686 else
687 {
688 cur_pos += layout_item->size.h;
689 continue;
690 }
691
692 x = layout_item->pos.x;
693 y = layout_item->pos.y + cur_pos;
694 w = layout_item->size.w;
695 h = layout_item->size.h + rounding + weight_y * extra;
696 cur_pos += h;
697
698 if (w < pd->min.w) w = pd->min.w;
699 if (w > vgmt.w) w = vgmt.w;
700
701 evas_object_geometry_set(layout_item->layout, (x + 0 - spos.x), (y + 0 - spos.y), w, h);
702 }
703 }
704 eina_accessor_free(nodes);
705
706 pd->resize = EINA_FALSE;
707}
708
709EOLIAN static void
710_efl_ui_list_view_precise_layouter_efl_ui_list_view_relayout_layout_do
711 (Eo *obj EINA_UNUSED, Efl_Ui_List_View_Precise_Layouter_Data *pd
712 , Efl_Ui_List_View_Model *modeler, int first EINA_UNUSED, Efl_Ui_List_View_Seg_Array *seg_array)
713{
714 if (!_initilize(obj, pd, modeler, seg_array) || !pd->seg_array)
715 return;
716
717 if (!pd->calc_job && pd->recalc && efl_ui_list_view_seg_array_count(seg_array) > 0)
718 {
719 // cache size of new items
720 pd->calc_progress = 0;
721 pd->calc_job = ecore_job_add(_calc_size_job, obj);
722 return;
723 }
724
725 _efl_ui_list_view_relayout_layout_do(pd);
726}
727
728#include "efl_ui_list_view_precise_layouter.eo.c"
diff --git a/src/lib/elementary/efl_ui_list_view_precise_layouter.eo b/src/lib/elementary/efl_ui_list_view_precise_layouter.eo
deleted file mode 100644
index 0a83c0a08b..0000000000
--- a/src/lib/elementary/efl_ui_list_view_precise_layouter.eo
+++ /dev/null
@@ -1,10 +0,0 @@
1class @beta Efl.Ui.List_View_Precise_Layouter extends Efl.Object implements Efl.Ui.List_View_Relayout
2{
3 implements {
4 Efl.Object.constructor;
5 Efl.Ui.List_View_Relayout.layout_do;
6 Efl.Ui.List_View_Relayout.content_created;
7 Efl.Ui.List_View_Relayout.model { set; }
8 Efl.Ui.List_View_Relayout.elements { get; }
9 }
10}
diff --git a/src/lib/elementary/efl_ui_list_view_private.h b/src/lib/elementary/efl_ui_list_view_private.h
deleted file mode 100644
index 2443cf4438..0000000000
--- a/src/lib/elementary/efl_ui_list_view_private.h
+++ /dev/null
@@ -1,78 +0,0 @@
1#ifndef EFL_UI_LIST_VIEW_PRIVATE_H
2#define EFL_UI_LIST_VIEW_PRIVATE_H
3
4#ifdef HAVE_CONFIG_H
5# include "elementary_config.h"
6#endif
7
8#include <Elementary.h>
9#include "efl_ui_list_view_relayout.eo.h"
10#include "efl_ui_list_view_pan.eo.h"
11#include "elm_priv.h"
12
13typedef struct _Efl_Ui_List_View_Data Efl_Ui_List_View_Data;
14int efl_ui_list_view_item_index_get(Efl_Ui_List_View_Layout_Item *item);
15
16#include "efl_ui_list_view_seg_array.h"
17
18struct _Efl_Ui_List_View_Data
19{
20 Eo *obj;
21 Eo *scrl_mgr;
22 Efl_Ui_List_View_Pan *pan_obj;
23 Efl_Model *model;
24
25 Eina_Stringshare *style;
26
27 struct {
28 Eina_Future *future;
29
30 int start;
31 int count;
32 } slice;
33
34 Efl_Ui_Layout_Factory *factory;
35 Eina_List *selected_items;
36
37 Efl_Ui_Focus_Manager *manager;
38 Efl_Ui_List_View_Relayout *relayout;
39 Efl_Ui_List_View_Seg_Array *seg_array;
40 int seg_array_first;
41
42 Elm_Object_Select_Mode select_mode;
43 Eina_Size2D min;
44
45 Eina_Bool homogeneous : 1;
46 Eina_Bool scrl_freeze : 1;
47};
48
49typedef struct _Efl_Ui_List_View_Pan_Data Efl_Ui_List_View_Pan_Data;
50
51struct _Efl_Ui_List_View_Pan_Data
52{
53 Eo *wobj;
54 Eina_Rect gmt;
55};
56
57#define EFL_UI_LIST_VIEW_DATA_GET(o, ptr) \
58 Efl_Ui_List_View_Data * ptr = efl_data_scope_get(o, EFL_UI_LIST_VIEW_CLASS)
59
60#define EFL_UI_LIST_VIEW_DATA_GET_OR_RETURN(o, ptr) \
61 EFL_UI_LIST_VIEW_DATA_GET(o, ptr); \
62 if (EINA_UNLIKELY(!ptr)) \
63 { \
64 ERR("No widget data for object %p (%s)", \
65 o, evas_object_type_get(o)); \
66 return; \
67 }
68
69#define EFL_UI_LIST_VIEW_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
70 EFL_UI_LIST_VIEW_DATA_GET(o, ptr); \
71 if (EINA_UNLIKELY(!ptr)) \
72 { \
73 ERR("No widget data for object %p (%s)", \
74 o, evas_object_type_get(o)); \
75 return val; \
76 }
77
78#endif
diff --git a/src/lib/elementary/efl_ui_list_view_relayout.eo b/src/lib/elementary/efl_ui_list_view_relayout.eo
deleted file mode 100644
index 07b5dc65bb..0000000000
--- a/src/lib/elementary/efl_ui_list_view_relayout.eo
+++ /dev/null
@@ -1,30 +0,0 @@
1interface @beta Efl.Ui.List_View_Relayout
2{
3 methods {
4 layout_do {
5 params {
6 modeler: Efl.Ui.List_View_Model;
7 first: int;
8 children: ptr(Efl_Ui_List_View_Seg_Array);
9 }
10 }
11 content_created {
12 params {
13 item: ptr(Efl.Ui.List_View_Layout_Item);
14 }
15 }
16 @property model {
17 [[Model that is/will be ]]
18 set {}
19 values {
20 model: Efl.Model; [[Efl model]]
21 }
22 }
23 @property elements {
24 get {}
25 values {
26 elements: list<Efl.Gfx.Entity>; [[The order to use]]
27 }
28 }
29 }
30}
diff --git a/src/lib/elementary/efl_ui_list_view_seg_array.c b/src/lib/elementary/efl_ui_list_view_seg_array.c
deleted file mode 100644
index 50f33b340b..0000000000
--- a/src/lib/elementary/efl_ui_list_view_seg_array.c
+++ /dev/null
@@ -1,477 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include "elm_priv.h"
6#include <assert.h>
7
8#include "efl_ui_list_view_private.h"
9#include "efl_ui_list_view_seg_array.h"
10
11static int
12_search_lookup_cb(Eina_Rbtree const* rbtree, const void* key, int length EINA_UNUSED, void* data EINA_UNUSED)
13{
14 Efl_Ui_List_View_Seg_Array_Node const* node = (void const*)rbtree;
15 int index = *(int*)key;
16 if(index < node->first)
17 {
18 return 1;
19 }
20 else if(index < node->first + node->length)
21 {
22 return 0;
23 }
24 else
25 {
26 return -1;
27 }
28}
29
30static int
31_insert_lookup_cb(Eina_Rbtree const* rbtree, const void* key, int length EINA_UNUSED, void* data EINA_UNUSED)
32{
33 Efl_Ui_List_View_Seg_Array_Node const* node = (void const*)rbtree;
34 int index = *(int*)key;
35 if(index < node->first)
36 {
37 return 1;
38 }
39 else if(index < node->first + node->max)
40 {
41 return 0;
42 }
43 else
44 {
45 return -1;
46 }
47}
48
49static Eina_Rbtree_Direction
50_rbtree_compare(Efl_Ui_List_View_Seg_Array_Node const* left,
51 Efl_Ui_List_View_Seg_Array_Node const* right, void* data EINA_UNUSED)
52{
53 if(left->first < right->first)
54 return EINA_RBTREE_LEFT;
55 else
56 return EINA_RBTREE_RIGHT;
57}
58
59static void
60_free_node(Efl_Ui_List_View_Seg_Array_Node* node, void* data EINA_UNUSED)
61{
62 int i = 0;
63
64 while (i < node->length)
65 {
66 Efl_Ui_List_View_Layout_Item* item = node->pointers[i];
67 efl_unref(item->children);
68 free(item);
69 ++i;
70 }
71
72 free(node);
73}
74
75static Efl_Ui_List_View_Seg_Array_Node*
76_alloc_node(Efl_Ui_List_View_Seg_Array* pd, int first)
77{
78 Efl_Ui_List_View_Seg_Array_Node* node;
79 node = calloc(1, sizeof(Efl_Ui_List_View_Seg_Array_Node) + pd->step_size*sizeof(Efl_Ui_List_View_Layout_Item*));
80 if (!node) return NULL;
81 node->first = first;
82 node->max = pd->step_size;
83 pd->root = (void*)eina_rbtree_inline_insert(EINA_RBTREE_GET(pd->root), EINA_RBTREE_GET(node),
84 EINA_RBTREE_CMP_NODE_CB(&_rbtree_compare), NULL);
85 pd->node_count++;
86 return node;
87}
88
89static Efl_Ui_List_View_Layout_Item*
90_create_item_partial(Efl_Model* model)
91{
92 Efl_Ui_List_View_Layout_Item* item = calloc(1, sizeof(Efl_Ui_List_View_Layout_Item));
93 if (!item) return NULL;
94 item->children = efl_ref(model);
95 return item;
96}
97
98static Efl_Ui_List_View_Layout_Item*
99_create_item(Efl_Model* model, Efl_Ui_List_View_Seg_Array_Node* node, unsigned int index)
100{
101 Efl_Ui_List_View_Layout_Item* item = _create_item_partial(model);
102 item->index_offset = index - node->first;
103 item->tree_node = node;
104 return item;
105}
106
107static void
108_efl_ui_list_view_seg_array_insert_at_node(Efl_Ui_List_View_Seg_Array* pd, int index,
109 Efl_Ui_List_View_Layout_Item* item, Efl_Ui_List_View_Seg_Array_Node* node)
110{
111 Eina_Iterator* iterator;
112 int pos;
113
114 if(node && node->length != node->max && (index - node->first) <= node->length)
115 {
116 pos = index - node->first;
117 item->tree_node = node;
118 item->index_offset = pos;
119 if(pos < node->length)
120 {
121 assert(node->length != node->max);
122
123 memmove(&node->pointers[pos], &node->pointers[pos+1], sizeof(node->pointers[pos])*(node->length - pos));
124 node->pointers[pos] = item;
125 node->length++;
126 }
127 else
128 {
129 assert(pos == node->length);
130
131 assert(node->length != node->max);
132 node->pointers[pos] = item;
133 node->length++;
134 }
135 }
136 else
137 {
138 node = _alloc_node(pd, index);
139 node->pointers[0] = item;
140 node->length++;
141 item->index_offset = 0;
142 item->tree_node = node;
143 }
144
145 node = (void*)EINA_RBTREE_GET(node)->son[EINA_RBTREE_LEFT];
146 iterator = eina_rbtree_iterator_infix((void*)node);
147 while(eina_iterator_next(iterator, (void**)&node))
148 {
149 node->first++;
150 }
151
152 eina_iterator_free(iterator);
153}
154
155static void
156_efl_ui_list_view_seg_array_insert_object(Efl_Ui_List_View_Seg_Array *pd, unsigned int index, Efl_Model *children)
157{
158 Efl_Ui_List_View_Seg_Array_Node *node;
159
160 node = (void*)eina_rbtree_inline_lookup(EINA_RBTREE_GET(pd->root),
161 &index, sizeof(index), &_insert_lookup_cb, NULL);
162 if (!node)
163 {
164 node = _alloc_node(pd, index);
165 }
166
167 assert(node->length < node->max);
168 node->pointers[node->length] = _create_item(children, node, index);
169 node->length++;
170 pd->count++;
171}
172
173typedef struct _Efl_Ui_List_View_Segarray_Eina_Accessor
174{
175 Eina_Accessor vtable;
176 Efl_Ui_List_View_Seg_Array* seg_array;
177} Efl_Ui_List_View_Segarray_Eina_Accessor;
178
179static Eina_Bool
180_efl_ui_list_view_seg_array_accessor_get_at(Efl_Ui_List_View_Segarray_Eina_Accessor* acc,
181 int idx, void** data)
182{
183 Efl_Ui_List_View_Seg_Array_Node* node;
184 node = (void*)eina_rbtree_inline_lookup(EINA_RBTREE_GET(acc->seg_array->root),
185 &idx, sizeof(idx), &_search_lookup_cb, NULL);
186 if (node && (node->first <= idx && node->first + node->length > idx))
187 {
188 int i = idx - node->first;
189 Efl_Ui_List_View_Layout_Item* item = node->pointers[i];
190 *data = item;
191 return EINA_TRUE;
192 }
193 return EINA_FALSE;
194}
195
196static void*
197_efl_ui_list_view_seg_array_accessor_get_container(Efl_Ui_List_View_Segarray_Eina_Accessor* acc EINA_UNUSED)
198{
199 return NULL;
200}
201
202static void
203_efl_ui_list_view_seg_array_accessor_free(Efl_Ui_List_View_Segarray_Eina_Accessor* acc EINA_UNUSED)
204{
205 free(acc);
206}
207
208static Eina_Bool
209_efl_ui_list_view_seg_array_accessor_lock(Efl_Ui_List_View_Segarray_Eina_Accessor* acc EINA_UNUSED)
210{
211 return EINA_FALSE;
212}
213
214static Eina_Bool
215_efl_ui_list_view_seg_array_accessor_unlock(Efl_Ui_List_View_Segarray_Eina_Accessor* acc EINA_UNUSED)
216{
217 return EINA_FALSE;
218}
219
220static Eina_Accessor*
221_efl_ui_list_view_seg_array_accessor_clone(Efl_Ui_List_View_Segarray_Eina_Accessor* acc EINA_UNUSED)
222{
223 return &acc->vtable;
224}
225
226static void
227_efl_ui_list_view_seg_array_accessor_setup(Efl_Ui_List_View_Segarray_Eina_Accessor* acc, Efl_Ui_List_View_Seg_Array* seg_array)
228{
229 EINA_MAGIC_SET(&acc->vtable, EINA_MAGIC_ACCESSOR);
230 acc->vtable.version = EINA_ACCESSOR_VERSION;
231 acc->vtable.get_at = FUNC_ACCESSOR_GET_AT(_efl_ui_list_view_seg_array_accessor_get_at);
232 acc->vtable.get_container = FUNC_ACCESSOR_GET_CONTAINER(_efl_ui_list_view_seg_array_accessor_get_container);
233 acc->vtable.free = FUNC_ACCESSOR_FREE(_efl_ui_list_view_seg_array_accessor_free);
234 acc->vtable.lock = FUNC_ACCESSOR_LOCK(_efl_ui_list_view_seg_array_accessor_lock);
235 acc->vtable.unlock = FUNC_ACCESSOR_LOCK(_efl_ui_list_view_seg_array_accessor_unlock);
236 acc->vtable.clone = FUNC_ACCESSOR_CLONE(_efl_ui_list_view_seg_array_accessor_clone);
237 acc->seg_array = seg_array;
238}
239
240typedef struct _Efl_Ui_List_View_Segarray_Node_Accessor
241{
242 Eina_Accessor vtable;
243 Efl_Ui_List_View_Seg_Array* seg_array;
244 Eina_Iterator* pre_iterator;
245 Efl_Ui_List_View_Seg_Array_Node* current_node;
246 int current_index;
247} Efl_Ui_List_View_Segarray_Node_Accessor;
248
249static Eina_Bool
250_efl_ui_list_view_seg_array_node_accessor_get_at(Efl_Ui_List_View_Segarray_Node_Accessor* acc,
251 int idx, void** data)
252{
253 if(idx == acc->current_index && acc->current_node)
254 {
255 (*data) = acc->current_node;
256 }
257 else
258 {
259 if(acc->current_index >= idx || !acc->current_node)
260 {
261 eina_iterator_free(acc->pre_iterator);
262 acc->pre_iterator = NULL;
263 acc->current_node = NULL;
264 acc->current_index = -1;
265 }
266
267 if(!acc->pre_iterator)
268 acc->pre_iterator = eina_rbtree_iterator_infix((void*)acc->seg_array->root);
269
270 for(;acc->current_index != idx;++acc->current_index)
271 {
272 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node))
273 {
274 --acc->current_index;
275 return EINA_FALSE;
276 }
277 }
278 (*data) = acc->current_node;
279 return EINA_TRUE;
280 }
281 return EINA_FALSE;
282}
283
284static void*
285_efl_ui_list_view_seg_array_node_accessor_get_container(Efl_Ui_List_View_Segarray_Node_Accessor* acc EINA_UNUSED)
286{
287 return NULL;
288}
289
290static void
291_efl_ui_list_view_seg_array_node_accessor_free(Efl_Ui_List_View_Segarray_Node_Accessor* acc EINA_UNUSED)
292{
293 if (acc->pre_iterator)
294 eina_iterator_free(acc->pre_iterator);
295 free(acc);
296}
297
298static Eina_Bool
299_efl_ui_list_view_seg_array_node_accessor_lock(Efl_Ui_List_View_Segarray_Node_Accessor* acc EINA_UNUSED)
300{
301 return EINA_FALSE;
302}
303
304static Eina_Bool
305_efl_ui_list_view_seg_array_node_accessor_unlock(Efl_Ui_List_View_Segarray_Node_Accessor* acc EINA_UNUSED)
306{
307 return EINA_FALSE;
308}
309
310static Eina_Accessor*
311_efl_ui_list_view_seg_array_node_accessor_clone(Efl_Ui_List_View_Segarray_Node_Accessor* acc EINA_UNUSED)
312{
313 return &acc->vtable;
314}
315
316static void
317_efl_ui_list_view_seg_array_node_accessor_setup(Efl_Ui_List_View_Segarray_Node_Accessor* acc, Efl_Ui_List_View_Seg_Array* seg_array)
318{
319 EINA_MAGIC_SET(&acc->vtable, EINA_MAGIC_ACCESSOR);
320 acc->vtable.version = EINA_ACCESSOR_VERSION;
321 acc->vtable.get_at = FUNC_ACCESSOR_GET_AT(_efl_ui_list_view_seg_array_node_accessor_get_at);
322 acc->vtable.get_container = FUNC_ACCESSOR_GET_CONTAINER(_efl_ui_list_view_seg_array_node_accessor_get_container);
323 acc->vtable.free = FUNC_ACCESSOR_FREE(_efl_ui_list_view_seg_array_node_accessor_free);
324 acc->vtable.lock = FUNC_ACCESSOR_LOCK(_efl_ui_list_view_seg_array_node_accessor_lock);
325 acc->vtable.unlock = FUNC_ACCESSOR_LOCK(_efl_ui_list_view_seg_array_node_accessor_unlock);
326 acc->vtable.clone = FUNC_ACCESSOR_CLONE(_efl_ui_list_view_seg_array_node_accessor_clone);
327 acc->seg_array = seg_array;
328 acc->pre_iterator = NULL;
329 acc->current_index = -1;
330 acc->current_node = NULL;
331}
332
333/* External Functions */
334
335Efl_Ui_List_View_Seg_Array *
336efl_ui_list_view_seg_array_setup(int size)
337{
338 Efl_Ui_List_View_Seg_Array *pd = calloc(1, sizeof(Efl_Ui_List_View_Seg_Array));
339 if (!pd) return NULL;
340 pd->step_size = size;
341
342 return pd;
343}
344
345void
346efl_ui_list_view_seg_array_free(Efl_Ui_List_View_Seg_Array *pd)
347{
348 if (pd->root)
349 eina_rbtree_delete(EINA_RBTREE_GET(pd->root), EINA_RBTREE_FREE_CB(_free_node), NULL);
350
351 pd->root = NULL;
352 free(pd);
353}
354
355void
356efl_ui_list_view_seg_array_flush(Efl_Ui_List_View_Seg_Array *pd)
357{
358 if (pd->root)
359 eina_rbtree_delete(EINA_RBTREE_GET(pd->root), EINA_RBTREE_FREE_CB(_free_node), NULL);
360
361 pd->root = NULL;
362 pd->node_count = 0;
363 pd->count = 0;
364}
365
366int
367efl_ui_list_view_seg_array_count(Efl_Ui_List_View_Seg_Array* pd)
368{
369 return pd->count;
370}
371
372void
373efl_ui_list_view_seg_array_insert(Efl_Ui_List_View_Seg_Array* pd, int index, Efl_Model* model)
374{
375 Efl_Ui_List_View_Seg_Array_Node* node, *next;
376 Efl_Ui_List_View_Layout_Item* item;
377
378 item = _create_item_partial(model);
379
380 node = (void*)eina_rbtree_inline_lookup(EINA_RBTREE_GET(pd->root),
381 &index, sizeof(index), &_insert_lookup_cb, NULL);
382 if(node)
383 {
384 next = (void*)EINA_RBTREE_GET(node)->son[EINA_RBTREE_LEFT];
385 if(next && next->first <= index)
386 _efl_ui_list_view_seg_array_insert_at_node(pd, index, item, next);
387 else
388 _efl_ui_list_view_seg_array_insert_at_node(pd, index, item, node);
389 }
390 else
391 _efl_ui_list_view_seg_array_insert_at_node(pd, index, item, NULL);
392}
393
394void
395efl_ui_list_view_seg_array_insert_value(Efl_Ui_List_View_Seg_Array *pd, int first, Eina_Value v)
396{
397 Efl_Model *children;
398 unsigned int i, len;
399
400 if (eina_value_type_get(&v) == EINA_VALUE_TYPE_OBJECT)
401 {
402 children = eina_value_object_get(&v);
403 _efl_ui_list_view_seg_array_insert_object(pd, first, children);
404 }
405 else if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ARRAY)
406 {
407 EINA_VALUE_ARRAY_FOREACH(&v, len, i, children)
408 {
409 unsigned int idx = first + i;
410
411 _efl_ui_list_view_seg_array_insert_object(pd, idx, children);
412 }
413 }
414 else
415 {
416 printf("Unknow type !\n");
417 }
418}
419
420
421Efl_Ui_List_View_Layout_Item*
422efl_ui_list_view_seg_array_remove(Efl_Ui_List_View_Seg_Array *pd, int index)
423{
424 Efl_Ui_List_View_Seg_Array_Node *node;
425 Efl_Ui_List_View_Layout_Item *item, *rt;
426 Eina_Iterator* iterator;
427 int offset;
428
429 node = (void*)eina_rbtree_inline_lookup(EINA_RBTREE_GET(pd->root),
430 &index, sizeof(index), &_insert_lookup_cb, NULL);
431 if (!node) return NULL;
432
433 offset = index - node->first;
434 if (offset >= node->length) return NULL;
435
436 rt = node->pointers[offset];
437 pd->count--;
438 node->length--;
439
440 while (offset < node->length)
441 {
442 node->pointers[offset] = node->pointers[offset+1];
443 item = node->pointers[offset];
444 --item->index_offset;
445 ++offset;
446 }
447
448 node = (void*)EINA_RBTREE_GET(node)->son[EINA_RBTREE_LEFT];
449 iterator = eina_rbtree_iterator_infix((void*)node);
450 while(eina_iterator_next(iterator, (void**)&node))
451 node->first--;
452
453 return rt;
454}
455
456Eina_Accessor*
457efl_ui_list_view_seg_array_accessor_get(Efl_Ui_List_View_Seg_Array* pd)
458{
459 Efl_Ui_List_View_Segarray_Eina_Accessor* acc = calloc(1, sizeof(Efl_Ui_List_View_Segarray_Eina_Accessor));
460 _efl_ui_list_view_seg_array_accessor_setup(acc, pd);
461 return &acc->vtable;
462}
463
464Eina_Accessor*
465efl_ui_list_view_seg_array_node_accessor_get(Efl_Ui_List_View_Seg_Array* pd)
466{
467 Efl_Ui_List_View_Segarray_Node_Accessor* acc = calloc(1, sizeof(Efl_Ui_List_View_Segarray_Node_Accessor));
468 _efl_ui_list_view_seg_array_node_accessor_setup(acc, pd);
469 return &acc->vtable;
470}
471
472int
473efl_ui_list_view_item_index_get(Efl_Ui_List_View_Layout_Item* item)
474{
475 Efl_Ui_List_View_Seg_Array_Node* node = item->tree_node;
476 return item->index_offset + node->first;
477}
diff --git a/src/lib/elementary/efl_ui_list_view_seg_array.h b/src/lib/elementary/efl_ui_list_view_seg_array.h
deleted file mode 100644
index adbfc28441..0000000000
--- a/src/lib/elementary/efl_ui_list_view_seg_array.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef EFL_UI_LIST_VIEW_SEG_ARRAY_H
2#define EFL_UI_LIST_VIEW_SEG_ARRAY_H
3
4typedef struct _Efl_Ui_List_View_SegArray_Node
5{
6 EINA_RBTREE;
7
8 int length;
9 int max;
10 int first;
11
12 void* layout_data;
13
14 Efl_Ui_List_View_Layout_Item* pointers[0];
15} Efl_Ui_List_View_Seg_Array_Node;
16
17typedef struct _Efl_Ui_List_View_Seg_Array
18{
19 Efl_Ui_List_View_Seg_Array_Node *root;
20
21 int step_size;
22 int node_count;
23 int count;
24} Efl_Ui_List_View_Seg_Array;
25
26
27Efl_Ui_List_View_Seg_Array * efl_ui_list_view_seg_array_setup(int size);
28void efl_ui_list_view_seg_array_free(Efl_Ui_List_View_Seg_Array *seg_array);
29void efl_ui_list_view_seg_array_flush(Efl_Ui_List_View_Seg_Array *seg_array);
30int efl_ui_list_view_seg_array_count(Efl_Ui_List_View_Seg_Array* seg_array);
31int efl_ui_list_view_item_index_get(Efl_Ui_List_View_Layout_Item* item);
32
33
34void efl_ui_list_view_seg_array_insert(Efl_Ui_List_View_Seg_Array* seg_array, int index, Efl_Model* model);
35void efl_ui_list_view_seg_array_insert_value(Efl_Ui_List_View_Seg_Array *seg_array, int first, Eina_Value value);
36Efl_Ui_List_View_Layout_Item* efl_ui_list_view_seg_array_remove(Efl_Ui_List_View_Seg_Array *seg_array, int index);
37
38Eina_Accessor* efl_ui_list_view_seg_array_accessor_get(Efl_Ui_List_View_Seg_Array* seg_array);
39Eina_Accessor* efl_ui_list_view_seg_array_node_accessor_get(Efl_Ui_List_View_Seg_Array* seg_array);
40
41
42#endif
diff --git a/src/lib/elementary/efl_ui_list_view_types.eot b/src/lib/elementary/efl_ui_list_view_types.eot
deleted file mode 100644
index 49aca5d33d..0000000000
--- a/src/lib/elementary/efl_ui_list_view_types.eot
+++ /dev/null
@@ -1,12 +0,0 @@
1struct @beta @free(free) Efl.Ui.List_View_Layout_Item {
2 layout: Efl.Ui.Layout;
3 layout_request: future<Efl.Ui.Layout>;
4 children: Efl.Model;
5 index_offset: int;
6 tree_node: void_ptr;
7 min: Eina.Size2D;
8 size: Eina.Size2D;
9 pos: Eina.Position2D;
10}
11
12struct @beta Efl_Ui_List_View_Seg_Array; [[TBD]]
diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build
index 2e48c5a39a..9580b3e229 100644
--- a/src/lib/elementary/meson.build
+++ b/src/lib/elementary/meson.build
@@ -111,8 +111,6 @@ pub_eo_files = [
111 'efl_ui_layout_part_bg.eo', 111 'efl_ui_layout_part_bg.eo',
112 'efl_ui_layout_part_legacy.eo', 112 'efl_ui_layout_part_legacy.eo',
113 'efl_ui_list_view.eo', 113 'efl_ui_list_view.eo',
114 'efl_ui_list_view_model.eo',
115 'efl_ui_list_view_pan.eo',
116 'efl_ui_item.eo', 114 'efl_ui_item.eo',
117 'efl_ui_default_item.eo', 115 'efl_ui_default_item.eo',
118 'efl_ui_group_item.eo', 116 'efl_ui_group_item.eo',
@@ -208,7 +206,6 @@ endforeach
208pub_eo_types_files = [ 206pub_eo_types_files = [
209 'elm_general.eot', 207 'elm_general.eot',
210 'efl_ui.eot', 208 'efl_ui.eot',
211 'efl_ui_list_view_types.eot',
212 'efl_ui_selection_types.eot', 209 'efl_ui_selection_types.eot',
213 'efl_ui_dnd_types.eot' 210 'efl_ui_dnd_types.eot'
214] 211]
@@ -236,8 +233,6 @@ priv_eo_files = [
236 'efl_ui_state_model.eo', 233 'efl_ui_state_model.eo',
237 'efl_ui_selection_manager.eo', 234 'efl_ui_selection_manager.eo',
238 'efl_datetime_manager.eo', 235 'efl_datetime_manager.eo',
239 'efl_ui_list_view_precise_layouter.eo',
240 'efl_ui_list_view_relayout.eo',
241 'efl_ui_size_model.eo', 236 'efl_ui_size_model.eo',
242 'efl_ui_homogeneous_model.eo', 237 'efl_ui_homogeneous_model.eo',
243 'efl_ui_exact_model.eo', 238 'efl_ui_exact_model.eo',
@@ -357,8 +352,6 @@ elementary_headers_unstable = [
357 'elm_widget_toolbar.h', 352 'elm_widget_toolbar.h',
358 'efl_ui_video_private.h', 353 'efl_ui_video_private.h',
359 'efl_ui_item_private.h', 354 'efl_ui_item_private.h',
360 'efl_ui_list_view_private.h',
361 'efl_ui_list_view_seg_array.h',
362 'elm_widget_web.h', 355 'elm_widget_web.h',
363 'efl_ui_clock.h', 356 'efl_ui_clock.h',
364 'elm_code.h', 357 'elm_code.h',
@@ -906,8 +899,6 @@ elementary_src = [
906 'efl_ui_grid_default_item.c', 899 'efl_ui_grid_default_item.c',
907 'efl_ui_grid.c', 900 'efl_ui_grid.c',
908 'efl_ui_list_view.c', 901 'efl_ui_list_view.c',
909 'efl_ui_list_view_precise_layouter.c',
910 'efl_ui_list_view_seg_array.c',
911 'efl_ui_layout_factory.c', 902 'efl_ui_layout_factory.c',
912 'efl_ui_scroller.c', 903 'efl_ui_scroller.c',
913 'efl_ui_scroll_manager.c', 904 'efl_ui_scroll_manager.c',