[*][Genlist] Do not unrealize the item if any icon object is focused.
authorDaniel Juyung Seo <juyung.seo@samsung.com>
Thu, 22 Sep 2011 10:30:34 +0000 (19:30 +0900)
committerDaniel Juyung Seo <juyung.seo@samsung.com>
Fri, 23 Sep 2011 00:34:36 +0000 (09:34 +0900)
Added "focused" smart callback to editfield.

Change-Id: Iaf86ea0532f8141f51d47ce0127867f11bad077b

src/lib/elm_editfield.c
src/lib/elm_genlist.c

index fa66746..fb21e81 100644 (file)
@@ -44,6 +44,13 @@ static void _show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _on_focus_hook(void *data, Evas_Object *obj);
 static Eina_Bool _empty_entry(Evas_Object *entry);
 
+static const char SIG_FOCUSED[] = "focused";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+   {SIG_FOCUSED, ""},
+   {NULL, NULL}
+};
+
 static void
 _del_hook(Evas_Object *obj)
 {
@@ -59,7 +66,7 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd || !wd->base)
       return;
-   if (!elm_widget_focus_get(obj) && !(elm_widget_disabled_get(obj)) )
+   if (!elm_widget_focus_get(obj))
      {
         evas_object_smart_callback_call(obj, "unfocused", NULL);
         wd->editing = EINA_FALSE;
@@ -80,6 +87,10 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
                }
           }
      }
+   else
+     {
+        evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
+     }
 }
 
 static void
@@ -343,6 +354,7 @@ elm_editfield_add(Evas_Object *parent)
    evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
    elm_widget_sub_object_add(obj, wd->entry);
    evas_object_show(wd->entry);
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
    _sizing_eval(obj);
 
    return obj;
index 058fc3e..52b45fd 100644 (file)
@@ -171,6 +171,7 @@ struct _Elm_Genlist_Item
    Eina_Bool                     updateme : 1;
    Eina_Bool                     nocache : 1;
    Eina_Bool                     move_effect_enabled : 1;
+   Eina_Bool                     defer_unrealize : 1;
 
    // TODO: refactoring
    Eina_Bool   effect_done : 1;
@@ -1685,6 +1686,20 @@ _item_cache_free(Item_Cache *itc)
 }
 
 static void
+_icon_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Elm_Genlist_Item *it = data;
+   if (it) it->defer_unrealize = EINA_TRUE;
+}
+
+static void
+_icon_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Elm_Genlist_Item *it = data;
+   if (it) it->defer_unrealize = EINA_FALSE;
+}
+
+static void
 _item_realize(Elm_Genlist_Item *it,
               int               in,
               Eina_Bool         calc)
@@ -1920,6 +1935,10 @@ _item_realize(Elm_Genlist_Item *it,
                              edje_object_part_swallow(it->base.view, key, ic);
                              evas_object_show(ic);
                              elm_widget_sub_object_add(it->base.widget, ic);
+                             // FIXME: if entry calcuates its cursor position correctly and conformant works,
+                             //        genlist does not need to handle this focus thing.
+                             evas_object_smart_callback_add(ic, "focused", _icon_focused, it);
+                             evas_object_smart_callback_add(ic, "unfocused", _icon_unfocused, it);
                          }
                     }
               }
@@ -2018,6 +2037,7 @@ _item_unrealize(Elm_Genlist_Item *it,
 
    if (!it->realized) return;
    if (it->wd->reorder_it == it) return;
+   if (it->defer_unrealize) return;
    evas_event_freeze(evas_object_evas_get(it->wd->obj));
    if (!calc)
      evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
@@ -4491,6 +4511,7 @@ elm_genlist_item_update(Elm_Genlist_Item *it)
    it->block->updateme = EINA_TRUE;
    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
    it->wd->update_job = ecore_job_add(_update_job, it->wd);
+   it->defer_unrealize = EINA_FALSE;
 }
 
 EAPI void