summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJee-Yong Um <jc9.um@samsung.com>2016-02-05 07:47:31 +0100
committerCedric BAIL <cedric@osg.samsung.com>2016-02-05 08:45:19 +0100
commitd195270b6415c165f842f4f3debba8f0fc43525d (patch)
treea49076ae5c355d2690452f3817c79e0766b4a64e
parentb57a785f02b43e86faf9012e4410e07046173703 (diff)
hoversel: improve key_action_move to handle disabled items
Summary: Existing key_action_move logic used elm_widget_focus_cycle on hover, but only handled the first and last item to move focus circularly. So if the first or last item is disabled, focus movement is blocked. This patch makes hoversel handle focus movement by itself to handle disabled item better. Test Plan: elementary_test -to hoversel Reviewers: Hermet, cedric, Jaehyun Differential Revision: https://phab.enlightenment.org/D3640 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/elc_hoversel.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index b089f4f6c..370d2d3ec 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -848,63 +848,67 @@ item_focused_get(Elm_Hoversel_Data *sd)
848} 848}
849 849
850static Eina_Bool 850static Eina_Bool
851item_focused_set(Elm_Object_Item *eo_item, Eina_Bool focus)
852{
853 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
854 if (elm_object_disabled_get(VIEW(item)))
855 return EINA_FALSE;
856 elm_object_focus_set(VIEW(item), focus);
857 return EINA_TRUE;
858}
859
860static Eina_Bool
851_key_action_move(Evas_Object *obj, const char *params) 861_key_action_move(Evas_Object *obj, const char *params)
852{ 862{
863 Eina_List *l;
864 Elm_Object_Item *focused_item, *eo_item;
865 Eina_Bool ret, next = EINA_FALSE;
866
853 ELM_HOVERSEL_DATA_GET(obj, sd); 867 ELM_HOVERSEL_DATA_GET(obj, sd);
854 const char *dir = params; 868 const char *dir = params;
855 869
856 Elm_Object_Item *eo_litem, *eo_fitem;
857 eo_litem = eina_list_last_data_get(sd->items);
858 eo_fitem = eina_list_data_get(sd->items);
859
860 _elm_widget_focus_auto_show(obj); 870 _elm_widget_focus_auto_show(obj);
861 if (!strcmp(dir, "down")) 871 if (!strcmp(dir, "down") || !strcmp(dir, "right"))
862 { 872 {
863 if ((!sd->horizontal) && 873 focused_item = item_focused_get(sd);
864 (item_focused_get(sd) == eo_litem)) 874 EINA_LIST_FOREACH(sd->items, l, eo_item)
865 { 875 {
866 ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem); 876 if (next)
867 elm_object_focus_set(VIEW(fitem), EINA_TRUE); 877 {
868 return EINA_TRUE; 878 ret = item_focused_set(eo_item, EINA_TRUE);
879 if (ret) return EINA_TRUE;
880 }
881 if (eo_item == focused_item) next = EINA_TRUE;
869 } 882 }
870 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_DOWN); 883 EINA_LIST_FOREACH(sd->items, l, eo_item)
871 return EINA_TRUE;
872 }
873 else if (!strcmp(dir, "up"))
874 {
875 if ((!sd->horizontal) &&
876 (item_focused_get(sd) == eo_fitem))
877 { 884 {
878 ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem); 885 if (eo_item == focused_item) return EINA_FALSE;
879 elm_object_focus_set(VIEW(litem), EINA_TRUE); 886
880 return EINA_TRUE; 887 ret = item_focused_set(eo_item, EINA_TRUE);
888 if (ret) return EINA_TRUE;
881 } 889 }
882 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_UP); 890 return EINA_FALSE;
883 return EINA_TRUE;
884 } 891 }
885 else if (!strcmp(dir, "left")) 892 else if (!strcmp(dir, "up") || !strcmp(dir, "left"))
886 { 893 {
887 if (sd->horizontal && 894 focused_item = item_focused_get(sd);
888 (item_focused_get(sd) == eo_fitem)) 895 EINA_LIST_REVERSE_FOREACH(sd->items, l, eo_item)
889 { 896 {
890 ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem); 897 if (next)
891 elm_object_focus_set(VIEW(litem), EINA_TRUE); 898 {
892 return EINA_TRUE; 899 ret = item_focused_set(eo_item, EINA_TRUE);
900 if (ret) return EINA_TRUE;
901 }
902 if (eo_item == focused_item) next = EINA_TRUE;
893 } 903 }
894 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_LEFT); 904 EINA_LIST_REVERSE_FOREACH(sd->items, l, eo_item)
895 return EINA_TRUE;
896 }
897 else if (!strcmp(dir, "right"))
898 {
899 if (sd->horizontal &&
900 (item_focused_get(sd) == eo_litem))
901 { 905 {
902 ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem); 906 if (eo_item == focused_item) return EINA_FALSE;
903 elm_object_focus_set(VIEW(fitem), EINA_TRUE); 907
904 return EINA_TRUE; 908 ret = item_focused_set(eo_item, EINA_TRUE);
909 if (ret) return EINA_TRUE;
905 } 910 }
906 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_RIGHT); 911 return EINA_FALSE;
907 return EINA_TRUE;
908 } 912 }
909 else return EINA_FALSE; 913 else return EINA_FALSE;
910} 914}