summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2014-03-24 02:07:41 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-03-24 02:07:41 +0900
commite97b9a790f21b0618c3696cfbe880b29c8edf7b8 (patch)
treec4d5e245ad61ee6eed0ff725bb665e01966ea1e6
parentc97c6d0d13de5af718e7fd4ee91968fc3447d94f (diff)
genlist: Check disabled status of an item in nearest visible item.
Also added a test for it.
-rw-r--r--src/bin/test_genlist.c29
-rw-r--r--src/lib/elm_genlist.c19
2 files changed, 34 insertions, 14 deletions
diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index 0736b7bf1..10dbd9413 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -3779,6 +3779,13 @@ _sel_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
3779} 3779}
3780 3780
3781static void 3781static void
3782_dis_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
3783 void *event_info EINA_UNUSED)
3784{
3785 elm_object_item_disabled_set(data, EINA_TRUE);
3786}
3787
3788static void
3782_focus_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, 3789_focus_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
3783 void *event_info EINA_UNUSED) 3790 void *event_info EINA_UNUSED)
3784{ 3791{
@@ -3791,10 +3798,10 @@ test_genlist_focus(void *data EINA_UNUSED,
3791 void *event_info EINA_UNUSED) 3798 void *event_info EINA_UNUSED)
3792{ 3799{
3793 Evas_Object *win, *bx, *bx2, *gl, *btn, *fr; 3800 Evas_Object *win, *bx, *bx2, *gl, *btn, *fr;
3794 Evas_Object *bx_opt, *chk, *bx_btn, *btn_focus, *btn_sel; 3801 Evas_Object *bx_opt, *chk, *bx_btn, *btn_focus, *btn_sel, *btn_dis;
3795 Evas_Object *bx_mv, *rd, *rdg; 3802 Evas_Object *bx_mv, *rd, *rdg;
3796 unsigned lhand, rhand; 3803 unsigned lhand, rhand;
3797 Elm_Object_Item *it = NULL, *it_2 = NULL; 3804 Elm_Object_Item *it = NULL, *it_0 = NULL, *it_2 = NULL;
3798 3805
3799 win = elm_win_util_standard_add("genlist-focus", "Genlist Focus"); 3806 win = elm_win_util_standard_add("genlist-focus", "Genlist Focus");
3800 elm_win_autodel_set(win, EINA_TRUE); 3807 elm_win_autodel_set(win, EINA_TRUE);
@@ -3878,8 +3885,9 @@ test_genlist_focus(void *data EINA_UNUSED,
3878 for (rhand = 0; rhand < _gl_focus_objects; rhand++) 3885 for (rhand = 0; rhand < _gl_focus_objects; rhand++)
3879 { 3886 {
3880 unsigned digit1 = lhand * 10 + rhand; 3887 unsigned digit1 = lhand * 10 + rhand;
3881 elm_genlist_item_append(gl, itc1, (void*)(uintptr_t)digit1, 3888 it = elm_genlist_item_append(gl, itc1, (void*)(uintptr_t)digit1,
3882 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); 3889 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
3890 if (!it_0) it_0 = it;
3883 3891
3884 unsigned digit2 = (_gl_focus_objects - lhand -1) * 10 + 3892 unsigned digit2 = (_gl_focus_objects - lhand -1) * 10 +
3885 (_gl_focus_objects - rhand -1); 3893 (_gl_focus_objects - rhand -1);
@@ -3978,11 +3986,6 @@ test_genlist_focus(void *data EINA_UNUSED,
3978 elm_object_text_set(fr, "Focus/Selection"); 3986 elm_object_text_set(fr, "Focus/Selection");
3979 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0); 3987 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
3980 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 3988 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
3981 // Focus/Selection
3982 fr = elm_frame_add(bx);
3983 elm_object_text_set(fr, "Focus/Selection");
3984 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
3985 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
3986 elm_box_pack_end(bx, fr); 3989 elm_box_pack_end(bx, fr);
3987 evas_object_show(fr); 3990 evas_object_show(fr);
3988 3991
@@ -4004,8 +4007,16 @@ test_genlist_focus(void *data EINA_UNUSED,
4004 elm_box_pack_end(bx_btn, btn_sel); 4007 elm_box_pack_end(bx_btn, btn_sel);
4005 evas_object_show(btn_sel); 4008 evas_object_show(btn_sel);
4006 4009
4010 btn_dis = elm_button_add(bx_btn);
4011 elm_object_text_set(btn_dis, "Disable 1st Item.");
4012 evas_object_size_hint_weight_set(btn_dis, 0.0, EVAS_HINT_EXPAND);
4013 evas_object_size_hint_align_set(btn_dis, EVAS_HINT_FILL, EVAS_HINT_FILL);
4014 elm_box_pack_end(bx_btn, btn_dis);
4015 evas_object_show(btn_dis);
4016
4007 evas_object_smart_callback_add(btn_focus, "clicked", _focus_btn_cb, it_2); 4017 evas_object_smart_callback_add(btn_focus, "clicked", _focus_btn_cb, it_2);
4008 evas_object_smart_callback_add(btn_sel, "clicked", _sel_btn_cb, it_2); 4018 evas_object_smart_callback_add(btn_sel, "clicked", _sel_btn_cb, it_2);
4019 evas_object_smart_callback_add(btn_dis, "clicked", _dis_btn_cb, it_0);
4009 4020
4010 evas_object_resize(win, 420, 600); 4021 evas_object_resize(win, 420, 600);
4011 evas_object_show(win); 4022 evas_object_show(win);
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index 9df255e1d..752aa750d 100644
--- a/src/lib/elm_genlist.c
+++ b/src/lib/elm_genlist.c
@@ -2856,22 +2856,30 @@ _elm_genlist_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
2856 Eina_List *item_list = NULL, *l = NULL; 2856 Eina_List *item_list = NULL, *l = NULL;
2857 Elm_Object_Item *item = NULL; 2857 Elm_Object_Item *item = NULL;
2858 ELM_GENLIST_DATA_GET(obj, sd); 2858 ELM_GENLIST_DATA_GET(obj, sd);
2859 Eina_Bool search_next = EINA_FALSE;
2859 2860
2860 if (!it) return NULL; 2861 if (!it) return NULL;
2861 2862
2862 evas_object_geometry_get(sd->pan_obj, &vx, &vy, &vw, &vh); 2863 evas_object_geometry_get(sd->pan_obj, &vx, &vy, &vw, &vh);
2863 evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); // FIXME: check if the item is realized or not 2864 evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); // FIXME: check if the item is realized or not
2864 2865
2866 item_list = elm_genlist_realized_items_get(obj);
2867
2865 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih)) 2868 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
2866 return it; 2869 {
2870 if (!elm_object_item_disabled_get(it))
2871 return it;
2872 else
2873 search_next = EINA_TRUE;
2874 }
2867 2875
2868 item_list = elm_genlist_realized_items_get(obj); 2876 if ((iy < vy) || search_next)
2869 if (iy < vy)
2870 { 2877 {
2871 EINA_LIST_FOREACH(item_list, l, item) 2878 EINA_LIST_FOREACH(item_list, l, item)
2872 { 2879 {
2873 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); 2880 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
2874 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) 2881 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
2882 !elm_object_item_disabled_get(item))
2875 return item; 2883 return item;
2876 } 2884 }
2877 } 2885 }
@@ -2880,7 +2888,8 @@ _elm_genlist_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
2880 EINA_LIST_REVERSE_FOREACH(item_list, l, item) 2888 EINA_LIST_REVERSE_FOREACH(item_list, l, item)
2881 { 2889 {
2882 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); 2890 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
2883 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) 2891 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
2892 !elm_object_item_disabled_get(item))
2884 return item; 2893 return item;
2885 } 2894 }
2886 } 2895 }