aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-10-19 18:27:42 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit0d97bc7e9719ea282cc540161ec83843dfc0f94e (patch)
treec418dac5230d297c49fc5294525bb5ca9dac9a20
parentefl-ui-list layout_do review WIP (diff)
downloadefl-0d97bc7e9719ea282cc540161ec83843dfc0f94e.tar.gz
elm: Some fixes in segarray
-rw-r--r--src/lib/elementary/efl_ui_list.c2
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c66
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.h2
3 files changed, 57 insertions, 13 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index f25ec3c255..f795a5a167 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -1090,7 +1090,7 @@ _efl_ui_list_efl_object_constructor(Eo *obj, Efl_Ui_List_Data *pd)
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_LIST);
- efl_ui_list_segarray_setup(&pd->segarray);
+ efl_ui_list_segarray_setup(&pd->segarray, 32);
manager = elm_obj_widget_focus_manager_create(obj, obj);
efl_composite_attach(obj, manager);
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index 9a2f81a3da..fa8c36cc7a 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -9,7 +9,7 @@
static Eina_Rbtree_Direction _rbtree_compare(Eina_Rbtree const* left, Eina_Rbtree const* right)
{
- Efl_Ui_List_SegArray_Node *nl = left, *nr = right;
+ Efl_Ui_List_SegArray_Node const *nl = left, *nr = right;
return !nl ? EINA_RBTREE_LEFT :
(
!nr ? EINA_RBTREE_RIGHT :
@@ -39,11 +39,17 @@ void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_siz
segarray->array_initial_size = initial_step_size;
}
+static Efl_Ui_List_Item* _create_item(Efl_Model* model, unsigned int index)
+{
+ Efl_Ui_List_Item* item = calloc(1, sizeof(Efl_Ui_List_Item));
+ item->model = model;
+ item->index = index;
+}
+
void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor)
{
int i;
Efl_Model* children;
- Efl_Ui_List_SegArray_Node* node = NULL;
Efl_Ui_List_SegArray_Node* first_node = NULL;
int array_first = 0;
@@ -56,11 +62,14 @@ void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int fi
EINA_ACCESSOR_FOREACH(accessor, i, children)
{
+ // if prefix'ing
if((first + i < array_first) || !efl_ui_list_segarray_count(segarray))
{
- if(!node)
+ // if no first_node
+ if(!first_node)
{
- node = _alloc_node(segarray, i + first, segarray->array_initial_size);
+ first_node = _alloc_node(segarray, i + first, segarray->array_initial_size);
+ first_node->pointers[0] = _create_item(children, first + i);
}
else
{
@@ -83,23 +92,55 @@ int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray)
typedef struct _Efl_Ui_List_Segarray_Eina_Accessor
{
Eina_Accessor vtable;
-
+ Efl_Ui_List_SegArray* segarray;
+ //Eina_Accessor* pre_accessor;
} Efl_Ui_List_Segarray_Eina_Accessor;
+static int _lookup_cb(Eina_Rbtree const* rbtree, const void* key, int length, void* data)
+{
+ Efl_Ui_List_SegArray_Node const* node = rbtree;
+ int index = *(int*)key;
+ if(node->first < index)
+ {
+ return -1;
+ }
+ else if(node->first + node->length < index)
+ {
+ return 0;
+ }
+ else
+ return 1;
+}
+
static Eina_Bool
_efl_ui_list_segarray_accessor_get_at(Efl_Ui_List_Segarray_Eina_Accessor* acc,
unsigned int idx, void** data)
{
+ Efl_Ui_List_SegArray_Node* node;
+ node = eina_rbtree_inline_lookup(acc->segarray->root, &idx, sizeof(idx), &_lookup_cb, NULL);
+ if(node)
+ {
+ if(node->first >= idx && node->first + node->length < idx)
+ {
+ int i = idx - node->first;
+ Efl_Ui_List* item = node->pointers[i];
+ *data = item;
+ return EINA_TRUE;
+ }
+ }
+ return EINA_FALSE;
}
static void*
_efl_ui_list_segarray_accessor_get_container(Efl_Ui_List_Segarray_Eina_Accessor* acc)
{
+ return NULL;
}
static void
_efl_ui_list_segarray_accessor_free(Efl_Ui_List_Segarray_Eina_Accessor* acc)
{
+ free(acc);
}
static void
@@ -119,22 +160,23 @@ _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)
+_efl_ui_list_segarray_accessor_setup(Efl_Ui_List_Segarray_Eina_Accessor* acc, Efl_Ui_List_SegArray* segarray)
{
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);
- acc->vtable.free = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_free);
- acc->vtable.lock = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_lock);
- acc->vtable.unlock = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_unlock);
- acc->vtable.clone = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_accessor_clone);
+ acc->vtable.get_container = FUNC_ACCESSOR_GET_CONTAINER(_efl_ui_list_segarray_accessor_get_container);
+ acc->vtable.free = FUNC_ACCESSOR_FREE(_efl_ui_list_segarray_accessor_free);
+ acc->vtable.lock = FUNC_ACCESSOR_LOCK(_efl_ui_list_segarray_accessor_lock);
+ acc->vtable.unlock = FUNC_ACCESSOR_LOCK(_efl_ui_list_segarray_accessor_unlock);
+ acc->vtable.clone = FUNC_ACCESSOR_CLONE(_efl_ui_list_segarray_accessor_clone);
+ acc->segarray = segarray;
}
Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray)
{
Efl_Ui_List_Segarray_Eina_Accessor* acc = calloc(1, sizeof(Efl_Ui_List_Segarray_Eina_Accessor));
- _efl_ui_list_segarray_accessor_setup(acc);
+ _efl_ui_list_segarray_accessor_setup(acc, segarray);
return &acc->vtable;
}
diff --git a/src/lib/elementary/efl_ui_list_segarray.h b/src/lib/elementary/efl_ui_list_segarray.h
index cbd9ca8578..8ab29543bd 100644
--- a/src/lib/elementary/efl_ui_list_segarray.h
+++ b/src/lib/elementary/efl_ui_list_segarray.h
@@ -28,5 +28,7 @@ typedef struct _Efl_Ui_List_SegArray
Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray);
void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor);
int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray);
+void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_size,
+ int initial_step_size);
#endif