Genlist/Gengrid : Modified to handle the focus highlight on unrealized items
authorSangHyeon Lee <sh10233.lee@samsung.com>
Wed, 11 Mar 2015 10:59:58 +0000 (19:59 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Wed, 11 Mar 2015 11:35:53 +0000 (20:35 +0900)
Summary:
When unrealized item is focused, edje object is not exist,
         so genlist cannot read the focus highlight information from edje object.
         Therefore, when the item is realized, check the item is focused or not and
         need to update focus highlight.

@fix

Test Plan: change edc for supporting focus highlight in edc, and set focus on unrealized items.

Reviewers: raster, seoz, jaehwan

Differential Revision: https://phab.enlightenment.org/D2128

legacy/elementary/src/lib/elm_gengrid.c
legacy/elementary/src/lib/elm_genlist.c

index 0f41654..35cb007 100644 (file)
@@ -1014,6 +1014,13 @@ _item_realize(Elm_Gen_Item *it)
    if (it->mouse_cursor)
      eo_do(eo_it, elm_wdg_item_cursor_set(it->mouse_cursor));
 
+   if (eo_it == sd->focused_item)
+     {
+        _elm_widget_item_highlight_in_theme(WIDGET(it), EO_OBJ(it));
+        _elm_widget_highlight_in_theme_update(WIDGET(it));
+        _elm_widget_focus_highlight_start(WIDGET(it));
+     }
+
    it->realized = EINA_TRUE;
    it->want_unrealize = EINA_FALSE;
 }
@@ -1617,15 +1624,18 @@ _elm_gengrid_item_focused(Elm_Object_Item *eo_it)
 
    sd->focused_item = eo_it;
 
-   if (elm_widget_focus_highlight_enabled_get(obj))
+   if (it->realized)
      {
-        edje_object_signal_emit
-           (VIEW(it), "elm,state,focused", "elm");
-     }
+        if (elm_widget_focus_highlight_enabled_get(obj))
+          {
+             edje_object_signal_emit
+                (VIEW(it), "elm,state,focused", "elm");
+          }
 
-   focus_raise = edje_object_data_get(VIEW(it), "focusraise");
-   if ((focus_raise) && (!strcmp(focus_raise, "on")))
-     evas_object_raise(VIEW(it));
+        focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+        if ((focus_raise) && (!strcmp(focus_raise, "on")))
+          evas_object_raise(VIEW(it));
+     }
    evas_object_smart_callback_call(obj, SIG_ITEM_FOCUSED, eo_it);
 }
 
@@ -3460,9 +3470,24 @@ _elm_gengrid_item_elm_widget_item_focus_set(Eo *eo_it, Elm_Gen_Item *it, Eina_Bo
                _elm_gengrid_item_unfocused(sd->focused_item);
              _elm_gengrid_item_focused(eo_it);
 
-             _elm_widget_item_highlight_in_theme(obj, eo_it);
-             _elm_widget_highlight_in_theme_update(obj);
-             _elm_widget_focus_highlight_start(obj);
+             /* If item is not realized state, widget couldn't get focus_highlight data. */
+             if (it->realized)
+               {
+                  const char *focus_raise;
+                  if (elm_widget_focus_highlight_enabled_get(obj))
+                    {
+                       edje_object_signal_emit
+                          (VIEW(it), "elm,state,focused", "elm");
+                    }
+
+                  focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+                  if ((focus_raise) && (!strcmp(focus_raise, "on")))
+                    evas_object_raise(VIEW(it));
+
+                  _elm_widget_item_highlight_in_theme(obj, eo_it);
+                  _elm_widget_highlight_in_theme_update(obj);
+                  _elm_widget_focus_highlight_start(obj);
+               }
           }
      }
    else
index 9258cda..87b3c2d 100644 (file)
@@ -1731,6 +1731,21 @@ _item_realize(Elm_Gen_Item *it,
 
         _elm_genlist_item_state_update(it, itc);
         _elm_genlist_item_index_update(it);
+
+        if (EO_OBJ(it) == sd->focused_item)
+          {
+             const char *focus_raise;
+             if (elm_widget_focus_highlight_enabled_get(WIDGET(it)))
+               edje_object_signal_emit(VIEW(it), SIGNAL_FOCUSED, "elm");
+
+             focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+             if ((focus_raise) && (!strcmp(focus_raise, "on")))
+               evas_object_raise(VIEW(it));
+
+             _elm_widget_item_highlight_in_theme(WIDGET(it), EO_OBJ(it));
+             _elm_widget_highlight_in_theme_update(WIDGET(it));
+             _elm_widget_focus_highlight_start(WIDGET(it));
+          }
      }
 
    /* homogeneous genlist shortcut */
@@ -2569,12 +2584,15 @@ _elm_genlist_item_focused(Elm_Object_Item *eo_it)
 
    sd->focused_item = eo_it;
 
-   if (elm_widget_focus_highlight_enabled_get(obj))
-     edje_object_signal_emit(VIEW(it), SIGNAL_FOCUSED, "elm");
+   if (it->realized)
+     {
+        if (elm_widget_focus_highlight_enabled_get(obj))
+          edje_object_signal_emit(VIEW(it), SIGNAL_FOCUSED, "elm");
 
-   focus_raise = edje_object_data_get(VIEW(it), "focusraise");
-   if ((focus_raise) && (!strcmp(focus_raise, "on")))
-     evas_object_raise(VIEW(it));
+        focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+        if ((focus_raise) && (!strcmp(focus_raise, "on")))
+          evas_object_raise(VIEW(it));
+     }
    evas_object_smart_callback_call(obj, SIG_ITEM_FOCUSED, eo_it);
 }
 
@@ -5806,9 +5824,13 @@ _elm_genlist_item_elm_widget_item_focus_set(Eo *eo_it, Elm_Gen_Item *it, Eina_Bo
                _elm_genlist_item_unfocused(sd->focused_item);
              _elm_genlist_item_focused(eo_it);
 
-             _elm_widget_item_highlight_in_theme(obj, EO_OBJ(it));
-             _elm_widget_highlight_in_theme_update(obj);
-             _elm_widget_focus_highlight_start(obj);
+             /* If item is not realized state, widget couldn't get focus_highlight data. */
+             if (it->realized)
+               {
+                  _elm_widget_item_highlight_in_theme(obj, EO_OBJ(it));
+                  _elm_widget_highlight_in_theme_update(obj);
+                  _elm_widget_focus_highlight_start(obj);
+               }
           }
      }
    else