Refactoring focus_cycle_next_get and copies
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>
Mon, 27 Sep 2010 21:13:25 +0000 (21:13 +0000)
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>
Mon, 27 Sep 2010 21:13:25 +0000 (21:13 +0000)
SVN revision: 52813

src/lib/elm_panel.c
src/lib/elm_scroller.c
src/lib/elm_widget.c

index 7482c400b97d7cf19ae3a13f29a45d55ef67f2e6..d9f9aecfb3fc0ac4fbbe519b21d7fcc1f7d8971d 100644 (file)
@@ -56,6 +56,7 @@ static Eina_Bool
 _elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Object *cur;
 
    if ((!wd) || (!wd->content))
      return EINA_FALSE;
@@ -63,14 +64,18 @@ _elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool
    if (wd->hidden)
      return EINA_FALSE;
 
+   cur = wd->content;
+
    /* Try Focus cycle in subitem */
-   if (elm_widget_focus_cycle(wd->content, dir, circular))
+   if (elm_widget_focus_cycle(cur, dir, circular))
      return EINA_TRUE;
+   /* Ignore focused subitem */
+   if (elm_widget_focus_get(cur) && (!circular))
+     return EINA_FALSE;
    /* Try give the focus to sub item*/
-   else if (elm_widget_can_focus_get(wd->content) &&
-            ((!elm_widget_focus_get(wd->content)) || circular))
+   if (elm_widget_can_focus_get(cur))
      {
-        elm_widget_focus_steal(wd->content);
+        elm_widget_focus_steal(cur);
         return EINA_TRUE;
      }
 
index 4e45a46f80a46a172d547e8864e4acc87bfbd7e0..67a14e32990c22ffbb69bfb9e24b0bb87c06c107 100644 (file)
@@ -108,17 +108,23 @@ static Eina_Bool
 _elm_scroller_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Object *cur;
+
    if ((!wd) || (!wd->content))
      return EINA_FALSE;
 
+   cur = wd->content;
+
    /* Try Focus cycle in subitem */
-   if (elm_widget_focus_cycle(wd->content, dir, circular))
+   if (elm_widget_focus_cycle(cur, dir, circular))
      return EINA_TRUE;
+   /* Ignore focused subitem */
+   if (elm_widget_focus_get(cur) && (!circular))
+     return EINA_FALSE;
    /* Try give the focus to sub item*/
-   else if (elm_widget_can_focus_get(wd->content) &&
-            ((!elm_widget_focus_get(wd->content)) || circular))
+   if (elm_widget_can_focus_get(cur))
      {
-        elm_widget_focus_steal(wd->content);
+        elm_widget_focus_steal(cur);
         return EINA_TRUE;
      }
 
index f3fae3ce36c3e148c680b8dc879bbe521aa1ef87..bb3b63df5f9ca402f94d48f922a81be5942758ec 100644 (file)
@@ -757,12 +757,15 @@ elm_widget_focus_cycle_next_get(Evas_Object *obj, Eina_List *items, void *(*list
         for (;l; l = list_next(l))
           {
              cur = list_data_get(l);
+
              /* Try Focus cycle in subitem */
              if (elm_widget_focus_cycle(cur, dir, child_circular))
                break;
+             /* Ignore focused subitem */
+             if (elm_widget_focus_get(cur) && (!child_circular))
+               continue;
              /* Try give the focus to sub item*/
-             else if (elm_widget_can_focus_get(cur) &&
-                      ((!elm_widget_focus_get(cur)) || child_circular))
+             if (elm_widget_can_focus_get(cur))
                {
                   elm_widget_focus_steal(cur);
                   break;