aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-18 19:36:11 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit994f44da9afaa318b2e5f4ce74ef47d2e7f6039f (patch)
treed8ae41436cfb4bfaa8404b0ef23adc9b72bbd933
parentelm: WIP code for segarray (diff)
downloadefl-994f44da9afaa318b2e5f4ce74ef47d2e7f6039f.tar.gz
efl-ui-list layout_do review WIP
-rw-r--r--src/lib/elementary/efl_ui_list.c2
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c96
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c5
3 files changed, 81 insertions, 22 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 58bc4da1c5..f25ec3c255 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -491,7 +491,7 @@ _layout_unrealize(Efl_Ui_List_Data *pd, Efl_Ui_List_Item *item)
}
/* TODO:calculate new min */
- _item_min_calc(pd, item, 0, 0);
+ //_item_min_calc(pd, item, 0, 0);
evt.child = item->model;
evt.layout = 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 41a3aff3d6..ef4fba357d 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -12,6 +12,7 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
{
Eina_Bool initialized;
Eina_Hash* size_information;
+ Evas_Coord width, height;
} Efl_Ui_List_Precise_Layouter_Data;
typedef struct _Efl_Ui_List_Precise_Layouter_Size
@@ -22,6 +23,59 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Size
#include "efl_ui_list_precise_layouter.eo.h"
+
+static void
+_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Precise_Layouter_Size *size, Evas_Coord new_w, Evas_Coord new_h)
+{
+// if(_horiz(pd->orient))
+// {
+// pdp->realized.w -= item->minw;
+// pd->realized.w += w;
+// if(pd->realized.h <= h)
+// pd->realized.h = h;
+// else if (pd->realized.h < item->minh)
+// {
+// pd->realized.h = h;
+// EINA_INARRAY_FOREACH(&pd->items.array, it)
+// {
+// litem = *it;
+// if (!litem) continue;
+// if (pd->realized.h < litem->minh)
+// pd->realized.h = litem->minh;
+//
+// if (litem != item && litem->minh == item->minh)
+// break;
+// }
+// }
+// }
+// else
+// {
+
+ pd->height += new_h - size->min_height;
+
+ if(pd->width <= new_w)
+ pd->width = new_w;
+ else if (pd->width == size->min_width)
+ {
+ pd->width = new_w;
+ /*EINA_INARRAY_FOREACH(&pd->items.array, it) //find new minimal width
+ {
+ litem = *it;
+ if (!litem) continue;
+ if (pd->realized.w < litem->minw)
+ pd->realized.w = litem->minw;
+
+ if (litem != item && litem->minw == item->minw)
+ break;
+ }
+ */
+ }
+// }
+
+ size->min_width = new_w;
+ size->min_height = new_h;
+}
+
static void
_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
@@ -30,7 +84,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
Efl_Ui_List_LayoutItem* layout_item;
Efl_Ui_List_Precise_Layouter_Size* size;
int i;
- /****/
Eina_Bool horiz = EINA_FALSE/*_horiz(pd->orient)*/, zeroweight = EINA_FALSE;
Evas_Coord ow, oh, want, minw, minh;
int boxx, boxy, boxw, boxh, length, /*pad, */extra = 0, rounding = 0;
@@ -40,6 +93,8 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
Eina_List *order = NULL;
int pad[4];
+ EINA_SAFETY_ON_NULL_RETURN(items);
+
if(!pd->initialized)
{
efl_ui_list_model_load_range_set(modeler, 0, -1); // load all
@@ -53,22 +108,27 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
size = eina_hash_find(pd->size_information, &layout_item);
if(!size)
{
- size = malloc(sizeof(Efl_Ui_List_Precise_Layouter_Size));
if(!layout_item->layout)
efl_ui_list_model_realize(modeler, layout_item);
if(!layout_item->layout)
{
// error
+ continue;
}
- size = malloc(sizeof(Efl_Ui_List_Precise_Layouter_Size));
+ size = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size));
edje_object_size_min_calc(layout_item->layout, &size->min_width, &size->min_height);
efl_gfx_size_hint_margin_get(layout_item->layout, &pad[0], &pad[1], &pad[2], &pad[3]);
efl_gfx_size_hint_weight_get(layout_item->layout, &size->weight_x, &size->weight_y);
size->min_width += pad[0] + pad[1];
size->min_height += pad[2] + pad[3];
+ pd->height += size->min_height;
+ if (pd->width < size->min_width)
+ pd->width = size->min_width;
+
+ eina_hash_add(pd->size_information, &layout_item, size);
/* pd->weight.x += item->wx; */
/* pd->weight.y += item->wy; */
}
@@ -80,19 +140,19 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
scale = evas_object_scale_get(modeler);
/* // Box align: used if "item has max size and fill" or "no item has a weight" */
/* // Note: cells always expand on the orthogonal direction */
- box_align[0] = 0;/*pd->align.h;*/
- box_align[1] = 0;/*pd->align.v;*/
- if (box_align[0] < 0)
- {
- box_fill[0] = EINA_TRUE;
- box_align[0] = 0.5;
- }
- if (box_align[1] < 0)
- {
- box_fill[1] = EINA_TRUE;
- box_align[1] = 0.5;
- }
-
+// box_align[0] = 0;/*pd->align.h;*/
+// box_align[1] = 0;/*pd->align.v;*/
+// if (box_align[0] < 0)
+// {
+// box_fill[0] = EINA_TRUE;
+// box_align[0] = 0.5;
+// }
+// if (box_align[1] < 0)
+// {
+// box_fill[1] = EINA_TRUE;
+// box_align[1] = 0.5;
+// }
+//
//count = 1;
/* count = eina_inarray_count(&pd->items.array); */
@@ -139,8 +199,8 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
// available space. if <0 we overflow
extra = length - want;
- minw = 100;//pd->realized.w + boxl + boxr;
- minh = 100;//pd->realized.h + pad * (count - 1) + boxt + boxb;
+ minw = pd->width + boxl + boxr;
+ minh = 100;//pd->height + pad * (count - 1) + boxt + boxb;
/* if (pd->item_count > count) */
/* minh = pd->item_count * average_item_size; */
}
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index 79f6994e0d..9a2f81a3da 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -53,7 +53,7 @@ void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int fi
eina_iterator_next(pre_iterator, &first_node);
array_first = first_node->first;
}
-
+
EINA_ACCESSOR_FOREACH(accessor, i, children)
{
if((first + i < array_first) || !efl_ui_list_segarray_count(segarray))
@@ -61,7 +61,6 @@ void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int fi
if(!node)
{
node = _alloc_node(segarray, i + first, segarray->array_initial_size);
-
}
else
{
@@ -69,7 +68,6 @@ void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int fi
}
else if(first + i < array_first + efl_ui_list_segarray_count(segarray))
{
-
}
else
{
@@ -123,6 +121,7 @@ _efl_ui_list_segarray_accessor_clone(Efl_Ui_List_Segarray_Eina_Accessor* acc)
static void
_efl_ui_list_segarray_accessor_setup(Efl_Ui_List_Segarray_Eina_Accessor* acc)
{
+ EINA_MAGIC_SET(&acc->vtable, EINA_MAGIC_ACCESSOR);
acc->vtable.version = EINA_ACCESSOR_VERSION;
acc->vtable.get_at = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_get_at);
acc->vtable.get_container = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_get_container);