summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-08-07 18:21:52 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-08-07 18:21:52 -0300
commitc75a443bdfc39333be7e4cae9b4d3927ec34b67f (patch)
treeb61b72cda9d93c486c1b7fc6610134110a949b87
parentbc0a2c2be29c4c69fe13599068fe5b9aa3d67eb7 (diff)
elementary: Fix efl_ui_list child,removed response from modelsdevs/felipealmeida/efl_ui_list_new
-rw-r--r--src/lib/elementary/efl_ui_list.c79
1 files changed, 58 insertions, 21 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 067b183c63..e38169da0f 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -28,6 +28,7 @@ static void _layout_realize(Efl_Ui_List_Data *, Efl_Ui_List_Item *);
28static void _layout_unrealize(Efl_Ui_List_Data *, Efl_Ui_List_Item *); 28static void _layout_unrealize(Efl_Ui_List_Data *, Efl_Ui_List_Item *);
29static Eina_Bool _update_items(Eo *, Efl_Ui_List_Data * /*, Eina_Bool*/); 29static Eina_Bool _update_items(Eo *, Efl_Ui_List_Data * /*, Eina_Bool*/);
30static void _insert_at(Efl_Ui_List_Data* pd, int index, Efl_Model* child); 30static void _insert_at(Efl_Ui_List_Data* pd, int index, Efl_Model* child);
31static void _remove_at(Efl_Ui_List_Data* pd, int index);
31 32
32static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 33static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
33static Eina_Bool _key_action_select(Evas_Object *obj, const char *params); 34static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
@@ -181,21 +182,18 @@ _child_removed_cb(void *data, const Efl_Event *event)
181{ 182{
182 Efl_Model_Children_Event* evt = event->info; 183 Efl_Model_Children_Event* evt = event->info;
183 Efl_Ui_List *obj = data; 184 Efl_Ui_List *obj = data;
184 Efl_Ui_List_Item *item;
185
186 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd); 185 EFL_UI_LIST_DATA_GET_OR_RETURN(obj, pd);
187 /* pd->item_count--; */ 186 int index = evt->index - pd->realized.start;
188 187
189 /* EINA_ARRAY_ITER_NEXT(pd->items.array, i, item, iterator) */ 188 fprintf(stderr, "%s %s:%d %d index\n", __func__, __FILE__, __LINE__, index); fflush(stderr);
190 /* { */ 189 if(index >= 0 && index < pd->realized.slice)
191 /* if (item->model == evt->child) */ 190 _remove_at(pd, index);
192 /* { */ 191 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
193 /* _child_remove(pd, item); */ 192
194 /* //FIXME pd->items = eina_list_remove_list(pd->items, li); */ 193 evas_object_smart_changed(pd->obj);
195 /* evas_object_smart_changed(pd->obj); */ 194 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
196 /* break; */ 195 _efl_ui_list_custom_layout(pd->obj);
197 /* } */ 196 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
198 /* } */
199} 197}
200 198
201static void 199static void
@@ -598,8 +596,10 @@ _child_release(Efl_Ui_List_Data* pd, Efl_Ui_List_Item* item, Eina_Inarray* recyc
598 efl_unref(item->model); 596 efl_unref(item->model);
599 // discard elm_layout to thrash to be able to reuse it 597 // discard elm_layout to thrash to be able to reuse it
600 assert(item->layout != NULL); 598 assert(item->layout != NULL);
601 eina_inarray_push(recycle_layouts, &item->layout); 599 if(recycle_layouts)
602 efl_ui_factory_release(pd->factory, item->layout); 600 eina_inarray_push(recycle_layouts, &item->layout);
601 else
602 efl_ui_factory_release(pd->factory, item->layout);
603 item->layout = NULL; 603 item->layout = NULL;
604 if(_horiz(pd->orient)) 604 if(_horiz(pd->orient))
605 pd->realized.w -= item->w; 605 pd->realized.w -= item->w;
@@ -610,6 +610,43 @@ _child_release(Efl_Ui_List_Data* pd, Efl_Ui_List_Item* item, Eina_Inarray* recyc
610} 610}
611 611
612static void 612static void
613_remove_at(Efl_Ui_List_Data* pd, int index)
614{
615 Efl_Ui_List_Item *to_first, *from_first;
616 int i, j;
617
618 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
619 // fits, just move around
620 to_first = pd->items.array.members;
621 to_first += index;
622 from_first = to_first + 1;
623 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
624
625 _child_release(pd, to_first, NULL);
626
627 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
628 for(i = index+1, j = 0; i != (int)pd->items.array.len; ++i, ++j)
629 _child_transient_release(pd, &from_first[j]);
630 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
631
632 memmove(to_first, from_first, sizeof(Efl_Ui_List_Item)*(pd->items.array.len - index - 1));
633 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
634
635 --pd->items.array.len;
636 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
637
638 for(i = index, j = 0; i != (int)pd->items.array.len; ++i, ++j)
639 {
640 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
641 to_first[j].index--;
642 _child_transient_setup(pd, &to_first[j]);
643 }
644 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
645 memset(&to_first[j], 0, sizeof(Efl_Ui_List_Item));
646 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
647}
648
649static void
613_insert_at(Efl_Ui_List_Data* pd, int index, Efl_Model* child) 650_insert_at(Efl_Ui_List_Data* pd, int index, Efl_Model* child)
614{ 651{
615 Efl_Ui_List_Item *to_first, *from_first; 652 Efl_Ui_List_Item *to_first, *from_first;
@@ -1286,12 +1323,12 @@ _efl_ui_list_elm_interface_atspi_selection_selected_children_count_get(Eo *obj E
1286EOLIAN Eo* 1323EOLIAN Eo*
1287_efl_ui_list_elm_interface_atspi_selection_selected_child_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int child_index) 1324_efl_ui_list_elm_interface_atspi_selection_selected_child_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, int child_index)
1288{ 1325{
1289 /* if(child_index < eina_inlist_count(&pd->items.array)) */ 1326 if(child_index < eina_list_count(pd->selected_items))
1290 /* { */ 1327 {
1291 /* Efl_Ui_List_Item* items = pd->items.array.members; */ 1328 Efl_Ui_List_Item* items = eina_list_nth(pd->selected_items, child_index);
1292 /* return items[child_index].layout; */ 1329 return items[child_index].layout;
1293 /* } */ 1330 }
1294 /* else */ 1331 else
1295 return NULL; 1332 return NULL;
1296} 1333}
1297 1334