aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-27 19:42:17 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit236bee625afe63eaed56aed5803ecd715b1608a1 (patch)
tree4c75aa554e33793e9bfd38320a41125438cb0284
parentelm: fixed list_example3 and unrealize to model_unset WIP (diff)
downloadefl-236bee625afe63eaed56aed5803ecd715b1608a1.tar.gz
Elm: efl_ui_list model set/unset update itens
-rw-r--r--src/lib/elementary/efl_ui_list.c19
-rw-r--r--src/lib/elementary/efl_ui_list.eo1
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c54
3 files changed, 43 insertions, 31 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 31ea811347..9c13eff014 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -325,7 +325,6 @@ _count_then(void * data, Efl_Event const* event)
int *count = ((Efl_Future_Event_Success*)event->info)->value;
pd->item_count = *count;
- printf("item count %d\n", pd->item_count);
pd->count_future = NULL;
_layout(pd);
@@ -1038,6 +1037,7 @@ _efl_ui_list_efl_object_finalize(Eo *obj, Efl_Ui_List_Data *pd)
if(!pd->relayout)
{
pd->relayout = efl_add(EFL_UI_LIST_PRECISE_LAYOUTER_CLASS, obj);
+ efl_ui_list_relayout_model_set(pd->relayout, pd->model);
}
return obj;
}
@@ -1093,9 +1093,6 @@ _efl_ui_list_layout_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Efl_U
EOLIAN static void
_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model)
{
- if (pd->relayout)
- efl_ui_list_relayout_model_set(pd->relayout, model);
-
if (pd->model == model)
return;
@@ -1109,7 +1106,8 @@ _efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *mod
{
/* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb, obj); */
/* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb, obj); */
- //TODO: SegArray Clear
+ //TODO: FIXME: XXX: SegArray Clear
+ efl_ui_list_segarray_setup(&pd->segarray, 32);
efl_unref(pd->model);
pd->model = NULL;
pd->item_count = 0;
@@ -1128,6 +1126,9 @@ _efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *mod
efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd);
}
+ if (pd->relayout)
+ efl_ui_list_relayout_model_set(pd->relayout, model);
+
evas_object_smart_changed(pd->obj);
}
@@ -1448,6 +1449,9 @@ _efl_ui_list_relayout_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED)
static void
_layout(Efl_Ui_List_Data *pd)
{
+ if (!pd->model)
+ return;
+
Eina_Accessor* accessor = efl_ui_list_segarray_accessor_get(&pd->segarray);
efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first,
@@ -1464,9 +1468,9 @@ _children_slice_then(void * data, Efl_Event const* event)
pd->segarray_first = pd->outstanding_slice.slice_start;
pd->outstanding_slice.slice_start = pd->outstanding_slice.slice_count = 0;
+ pd->slice_future = NULL;
}
-
/* EFL UI LIST MODEL INTERFACE */
EOLIAN static Eina_Size2D
_efl_ui_list_efl_ui_list_model_min_size_get(Eo *obj, Efl_Ui_List_Data *pd)
@@ -1514,6 +1518,7 @@ _efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_L
EINA_SAFETY_ON_NULL_RETURN(item->layout);
evas_object_hide(item->layout);
+ evas_object_move(item->layout, -9999, -9999);
evt.child = item->children;
evt.layout = item->layout;
@@ -1528,7 +1533,7 @@ _efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_L
EOLIAN static void
_efl_ui_list_efl_ui_list_model_load_range_set(Eo* obj, Efl_Ui_List_Data* pd, int first, int count)
{
- // slice
+ //FIXME?? slice cancel??
if(!pd->slice_future)
{
pd->slice_future = efl_model_children_slice_get(pd->model, first, count);
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
index 749b182342..776d36717f 100644
--- a/src/lib/elementary/efl_ui_list.eo
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -71,6 +71,7 @@ class Efl.Ui.List (Efl.Ui.Layout, Efl.Ui.View, Elm.Interface_Scrollable,
Efl.Ui.List.Model.load_range { set;}
Efl.Ui.List.Model.realize;
+ Efl.Ui.List.Model.unrealize;
Efl.Ui.List.Model.size { get; }
Efl.Ui.List.Model.min_size { get; set; }
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index f01eb863c0..03c8ec1726 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -24,6 +24,7 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
Eina_Hash* size_information;
Eina_Size2D min;
Efl_Model* model;
+ Efl_Ui_List_Model *modeler;
unsigned int count_total;
Efl_Future *count_future;
} Efl_Ui_List_Precise_Layouter_Data;
@@ -56,7 +57,6 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
min.w += pad[0] + pad[1];
min.h += pad[2] + pad[3];
-// DBG("size information for item %d width %d height %d", i, size->min.w, size->min.h);
// if(_horiz(pd->orient))
// {
// pdp->realized.w -= item->minw;
@@ -87,18 +87,20 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
pd->min.w = min.w;
else if (pd->min.w == size->min.w)
{
+ Efl_Ui_List_Precise_Layouter_Size *size_item;
+ Eina_Iterator *size_iterator;
+
pd->min.w = min.w;
- /*EINA_INARRAY_FOREACH(&pd->items.array, it) //find new minimal width
+ size_iterator = eina_hash_iterator_data_new(pd->size_information);
+ EINA_ITERATOR_FOREACH(size_iterator, size_item)
{
- litem = *it;
- if (!litem) continue;
- if (pd->realized.w < litem->minw)
- pd->realized.w = litem->minw;
+ if (pd->min.w < size_item->min.w)
+ pd->min.w = size_item->min.w;
- if (litem != item && litem->minw == item->minw)
+ if (size->min.w == size_item->min.w)
break;
}
- */
+ eina_iterator_free(size_iterator);
}
// }
@@ -139,40 +141,44 @@ _initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_Li
if(pd->initialized)
return;
+ pd->modeler = modeler;
pd->initialized = EINA_TRUE;
efl_ui_list_model_load_range_set(modeler, 0, 0); // load all
- pd->size_information = eina_hash_pointer_new(&free);
pd->min.w = 0;
pd->min.h = 0;
}
-static Eina_Bool
-_size_clear_fn(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata EINA_UNUSED)
-{
- Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
- Efl_Ui_List_LayoutItem* layout_item = data;
-
- cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
- free(cb_data);
-}
-
static void
_finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
{
- pd->initialized = EINA_FALSE;
+ Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
+ Efl_Ui_List_LayoutItem *layout_item;
+ Eina_Iterator *item_iterator;
+ void *data;
- eina_hash_foreach(pd->size_information, _size_clear_fn, pd);
+ item_iterator = eina_hash_iterator_key_new(pd->size_information);
+ while(eina_iterator_next(item_iterator, &data))
+ {
+ layout_item = *(Efl_Ui_List_LayoutItem **)data;
+ cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
+ efl_ui_list_model_unrealize(pd->modeler, layout_item);
+ free(cb_data);
+ }
+ eina_iterator_free(item_iterator);
- eina_hash_free(pd->size_information);
- pd->size_information = NULL;
+ eina_hash_free_buckets(pd->size_information);
+ pd->modeler = NULL;
pd->min.w = 0;
pd->min.h = 0;
+
+ pd->initialized = EINA_FALSE;
}
EOLIAN static Efl_Object *
_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
+ pd->size_information = eina_hash_pointer_new(&free);
pd->initialized = EINA_FALSE;
pd->count_future = NULL;
@@ -195,8 +201,8 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED
if (pd->model)
{
- efl_unref(pd->model);
_finalize(obj, pd);
+ efl_unref(pd->model);
pd->model = NULL;
}