summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-12-10 20:35:42 +0100
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-12-11 10:46:52 +0100
commit3a79575cdf4d4881c996bfb3c0d7a03155702e89 (patch)
tree0957d8ff3b7229a0d5057470ea847d05c4fea9c9 /src/bin
parent87cc19b94d3c36f41d15744914aade783eb0d77e (diff)
Some more focus movement tests
Those two layouts are quite simple but in real it's difficult to solve both in the best way
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_focus.c113
2 files changed, 114 insertions, 1 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index c88bca9b13..05fb022d6b 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -245,6 +245,7 @@ void test_focus3(void *data, Evas_Object *obj, void *event_info);
245void test_focus_object_style(void *data, Evas_Object *obj, void *event_info); 245void test_focus_object_style(void *data, Evas_Object *obj, void *event_info);
246void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info); 246void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info);
247void test_focus4(void *data, Evas_Object *obj, void *event_info); 247void test_focus4(void *data, Evas_Object *obj, void *event_info);
248void test_focus5(void *data, Evas_Object *obj, void *event_info);
248void test_flipselector(void *data, Evas_Object *obj, void *event_info); 249void test_flipselector(void *data, Evas_Object *obj, void *event_info);
249void test_diskselector(void *data, Evas_Object *obj, void *event_info); 250void test_diskselector(void *data, Evas_Object *obj, void *event_info);
250void test_colorselector(void *data, Evas_Object *obj, void *event_info); 251void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@@ -1089,6 +1090,7 @@ add_tests:
1089 ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style); 1090 ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style);
1090 ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy); 1091 ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy);
1091 ADD_TEST(NULL, "Focus", "Focus 4", test_focus4); 1092 ADD_TEST(NULL, "Focus", "Focus 4", test_focus4);
1093 ADD_TEST(NULL, "Focus", "Focus 5", test_focus5);
1092 1094
1093 //------------------------------// 1095 //------------------------------//
1094 ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe); 1096 ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);
diff --git a/src/bin/elementary/test_focus.c b/src/bin/elementary/test_focus.c
index eef451e6cf..d4edd4a560 100644
--- a/src/bin/elementary/test_focus.c
+++ b/src/bin/elementary/test_focus.c
@@ -900,6 +900,8 @@ test_focus3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
900 evas_object_show(win); 900 evas_object_show(win);
901} 901}
902 902
903/**** focus 4 ****/
904
903static void 905static void
904btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 906btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
905{ 907{
@@ -926,7 +928,7 @@ test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
926 Evas_Object *win, *box, *sc, *btn, *ly, *btn2; 928 Evas_Object *win, *box, *sc, *btn, *ly, *btn2;
927 char buf[PATH_MAX]; 929 char buf[PATH_MAX];
928 930
929 win = elm_win_util_standard_add("focus4", "Focus 5"); 931 win = elm_win_util_standard_add("focus4", "Focus 4");
930 elm_win_autodel_set(win, EINA_TRUE); 932 elm_win_autodel_set(win, EINA_TRUE);
931 933
932 box = elm_box_add(win); 934 box = elm_box_add(win);
@@ -965,3 +967,112 @@ test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
965 evas_object_show(win); 967 evas_object_show(win);
966} 968}
967 969
970/**** focus 5 ****/
971
972struct _focus5_obj {
973 const char *name;
974 Evas_Coord x, y, w, h;
975};
976
977struct _focus5_obj _focus5_layout_data1[] = {
978 {"top", 40, 0, 20, 10},
979 {"bottom", 40, 90, 20, 10},
980 {"left", 0, 45, 20, 10},
981 {"right", 80, 45, 20, 10},
982 {NULL, 0, 0, 0, 0} /* sentinel */
983};
984
985struct _focus5_obj _focus5_layout_data2[] = {
986 {"top L", 0, 0, 20, 10},
987 {"top R", 80, 0, 20, 10},
988 {"bot L", 0, 90, 20, 10},
989 {"bot R", 80, 90, 20, 10},
990 {"center", 40, 40, 20, 10},
991 {NULL, 0, 0, 0, 0} /* sentinel */
992};
993
994struct _focus5_obj _focus5_layout_data3[] = {
995 {"top", 40, 0, 20, 10},
996 {"bottom", 40, 90, 20, 10},
997 {"left", 0, 45, 20, 10},
998 {"right", 80, 45, 20, 10},
999 {"top L", 0, 0, 20, 10},
1000 {"top R", 80, 0, 20, 10},
1001 {"bot L", 0, 90, 20, 10},
1002 {"bot R", 80, 90, 20, 10},
1003 {"center", 40, 40, 20, 10},
1004 {NULL, 0, 0, 0, 0} /* sentinel */
1005};
1006
1007void
1008_focus5_layout(Evas_Object *grid, struct _focus5_obj *layout)
1009{
1010 Evas_Object *obj;
1011
1012 evas_object_data_set(grid, "layout", layout);
1013 elm_grid_clear(grid, EINA_TRUE);
1014
1015 while(layout->name) {
1016 printf("button: %s\n", layout->name);
1017 obj = elm_button_add(grid);
1018 elm_object_text_set(obj, layout->name);
1019 elm_grid_pack(grid, obj, layout->x, layout->y, layout->w, layout->h);
1020 evas_object_show(obj);
1021 layout++;
1022 }
1023}
1024
1025static void
1026_focus5_btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1027{
1028 Evas_Object *grid = data;
1029 struct _focus5_obj *layout = evas_object_data_get(grid, "layout");
1030
1031 // brrr...a really naive looping
1032 if (layout == _focus5_layout_data1)
1033 _focus5_layout(grid, _focus5_layout_data2);
1034 else if (layout == _focus5_layout_data2)
1035 _focus5_layout(grid, _focus5_layout_data3);
1036 // else if (layout == _focus5_layout_data3)
1037 // _focus5_layout(grid, _focus5_layout_data4);
1038 else
1039 _focus5_layout(grid, _focus5_layout_data1);
1040
1041}
1042
1043void
1044test_focus5(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1045{
1046 Evas_Object *win, *box, *sep, *btn, *grid;
1047
1048 win = elm_win_util_standard_add("focus5", "Focus 5");
1049 elm_win_autodel_set(win, EINA_TRUE);
1050
1051 box = elm_box_add(win);
1052 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1053 elm_win_resize_object_add(win, box);
1054 evas_object_show(box);
1055
1056 grid = elm_grid_add(box);
1057 elm_grid_size_set(grid, 100, 100);
1058 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
1059 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1060 elm_box_pack_end(box, grid);
1061 evas_object_show(grid);
1062 _focus5_layout(grid, _focus5_layout_data1);
1063
1064 sep = elm_separator_add(box);
1065 elm_separator_horizontal_set(sep, EINA_TRUE);
1066 elm_box_pack_end(box, sep);
1067 evas_object_show(sep);
1068
1069 btn = elm_button_add(box);
1070 elm_object_focus_allow_set(btn, EINA_FALSE);
1071 elm_box_pack_end(box, btn);
1072 elm_object_text_set(btn, "Show next layout (this btn is NOT focusable)");
1073 evas_object_smart_callback_add(btn, "clicked", _focus5_btn_clicked, grid);
1074 evas_object_show(btn);
1075
1076 evas_object_resize(win, 400, 400);
1077 evas_object_show(win);
1078}