From 7bdc8b2a7bf3cb1567ca3f86a70beccc17ef00a3 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Fri, 31 Mar 2017 21:23:48 +0200 Subject: combobox: fix 0px height on first click the height of a item is 0 because the item is not realized, so if no item is realized we are waiting until one is realized, until then we just take 1px as a height, so at minimum one item needs to be realized. If there is a realized item (or we are getting the event that there is one) we are just calling _table_resize again, and are getting the size for real. --- src/lib/elementary/elc_combobox.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib/elementary/elc_combobox.c b/src/lib/elementary/elc_combobox.c index 154318178c..01dc21a05a 100644 --- a/src/lib/elementary/elc_combobox.c +++ b/src/lib/elementary/elc_combobox.c @@ -33,6 +33,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {NULL, NULL} }; +static void _table_resize(void *data); static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); @@ -140,6 +141,12 @@ count_items_genlist(void *data) eina_iterator_free(filter_iter); } +static void +_item_realized(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + _table_resize(data); +} + static void _table_resize(void *data) { @@ -148,11 +155,24 @@ _table_resize(void *data) { int hover_parent_w, hover_parent_h, obj_h, obj_w, obj_y, win_y_offset; int current_height, h; + Eina_List *realized; + sd->item = elm_genlist_first_item_get(sd->genlist); - //FIXME:- the height of item is zero, sometimes. - evas_object_geometry_get(elm_object_item_track(sd->item), NULL, NULL, - NULL, &h); - if (h) sd->item_height = h; + + if (!(realized = elm_genlist_realized_items_get(sd->genlist))) + { + //nothing realized and wait until at least one item is realized + h = 1; + evas_object_smart_callback_add(sd->genlist, "realized", _item_realized, data); + } + else + { + // take the first, and update according to that + evas_object_geometry_get(elm_object_item_track(eina_list_data_get(realized)), NULL, NULL, + NULL, &h); + } + + sd->item_height = h; evas_object_geometry_get(sd->entry, NULL, NULL, &obj_w, NULL); evas_object_geometry_get(data, NULL, &obj_y, NULL, &obj_h); evas_object_geometry_get(sd->hover_parent, NULL, NULL, &hover_parent_w, -- cgit v1.2.1