forked from enlightenment/efl
test_genlist: Flourish genlist focus test case to reveal more bugs.
- Added focus highlight enable/disable option. - Added a button to set the focus to 2nd item after 1.5 seconds. - Added a button to select the 2nd item after 1.5 seconds. - Removed unnecessary frame and lable for the test.
This commit is contained in:
parent
31e81c1ecd
commit
a6063a3c9c
|
@ -3675,7 +3675,8 @@ gl_focus_content_get(void *data, Evas_Object *obj, const char *part)
|
|||
}
|
||||
|
||||
static void
|
||||
gl_focus_focus_on_selection_set(Evas_Object *gl, Evas_Object *chk, Eina_Bool focus)
|
||||
test_genlist_focus_focus_on_selection_set(Evas_Object *gl,
|
||||
Evas_Object *chk, Eina_Bool focus)
|
||||
{
|
||||
elm_genlist_focus_on_selection_set(gl, focus);
|
||||
elm_check_state_set(chk, focus);
|
||||
|
@ -3683,85 +3684,143 @@ gl_focus_focus_on_selection_set(Evas_Object *gl, Evas_Object *chk, Eina_Bool foc
|
|||
}
|
||||
|
||||
static void
|
||||
gl_focus_focus_check_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
test_genlist_focus_focus_check_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eina_Bool nextstate = !elm_genlist_focus_on_selection_get(data);
|
||||
gl_focus_focus_on_selection_set(data, obj, nextstate);
|
||||
test_genlist_focus_focus_on_selection_set(data, obj, nextstate);
|
||||
}
|
||||
|
||||
static void
|
||||
gl_focus_focus_animate_check_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
test_genlist_focus_focus_highlight_check_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_win_focus_highlight_enabled_set((Evas_Object *)data,
|
||||
elm_check_state_get(obj));
|
||||
}
|
||||
|
||||
static void
|
||||
test_genlist_focus_focus_animate_check_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_win_focus_highlight_animate_set((Evas_Object *)data,
|
||||
elm_check_state_get(obj));
|
||||
}
|
||||
|
||||
static Ecore_Timer *timer = NULL;
|
||||
static void
|
||||
_test_genlist_focus_win_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
ecore_timer_del(timer);
|
||||
timer = NULL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_focus_timer_cb(void *data)
|
||||
{
|
||||
elm_object_item_focus_set(data, EINA_TRUE);
|
||||
timer = NULL;
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_select_timer_cb(void *data)
|
||||
{
|
||||
elm_genlist_item_selected_set(data, EINA_TRUE);
|
||||
timer = NULL;
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static void
|
||||
_focus_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
ecore_timer_del(timer);
|
||||
timer = ecore_timer_add(1.5, _focus_timer_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_sel_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
ecore_timer_del(timer);
|
||||
timer = ecore_timer_add(1.5, _select_timer_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_focus_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
printf("Button clicked: %s\n", (char *)data);
|
||||
}
|
||||
|
||||
void
|
||||
test_genlist_focus(void *data EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *bx_horiz, *gl, *btn, *fr, *lb;
|
||||
Evas_Object *win, *bx, *bx2, *gl, *btn, *fr;
|
||||
Evas_Object *bx_opt, *chk, *bx_btn, *btn_focus, *btn_sel;
|
||||
unsigned lhand, rhand;
|
||||
Elm_Object_Item *it = NULL, *it_2 = NULL;
|
||||
|
||||
win = elm_win_util_standard_add("genlist-item-focus", "Genlist Item Focus");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL,
|
||||
_test_genlist_focus_win_del_cb, NULL);
|
||||
|
||||
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||||
elm_win_focus_highlight_animate_set(win, EINA_TRUE);
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
bx_horiz = elm_box_add(win);
|
||||
elm_box_horizontal_set(bx_horiz, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(bx_horiz, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, bx_horiz);
|
||||
evas_object_show(bx_horiz);
|
||||
|
||||
btn = elm_button_add(bx_horiz);
|
||||
elm_object_text_set(btn, "Left");
|
||||
elm_box_pack_end(bx_horiz, btn);
|
||||
evas_object_show(btn);
|
||||
|
||||
bx = elm_box_add(bx_horiz);
|
||||
bx = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx_horiz, bx);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
evas_object_show(bx);
|
||||
|
||||
fr = elm_frame_add(bx);
|
||||
elm_object_text_set(fr, "Genlist Item Focus");
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
|
||||
lb = elm_label_add(fr);
|
||||
elm_object_text_set(lb, "<align=left>This test cases list down the"
|
||||
" focus check points related to genlist items.<br/>"
|
||||
" 1. No focus highlight on widget items<br/>"
|
||||
" 2. No animation on widget item<br/>"
|
||||
" 3. No focus movement between widget to widget items<br/>"
|
||||
" </align>");
|
||||
elm_object_content_set(fr, lb);
|
||||
evas_object_show(lb);
|
||||
|
||||
btn = elm_button_add(bx);
|
||||
elm_object_text_set(btn, "Up");
|
||||
elm_box_pack_end(bx, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked",
|
||||
_focus_button_clicked_cb, "Up");
|
||||
evas_object_show(btn);
|
||||
|
||||
bx2 = elm_box_add(bx);
|
||||
elm_box_horizontal_set(bx2, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, bx2);
|
||||
evas_object_show(bx2);
|
||||
|
||||
btn = elm_button_add(bx2);
|
||||
elm_object_text_set(btn, "Left");
|
||||
elm_box_pack_end(bx2, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked",
|
||||
_focus_button_clicked_cb, "Left");
|
||||
evas_object_show(btn);
|
||||
|
||||
gl = elm_genlist_add(bx);
|
||||
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, gl);
|
||||
elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
||||
elm_box_pack_end(bx2, gl);
|
||||
evas_object_show(gl);
|
||||
elm_object_focus_set(gl, EINA_TRUE);
|
||||
|
||||
btn = elm_button_add(bx2);
|
||||
elm_object_text_set(btn, "Right");
|
||||
elm_box_pack_end(bx2, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked",
|
||||
_focus_button_clicked_cb, "Right");
|
||||
evas_object_show(btn);
|
||||
|
||||
btn = elm_button_add(bx);
|
||||
elm_object_text_set(btn, "Down");
|
||||
elm_box_pack_end(bx, btn);
|
||||
evas_object_show(btn);
|
||||
|
||||
btn = elm_button_add(bx_horiz);
|
||||
elm_object_text_set(btn, "Right");
|
||||
elm_box_pack_end(bx_horiz, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked",
|
||||
_focus_button_clicked_cb, "Down");
|
||||
evas_object_show(btn);
|
||||
|
||||
itc1 = elm_genlist_item_class_new();
|
||||
|
@ -3785,10 +3844,13 @@ test_genlist_focus(void *data EINA_UNUSED,
|
|||
unsigned digit1 = lhand * 10 + rhand;
|
||||
elm_genlist_item_append(gl, itc1, (void*)(uintptr_t)digit1,
|
||||
NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
|
||||
unsigned digit2 = (_gl_focus_objects - lhand -1) * 10 +
|
||||
(_gl_focus_objects - rhand -1);
|
||||
elm_genlist_item_append(gl, itc1, (void*)(uintptr_t)digit2,
|
||||
it = elm_genlist_item_append(gl, itc1, (void*)(uintptr_t)digit2,
|
||||
NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
if (!it_2) it_2 = it;
|
||||
|
||||
if (rhand == (_gl_focus_objects - 1))
|
||||
elm_genlist_item_append(gl, itc4, (void*)(uintptr_t)digit1,
|
||||
NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
|
||||
|
@ -3798,7 +3860,77 @@ test_genlist_focus(void *data EINA_UNUSED,
|
|||
elm_genlist_item_class_free(itc1);
|
||||
elm_genlist_item_class_free(itc4);
|
||||
|
||||
evas_object_resize(win, 320, 450);
|
||||
// Options
|
||||
fr = elm_frame_add(bx);
|
||||
elm_object_text_set(fr, "Options");
|
||||
evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
|
||||
bx_opt = elm_box_add(fr);
|
||||
elm_box_horizontal_set(bx_opt, EINA_TRUE);
|
||||
elm_object_content_set(fr, bx_opt);
|
||||
evas_object_show(bx_opt);
|
||||
|
||||
chk = elm_check_add(bx_opt);
|
||||
elm_object_text_set(chk, "Focus Highlight");
|
||||
elm_check_state_set(chk, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(chk, "changed",
|
||||
test_genlist_focus_focus_highlight_check_changed,
|
||||
win);
|
||||
elm_box_pack_end(bx_opt, chk);
|
||||
evas_object_show(chk);
|
||||
|
||||
chk = elm_check_add(bx_opt);
|
||||
elm_object_text_set(chk, "Focus Animation");
|
||||
elm_check_state_set(chk, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(chk, "changed",
|
||||
test_genlist_focus_focus_animate_check_changed,
|
||||
win);
|
||||
elm_box_pack_end(bx_opt, chk);
|
||||
evas_object_show(chk);
|
||||
|
||||
chk = elm_check_add(bx_opt);
|
||||
elm_object_text_set(chk, "Focus on selection");
|
||||
evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(chk, "changed",
|
||||
test_genlist_focus_focus_check_changed, gl);
|
||||
elm_box_pack_end(bx_opt, chk);
|
||||
evas_object_show(chk);
|
||||
|
||||
// Focus/Selection
|
||||
fr = elm_frame_add(bx);
|
||||
elm_object_text_set(fr, "Focus/Selection");
|
||||
evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
|
||||
bx_btn = elm_box_add(fr);
|
||||
elm_object_content_set(fr, bx_btn);
|
||||
evas_object_show(bx_btn);
|
||||
|
||||
btn_focus = elm_button_add(bx_btn);
|
||||
elm_object_text_set(btn_focus, "Focus 2nd Item after 1.5 seconds.");
|
||||
evas_object_size_hint_weight_set(btn_focus, 0.0, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn_focus, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx_btn, btn_focus);
|
||||
evas_object_show(btn_focus);
|
||||
|
||||
btn_sel = elm_button_add(bx_btn);
|
||||
elm_object_text_set(btn_sel, "Select 2nd Item after 1.5 seconds.");
|
||||
evas_object_size_hint_weight_set(btn_sel, 0.0, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn_sel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx_btn, btn_sel);
|
||||
evas_object_show(btn_sel);
|
||||
|
||||
evas_object_smart_callback_add(btn_focus, "clicked", _focus_btn_cb, it_2);
|
||||
evas_object_smart_callback_add(btn_sel, "clicked", _sel_btn_cb, it_2);
|
||||
|
||||
evas_object_resize(win, 420, 600);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue