From: Jee-Yong Um Date: Thu, 18 Aug 2016 03:50:14 +0000 (+0900) Subject: hoversel: do item view creation at the time of item addition. X-Git-Tag: accepted/tizen/common/20160826.142851~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F84301%2F1;p=platform%2Fupstream%2Felementary.git hoversel: do item view creation at the time of item addition. ================================================================================== hoversel: do item view creation at the time of item addition. Summary: Currently hoversel creates the item view when user clicks on hoversel, So it will cause a delay for the hover to come depending on number of items as the items in hover have to be created. If item creation is done during item_add that delay can be avoided and pressed effect also will become smooth (item_add will be taking more time with this change, but it happens only once). If applications prefer memory usage more than execution time, then applications can do item_add in hoversel clicked callback. Test Plan: elementary_test Reviewers: raster, Hermet, conr2d, prince.dubey, shilpasingh, cedric Reviewed By: cedric Subscribers: rajeshps, poornima.srinivasan Differential Revision: https://phab.enlightenment.org/D3058 ================================================================================== Signed-Off-By: Jee-Yong Um Change-Id: Iaa6cdc46c76aa34f7bf007742ef1cc41e6d79620 --- diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c index 51e084b..621fe28 100644 --- a/src/lib/elc_hoversel.c +++ b/src/lib/elc_hoversel.c @@ -62,6 +62,8 @@ EOLIAN static Elm_Theme_Apply _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd) { Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED; + Eina_List *l; + Elm_Object_Item *eo_item; ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, ELM_THEME_APPLY_FAILED); @@ -83,11 +85,22 @@ _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd) eina_stringshare_replace(&(wd->style), style); - eina_stringshare_del(style); - if (sd->hover) elm_widget_mirrored_set(sd->hover, elm_widget_mirrored_get(obj)); + if (sd->horizontal) + snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s", style); + else + snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s", style); + + EINA_LIST_FOREACH(sd->items, l, eo_item) + { + ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item); + elm_object_style_set(VIEW(item), buf); + elm_object_text_set(VIEW(item), item->label); + } + + eina_stringshare_del(style); elm_hoversel_hover_end(obj); return int_ret; @@ -323,9 +336,11 @@ _hover_del(Evas_Object *obj) EINA_LIST_FOREACH(sd->items, l, eo_item) { ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it); - VIEW(it) = NULL; + elm_box_unpack(sd->bx, VIEW(it)); + evas_object_hide(VIEW(it)); } ELM_SAFE_FREE(sd->hover, evas_object_del); + sd->bx = NULL; sd->scr = NULL; sd->last_location = NULL; @@ -354,7 +369,6 @@ static void _activate(Evas_Object *obj) { Elm_Object_Item *eo_item; - Evas_Object *bt, *bx, *ic; const Eina_List *l; char buf[4096]; @@ -365,11 +379,12 @@ _activate(Evas_Object *obj) elm_hoversel_hover_end(obj); return; } - sd->expanded = EINA_TRUE; if (elm_widget_disabled_get(obj)) return; if (!sd->items) return; + sd->expanded = EINA_TRUE; + sd->hover = elm_hover_add(sd->hover_parent); elm_widget_sub_object_add(obj, sd->hover); @@ -389,51 +404,21 @@ _activate(Evas_Object *obj) elm_hover_target_set(sd->hover, obj); /* hover's content */ - bx = elm_box_add(sd->hover); - elm_box_homogeneous_set(bx, EINA_TRUE); - elm_box_horizontal_set(bx, sd->horizontal); - evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - if (sd->horizontal) - snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s", - elm_widget_style_get(obj)); - else - snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s", - elm_widget_style_get(obj)); + sd->bx = elm_box_add(sd->hover); + elm_box_homogeneous_set(sd->bx, EINA_TRUE); + elm_box_horizontal_set(sd->bx, sd->horizontal); + evas_object_size_hint_align_set(sd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(sd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); EINA_LIST_FOREACH(sd->items, l, eo_item) { ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item); - VIEW(item) = bt = elm_button_add(bx); - elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj)); - elm_object_style_set(bt, buf); - elm_object_text_set(bt, item->label); - - if (item->icon_file) - { - ic = elm_icon_add(bt); - elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE); - if (item->icon_type == ELM_ICON_FILE) - elm_image_file_set(ic, item->icon_file, item->icon_group); - else if (item->icon_type == ELM_ICON_STANDARD) - elm_icon_standard_set(ic, item->icon_file); - elm_object_part_content_set(bt, "icon", ic); - } - - evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(bx, bt); - eo_do(bt, eo_event_callback_add - (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item)); - evas_object_show(bt); - eo_do(bt, - eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item), - eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item)); + evas_object_show(VIEW(item)); + elm_box_pack_end(sd->bx, VIEW(item)); } _create_scroller(obj, sd); - elm_object_content_set(sd->scr, bx); + elm_object_content_set(sd->scr, sd->bx); _resizing_eval(obj, sd); elm_object_part_content_set(sd->hover, sd->last_location, sd->tbl); @@ -581,6 +566,8 @@ _elm_hoversel_evas_object_smart_del(Eo *obj, Elm_Hoversel_Data *sd) EINA_LIST_FREE(sd->items, eo_item) { + ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it); + ELM_SAFE_FREE(VIEW(it), evas_object_del); eo_del(eo_item); } elm_hoversel_hover_parent_set(obj, NULL); @@ -761,6 +748,9 @@ _elm_hoversel_item_eo_base_constructor(Eo *obj, Elm_Hoversel_Item_Data *it) EOLIAN static Elm_Object_Item* _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data) { + Evas_Object *bt, *ic; + char buf[4096]; + Eo *eo_item = eo_add(ELM_HOVERSEL_ITEM_CLASS, obj); if (!eo_item) return NULL; @@ -772,6 +762,36 @@ _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const item->func = func; WIDGET_ITEM_DATA_SET(eo_item, data); + if (sd->horizontal) + snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s", + elm_widget_style_get(obj)); + else + snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s", + elm_widget_style_get(obj)); + + VIEW(item) = bt = elm_button_add(obj); + elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj)); + elm_object_style_set(bt, buf); + elm_object_text_set(bt, item->label); + + if (item->icon_file) + { + ic = elm_icon_add(bt); + elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE); + if (item->icon_type == ELM_ICON_FILE) + elm_image_file_set(ic, item->icon_file, item->icon_group); + else if (item->icon_type == ELM_ICON_STANDARD) + elm_icon_standard_set(ic, item->icon_file); + elm_object_part_content_set(bt, "icon", ic); + } + + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + eo_do(bt, + eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item), + eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item), + eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item)); + sd->items = eina_list_append(sd->items, eo_item); return eo_item; diff --git a/src/lib/elm_widget_hoversel.h b/src/lib/elm_widget_hoversel.h index 56e521b..d8441aa 100644 --- a/src/lib/elm_widget_hoversel.h +++ b/src/lib/elm_widget_hoversel.h @@ -35,6 +35,7 @@ struct _Elm_Hoversel_Data Evas_Object *spacer; Evas_Object *tbl; Evas_Object *scr; + Evas_Object *bx; const char *last_location; Eina_List *items;