seoz pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=c97c6d0d13de5af718e7fd4ee91968fc3447d94f
commit c97c6d0d13de5af718e7fd4ee91968fc3447d94f Author: Daniel Juyung Seo <[email protected]> Date: Mon Mar 24 01:51:37 2014 +0900 list: Check disabled status of an item in nearest visible item. Also added a test for it. --- src/bin/test_list.c | 21 +++++++++++++++++++-- src/lib/elm_list.c | 21 +++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/bin/test_list.c b/src/bin/test_list.c index 6bfc553..d864860 100644 --- a/src/bin/test_list.c +++ b/src/bin/test_list.c @@ -1368,6 +1368,13 @@ _sel_btn_cb(void *data, Evas_Object *obj EINA_UNUSED, } static void +_dis_btn_cb(void *data, Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + elm_object_item_disabled_set(data, EINA_TRUE); +} + +static void _focus_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -1378,10 +1385,10 @@ static void _test_list_focus(const char *name, const char *title, Eina_Bool horiz) { Evas_Object *win, *li, *btn, *bx, *bx2, *fr, *bx_opt, *chk, *bx_btn; - Evas_Object *btn_focus, *btn_sel, *bx_mv, *rd, *rdg; + Evas_Object *btn_focus, *btn_sel, *btn_dis, *bx_mv, *rd, *rdg; unsigned int lhand, rhand, idx; char buf[256]; - Elm_Object_Item *it = NULL, *it_3 = NULL; + Elm_Object_Item *it = NULL, *it_0 = NULL, *it_3 = NULL; win = elm_win_util_standard_add(name, title); elm_win_autodel_set(win, EINA_TRUE); @@ -1550,6 +1557,13 @@ _test_list_focus(const char *name, const char *title, Eina_Bool horiz) elm_box_pack_end(bx_btn, btn_sel); evas_object_show(btn_sel); + btn_dis = elm_button_add(bx_btn); + elm_object_text_set(btn_dis, "Disable 1st Item."); + evas_object_size_hint_weight_set(btn_dis, 0.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(btn_dis, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx_btn, btn_dis); + evas_object_show(btn_dis); + for (idx = 0; _list_focus_combo[idx] >= 0; idx++) { lhand = _list_focus_combo[idx] / 10; @@ -1565,6 +1579,8 @@ _test_list_focus(const char *name, const char *title, Eina_Bool horiz) test_list_focus_content_get(li, lhand, horiz), test_list_focus_content_get(li, rhand, horiz), NULL, NULL); + if (idx == 0) + it_0 = it; if (idx == 4) elm_object_item_disabled_set(it, EINA_TRUE); if (idx == 2) @@ -1573,6 +1589,7 @@ _test_list_focus(const char *name, const char *title, Eina_Bool horiz) evas_object_smart_callback_add(btn_focus, "clicked", _focus_btn_cb, it_3); evas_object_smart_callback_add(btn_sel, "clicked", _sel_btn_cb, it_3); + evas_object_smart_callback_add(btn_dis, "clicked", _dis_btn_cb, it_0); elm_list_go(li); evas_object_show(li); diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c index 9b7212a..aa0367a 100644 --- a/src/lib/elm_list.c +++ b/src/lib/elm_list.c @@ -1084,25 +1084,33 @@ _elm_list_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it) Eina_List *item_list = NULL; Elm_Object_Item *item = NULL; ELM_LIST_DATA_GET(obj, sd); + Eina_Bool search_next = EINA_FALSE; if (!it) return NULL; evas_object_geometry_get(obj, &vx, &vy, &vw, &vh); evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); - if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih)) - return it; - item_list = eina_list_data_find_list(sd->items, it); + if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih)) + { + if (!elm_object_item_disabled_get(it)) + return it; + else + search_next = EINA_TRUE; + } + if ((!sd->h_mode && (iy < vy)) || - (sd->h_mode && (iw < vw))) + (sd->h_mode && (iw < vw)) || + search_next) { while ((item_list = eina_list_next(item_list))) { item = eina_list_data_get(item_list); evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); - if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) + if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) && + !elm_object_item_disabled_get(item)) return item; } } @@ -1112,7 +1120,8 @@ _elm_list_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it) { item = eina_list_data_get(item_list); evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); - if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) + if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) && + !elm_object_item_disabled_get(item)) return item; } } --
