summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgodly.talias <godly.talias@samsung.com>2015-11-09 12:18:49 -0800
committerCedric BAIL <cedric@osg.samsung.com>2015-11-09 12:37:09 -0800
commit58edfd10d7b077382178713699d9c84367d1686c (patch)
tree7d31c7ebf2af607157de3fc8000ba2e94b742b50
parentf7edbd6cbeaf129e5682126a7015334ad3632e3e (diff)
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: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--AUTHORS2
-rw-r--r--src/lib/elc_hoversel.c105
-rw-r--r--src/lib/elm_widget_hoversel.h1
3 files changed, 66 insertions, 42 deletions
diff --git a/AUTHORS b/AUTHORS
index eefcd8133..1c8b97913 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -164,5 +164,5 @@ Jee-Yong Um <conr2d@gmail.com>
164Ji-In Moon <jiin.moon@samsung.com> 164Ji-In Moon <jiin.moon@samsung.com>
165Subodh Kumar <s7158.kumar@samsung.com> 165Subodh Kumar <s7158.kumar@samsung.com>
166Kumar Navneet <k.navneet@samsung.com> 166Kumar Navneet <k.navneet@samsung.com>
167Godly T Alias <godly.talias@samsung.com> 167Godly T Alias <godly.talias@samsung.com> <godlytalias@yahoo.co.in>
168Shashank Pandey <shashank.p@samsung.com> <shashank0990@gmail.com> 168Shashank Pandey <shashank.p@samsung.com> <shashank0990@gmail.com>
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index 11e943659..11c85febf 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -60,6 +60,8 @@ EOLIAN static Eina_Bool
60_elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd) 60_elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd)
61{ 61{
62 Eina_Bool int_ret = EINA_FALSE; 62 Eina_Bool int_ret = EINA_FALSE;
63 Eina_List *l;
64 Elm_Object_Item *eo_item;
63 65
64 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 66 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
65 67
@@ -81,11 +83,22 @@ _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd)
81 83
82 eina_stringshare_replace(&(wd->style), style); 84 eina_stringshare_replace(&(wd->style), style);
83 85
84 eina_stringshare_del(style);
85
86 if (sd->hover) 86 if (sd->hover)
87 elm_widget_mirrored_set(sd->hover, elm_widget_mirrored_get(obj)); 87 elm_widget_mirrored_set(sd->hover, elm_widget_mirrored_get(obj));
88 88
89 if (sd->horizontal)
90 snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s", style);
91 else
92 snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s", style);
93
94 EINA_LIST_FOREACH(sd->items, l, eo_item)
95 {
96 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
97 elm_object_style_set(VIEW(item), buf);
98 elm_object_text_set(VIEW(item), item->label);
99 }
100
101 eina_stringshare_del(style);
89 elm_hoversel_hover_end(obj); 102 elm_hoversel_hover_end(obj);
90 103
91 return EINA_TRUE; 104 return EINA_TRUE;
@@ -346,9 +359,11 @@ _hover_end_finished(void *data,
346 EINA_LIST_FOREACH(sd->items, l, eo_item) 359 EINA_LIST_FOREACH(sd->items, l, eo_item)
347 { 360 {
348 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it); 361 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
349 VIEW(it) = NULL; 362 elm_box_unpack(sd->bx, VIEW(it));
363 evas_object_hide(VIEW(it));
350 } 364 }
351 ELM_SAFE_FREE(sd->hover, evas_object_del); 365 ELM_SAFE_FREE(sd->hover, evas_object_del);
366 sd->bx = NULL;
352 sd->scr = NULL; 367 sd->scr = NULL;
353 sd->last_location = NULL; 368 sd->last_location = NULL;
354 369
@@ -360,7 +375,6 @@ static void
360_activate(Evas_Object *obj) 375_activate(Evas_Object *obj)
361{ 376{
362 Elm_Object_Item *eo_item; 377 Elm_Object_Item *eo_item;
363 Evas_Object *bt, *bx, *ic;
364 const Eina_List *l; 378 const Eina_List *l;
365 char buf[4096]; 379 char buf[4096];
366 380
@@ -394,49 +408,19 @@ _activate(Evas_Object *obj)
394 elm_hover_target_set(sd->hover, obj); 408 elm_hover_target_set(sd->hover, obj);
395 409
396 /* hover's content */ 410 /* hover's content */
397 bx = elm_box_add(sd->hover); 411 sd->bx = elm_box_add(sd->hover);
398 elm_box_homogeneous_set(bx, EINA_TRUE); 412 elm_box_homogeneous_set(sd->bx, EINA_TRUE);
399 elm_box_horizontal_set(bx, sd->horizontal); 413 elm_box_horizontal_set(sd->bx, sd->horizontal);
400
401 if (sd->horizontal)
402 snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s",
403 elm_widget_style_get(obj));
404 else
405 snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
406 elm_widget_style_get(obj));
407 414
408 EINA_LIST_FOREACH(sd->items, l, eo_item) 415 EINA_LIST_FOREACH(sd->items, l, eo_item)
409 { 416 {
410 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item); 417 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
411 VIEW(item) = bt = elm_button_add(bx); 418 evas_object_show(VIEW(item));
412 elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj)); 419 elm_box_pack_end(sd->bx, VIEW(item));
413 elm_object_style_set(bt, buf);
414 elm_object_text_set(bt, item->label);
415
416 if (item->icon_file)
417 {
418 ic = elm_icon_add(bt);
419 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
420 if (item->icon_type == ELM_ICON_FILE)
421 elm_image_file_set(ic, item->icon_file, item->icon_group);
422 else if (item->icon_type == ELM_ICON_STANDARD)
423 elm_icon_standard_set(ic, item->icon_file);
424 elm_object_part_content_set(bt, "icon", ic);
425 }
426
427 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
428 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
429 elm_box_pack_end(bx, bt);
430 eo_do(bt, eo_event_callback_add
431 (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item));
432 evas_object_show(bt);
433 eo_do(bt,
434 eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item),
435 eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item));
436 } 420 }
437 421
438 _create_scroller(obj, sd); 422 _create_scroller(obj, sd);
439 elm_object_content_set(sd->scr, bx); 423 elm_object_content_set(sd->scr, sd->bx);
440 424
441 _resizing_eval(obj, sd); 425 _resizing_eval(obj, sd);
442 elm_object_part_content_set(sd->hover, sd->last_location, sd->tbl); 426 elm_object_part_content_set(sd->hover, sd->last_location, sd->tbl);
@@ -573,6 +557,8 @@ _elm_hoversel_evas_object_smart_del(Eo *obj, Elm_Hoversel_Data *sd)
573 557
574 EINA_LIST_FREE(sd->items, eo_item) 558 EINA_LIST_FREE(sd->items, eo_item)
575 { 559 {
560 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
561 ELM_SAFE_FREE(VIEW(it), evas_object_del);
576 eo_del(eo_item); 562 eo_del(eo_item);
577 } 563 }
578 elm_hoversel_hover_parent_set(obj, NULL); 564 elm_hoversel_hover_parent_set(obj, NULL);
@@ -717,11 +703,13 @@ _elm_hoversel_hover_end(Eo *obj, Elm_Hoversel_Data *sd)
717 EINA_LIST_FOREACH(sd->items, l, eo_item) 703 EINA_LIST_FOREACH(sd->items, l, eo_item)
718 { 704 {
719 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it); 705 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
720 VIEW(it) = NULL; 706 elm_box_unpack(sd->bx, VIEW(it));
707 evas_object_hide(VIEW(it));
721 } 708 }
722 ELM_SAFE_FREE(sd->hover, evas_object_del); 709 ELM_SAFE_FREE(sd->hover, evas_object_del);
723 sd->scr = NULL; 710 sd->scr = NULL;
724 sd->last_location = NULL; 711 sd->last_location = NULL;
712 sd->bx = NULL;
725 713
726 eo_do(obj, eo_event_callback_call(ELM_HOVERSEL_EVENT_DISMISSED, NULL)); 714 eo_do(obj, eo_event_callback_call(ELM_HOVERSEL_EVENT_DISMISSED, NULL));
727 } // for backward compatibility 715 } // for backward compatibility
@@ -763,6 +751,9 @@ _elm_hoversel_item_eo_base_constructor(Eo *obj, Elm_Hoversel_Item_Data *it)
763EOLIAN static Elm_Object_Item* 751EOLIAN static Elm_Object_Item*
764_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) 752_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)
765{ 753{
754 Evas_Object *bt, *ic;
755 char buf[4096];
756
766 Eo *eo_item = eo_add(ELM_HOVERSEL_ITEM_CLASS, obj); 757 Eo *eo_item = eo_add(ELM_HOVERSEL_ITEM_CLASS, obj);
767 if (!eo_item) return NULL; 758 if (!eo_item) return NULL;
768 759
@@ -774,6 +765,38 @@ _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const
774 item->func = func; 765 item->func = func;
775 WIDGET_ITEM_DATA_SET(eo_item, data); 766 WIDGET_ITEM_DATA_SET(eo_item, data);
776 767
768 if (sd->horizontal)
769 snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s",
770 elm_widget_style_get(obj));
771 else
772 snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
773 elm_widget_style_get(obj));
774
775
776 VIEW(item) = bt = elm_button_add(obj);
777 elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
778 elm_object_style_set(bt, buf);
779 elm_object_text_set(bt, item->label);
780
781 if (item->icon_file)
782 {
783 ic = elm_icon_add(bt);
784 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
785 if (item->icon_type == ELM_ICON_FILE)
786 elm_image_file_set(ic, item->icon_file, item->icon_group);
787 else if (item->icon_type == ELM_ICON_STANDARD)
788 elm_icon_standard_set(ic, item->icon_file);
789 elm_object_part_content_set(bt, "icon", ic);
790 }
791
792 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
793 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
794 eo_do(bt,
795 eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item));
796 eo_do(bt,
797 eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item),
798 eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item));
799
777 sd->items = eina_list_append(sd->items, eo_item); 800 sd->items = eina_list_append(sd->items, eo_item);
778 801
779 return eo_item; 802 return eo_item;
diff --git a/src/lib/elm_widget_hoversel.h b/src/lib/elm_widget_hoversel.h
index 56e521ba5..d8441aa52 100644
--- a/src/lib/elm_widget_hoversel.h
+++ b/src/lib/elm_widget_hoversel.h
@@ -35,6 +35,7 @@ struct _Elm_Hoversel_Data
35 Evas_Object *spacer; 35 Evas_Object *spacer;
36 Evas_Object *tbl; 36 Evas_Object *tbl;
37 Evas_Object *scr; 37 Evas_Object *scr;
38 Evas_Object *bx;
38 const char *last_location; 39 const char *last_location;
39 40
40 Eina_List *items; 41 Eina_List *items;