summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-02-24 11:33:27 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-02-24 11:33:27 +0100
commita07653504f31395105f75a8c4ffd7229d29f9d09 (patch)
tree085ec0532c389428f34eb7031b8d7b8992857920
parentb851afcb139bd6579b8020ea70cd6c8e6b34e46f (diff)
Focus test 6: add ability to move the focus by API
-rw-r--r--src/bin/elementary/test_focus.c90
1 files changed, 81 insertions, 9 deletions
diff --git a/src/bin/elementary/test_focus.c b/src/bin/elementary/test_focus.c
index 3701b4575d..567e6e9f7b 100644
--- a/src/bin/elementary/test_focus.c
+++ b/src/bin/elementary/test_focus.c
@@ -1087,12 +1087,22 @@ _focus6_gl_text_get(void *data, Evas_Object *obj EINA_UNUSED,
1087 snprintf(buf, sizeof(buf), "Focus item %d", (int)(uintptr_t)data); 1087 snprintf(buf, sizeof(buf), "Focus item %d", (int)(uintptr_t)data);
1088 return strdup(buf); 1088 return strdup(buf);
1089} 1089}
1090
1091static void
1092_focus6_btn_clicked(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1093{
1094 Evas_Object *ly = data;
1095 Elm_Focus_Direction dir = (uintptr_t)evas_object_data_get(obj, "direction");
1096
1097 elm_object_focus_next(ly, dir);
1098}
1099
1090void 1100void
1091test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1101test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1092{ 1102{
1093 Evas_Object *win, *ly, *lb, *btn, *gl; 1103 Evas_Object *win, *box, *box2, *sep, *ly, *lb, *btn, *gl;
1094 Elm_Genlist_Item_Class *itc; 1104 Elm_Genlist_Item_Class *itc;
1095// Elm_Object_Item *it; 1105 Elm_Object_Item *it;
1096 char buf[PATH_MAX]; 1106 char buf[PATH_MAX];
1097 int i; 1107 int i;
1098 1108
@@ -1100,13 +1110,19 @@ test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
1100 elm_win_autodel_set(win, EINA_TRUE); 1110 elm_win_autodel_set(win, EINA_TRUE);
1101 elm_win_focus_highlight_enabled_set(win, EINA_TRUE); 1111 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
1102 1112
1113 // main vertical box
1114 box = elm_box_add(win);
1115 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1116 elm_win_resize_object_add(win, box);
1117 evas_object_show(box);
1118
1103 // main layout 1119 // main layout
1104 ly = elm_layout_add(win); 1120 ly = elm_layout_add(win);
1105 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get()); 1121 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
1106 elm_layout_file_set(ly, buf, "focus_test_6"); 1122 elm_layout_file_set(ly, buf, "focus_test_6");
1107 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1123 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1108 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL); 1124 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
1109 elm_win_resize_object_add(win, ly); 1125 elm_box_pack_end(box, ly);
1110 evas_object_show(ly); 1126 evas_object_show(ly);
1111 1127
1112 lb = elm_label_add(ly); 1128 lb = elm_label_add(ly);
@@ -1126,12 +1142,16 @@ test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
1126 itc->func.text_get = _focus6_gl_text_get; 1142 itc->func.text_get = _focus6_gl_text_get;
1127 for (i = 0; i < 3; i++) 1143 for (i = 0; i < 3; i++)
1128 { 1144 {
1129// it = 1145 it = elm_genlist_item_append(gl, itc, (void*)(uintptr_t)i, NULL,
1130 elm_genlist_item_append(gl, itc, (void*)(uintptr_t)i, NULL, 1146 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1131 ELM_GENLIST_ITEM_NONE, NULL, NULL); 1147
1132 /* This is another bug! This focus item at start do not work */ 1148 if (i == 1)
1133 // if (i == 1) 1149 {
1134 // elm_object_item_focus_set(it, EINA_TRUE); 1150 elm_genlist_item_selected_set(it, EINA_TRUE);
1151
1152 /* This is another bug! This focus item at start do not work */
1153 // elm_object_item_focus_set(it, EINA_TRUE);
1154 }
1135 } 1155 }
1136 elm_genlist_item_class_free(itc); 1156 elm_genlist_item_class_free(itc);
1137 1157
@@ -1147,6 +1167,58 @@ test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
1147 elm_object_focus_set(btn, EINA_TRUE); 1167 elm_object_focus_set(btn, EINA_TRUE);
1148 } 1168 }
1149 1169
1170 // 4 buttons (not focusable) to test focus move by API
1171 sep = elm_separator_add(win);
1172 elm_separator_horizontal_set(sep, EINA_TRUE);
1173 elm_box_pack_end(box, sep);
1174 evas_object_show(sep);
1175
1176 box2 = elm_box_add(win);
1177 elm_box_horizontal_set(box2, EINA_TRUE);
1178 evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, 0.0);
1179 evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, 0.0);
1180 elm_box_pack_end(box, box2);
1181 evas_object_show(box2);
1182
1183 lb = elm_label_add(ly);
1184 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
1185 elm_object_text_set(lb, "Move the focus using elm_object_focus_next()");
1186 elm_box_pack_end(box2, lb);
1187 evas_object_show(lb);
1188
1189 btn = elm_button_add(win);
1190 elm_object_text_set(btn, "LEFT");
1191 elm_object_focus_allow_set(btn, EINA_FALSE);
1192 evas_object_data_set(btn, "direction", (void *)(uintptr_t)ELM_FOCUS_LEFT);
1193 evas_object_smart_callback_add(btn, "clicked", _focus6_btn_clicked, ly);
1194 elm_box_pack_end(box2, btn);
1195 evas_object_show(btn);
1196
1197 btn = elm_button_add(win);
1198 elm_object_text_set(btn, "UP");
1199 elm_object_focus_allow_set(btn, EINA_FALSE);
1200 evas_object_data_set(btn, "direction", (void *)(uintptr_t)ELM_FOCUS_UP);
1201 evas_object_smart_callback_add(btn, "clicked", _focus6_btn_clicked, ly);
1202 elm_box_pack_end(box2, btn);
1203 evas_object_show(btn);
1204
1205 btn = elm_button_add(win);
1206 elm_object_text_set(btn, "DOWN");
1207 elm_object_focus_allow_set(btn, EINA_FALSE);
1208 evas_object_data_set(btn, "direction", (void *)(uintptr_t)ELM_FOCUS_DOWN);
1209 evas_object_smart_callback_add(btn, "clicked", _focus6_btn_clicked, ly);
1210 elm_box_pack_end(box2, btn);
1211 evas_object_show(btn);
1212
1213 btn = elm_button_add(win);
1214 elm_object_text_set(btn, "RIGHT");
1215 elm_object_focus_allow_set(btn, EINA_FALSE);
1216 evas_object_data_set(btn, "direction", (void *)(uintptr_t)ELM_FOCUS_RIGHT);
1217 evas_object_smart_callback_add(btn, "clicked", _focus6_btn_clicked, ly);
1218 elm_box_pack_end(box2, btn);
1219 evas_object_show(btn);
1220
1221 // size and show the window
1150 evas_object_resize(win, 400, 400); 1222 evas_object_resize(win, 400, 400);
1151 evas_object_show(win); 1223 evas_object_show(win);
1152} 1224}