focus: update the focus in_theme status on each item's focus set.
authorDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 11 May 2014 16:04:25 +0000 (01:04 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 11 May 2014 16:25:43 +0000 (01:25 +0900)
As widget and widget item can have different in_theme value (since
 30cada369), we need to update in_theme value whenever the widget or
widget item get the focus.

Applied this logic to genlist, gengrid, toolbar first.
List focus is not working well at the moment.

This fixes small focus highlight on the left top corner of genlist
when the genlist scroller is clicked before the genlist is focused.

Special thanks to zmike for the report.

src/lib/elm_gengrid.c
src/lib/elm_genlist.c
src/lib/elm_toolbar.c
src/lib/elm_widget.c
src/lib/elm_widget.h
src/lib/elm_win.c

index 3eebaf4..9402164 100644 (file)
@@ -911,8 +911,6 @@ _item_realize(Elm_Gen_Item *it)
    if (it->mouse_cursor)
      elm_widget_item_cursor_set(it, it->mouse_cursor);
 
-   _elm_widget_item_highlight_in_theme(WIDGET(it), (Elm_Object_Item *)it);
-
    it->realized = EINA_TRUE;
    it->want_unrealize = EINA_FALSE;
 }
@@ -2917,6 +2915,9 @@ _item_focus_set_hook(Elm_Object_Item *it, Eina_Bool focused)
              if (sd->focused_item)
                _elm_gengrid_item_unfocused((Elm_Gen_Item *)sd->focused_item);
              _elm_gengrid_item_focused((Elm_Gen_Item *)it);
+
+             _elm_widget_item_highlight_in_theme(obj, (Elm_Object_Item *)it);
+             _elm_widget_highlight_in_theme_update(obj);
              _elm_widget_focus_highlight_start(obj);
           }
      }
index c524d1a..640b618 100644 (file)
@@ -1754,9 +1754,6 @@ _item_realize(Elm_Gen_Item *it,
 
    if (it->decorate_it_set) _decorate_item_set(it);
 
-   if (!calc)
-     _elm_widget_item_highlight_in_theme(WIDGET(it), (Elm_Object_Item *)it);
-
    edje_object_message_signal_process(VIEW(it));
 }
 
@@ -5655,6 +5652,9 @@ _item_focus_set_hook(Elm_Object_Item *it, Eina_Bool focused)
              if (sd->focused_item)
                _elm_genlist_item_unfocused((Elm_Gen_Item *)sd->focused_item);
              _elm_genlist_item_focused((Elm_Gen_Item *)it);
+
+             _elm_widget_item_highlight_in_theme(obj, (Elm_Object_Item *)it);
+             _elm_widget_highlight_in_theme_update(obj);
              _elm_widget_focus_highlight_start(obj);
           }
      }
index 5ad643a..a4e257f 100644 (file)
@@ -820,6 +820,9 @@ _item_focus_set_hook(Elm_Object_Item *it, Eina_Bool focused)
         if (it)
           _elm_toolbar_item_unfocused((Elm_Toolbar_Item *)it);
      }
+
+   _elm_widget_item_highlight_in_theme(obj, (Elm_Object_Item *)it);
+   _elm_widget_highlight_in_theme_update(obj);
    _elm_widget_focus_highlight_start(obj);
 }
 
index 47f1855..57f0574 100644 (file)
@@ -1387,6 +1387,18 @@ _elm_widget_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *s
    /* FIXME: if focused, it should switch from one mode to the other */
 }
 
+void
+_elm_widget_highlight_in_theme_update(Eo *obj)
+{
+   Evas_Object *top = elm_widget_top_get(obj);
+
+   if (top && eo_isa(top, ELM_OBJ_WIN_CLASS))
+     {
+        _elm_win_focus_highlight_in_theme_update(
+           top, elm_widget_highlight_in_theme_get(obj));
+     }
+}
+
 EOLIAN static Eina_Bool
 _elm_widget_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
 {
index cdca308..808b6ed 100644 (file)
@@ -521,7 +521,9 @@ void                  _elm_access_widget_item_access_order_set(Elm_Widget_Item *
 const Eina_List      *_elm_access_widget_item_access_order_get(const Elm_Widget_Item *item);
 void                  _elm_access_widget_item_access_order_unset(Elm_Widget_Item *item);
 void                  _elm_widget_focus_highlight_start(const Evas_Object *obj);
+void                  _elm_widget_highlight_in_theme_update(Eo *obj);
 void                  _elm_win_focus_highlight_start(Evas_Object *obj);
+void                   _elm_win_focus_highlight_in_theme_update(Evas_Object *obj, Eina_Bool in_theme);
 
 EAPI void             _elm_access_clear(Elm_Access_Info *ac);
 EAPI void             _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text);
index aa80b2b..5976315 100644 (file)
@@ -4745,6 +4745,13 @@ _elm_win_window_id_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
 }
 
 void
+_elm_win_focus_highlight_in_theme_update(Evas_Object *obj, Eina_Bool in_theme)
+{
+   ELM_WIN_DATA_GET(obj, sd);
+   sd->focus_highlight.cur.in_theme = !!in_theme;
+}
+
+void
 _elm_win_focus_highlight_start(Evas_Object *obj)
 {
    ELM_WIN_DATA_GET(obj, sd);