[Genlist/list] Only focus on default or always items
authorTae-Hwan Kim <the81.kim@samsung.com>
Thu, 25 Apr 2013 18:56:45 +0000 (03:56 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Wed, 12 Jun 2013 04:32:00 +0000 (13:32 +0900)
Change-Id: Ib68c8986c3220fb0638ead5ecb4d494f0e219710

src/lib/elm_genlist.c
src/lib/elm_list.c

index 33792af..2ca8d57 100644 (file)
@@ -2636,50 +2636,59 @@ static void _item_unfocused(Elm_Gen_Item *it)
       sd->focused = NULL;
 }
 
-static Elm_Gen_Item *_item_focused_search(Elm_Gen_Item *it, int dir)
+static Elm_Gen_Item *_item_focusable_search(Elm_Gen_Item *it, int dir)
 {
    if (!it) return NULL;
    Elm_Gen_Item *tmp = it;
    if (dir == 1)
      {
-        tmp = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(tmp)->next);
+        while (tmp)
+          {
+             if ((tmp->select_mode == ELM_OBJECT_SELECT_MODE_DEFAULT) ||
+                 (tmp->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
+                break;
+             tmp = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(tmp)->next);
+          }
      }
    else
      {
-        tmp = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(tmp)->prev);
+        while (tmp)
+          {
+             if ((tmp->select_mode == ELM_OBJECT_SELECT_MODE_DEFAULT) ||
+                 (tmp->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
+                break;
+             tmp = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(tmp)->prev);
+          }
      }
-   if (!tmp) tmp = it;
    return tmp;
 }
 
 static Eina_Bool _item_focused_next(Elm_Genlist_Smart_Data *sd, int dir)
 {
-   Elm_Gen_Item *it = NULL, *old_focused = NULL;
-   if (elm_widget_focus_get(ELM_WIDGET_DATA(sd)->obj))
-      edje_object_signal_emit
-         (ELM_WIDGET_DATA(sd)->resize_obj, "elm,state,unfocused", "elm");
-
-   old_focused = sd->focused;
+   Elm_Gen_Item *it = NULL;
+   Elm_Gen_Item *old_focused = sd->focused;
 
-   if (!sd->focused)
+   if (sd->focused)
      {
         if (dir == 1)
-           it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
+           it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(sd->focused)->next);
         else
-           it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
+           it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(sd->focused)->prev);
+        _item_unfocused(sd->focused);
      }
    else
      {
-        it = sd->focused;
-        _item_unfocused(sd->focused);
-        it = _item_focused_search(it, dir);
+        if (dir == 1) it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
+        else it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
+     }
+   it = _item_focusable_search(it, dir);
+   if (!it)
+     {
+        _item_focused(old_focused);
+        return EINA_FALSE;
      }
    _item_focused(it);
-
-   if (old_focused == sd->focused)
-     return EINA_FALSE;
-   else
-     return EINA_TRUE;
+   return EINA_TRUE;
 }
 
 static Eina_Bool
index a4437b0..693f97f 100644 (file)
@@ -225,46 +225,34 @@ static void _item_unfocused(Elm_List_Item *it)
       sd->focused = NULL;
 }
 
-static Elm_List_Item *_item_focused_search(Elm_List_Item *it, int dir)
-{
-   if (!it) return NULL;
-   Eina_List *l = eina_list_data_find_list(it->sd->items, it);
-   Eina_List *tmp = l;
-   if (dir == 1) tmp = eina_list_next(tmp);
-   else tmp = eina_list_prev(tmp);
-   if (!tmp) tmp = l;
-   return (Elm_List_Item *)eina_list_data_get(tmp);
-}
-
 static Eina_Bool _item_focused_next(Elm_List_Smart_Data *sd, int dir)
 {
-   Elm_List_Item *it = NULL, *old_focused = NULL;
-
-   if (elm_widget_focus_get(ELM_WIDGET_DATA(sd)->obj))
-      edje_object_signal_emit
-         (ELM_WIDGET_DATA(sd)->resize_obj, "elm,state,unfocused", "elm");
-
-   old_focused = sd->focused;
+   Elm_List_Item *it = NULL;
+   Elm_List_Item *old_focused = (Elm_List_Item *)sd->focused;
 
-   if (!sd->focused)
+   if (sd->focused)
      {
+        Eina_List *l = eina_list_data_find_list(sd->items, sd->focused);
         if (dir == 1)
-           it = (Elm_List_Item *)eina_list_data_get(sd->items);
+          {
+             it = (Elm_List_Item *)eina_list_data_get(eina_list_next(l));
+          }
         else
-           it = (Elm_List_Item *)eina_list_data_get(eina_list_last(sd->items));
+           it = (Elm_List_Item *)eina_list_data_get(eina_list_prev(l));
+        _item_unfocused((Elm_List_Item *)sd->focused);
      }
    else
      {
-        it = (Elm_List_Item *)sd->focused;
-        _item_unfocused((Elm_List_Item *)sd->focused);
-        it = _item_focused_search(it, dir);
+        if (dir == 1) it = (Elm_List_Item *)eina_list_data_get(sd->items);
+        else it = (Elm_List_Item *)eina_list_data_get(eina_list_last(sd->items));
+     }
+   if (!it)
+     {
+        _item_focused(old_focused);
+        return EINA_FALSE;
      }
    _item_focused(it);
-
-   if (old_focused == sd->focused)
-     return EINA_FALSE;
-   else
-     return EINA_TRUE;
+   return EINA_TRUE;
 }