summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-25 16:17:31 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commitb278a69711d0b02c60f6955c33cdd1fb072115bf (patch)
tree1c30bac2539edf8cd383416a12f5b56f1015ae14
parent8588c531874fb7482dfba14c52b67a4519d22297 (diff)
elm: fixed scroll size
-rw-r--r--src/lib/elementary/efl_ui_list.c5
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c103
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.eo1
-rw-r--r--src/lib/elementary/efl_ui_list_relayout.eo7
4 files changed, 87 insertions, 29 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 78746bc81d..7075ef985f 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -1094,6 +1094,9 @@ _efl_ui_list_layout_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Efl_U
1094EOLIAN static void 1094EOLIAN static void
1095_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model) 1095_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model)
1096{ 1096{
1097 if (pd->relayout)
1098 efl_ui_list_relayout_model_set(pd->relayout, model);
1099
1097 if (pd->model == model) 1100 if (pd->model == model)
1098 return; 1101 return;
1099 1102
@@ -1502,7 +1505,7 @@ _efl_ui_list_efl_ui_list_model_min_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_
1502 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 1505 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1503 1506
1504 pd->min.w = min.w; 1507 pd->min.w = min.w;
1505 pd->min.h = min.h; 1508 pd->min.h = min.h;// + 200;
1506 1509
1507 evas_object_size_hint_min_set(wd->resize_obj, pd->min.w, pd->min.h); 1510 evas_object_size_hint_min_set(wd->resize_obj, pd->min.w, pd->min.h);
1508 DBG("min_size_set w:%d h:%d", pd->min.w, pd->min.h); 1511 DBG("min_size_set w:%d h:%d", pd->min.w, pd->min.h);
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index e1660bb65c..13aee83afd 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -22,6 +22,9 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
22 Eina_Bool initialized; 22 Eina_Bool initialized;
23 Eina_Hash* size_information; 23 Eina_Hash* size_information;
24 Eina_Size2D min; 24 Eina_Size2D min;
25 Efl_Model* model;
26 unsigned int count_total;
27 Efl_Future *count_future;
25} Efl_Ui_List_Precise_Layouter_Data; 28} Efl_Ui_List_Precise_Layouter_Data;
26 29
27typedef struct _Efl_Ui_List_Precise_Layouter_Size 30typedef struct _Efl_Ui_List_Precise_Layouter_Size
@@ -85,17 +88,64 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Precise_Layout
85 size->min.h = new_h; 88 size->min.h = new_h;
86} 89}
87 90
91static void
92_count_then(void * data, Efl_Event const* event)
93{
94 Efl_Ui_List_Precise_Layouter_Data *pd = data;
95 EINA_SAFETY_ON_NULL_RETURN(pd);
96 pd->count_future = NULL;
97
98 pd->count_total = *(int*)((Efl_Future_Event_Success*)event->info)->value;
99}
100
101static void
102_count_error(void * data, Efl_Event const* event EINA_UNUSED)
103{
104 Efl_Ui_List_Precise_Layouter_Data *pd = data;
105 EINA_SAFETY_ON_NULL_RETURN(pd);
106 pd->count_future = NULL;
107}
88 108
89EOLIAN static Efl_Object * 109EOLIAN static Efl_Object *
90_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd) 110_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
91{ 111{
92 obj = efl_constructor(efl_super(obj, MY_CLASS)); 112 obj = efl_constructor(efl_super(obj, MY_CLASS));
93 pd->initialized = EINA_FALSE; 113 pd->initialized = EINA_FALSE;
114 pd->count_future = NULL;
94 115
95 return obj; 116 return obj;
96} 117}
97 118
98EOLIAN static void 119EOLIAN static void
120_efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Model *model)
121{
122 if (pd->model == model)
123 return;
124
125 pd->count_total = 0;
126
127 if (pd->count_future)
128 {
129 efl_future_cancel(pd->count_future);
130 pd->count_future = NULL;
131 }
132
133 if (pd->model)
134 {
135 efl_unref(pd->model);
136 pd->model = NULL;
137 }
138
139 if (model)
140 {
141 pd->model = model;
142 efl_ref(pd->model);
143 pd->count_future = efl_model_children_count_get(pd->model);
144 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd);
145 }
146}
147
148EOLIAN static void
99_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do 149_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
100 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd 150 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
101 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *items) 151 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *items)
@@ -109,7 +159,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
109 int boxl = 0, boxr = 0, boxt = 0, boxb = 0; 159 int boxl = 0, boxr = 0, boxt = 0, boxb = 0;
110 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 }; 160 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 };
111 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE }; 161 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
112 Eina_List *order = NULL;
113 int pad[4]; 162 int pad[4];
114 163
115 DBG("layout_do first %d count %d", first, count); 164 DBG("layout_do first %d count %d", first, count);
@@ -122,7 +171,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
122 pd->initialized = EINA_TRUE; 171 pd->initialized = EINA_TRUE;
123 pd->min.w = 0; 172 pd->min.w = 0;
124 pd->min.h = 0; 173 pd->min.h = 0;
125 DBG("************ w:%d h:%d", pd->min.w, pd->min.h);
126 } 174 }
127 175
128 // cache size of new items 176 // cache size of new items
@@ -183,20 +231,19 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
183 scale = evas_object_scale_get(modeler); 231 scale = evas_object_scale_get(modeler);
184/* // Box align: used if "item has max size and fill" or "no item has a weight" */ 232/* // Box align: used if "item has max size and fill" or "no item has a weight" */
185/* // Note: cells always expand on the orthogonal direction */ 233/* // Note: cells always expand on the orthogonal direction */
186// box_align[0] = 0;/*pd->align.h;*/ 234 box_align[0] = 0;/*pd->align.h;*/
187// box_align[1] = 0;/*pd->align.v;*/ 235 box_align[1] = 0;/*pd->align.v;*/
188// if (box_align[0] < 0) 236 if (box_align[0] < 0)
189// { 237 {
190// box_fill[0] = EINA_TRUE; 238 box_fill[0] = EINA_TRUE;
191// box_align[0] = 0.5; 239 box_align[0] = 0.5;
192// } 240 }
193// if (box_align[1] < 0) 241 if (box_align[1] < 0)
194// { 242 {
195// box_fill[1] = EINA_TRUE; 243 box_fill[1] = EINA_TRUE;
196// box_align[1] = 0.5; 244 box_align[1] = 0.5;
197// } 245 }
198// 246
199 //count = 1;
200/* count = eina_inarray_count(&pd->items.array); */ 247/* count = eina_inarray_count(&pd->items.array); */
201 248
202 // box outer margin 249 // box outer margin
@@ -216,7 +263,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
216 length = boxw; 263 length = boxw;
217 want = 100;//pd->realized.w; 264 want = 100;//pd->realized.w;
218 //pad = pd->pad.scalable ? (pd->pad.h * scale) : pd->pad.h; 265 //pad = pd->pad.scalable ? (pd->pad.h * scale) : pd->pad.h;
219 pad = 1; 266 pad = 0;
220 267
221 // padding can not be squeezed (note: could make it an option) 268 // padding can not be squeezed (note: could make it an option)
222 length -= pad * (count - 1); 269 length -= pad * (count - 1);
@@ -233,17 +280,19 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
233 int pad; 280 int pad;
234 length = boxh; 281 length = boxh;
235 want = pd->min.h; 282 want = pd->min.h;
236 pad = 1;//pd->pad.scalable ? (pd->pad.v * scale) : pd->pad.v; 283 pad = 0;//pd->pad.scalable ? (pd->pad.v * scale) : pd->pad.v;
237 284
285 //FIXME?? use eina_hash_population(pd->size_information) or count
286 int population = eina_hash_population(pd->size_information);
238 // padding can not be squeezed (note: could make it an option) 287 // padding can not be squeezed (note: could make it an option)
239 length -= pad * (count - 1); 288 length -= pad * (population - 1); //(count - 1);
240 // available space. if <0 we overflow 289 // available space. if <0 we overflow
241 extra = length - want; 290 extra = length - want;
242 291
243 minw = pd->min.w + boxl + boxr; 292 minw = pd->min.w + boxl + boxr;
244 minh = pd->min.h + pad * (count - 1) + boxt + boxb; 293 minh = pd->min.h + pad * (/*count*/ population - 1) + boxt + boxb;
245 /* if (pd->item_count > count) */ 294 if (pd->count_total > population) //count)
246 /* minh = pd->item_count * average_item_size; */ 295 minh *= (pd->count_total / population); //count);
247 } 296 }
248 297
249// if (pd->min.h != minh || pd->min.w != minw) 298// if (pd->min.h != minh || pd->min.w != minw)
@@ -252,9 +301,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
252// pd->min.h = minh; 301// pd->min.h = minh;
253// } 302// }
254 303
255 DBG("min_size_set w:%d h:%d", pd->min.w, pd->min.h);
256 efl_ui_list_model_min_size_set(modeler, pd->min); 304 efl_ui_list_model_min_size_set(modeler, pd->min);
257
258 if (extra < 0) extra = 0; 305 if (extra < 0) extra = 0;
259 306
260 weight[0] = 1;//pd->weight.x; 307 weight[0] = 1;//pd->weight.x;
@@ -287,7 +334,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
287 double align[2]; 334 double align[2];
288 int item_pad[4]; 335 int item_pad[4];
289 Eina_Size2D max; 336 Eina_Size2D max;
290 int pad = 1; 337 int pad = 0;
291 338
292 size = eina_hash_find(pd->size_information, &layout_item); 339 size = eina_hash_find(pd->size_information, &layout_item);
293 340
@@ -311,8 +358,8 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
311 if (max.h < size->min.h) max.h = size->min.h; 358 if (max.h < size->min.h) max.h = size->min.h;
312 359
313 /* // extra rounding up (compensate cumulative error) */ 360 /* // extra rounding up (compensate cumulative error) */
314 /* if ((id == (count - 1)) && (cur_pos - floor(cur_pos) >= 0.5)) */ 361 if ((i == (count - 1)) && (cur_pos - floor(cur_pos) >= 0.5))
315 /* rounding = 1; */ 362 rounding = 1;
316 363
317 if (horiz) 364 if (horiz)
318 { 365 {
@@ -390,11 +437,11 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
390 if (w > ow) w = ow; 437 if (w > ow) w = ow;
391 } 438 }
392 439
440// DBG("------- size_h:%d -- h:%.2f --- ", size->min.h, h);
393 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h); 441 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h);
394 442
395 /* layout_item->x = x; */ 443 /* layout_item->x = x; */
396 /* layout_item->y = y; */ 444 /* layout_item->y = y; */
397/* order = eina_list_append(order, litem->layout); */
398 445
399/* // fprintf(stderr, "x: %.2f y: %.2f w: %.2f h: %.2f old x: %.2f old y: %.2f old w: %.2f old h: %.2f\n" */ 446/* // fprintf(stderr, "x: %.2f y: %.2f w: %.2f h: %.2f old x: %.2f old y: %.2f old w: %.2f old h: %.2f\n" */
400/* // , (x + 0 - pd->pan.x), (y + 0 - pd->pan.y), (float)w, (float)h */ 447/* // , (x + 0 - pd->pan.x), (y + 0 - pd->pan.y), (float)w, (float)h */
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.eo b/src/lib/elementary/efl_ui_list_precise_layouter.eo
index dc49c8d85e..d6d276e4a4 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.eo
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.eo
@@ -3,5 +3,6 @@ class Efl.Ui.List.Precise_Layouter (Efl.Object, Efl.Ui.List.Relayout)
3 implements { 3 implements {
4 Efl.Object.constructor; 4 Efl.Object.constructor;
5 Efl.Ui.List.Relayout.layout_do; 5 Efl.Ui.List.Relayout.layout_do;
6 Efl.Ui.List.Relayout.model { set; }
6 } 7 }
7} 8}
diff --git a/src/lib/elementary/efl_ui_list_relayout.eo b/src/lib/elementary/efl_ui_list_relayout.eo
index 5e9b834084..b9d86d1c2c 100644
--- a/src/lib/elementary/efl_ui_list_relayout.eo
+++ b/src/lib/elementary/efl_ui_list_relayout.eo
@@ -11,5 +11,12 @@ interface Efl.Ui.List.Relayout (Efl.Interface)
11 children: accessor<Efl.Ui.List.LayoutItem>; 11 children: accessor<Efl.Ui.List.LayoutItem>;
12 } 12 }
13 } 13 }
14 @property model {
15 [[Model that is/will be ]]
16 set {}
17 values {
18 model: Efl.Model; [[Efl model]]
19 }
20 }
14 } 21 }
15} 22}