aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2016-07-01 11:52:39 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-01 17:20:40 +0900
commiteffe9b169658ec10f2edca087e4cfd4d8cea8dcf (patch)
tree92310a816f854d74e4e02c2514836cabd486fd41
parenttests: Disable profile_exists as it fails on jenkins (diff)
downloadefl-effe9b169658ec10f2edca087e4cfd4d8cea8dcf.tar.gz
gengrid: fix focus issue when prev/next item is disabled
Summary: After setting focus to disabled item, focus does not work properly. It is necessary to consider disabled state of each item when selecting next focused item. Signed-off-by: Jehun Lim <jehun.lim@samsung.com> Test Plan: 1. elementary_test -to 'gengrid disabled item focus' 2. check 'item select on focus disable' 3. move focus to disabled item 4. observe focus and compare before this patch Reviewers: cedric Subscribers: minkyu, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4115
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_gengrid.c72
-rw-r--r--src/lib/elementary/elm_gengrid.c81
3 files changed, 131 insertions, 24 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 9cdc7b0f92..f40de25af3 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -155,6 +155,7 @@ void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_focus(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_update(void *data, Evas_Object *obj, void *event_info);
+void test_gengrid_disabled_item_focus(void *data, Evas_Object *obj, void *event_info);
void test_win_state(void *data, Evas_Object *obj, void *event_info);
void test_win_state2(void *data, Evas_Object *obj, void *event_info);
void test_progressbar(void *data, Evas_Object *obj, void *event_info);
@@ -750,6 +751,7 @@ add_tests:
ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed);
ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus", test_gengrid_focus);
ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Update", test_gengrid_update);
+ ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Disabled Item Focus", test_gengrid_disabled_item_focus);
//------------------------------//
ADD_TEST(NULL, "General", "Scaling", test_scaling);
diff --git a/src/bin/elementary/test_gengrid.c b/src/bin/elementary/test_gengrid.c
index c2119fa913..92a7b016dd 100644
--- a/src/bin/elementary/test_gengrid.c
+++ b/src/bin/elementary/test_gengrid.c
@@ -2235,3 +2235,75 @@ test_gengrid_update(void *data EINA_UNUSED,
evas_object_resize(win, 600, 600);
evas_object_show(win);
}
+
+void
+test_gengrid_disabled_item_focus(void *data EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Evas_Object *win, *bx, *obx, *grid, *ck;
+ Elm_Gengrid_Item_Class *ic;
+ Item_Data *id;
+ int i, n;
+ char buf[PATH_MAX];
+
+ win = elm_win_util_standard_add("gengrid_disabled_focus", "Gengrid Disabled Focus");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_show(bx);
+
+ grid = elm_gengrid_add(win);
+
+ elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(150), ELM_SCALE_SIZE(150));
+ elm_gengrid_multi_select_set(grid, EINA_FALSE);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_min_set(grid, 600, 550);
+ elm_box_pack_end(bx, grid);
+ evas_object_show(grid);
+ evas_object_smart_callback_add(grid, "item,focused", _gengrid_focus_item_cb, "item,focused");
+ evas_object_smart_callback_add(grid, "item,unfocused", _gengrid_focus_item_cb, "item,unfocused");
+ evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
+
+ obx = elm_box_add(win);
+ evas_object_size_hint_weight_set(obx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_box_horizontal_set(obx, EINA_TRUE);
+ elm_box_pack_end(bx, obx);
+ evas_object_show(obx);
+
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Item select on focus disable");
+ elm_check_state_set(ck, elm_config_item_select_on_focus_disabled_get());
+ evas_object_smart_callback_add(ck, "changed",
+ _gg_focus_item_select_on_focus_disable_changed_cb,
+ NULL);
+ elm_box_pack_end(obx, ck);
+ evas_object_show(ck);
+
+ ic = elm_gengrid_item_class_new();
+ ic->item_style = "default";
+ ic->func.text_get = grid_text_get;
+ ic->func.content_get = grid_content_get;
+ ic->func.state_get = NULL;
+ ic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 23; i++)
+ {
+ id = calloc(1, sizeof(Item_Data));
+ snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
+ n = (n + 1) % 9;
+ id->mode = i;
+ id->path = eina_stringshare_add(buf);
+ id->item = elm_gengrid_item_append(grid, ic, id, NULL, NULL);
+ if (i == 4 || i == 8 || i == 11 || i == 22)
+ elm_object_item_disabled_set(id->item, EINA_TRUE);
+ }
+
+ elm_gengrid_item_class_free(ic);
+
+ evas_object_resize(win, 600, 600);
+ evas_object_show(win);
+}
diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c
index 1bbe5409b8..3abe8575d4 100644
--- a/src/lib/elementary/elm_gengrid.c
+++ b/src/lib/elementary/elm_gengrid.c
@@ -2075,27 +2075,32 @@ _item_focus_up(Elm_Gengrid_Data *sd)
if (!sd->focused_item)
{
prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
- while ((prev) && (prev->generation < sd->generation))
+ while (((prev) && (prev->generation < sd->generation))
+ || elm_object_item_disabled_get(EO_OBJ(prev)))
prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
- elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
- return EINA_TRUE;
}
else
{
Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
if (!eo_prev) return EINA_FALSE;
- prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
if (eo_prev == sd->focused_item) return EINA_FALSE;
- }
- for (i = 1; i < sd->nmax; i++)
- {
- Elm_Object_Item *eo_tmp =
- elm_gengrid_item_prev_get(EO_OBJ(prev));
- if (!eo_tmp) return EINA_FALSE;
- prev = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
+ eo_prev = sd->focused_item;
+ while (eo_prev)
+ {
+ for (i = 0; i < sd->nmax; i++)
+ {
+ eo_prev = elm_gengrid_item_prev_get(eo_prev);
+ if (!eo_prev) return EINA_FALSE;
+ }
+ if (!elm_object_item_disabled_get(eo_prev)) break;
+ }
+
+ prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
}
+ if (!prev) return EINA_FALSE;
+
elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
return EINA_TRUE;
@@ -2106,12 +2111,13 @@ _item_focus_down(Elm_Gengrid_Data *sd)
{
unsigned int i, idx;
Elm_Gen_Item *next = NULL;
- Elm_Object_Item *eo_tmp = NULL;
+ Elm_Object_Item *eo_next = NULL;
if (!sd->focused_item)
{
next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
- while ((next) && (next->generation < sd->generation))
+ while (((next) && (next->generation < sd->generation))
+ || elm_object_item_disabled_get(EO_OBJ(next)))
next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
}
else
@@ -2125,21 +2131,28 @@ _item_focus_down(Elm_Gengrid_Data *sd)
return EINA_FALSE;
if (idx > sd->item_count - sd->nmax)
{
- eo_tmp = elm_gengrid_last_item_get(sd->obj);
- next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
+ eo_next = elm_gengrid_last_item_get(sd->obj);
+ if (elm_object_item_disabled_get(eo_next)) return EINA_FALSE;
}
else
{
- next = eo_data_scope_get(sd->focused_item, ELM_GENGRID_ITEM_CLASS);
- for (i = 0; i < sd->nmax; i++)
+ eo_next = sd->focused_item;
+ while (eo_next)
{
- eo_tmp = elm_gengrid_item_next_get(EO_OBJ(next));
- if (!eo_tmp) return EINA_FALSE;
- next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS);
+ for (i = 0; i < sd->nmax; i++)
+ {
+ eo_next = elm_gengrid_item_next_get(eo_next);
+ if (!eo_next) return EINA_FALSE;
+ }
+ if (!elm_object_item_disabled_get(eo_next)) break;
}
}
+
+ next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
}
+ if (!next) return EINA_FALSE;
+
elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
return EINA_TRUE;
@@ -2153,17 +2166,27 @@ _item_focus_left(Elm_Gengrid_Data *sd)
if (!sd->focused_item)
{
prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
- while ((prev) && (prev->generation < sd->generation))
+ while (((prev) && (prev->generation < sd->generation))
+ || elm_object_item_disabled_get(EO_OBJ(prev)))
prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
}
else
{
Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
if (!eo_prev) return EINA_FALSE;
- prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
if (eo_prev == sd->focused_item) return EINA_FALSE;
+
+ while (eo_prev)
+ {
+ if (!elm_object_item_disabled_get(eo_prev)) break;
+ eo_prev = elm_gengrid_item_prev_get(eo_prev);
+ }
+
+ prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
}
+ if (!prev) return EINA_FALSE;
+
elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
return EINA_TRUE;
@@ -2177,17 +2200,27 @@ _item_focus_right(Elm_Gengrid_Data *sd)
if (!sd->focused_item)
{
next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
- while ((next) && (next->generation < sd->generation))
+ while (((next) && (next->generation < sd->generation))
+ || elm_object_item_disabled_get(EO_OBJ(next)))
next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
}
else
{
Elm_Object_Item *eo_next = elm_gengrid_item_next_get(sd->focused_item);
if (!eo_next) return EINA_FALSE;
- next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
if (eo_next == sd->focused_item) return EINA_FALSE;
+
+ while (eo_next)
+ {
+ if (!elm_object_item_disabled_get(eo_next)) break;
+ eo_next = elm_gengrid_item_next_get(eo_next);
+ }
+
+ next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
}
+ if (!next) return EINA_FALSE;
+
elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
return EINA_TRUE;