From dfc98980f889eb4c00144a2883fba5abdd489349 Mon Sep 17 00:00:00 2001 From: raster Date: Sat, 19 Mar 2011 15:11:45 +0000 Subject: [PATCH] new test for testing focus on deleted.. and hidden widgets git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@57897 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/Makefile.am | 1 + src/bin/test.c | 2 + src/bin/test_focus3.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 src/bin/test_focus3.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index ab936c8..cd124a7 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -88,6 +88,7 @@ test_tooltip.c \ test_cursor.c \ test_focus.c \ test_focus2.c \ +test_focus3.c \ test_flipselector.c \ test_diskselector.c \ test_colorselector.c \ diff --git a/src/bin/test.c b/src/bin/test.c index 0296be9..78577ee 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -114,6 +114,7 @@ void test_cursor2(void *data, Evas_Object *obj, void *event_info); void test_cursor3(void *data, Evas_Object *obj, void *event_info); void test_focus(void *data, Evas_Object *obj, void *event_info); void test_focus2(void *data, Evas_Object *obj, void *event_info); +void test_focus3(void *data, Evas_Object *obj, void *event_info); void test_flipselector(void *data, Evas_Object *obj, void *event_info); void test_diskselector(void *data, Evas_Object *obj, void *event_info); void test_colorselector(void *data, Evas_Object *obj, void *event_info); @@ -366,6 +367,7 @@ my_win_main(char *autorun) ADD_TEST("Cursor 3", test_cursor3); ADD_TEST("Focus", test_focus); ADD_TEST("Focus 2", test_focus2); + ADD_TEST("Focus 3", test_focus3); ADD_TEST("Flip Selector", test_flipselector); ADD_TEST("Disk Selector", test_diskselector); ADD_TEST("Color Selector", test_colorselector); diff --git a/src/bin/test_focus3.c b/src/bin/test_focus3.c new file mode 100644 index 0000000..d128aba --- /dev/null +++ b/src/bin/test_focus3.c @@ -0,0 +1,112 @@ +/* Test for Focus Chain Linear*/ +#include +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#ifndef ELM_LIB_QUICKLAUNCH + +static Evas_Object *foc = NULL; + +static void +_foc(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + foc = obj; + printf("foc -> %p\n", foc); +} + +static void +_unfoc(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + foc = NULL; + printf("foc -> %p\n", foc); +} + +static void +_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *bx = data, *en; + + en = elm_scrolled_entry_add(elm_object_top_widget_get(bx)); + elm_scrolled_entry_entry_set(en, "An entry"); + evas_object_smart_callback_add(en, "focused", _foc, NULL); + evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); + elm_scrolled_entry_single_line_set(en, 1); + elm_box_pack_start(bx, en); + evas_object_show(en); +} + +static void +_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + if (foc) evas_object_del(foc); +} + +static void +_hide(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + if (foc) evas_object_hide(foc); +} + +void +test_focus3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win, *bg, *bx, *bt, *en; + + win = elm_win_add(NULL, "focus3", ELM_WIN_BASIC); + elm_win_title_set(win, "Focus 3"); + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + evas_object_resize(win, 320, 480); + elm_win_autodel_set(win, EINA_TRUE); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bg); + + 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); + + en = elm_scrolled_entry_add(win); + elm_scrolled_entry_entry_set(en, "An entry"); + evas_object_smart_callback_add(en, "focused", _foc, NULL); + evas_object_smart_callback_add(en, "unfocused", _unfoc, NULL); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); + elm_scrolled_entry_single_line_set(en, 1); + elm_box_pack_end(bx, en); + evas_object_show(en); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, 0); + elm_button_label_set(bt, "Add"); + evas_object_smart_callback_add(bt, "clicked", _add, bx); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, 0); + elm_button_label_set(bt, "Del"); + evas_object_smart_callback_add(bt, "clicked", _del, NULL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_focus_allow_set(bt, 0); + elm_button_label_set(bt, "Hide"); + evas_object_smart_callback_add(bt, "clicked", _hide, NULL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + evas_object_show(win); +} +#endif -- 2.7.4