aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-26 19:47:07 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commitde3aab9aa8275a81d1cf53c6ae92a8f5a3b5d3fe (patch)
tree6f37324ee707f8eacd42566709d2fbf065d75213
parentelm: fix changed size hints callback add in efl_ui_list_precise_layout (diff)
downloadefl-de3aab9aa8275a81d1cf53c6ae92a8f5a3b5d3fe.tar.gz
elm: fixed list_example3 and unrealize to model_unset WIP
-rw-r--r--src/examples/elementary/efl_ui_list_example_3.c35
-rw-r--r--src/lib/elementary/efl_ui_list.c24
-rw-r--r--src/lib/elementary/efl_ui_list_model.eo5
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c49
4 files changed, 86 insertions, 27 deletions
diff --git a/src/examples/elementary/efl_ui_list_example_3.c b/src/examples/elementary/efl_ui_list_example_3.c
index 2be8cba149..c4c8d4241e 100644
--- a/src/examples/elementary/efl_ui_list_example_3.c
+++ b/src/examples/elementary/efl_ui_list_example_3.c
@@ -81,17 +81,17 @@ _bt_del_clicked(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
Efl_Object *l = NULL;
Eo *child = NULL;
- l = elm_interface_atspi_selection_selected_child_get(priv->list1, 0);
- printf("selection %p\n", l);
- if(l)
- {
- child = efl_ui_view_model_get(l);
- efl_model_child_del(priv->model, child);
- }
- else
- {
- printf("no selection\n");
- }
+// l = elm_interface_atspi_selection_selected_child_get(priv->list1, 0);
+// printf("selection %p\n", l);
+// if(l)
+// {
+// child = efl_ui_view_model_get(l);
+// efl_model_child_del(priv->model, child);
+// }
+// else
+// {
+// printf("no selection\n");
+// }
}
static void
@@ -132,7 +132,6 @@ static void
_realized_1_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Ui_List_Item_Event *ie = event->info;
- elm_layout_theme_set(ie->layout, "list", "item", "default");
evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -144,8 +143,7 @@ static void
_realized_2_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Ui_List_Item_Event *ie = event->info;
-// printf("relized 2\n");
- elm_layout_theme_set(ie->layout, "list", "item", "default");
+ printf("relized 2\n");
evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -189,6 +187,7 @@ elm_main(int argc, char **argv)
{
Priv_Data *priv;
Evas_Object *win, *bx, *vbx, *bt;
+ Efl_Ui_Layout_Factory *factory;
priv = alloca(sizeof(Priv_Data));
memset(priv, 0, sizeof(Priv_Data));
@@ -204,16 +203,22 @@ elm_main(int argc, char **argv)
evas_object_show(bx);
priv->model = _make_model();
+ factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
+ efl_ui_model_connect(factory, "elm.text", "filename");
+ efl_ui_layout_factory_theme_config(factory, "list", "item", "default");
+
priv->list1 = efl_add(EFL_UI_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
efl_event_callback_add(priv->list1, EFL_UI_LIST_EVENT_ITEM_REALIZED, _realized_1_cb, priv);
evas_object_size_hint_weight_set(priv->list1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(priv->list1, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, priv->list1);
+ efl_ui_list_layout_factory_set(priv->list1, factory);
priv->list2 = efl_add(EFL_UI_LIST_CLASS, win, efl_ui_view_model_set(efl_added, priv->model));
efl_event_callback_add(priv->list2, EFL_UI_LIST_EVENT_ITEM_REALIZED, _realized_2_cb, priv->list2);
evas_object_size_hint_weight_set(priv->list2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(priv->list2, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ efl_ui_list_layout_factory_set(priv->list2, factory);
vbx = elm_box_add(win);
elm_box_pack_end(bx, vbx);
@@ -285,8 +290,6 @@ elm_main(int argc, char **argv)
evas_object_show(bt);
elm_box_pack_end(vbx, bt);
-
-
elm_box_pack_end(bx, priv->list2);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv);
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 239bd13cfc..31ea811347 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -1109,8 +1109,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
efl_unref(pd->model);
- //_efl_ui_list_children_free(obj, pd);
pd->model = NULL;
pd->item_count = 0;
}
@@ -1462,7 +1462,6 @@ _children_slice_then(void * data, Efl_Event const* event)
efl_ui_list_segarray_insert_accessor(&pd->segarray, pd->outstanding_slice.slice_start, acc);
-
pd->segarray_first = pd->outstanding_slice.slice_start;
pd->outstanding_slice.slice_start = pd->outstanding_slice.slice_count = 0;
}
@@ -1490,8 +1489,8 @@ _efl_ui_list_efl_ui_list_model_min_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_
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)
{
- DBG("model_realize");
Efl_Ui_List_Item_Event evt;
+ DBG("model_realize");
EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
item->layout = efl_ui_factory_create(pd->factory, item->children, obj);
@@ -1508,6 +1507,25 @@ _efl_ui_list_efl_ui_list_model_realize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_Lis
}
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);
+ EINA_SAFETY_ON_NULL_RETURN(item->layout);
+
+ evas_object_hide(item->layout);
+
+ evt.child = item->children;
+ evt.layout = item->layout;
+ evt.index = item->index;
+ efl_event_callback_call(obj, EFL_UI_LIST_EVENT_ITEM_UNREALIZED, &evt);
+
+ efl_ui_view_model_set(item->layout, NULL);
+ efl_ui_factory_release(pd->factory, item->layout);
+ item->layout = NULL;
+}
+
+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
diff --git a/src/lib/elementary/efl_ui_list_model.eo b/src/lib/elementary/efl_ui_list_model.eo
index bb685b9d25..ba2b2dc107 100644
--- a/src/lib/elementary/efl_ui_list_model.eo
+++ b/src/lib/elementary/efl_ui_list_model.eo
@@ -16,6 +16,11 @@ interface Efl.Ui.List.Model (Efl.Interface)
}
return: ptr(Efl.Ui.List.LayoutItem);
}
+ unrealize {
+ params {
+ item: ptr(Efl.Ui.List.LayoutItem);
+ }
+ }
// @property visible_range {
// set {}
// values {
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 1c7da2f00c..f01eb863c0 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -17,6 +17,7 @@
#define MY_CLASS EFL_UI_LIST_PRECISE_LAYOUTER_CLASS
+
typedef struct _Efl_Ui_List_Precise_Layouter_Data
{
Eina_Bool initialized;
@@ -42,6 +43,8 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Callback_Data
#include "efl_ui_list_precise_layouter.eo.h"
+static void _initilize(Eo *, Efl_Ui_List_Precise_Layouter_Data*, Efl_Ui_List_Model*);
+static void _finalize(Eo *, Efl_Ui_List_Precise_Layouter_Data*);
static void
_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_Ui_List_Precise_Layouter_Size *size, Eina_Size2D min)
@@ -130,6 +133,42 @@ _on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
_item_min_calc(cb_data->pd, obj, cb_data->size, min);
}
+static void
+_initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Model *modeler)
+{
+ if(pd->initialized)
+ return;
+
+ 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;
+
+ eina_hash_foreach(pd->size_information, _size_clear_fn, pd);
+
+ eina_hash_free(pd->size_information);
+ pd->size_information = NULL;
+ pd->min.w = 0;
+ pd->min.h = 0;
+}
+
EOLIAN static Efl_Object *
_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
{
@@ -157,6 +196,7 @@ _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);
pd->model = NULL;
}
@@ -187,14 +227,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
DBG("layout_do first %d count %d", first, count);
EINA_SAFETY_ON_NULL_RETURN(items);
- if(!pd->initialized)
- {
- efl_ui_list_model_load_range_set(modeler, 0, 0); // load all
- pd->size_information = eina_hash_pointer_new(&free);
- pd->initialized = EINA_TRUE;
- pd->min.w = 0;
- pd->min.h = 0;
- }
+ _initilize(obj, pd, modeler);
// cache size of new items
EINA_ACCESSOR_FOREACH(items, i, layout_item)