cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=bc78159ff362e6867abc2a6451af9eb84b093245

commit bc78159ff362e6867abc2a6451af9eb84b093245
Author: Jee-Yong Um <jc9...@samsung.com>
Date:   Mon Jan 4 15:17:23 2016 -0800

    hoversel: auto update hoversel after dismiss animation finished.
    
    Summary:
    If auto_update feature changes hoversel width,
    dismiss animation seems awful because hoversel contents move to
    changed position in an instant.
    This patch makes hoversel update its content with clicked item
    after dismiss animation finished.
    
    Test Plan: elementary_test hoversel
    
    Reviewers: raster, cedric, jpeg
    
    Differential Revision: https://phab.enlightenment.org/D3519
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/bin/test_hoversel.c |  3 ++-
 src/lib/elc_hoversel.c  | 27 +++++++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/bin/test_hoversel.c b/src/bin/test_hoversel.c
index 15d4203..9dceb3f 100644
--- a/src/bin/test_hoversel.c
+++ b/src/bin/test_hoversel.c
@@ -107,7 +107,6 @@ _hoversel_selected_cb(void *data EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED,
    const char *txt = elm_object_item_text_get(event_info);
 
    printf("'selected' callback is called. (selected item : %s)\n", txt);
-   elm_object_text_set(obj, txt);
 }
 
 static void
@@ -165,6 +164,7 @@ test_hoversel(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_
    hoversel = elm_hoversel_add(win);
 // FIXME: need to add horizontal hoversel theme to default some day
 //   elm_hoversel_horizontal_set(bt, EINA_TRUE);
+   elm_hoversel_auto_update_set(hoversel, EINA_TRUE);
    elm_hoversel_hover_parent_set(hoversel, win);
    elm_object_text_set(hoversel, "Labels");
    elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
@@ -265,6 +265,7 @@ test_hoversel(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_
    evas_object_show(hoversel);
 
    hoversel = elm_hoversel_add(win);
+   elm_hoversel_auto_update_set(hoversel, EINA_TRUE);
    elm_hoversel_hover_parent_set(hoversel, win);
    elm_object_text_set(hoversel, "Custom Item Style");
    elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index 20285c4..51625da 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -121,20 +121,14 @@ _on_hover_clicked(void *data EINA_UNUSED,
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_on_item_clicked(void *data EINA_UNUSED,
-                     Eo *obj EINA_UNUSED, const Eo_Event_Description *desc 
EINA_UNUSED,
-                     void *event_info EINA_UNUSED)
+static void
+_auto_update(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 
void *event_info EINA_UNUSED)
 {
    Elm_Hoversel_Item_Data *item = data;
    Evas_Object *obj2 = WIDGET(item);
-   Elm_Object_Item *eo_it = EO_OBJ(item);
 
    ELM_HOVERSEL_DATA_GET(obj2, sd);
 
-   if (item->func) item->func((void *)WIDGET_ITEM_DATA_GET(eo_it), obj2, 
eo_it);
-   eo_do(obj2, 
eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it));
-
    if (sd->auto_update)
      {
         Evas_Object *ic;
@@ -156,6 +150,23 @@ _on_item_clicked(void *data EINA_UNUSED,
         if(item->label)
           elm_object_text_set(obj2, item->label);
      }
+}
+
+static Eina_Bool
+_on_item_clicked(void *data EINA_UNUSED,
+                     Eo *obj EINA_UNUSED, const Eo_Event_Description *desc 
EINA_UNUSED,
+                     void *event_info EINA_UNUSED)
+{
+   Elm_Hoversel_Item_Data *item = data;
+   Evas_Object *obj2 = WIDGET(item);
+   Elm_Object_Item *eo_it = EO_OBJ(item);
+
+   ELM_HOVERSEL_DATA_GET(obj2, sd);
+
+   if (item->func) item->func((void *)WIDGET_ITEM_DATA_GET(eo_it), obj2, 
eo_it);
+   eo_do(obj2, 
eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it));
+
+   evas_object_event_callback_add(sd->hover, EVAS_CALLBACK_DEL, _auto_update, 
item);
 
    elm_hoversel_hover_end(obj2);
 

-- 


Reply via email to