summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-07-10 19:41:30 -0300
committerLarry Jr <larry.olj@gmail.com>2017-07-27 17:31:47 -0300
commita19430f35785d6f5d8827eda6baabfb565648681 (patch)
tree098eaddace7fcc410db0646da976872c97d4e7a1
parent76b33cf27da6eb3e305af837766172632ca973ae (diff)
downloadefl-a19430f35785d6f5d8827eda6baabfb565648681.tar.gz
elementary: efl_ui_list fixed resize list
removed deprecated focus
-rw-r--r--src/examples/elementary/efl_ui_list_example_2.c5
-rw-r--r--src/examples/elementary/efl_ui_list_example_3.c6
-rw-r--r--src/lib/elementary/efl_ui_list.c149
-rw-r--r--src/lib/elementary/efl_ui_list.eo12
4 files changed, 66 insertions, 106 deletions
diff --git a/src/examples/elementary/efl_ui_list_example_2.c b/src/examples/elementary/efl_ui_list_example_2.c
index 20de0b9230..4efe86f30e 100644
--- a/src/examples/elementary/efl_ui_list_example_2.c
+++ b/src/examples/elementary/efl_ui_list_example_2.c
@@ -35,6 +35,11 @@ _realized_cb(void *data, const Efl_Event *event)
{
Efl_Ui_List_Item_Event *ie = event->info;
Priv_Data *pd = data;
+ elm_layout_theme_set(ie->layout, "list", "item", "default");
+ printf("realize %d\n", ie->index);
+
+ 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);
efl_ui_model_connect(ie->layout, "elm.text", "filename");
efl_ui_model_factory_connect(ie->layout, "elm.swallow.icon", pd->imf);
diff --git a/src/examples/elementary/efl_ui_list_example_3.c b/src/examples/elementary/efl_ui_list_example_3.c
index e085432f84..5d7fb483b8 100644
--- a/src/examples/elementary/efl_ui_list_example_3.c
+++ b/src/examples/elementary/efl_ui_list_example_3.c
@@ -125,7 +125,10 @@ 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);
efl_ui_model_connect(ie->layout, "elm.text", "name");
efl_ui_model_connect(ie->layout, "signal/elm,state,%v", "odd_style");
}
@@ -134,7 +137,10 @@ static void
_realized_2_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);
efl_ui_model_connect(ie->layout, "elm.text", "occupation");
}
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index a0d11471a5..c157ebbfb9 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -520,6 +520,7 @@ _children_then(void * data, Efl_Event const* event)
}
memmove(array->data+diff, array->data, idx * s);
memcpy(array->data, cacheit, diff * s);
+ free(cacheit);
}
idx = 0;
}
@@ -543,6 +544,7 @@ _children_then(void * data, Efl_Event const* event)
}
memmove(array->data, array->data+diff, idx * s);
memcpy(array->data+idx, cacheit, diff * s);
+ free(cacheit);
}
}
@@ -582,21 +584,6 @@ _children_then(void * data, Efl_Event const* event)
++idx;
}
- for (;i < sd->newslice;++i)
- {
- item = eina_array_pop(array);
- elm_widget_sub_object_del(pd->obj, item->layout);
- if (horz)
- pd->realized.w -= item->minw;
- else
- pd->realized.h -= item->minh;
- free(item);
- }
-/*
- Eina_Array_Iterator iterator;
- EINA_ARRAY_ITER_NEXT(pd->items, i, item, iterator)
- printf("id=%d\n", item->index);
-*/
pd->avsom = horz ? pd->realized.w : pd->realized.h;
free(sd);
pd->avit = pd->avsom / eina_array_count(pd->items);
@@ -714,73 +701,6 @@ _efl_ui_list_elm_widget_theme_apply(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED)
return elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS));
}
-EOLIAN static Eina_Bool
-_efl_ui_list_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *_pd EINA_UNUSED)
-{
- return EINA_TRUE;
-}
-
-static void *
-_efl_ui_list_eina_list_layout_get(const Eina_List *list)
-{
- Efl_Ui_List_Item *litem = eina_list_data_get(list);
-
- return litem->layout;
-}
-
-
-EOLIAN static Evas_Object*
-_efl_ui_list_elm_widget_focused_object_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd)
-{
- if (!pd->focused) return NULL;
- return pd->focused->layout;
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_list_elm_widget_focus_next(Eo *obj, Efl_Ui_List_Data *pd, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
-{
- const Eina_List *items;
- void *(*list_data_get)(const Eina_List *list);
-
- if ((items = elm_widget_focus_custom_chain_get(obj)))
- list_data_get = eina_list_data_get;
- else
- {
- // items = pd->items;
- //FIXME list_data_get = _efl_ui_list_eina_list_layout_get;
-
- if (!items) return EINA_FALSE;
- }
-
- return elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next, next_item);
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_list_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *_pd EINA_UNUSED)
-{
- return EINA_TRUE;
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_list_elm_widget_focus_direction(Eo *obj, Efl_Ui_List_Data *pd, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
-{
- const Eina_List *items;
- void *(*list_data_get)(const Eina_List *list);
-
- if ((items = elm_widget_focus_custom_chain_get(obj)))
- list_data_get = eina_list_data_get;
- else
- {
-//FIXME items = pd->items;
-// list_data_get = _efl_ui_list_eina_list_layout_get;
-
- if (!items) return EINA_FALSE;
- }
-
- return elm_widget_focus_list_direction_get
- (obj, base, items, list_data_get, degree, direction, direction_item, weight);
-}
-
EOLIAN static void
_efl_ui_list_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_List_Data *pd)
{
@@ -805,13 +725,28 @@ _efl_ui_list_efl_gfx_position_set(Eo *obj, Efl_Ui_List_Data *pd, Evas_Coord x, E
EOLIAN static void
_efl_ui_list_efl_gfx_size_set(Eo *obj, Efl_Ui_List_Data *pd, Evas_Coord w, Evas_Coord h)
{
+ Evas_Coord oldw, oldh;
+ Eina_Bool load = EINA_FALSE;
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, w, h))
return;
+ evas_object_geometry_get(obj, NULL, NULL, &oldw, &oldh);
+
efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);
evas_object_resize(pd->hit_rect, w, h);
- if (_load_items(obj, pd, EINA_TRUE))
+
+ if (_horiz(pd->orient))
+ {
+ if (w != oldw) load = EINA_TRUE;
+ }
+ else
+ {
+ if (h != oldh) load = EINA_TRUE;
+ }
+
+
+ if (load && _load_items(obj, pd, EINA_TRUE))
return;
_efl_ui_list_custom_layout(obj);
@@ -889,6 +824,8 @@ _efl_ui_list_efl_canvas_group_group_add(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSE
efl_data_ref(obj, MY_CLASS);
pan_data->wobj = obj;
pan_data->wpd = pd;
+ pd->pan.x = 0;
+ pd->pan.y = 0;
elm_interface_scrollable_extern_pan_set(obj, pd->pan.obj);
evas_object_show(pd->pan.obj);
@@ -914,6 +851,18 @@ _efl_ui_list_efl_canvas_group_group_del(Eo *obj, Efl_Ui_List_Data *pd)
EOLIAN static Eo *
_efl_ui_list_efl_object_constructor(Eo *obj, Efl_Ui_List_Data *pd)
{
+
+ {
+ Efl_Ui_Focus_Manager *manager;
+
+ manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL,
+ efl_ui_focus_manager_root_set(efl_added, obj)
+ );
+
+ efl_composite_attach(obj, manager);
+ _efl_ui_focus_manager_redirect_events_add(manager, obj);
+ }
+
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->obj = obj;
efl_canvas_object_type_set(obj, MY_CLASS_NAME);
@@ -1328,7 +1277,6 @@ _load_items(Eo *obj, Efl_Ui_List_Data *pd, Eina_Bool recalc)
slice = slice > 8 ? slice : 8;
slicestart = newstart = newstart > 1 ? newstart : 1;
- printf("avit=%d slice=%d\n", pd->avit, slice);
if (!recalc && newstart == pd->realized.start && slice == pd->realized.slice)
return EINA_FALSE;
@@ -1354,10 +1302,9 @@ _load_items(Eo *obj, Efl_Ui_List_Data *pd, Eina_Bool recalc)
{
int aux = (slicestart + slice - 1) - pd->item_count;
slice -= aux;
- newstart -= aux;
+ newstart = newstart - aux > 1 ? newstart - aux : 1;
}
-// printf("start=%d slicestart=%d slice=%d\n", newstart, slicestart, slice);
if (slice > 0)
{
sd = malloc(sizeof(Efl_Ui_List_Slice));
@@ -1369,21 +1316,23 @@ _load_items(Eo *obj, Efl_Ui_List_Data *pd, Eina_Bool recalc)
pd->future = efl_model_children_slice_get(pd->model, slicestart, slice);
efl_future_then(pd->future, &_children_then, &_children_error, NULL, sd);
}
- else if (slice < 0)
+ else
{
- while (slice++ < 0)
- {
- item = eina_array_pop(pd->items);
- if (!item) break;
- if (horz)
- pd->realized.w -= item->minw;
- else
- pd->realized.h -= item->minh;
- _child_remove(pd, item);
- }
- pd->avsom = horz ? pd->realized.w : pd->realized.h;
- pd->avit = pd->avsom / eina_array_count(pd->items);
- evas_object_smart_changed(pd->obj);
+ while (pd->realized.slice < (int)eina_array_count(pd->items))
+ {
+ item = eina_array_pop(pd->items);
+ if (!item) break;
+ if (horz)
+ pd->realized.w -= item->minw;
+ else
+ pd->realized.h -= item->minh;
+ _child_remove(pd, item);
+ }
+ pd->avsom = horz ? pd->realized.w : pd->realized.h;
+ if (eina_array_count(pd->items))
+ pd->avit = pd->avsom / eina_array_count(pd->items);
+
+ return EINA_FALSE;
}
return EINA_TRUE;
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
index ccf49b9524..d03a7c34e6 100644
--- a/src/lib/elementary/efl_ui_list.eo
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -7,7 +7,7 @@ struct Efl.Ui.List.Item_Event
class Efl.Ui.List (Elm.Layout, Efl.Ui.View, Elm.Interface_Scrollable,
Elm.Interface.Atspi_Widget_Action, Elm.Interface.Atspi.Selection,
- Efl.Ui.Clickable, Efl.Ui.Selectable)
+ Efl.Ui.Clickable, Efl.Ui.Selectable, Efl.Ui.Focus.Manager)
{
methods {
@property homogeneous {
@@ -60,13 +60,13 @@ class Efl.Ui.List (Elm.Layout, Efl.Ui.View, Elm.Interface_Scrollable,
// Widget
Elm.Widget.theme_apply;
- Elm.Widget.focus_next_manager_is;
- Elm.Widget.focus_direction_manager_is;
- Elm.Widget.focus_next;
- Elm.Widget.focus_direction;
+// Elm.Widget.focus_next_manager_is;
+// Elm.Widget.focus_direction_manager_is;
+// Elm.Widget.focus_next;
+// Elm.Widget.focus_direction;
// Elm.Widget.activate;
// Elm.Widget.focused_item { get; }
- Elm.Widget.focused_object { get; }
+// Elm.Widget.focused_object { get; }
Elm.Widget.widget_event;
Elm.Layout.sizing_eval;