From e8b35b22b51ccfe979bd91558b6f8fc0391d7bdc Mon Sep 17 00:00:00 2001 From: VBS Date: Tue, 3 Mar 2015 19:58:40 +0900 Subject: [PATCH] genlist: Implemented genlist expand mode and content_min_limit function Summary: 1. Implemented genlist mode ELM_LIST_EXPAND 2. Implemented content_min_limit function which override scroll interface. This function will be used by call API elm_scroller_content_min_limit. This function will set the object minimum size as its scroll content size, if parameter value is EINA_TRUE. @feature Test Plan: Add new test case in test_popup.c Reviewers: raster, seoz Subscribers: stefan_schmidt, bluezery Differential Revision: https://phab.enlightenment.org/D1279 Origin: upstream Change-Id: Ib3c6d80ac44582659b2bb0ae47bb622fc559c189 --- src/bin/test_popup.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_genlist.c | 52 ++++++++++++++++++++++++++++++++++++-- src/lib/elm_widget_genlist.h | 6 +++++ 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/src/bin/test_popup.c b/src/bin/test_popup.c index 61f0688..fec2abb 100644 --- a/src/bin/test_popup.c +++ b/src/bin/test_popup.c @@ -594,6 +594,14 @@ _list_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) evas_object_del(data); } +char * +gl_popup_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) +{ + char buf[256]; + snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data); + return strdup(buf); +} + static void _popup_center_title_list_content_1button_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) @@ -624,6 +632,54 @@ _popup_center_title_list_content_1button_cb(void *data, Evas_Object *obj EINA_UN } static void +_popup_center_title_genlist_content_1button_cb(void *data, Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Evas_Object *popup, *genlist; + Evas_Object *btn; + int i; + + popup = elm_popup_add(data); + elm_object_part_text_set(popup, "title,text", "Title"); + + Elm_Genlist_Item_Class *itc1 = elm_genlist_item_class_new(); + itc1->item_style = "default"; + itc1->func.text_get = gl_popup_text_get; + itc1->func.content_get = NULL; + itc1->func.state_get = NULL; + itc1->func.del = NULL; + + // genlist as a popup content + genlist = elm_genlist_add(popup); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE); + + for (i = 0; i < 10; i++) + { + elm_genlist_item_append(genlist, + itc1, + (void *)(uintptr_t)i/* item data */, + NULL/* parent */, + ELM_GENLIST_ITEM_NONE, + NULL, + NULL); + } + elm_genlist_item_class_free(itc1); + elm_object_content_set(popup, genlist); + + // popup buttons + btn = elm_button_add(popup); + elm_object_text_set(btn, "OK"); + elm_object_part_content_set(popup, "button1", btn); + evas_object_smart_callback_add(btn, "clicked", _popup_close_cb, popup); + + // popup show should be called after adding all the contents and the buttons + // of popup to set the focus into popup's contents correctly. + evas_object_show(popup); +} + + +static void _subpopup_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -720,6 +776,9 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, elm_list_item_append(list, "popup-center-title + list content + 1 button", NULL, NULL, _popup_center_title_list_content_1button_cb, win); + elm_list_item_append(list, "popup-center-title + genlist content + 1 button", + NULL, NULL, _popup_center_title_genlist_content_1button_cb, + win); elm_list_item_append(list, "subpopup + X button", NULL, NULL, _subpopup_cb, win); diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index d282b17..1513714 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -851,22 +851,52 @@ _elm_genlist_elm_layout_sizing_eval(Eo *obj, Elm_Genlist_Data *sd) minw = vmw; minh = vmh; } - else if (sd->mode == ELM_LIST_LIMIT) + + if (sd->scr_minw) { maxw = -1; minw = vmw + sd->realminw; } else { + minw = vmw; + } + if (sd->scr_minh) + { + maxh = -1; + minh = vmh + sd->minh; + } + else + { minw = vmw; minh = vmh; } + if ((maxw > 0) && (minw > maxw)) + minw = maxw; + if ((maxh > 0) && (minh > maxh)) + minh = maxh; + evas_object_size_hint_min_set(obj, minw, minh); evas_object_size_hint_max_set(obj, maxw, maxh); } static void +_content_min_limit_cb(Evas_Object *obj, + Eina_Bool w, + Eina_Bool h) +{ + ELM_GENLIST_DATA_GET(obj, sd); + + if ((sd->mode == ELM_LIST_LIMIT) || + (sd->mode == ELM_LIST_EXPAND)) return; + sd->scr_minw = !!w; + sd->scr_minh = !!h; + + elm_layout_sizing_eval(obj); +} + +static void _item_contract_emit(Elm_Object_Item *eo_it) { ELM_GENLIST_ITEM_DATA_GET(eo_it, it); @@ -5423,7 +5453,8 @@ _elm_genlist_evas_object_smart_add(Eo *obj, Elm_Genlist_Data *priv) elm_interface_scrollable_vbar_unpress_cb_set(_vbar_unpress_cb), elm_interface_scrollable_hbar_drag_cb_set(_hbar_drag_cb), elm_interface_scrollable_hbar_press_cb_set(_hbar_press_cb), - elm_interface_scrollable_hbar_unpress_cb_set(_hbar_unpress_cb)); + elm_interface_scrollable_hbar_unpress_cb_set(_hbar_unpress_cb), + elm_interface_scrollable_content_min_limit_cb_set(_content_min_limit_cb)); priv->mode = ELM_LIST_SCROLL; priv->max_items_per_block = MAX_ITEMS_PER_BLOCK; @@ -7134,6 +7165,23 @@ _elm_genlist_mode_set(Eo *obj, Elm_Genlist_Data *sd, Elm_List_Mode mode) { if (sd->mode == mode) return; sd->mode = mode; + + if (sd->mode == ELM_LIST_LIMIT) + { + sd->scr_minw = EINA_TRUE; + sd->scr_minh = EINA_FALSE; + } + else if (sd->mode == ELM_LIST_EXPAND) + { + sd->scr_minw = EINA_TRUE; + sd->scr_minh = EINA_TRUE; + } + else + { + sd->scr_minw = EINA_FALSE; + sd->scr_minh = EINA_FALSE; + } + elm_layout_sizing_eval(obj); } diff --git a/src/lib/elm_widget_genlist.h b/src/lib/elm_widget_genlist.h index 7d0c900..a6e2422 100644 --- a/src/lib/elm_widget_genlist.h +++ b/src/lib/elm_widget_genlist.h @@ -60,6 +60,12 @@ struct _Elm_Genlist_Data int item_width, item_height; int group_item_width, group_item_height; int minw, minh; + Eina_Bool scr_minw : 1; /* a flag for determining + * minimum width to limit + * as their content size */ + Eina_Bool scr_minh : 1; /* a flag for determining + * minimum height to limit + * as their content size */ unsigned int item_count; Evas_Coord pan_x, pan_y; Elm_Object_Select_Mode select_mode; -- 2.7.4