summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-11-11 20:37:25 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commite649d932beddc9913525249d53c11b1fddf0641b (patch)
tree8f2d40a7b15a2941eb6dee05697a21add231c8c9
parent0332cf008e64b07332e7a17e60b95f6c9b74803c (diff)
downloadefl-e649d932beddc9913525249d53c11b1fddf0641b.tar.gz
elm: WIP in efl_ui_list change in layouting through cache
-rw-r--r--src/lib/elementary/efl_ui_list.c4
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c281
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c4
3 files changed, 161 insertions, 128 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 2455e8e6e8..4151a36ca7 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -1474,7 +1474,7 @@ EOLIAN static Efl_Ui_List_LayoutItem *
_efl_ui_list_efl_ui_list_model_realize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
{
Efl_Ui_List_Item_Event evt;
-// DBG("model_realize");
+ DBG("model_realize");
EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
item->layout = efl_ui_factory_create(pd->factory, item->children, obj);
@@ -1495,7 +1495,7 @@ EOLIAN static void
_efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
{
Efl_Ui_List_Item_Event evt;
-// DBG("model_unrealize item:%p", item);
+ DBG("model_unrealize item:%p", item);
EINA_SAFETY_ON_NULL_RETURN(item->layout);
evas_object_hide(item->layout);
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 9a806ec2d8..53d5b1bba6 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -496,138 +496,171 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
(pd->modeler, NULL, NULL, &ow, &oh);
elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
+
+ DBG("scr_x: %d, scr_y: %d\n", (int)scr_x, (int)scr_y);
+
// scan all items, get their properties, calculate total weight & min size
// cache size of new items
Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
+
+ /* int sum_node_top = 0; */
+
EINA_ACCESSOR_FOREACH(nodes, i, items_node)
{
+ Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
+ if (!nodedata)
+ {
+ DBG("no data in node!");
+ continue;
+ }
- Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
- if (!nodedata) continue;
-
- if (!nodedata->realized)
- {
- cur_pos += nodedata->min.h;
- continue;
- }
+ /* int start_pos = ; */
+ /* if(start_pos < 0) */
+ /* start_pos = 0; */
+ if(scr_y < cur_pos + nodedata->min.h + boxh
+ && scr_y + boxh + boxh > cur_pos) // start in this node
+ {
+ DBG("cur_pos: %d\n", (int)cur_pos);
- for(j = 0; j != items_node->length;++j)
- {
- layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
- double cx, cy, cw, ch, x, y, w, h;
- double weight_x, weight_y;
- double align[2];
- int item_pad[4];
- Eina_Size2D max;
- int pad = 0;
-
- if(layout_item->min.w && layout_item->min.h)
- {
+ for(j = 0; j != items_node->length && scr_y + boxh + boxh > cur_pos;++j)
+ {
+ DBG("cur_pos item by item: %d\n", (int)cur_pos);
+ layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
+ double cx, cy, cw, ch, x, y, w, h;
+ double weight_x, weight_y;
+ double align[2];
+ int item_pad[4];
+ Eina_Size2D max;
+ int pad = 0;
+
+ if(layout_item->min.w && layout_item->min.h)
+ {
// DBG("size information for item %d width %d height %d", j, layout_item->min.w, layout_item->min.h);
-
- assert(layout_item->layout != NULL);
- efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y);
- efl_gfx_size_hint_align_get(layout_item->layout, &align[0], &align[1]);
- max = efl_gfx_size_hint_max_get(layout_item->layout);
- efl_gfx_size_hint_margin_get(layout_item->layout, &item_pad[0], &item_pad[1], &item_pad[2], &item_pad[3]);
-
- if (align[0] < 0) align[0] = -1;
- if (align[1] < 0) align[1] = -1;
- if (align[0] > 1) align[0] = 1;
- if (align[1] > 1) align[1] = 1;
-
- if (max.w <= 0) max.w = INT_MAX;
- if (max.h <= 0) max.h = INT_MAX;
- if (max.w < layout_item->min.w) max.w = layout_item->min.w;
- if (max.h < layout_item->min.h) max.h = layout_item->min.h;
-
- // extra rounding up (compensate cumulative error)
- if ((i == (pd->count - 1)) && (cur_pos - floor(cur_pos) >= 0.5))
- rounding = 1;
-
- if (horiz)
- {
- cx = boxx + cur_pos;
- cy = boxy;
- cw = layout_item->min.w + rounding + (zeroweight ? 1.0 : weight_x) * extra / weight[0];
- ch = boxh;
- cur_pos += cw + pad;
- }
- else
- {
- cx = boxx;
- cy = boxy + cur_pos;
- cw = boxw;
- ch = layout_item->min.h + rounding + (zeroweight ? 1.0 : weight_y) * extra / weight[1];
- cur_pos += ch + pad;
- }
-
- // horizontally
- if (max.w < INT_MAX)
- {
- w = MIN(MAX(layout_item->min.w - item_pad[0] - item_pad[1], max.w), cw);
- if (align[0] < 0)
- {
- // bad case: fill+max are not good together
- x = cx + ((cw - w) * box_align[0]) + item_pad[0];
- }
- else
- x = cx + ((cw - w) * align[0]) + item_pad[0];
- }
- else if (align[0] < 0)
- {
- // fill x
- w = cw - item_pad[0] - item_pad[1];
- x = cx + item_pad[0];
- }
- else
- {
- w = layout_item->min.w - item_pad[0] - item_pad[1];
- x = cx + ((cw - w) * align[0]) + item_pad[0];
- }
-
- // vertically
- if (max.h < INT_MAX)
- {
- h = MIN(MAX(layout_item->min.h - item_pad[2] - item_pad[3], max.h), ch);
- if (align[1] < 0)
- {
- // bad case: fill+max are not good together
- y = cy + ((ch - h) * box_align[1]) + item_pad[2];
- }
- else
- y = cy + ((ch - h) * align[1]) + item_pad[2];
- }
- else if (align[1] < 0)
- {
- // fill y
- h = ch - item_pad[2] - item_pad[3];
- y = cy + item_pad[2];
- }
- else
- {
- h = layout_item->min.h - item_pad[2] - item_pad[3];
- y = cy + ((ch - h) * align[1]) + item_pad[2];
- }
-
- if (horiz)
- {
- if (h < pd->min.h) h = pd->min.h;
- if (h > oh) h = oh;
- }
- else
- {
- if (w < pd->min.w) w = pd->min.w;
- if (w > ow) w = ow;
- }
-
-// DBG("------- x=%0.f, y=%0.f, w=%0.f, h=%0.f --- ", x, y, w, h);
- evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h);
-
- /* layout_item->x = x; */
- /* layout_item->y = y; */
- } /* if (size) end */
- }
+ if(!layout_item->layout)
+ {
+ DBG("realizing showing item\n");
+ efl_ui_list_model_realize(pd->modeler, layout_item);
+ assert(layout_item->layout != NULL);
+ }
+ efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y);
+ efl_gfx_size_hint_align_get(layout_item->layout, &align[0], &align[1]);
+ max = efl_gfx_size_hint_max_get(layout_item->layout);
+ efl_gfx_size_hint_margin_get(layout_item->layout, &item_pad[0], &item_pad[1], &item_pad[2], &item_pad[3]);
+
+ if (align[0] < 0) align[0] = -1;
+ if (align[1] < 0) align[1] = -1;
+ if (align[0] > 1) align[0] = 1;
+ if (align[1] > 1) align[1] = 1;
+
+ if (max.w <= 0) max.w = INT_MAX;
+ if (max.h <= 0) max.h = INT_MAX;
+ if (max.w < layout_item->min.w) max.w = layout_item->min.w;
+ if (max.h < layout_item->min.h) max.h = layout_item->min.h;
+
+ // extra rounding up (compensate cumulative error)
+ if ((i == (pd->count - 1)) && (cur_pos - floor(cur_pos) >= 0.5))
+ rounding = 1;
+
+ if (horiz)
+ {
+ cx = boxx + cur_pos;
+ cy = boxy;
+ cw = layout_item->min.w + rounding + (zeroweight ? 1.0 : weight_x) * extra / weight[0];
+ ch = boxh;
+ cur_pos += cw + pad;
+ }
+ else
+ {
+ cx = boxx;
+ cy = boxy + cur_pos;
+ cw = boxw;
+ ch = layout_item->min.h + rounding + (zeroweight ? 1.0 : weight_y) * extra / weight[1];
+ cur_pos += ch + pad;
+ }
+
+ // horizontally
+ if (max.w < INT_MAX)
+ {
+ w = MIN(MAX(layout_item->min.w - item_pad[0] - item_pad[1], max.w), cw);
+ if (align[0] < 0)
+ {
+ // bad case: fill+max are not good together
+ x = cx + ((cw - w) * box_align[0]) + item_pad[0];
+ }
+ else
+ x = cx + ((cw - w) * align[0]) + item_pad[0];
+ }
+ else if (align[0] < 0)
+ {
+ // fill x
+ w = cw - item_pad[0] - item_pad[1];
+ x = cx + item_pad[0];
+ }
+ else
+ {
+ w = layout_item->min.w - item_pad[0] - item_pad[1];
+ x = cx + ((cw - w) * align[0]) + item_pad[0];
+ }
+
+ // vertically
+ if (max.h < INT_MAX)
+ {
+ h = MIN(MAX(layout_item->min.h - item_pad[2] - item_pad[3], max.h), ch);
+ if (align[1] < 0)
+ {
+ // bad case: fill+max are not good together
+ y = cy + ((ch - h) * box_align[1]) + item_pad[2];
+ }
+ else
+ y = cy + ((ch - h) * align[1]) + item_pad[2];
+ }
+ else if (align[1] < 0)
+ {
+ // fill y
+ h = ch - item_pad[2] - item_pad[3];
+ y = cy + item_pad[2];
+ }
+ else
+ {
+ h = layout_item->min.h - item_pad[2] - item_pad[3];
+ y = cy + ((ch - h) * align[1]) + item_pad[2];
+ }
+
+ if (horiz)
+ {
+ if (h < pd->min.h) h = pd->min.h;
+ if (h > oh) h = oh;
+ }
+ else
+ {
+ if (w < pd->min.w) w = pd->min.w;
+ if (w > ow) w = ow;
+ }
+
+ // DBG("------- x=%0.f, y=%0.f, w=%0.f, h=%0.f --- ", x, y, w, h);
+ evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h);
+
+ // layout_item->x = x;
+ // layout_item->y = y;
+
+ } /* if (size) end */
+ }
+ }
+ else if (nodedata->realized) // unrealize
+ {
+ for(j = 0; j != items_node->length;++j)
+ {
+ layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
+ if(layout_item->layout)
+ efl_ui_list_model_unrealize(pd->modeler, layout_item);
+ }
+ nodedata->realized = EINA_FALSE;
+ cur_pos += nodedata->min.h;
+ }
+ else
+ {
+ cur_pos += nodedata->min.h;
+ }
} /* EINA ACCESSOR FOREACH END */
eina_accessor_free(nodes);
}
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index fced099e52..1768815ae1 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -247,14 +247,14 @@ _efl_ui_list_segarray_node_accessor_get_at(Efl_Ui_List_Segarray_Node_Accessor* a
for(;acc->current_index != idx;++acc->current_index)
{
- DBG("for current_index: %d idx: %d", acc->current_index, idx);
+ /* DBG("for current_index: %d idx: %d", acc->current_index, idx); */
if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node))
{
--acc->current_index;
return EINA_FALSE;
}
}
- DBG("out of loop");
+ /* DBG("out of loop"); */
(*data) = acc->current_node;
return EINA_TRUE;
}