1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 typedef struct _Testitem
10 Elm_Object_Item *item;
12 Elm_Object_Item *item;
13 >>>>>>> remotes/origin/upstream
19 static Elm_Gengrid_Item_Class gic;
22 grdt_lbl_get(void *data,
23 Evas_Object *obj __UNUSED__,
24 const char *part __UNUSED__)
26 const Testitem *ti = data;
28 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
33 grdt_content_get(void *data,
37 const Testitem *ti = data;
38 if (!strcmp(part, "elm.swallow.icon"))
40 Evas_Object *icon = elm_bg_add(obj);
41 elm_bg_file_set(icon, ti->path, NULL);
42 evas_object_size_hint_aspect_set(icon,
43 EVAS_ASPECT_CONTROL_VERTICAL,
45 evas_object_show(icon);
51 static Elm_Genlist_Item_Class itct;
54 gltt_exp(void *data __UNUSED__,
55 Evas_Object *obj __UNUSED__,
58 Elm_Object_Item *glit = event_info;
60 Evas_Object *gl = elm_genlist_item_genlist_get(glit);
61 int val = (int) elm_object_item_data_get(glit);
62 Elm_Object_Item *glit1, *glit2, *glit3;
65 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 1), glit,
66 ELM_GENLIST_ITEM_NONE, NULL, NULL);
67 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 2), glit,
68 ELM_GENLIST_ITEM_NONE, NULL, NULL);
69 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 3), glit,
70 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
72 Evas_Object *gl = elm_object_item_widget_get(glit);
73 int val = (int)(long) elm_object_item_data_get(glit);
74 Elm_Object_Item *glit1, *glit2, *glit3;
77 glit1 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 1), glit,
78 ELM_GENLIST_ITEM_NONE, NULL, NULL);
79 glit2 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 2), glit,
80 ELM_GENLIST_ITEM_NONE, NULL, NULL);
81 glit3 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 3), glit,
82 ELM_GENLIST_ITEM_TREE, NULL, NULL);
83 >>>>>>> remotes/origin/upstream
85 elm_genlist_item_tooltip_text_set(glit1, "Testing A");
86 elm_genlist_item_tooltip_text_set(glit2, "Testing B");
87 elm_genlist_item_tooltip_text_set(glit3, "Testing C");
91 gltt_con(void *data __UNUSED__,
92 Evas_Object *obj __UNUSED__,
95 Elm_Object_Item *glit = event_info;
96 elm_genlist_item_subitems_clear(glit);
100 gltt_exp_req(void *data __UNUSED__,
101 Evas_Object *obj __UNUSED__,
104 Elm_Object_Item *glit = event_info;
105 elm_genlist_item_expanded_set(glit, EINA_TRUE);
109 gltt_con_req(void *data __UNUSED__,
110 Evas_Object *obj __UNUSED__,
113 Elm_Object_Item *glit = event_info;
114 elm_genlist_item_expanded_set(glit, EINA_FALSE);
118 gltt_text_get(void *data,
119 Evas_Object *obj __UNUSED__,
120 const char *part __UNUSED__)
123 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
128 _tt_item_icon(void *data __UNUSED__,
129 Evas_Object *obj __UNUSED__,
131 void *item __UNUSED__)
133 Evas_Object *ic = elm_icon_add(tt);
135 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
136 elm_app_data_dir_get());
137 elm_icon_file_set(ic, buf, NULL);
139 elm_icon_scale_set(ic, 0, 0);
141 elm_icon_resizable_set(ic, 0, 0);
142 >>>>>>> remotes/origin/upstream
143 evas_object_resize(ic, 64, 64);
148 _tt_item_icon2(void *data __UNUSED__,
149 Evas_Object *obj __UNUSED__,
151 void *item __UNUSED__)
153 Evas_Object *ic = elm_icon_add(tt);
155 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
156 elm_icon_file_set(ic, buf, NULL);
158 elm_icon_scale_set(ic, 0, 0);
160 elm_icon_resizable_set(ic, 0, 0);
161 >>>>>>> remotes/origin/upstream
166 _tt_item_icon3(void *data __UNUSED__,
167 Evas_Object *obj __UNUSED__,
169 void *item __UNUSED__)
172 Evas_Object *ic = elm_icon_add(tt);
175 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
176 elm_icon_file_set(ic, buf, NULL);
177 elm_icon_size_get(ic, &w, &h);
178 elm_win_screen_size_get(tt, NULL, NULL, &sw, &sh);
179 if ((w > sw) || (h > sh))
182 if ((float)w / (float)sw >= 0.8)
183 sc = ((float)sw * 0.8) / (float)w;
184 else if ((float)h / (float)sh >= 0.8)
185 sc = ((float)sh * 0.8) / (float)h;
186 if (sc) elm_object_scale_set(ic, sc);
192 _tt_item_label(void *data __UNUSED__,
193 Evas_Object *obj __UNUSED__,
195 void *item __UNUSED__)
197 Evas_Object *l = elm_label_add(tt);
198 elm_object_text_set(l, "Something useful here?<ps/>"
199 "No probably not, but this is a super long label<ps/>"
200 "which probably breaks on your system, now doesn't it?<ps/>"
201 "Yeah, I thought so.");
202 elm_label_line_wrap_set(l, ELM_WRAP_MIXED);
207 _tt_item_icon_del(void *data,
208 Evas_Object *obj __UNUSED__,
211 // test to check for del_cb behavior!
212 printf("_tt_icon_del: data=%ld (== 456?), event_info=%p\n",
213 (long)data, event_info);
217 _tt_text_replace(void *data __UNUSED__,
219 void *event_info __UNUSED__)
221 static int count = 0;
223 snprintf(buf, sizeof(buf), "count=%d", count);
225 elm_object_tooltip_text_set(obj, buf);
229 _tt_timer_del(void *data __UNUSED__,
232 void *event_info __UNUSED__)
234 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
236 ecore_timer_del(timer);
240 _tt_text_replace_timer_cb(void *data)
242 _tt_text_replace(NULL, data, NULL);
247 _tt_text_replace_timed(void *data __UNUSED__,
249 void *event_info __UNUSED__)
251 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
254 ecore_timer_del(timer);
255 evas_object_data_del(obj, "test-timer");
256 elm_object_text_set(obj, "Simple text tooltip, click to start"
261 timer = ecore_timer_add(1.5, _tt_text_replace_timer_cb, obj);
262 evas_object_data_set(obj, "test-timer", timer);
263 elm_object_text_set(obj, "Simple text tooltip, click to stop changed"
268 _tt_icon(void *data __UNUSED__,
269 Evas_Object *obj __UNUSED__,
272 Evas_Object *ic = elm_icon_add(tt);
274 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
275 elm_app_data_dir_get());
276 elm_icon_file_set(ic, buf, NULL);
278 elm_icon_scale_set(ic, 0, 0);
280 elm_icon_resizable_set(ic, 0, 0);
281 >>>>>>> remotes/origin/upstream
282 evas_object_resize(ic, 64, 64);
287 _tt_icon2(void *data __UNUSED__,
288 Evas_Object *obj __UNUSED__,
291 Evas_Object *ic = elm_icon_add(tt);
293 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
294 elm_icon_file_set(ic, buf, NULL);
296 elm_icon_scale_set(ic, 0, 0);
298 elm_icon_resizable_set(ic, 0, 0);
299 >>>>>>> remotes/origin/upstream
300 evas_object_resize(ic, 64, 64);
305 _tt_icon_del(void *data,
306 Evas_Object *obj __UNUSED__,
309 // test to check for del_cb behavior!
310 printf("_tt_icon_del: data=%ld (== 123?), event_info=%p\n",
311 (long)data, event_info);
315 _tt_icon_replace_timer_cb(void *data)
317 static int current = 0;
319 elm_object_tooltip_content_cb_set
320 (data, current ? _tt_icon2 : _tt_icon, NULL, NULL);
327 _tt_icon_replace_timed(void *data __UNUSED__,
329 void *event_info __UNUSED__)
331 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
334 ecore_timer_del(timer);
335 evas_object_data_del(obj, "test-timer");
336 elm_object_text_set(obj, "Icon tooltip, click to start changed"
341 timer = ecore_timer_add(1.5, _tt_icon_replace_timer_cb, obj);
342 evas_object_data_set(obj, "test-timer", timer);
343 elm_object_text_set(obj, "Icon tooltip, click to stop changed timed");
347 _tt_style_replace_timer_cb(void *data)
349 static int current = 0;
350 elm_object_tooltip_style_set(data, current ? NULL : "transparent");
356 _tt_style_replace_timed(void *data __UNUSED__,
358 void *event_info __UNUSED__)
360 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
363 ecore_timer_del(timer);
364 evas_object_data_del(obj, "test-timer");
365 elm_object_text_set(obj, "Icon tooltip style, click to start"
370 timer = ecore_timer_add(1.5, _tt_style_replace_timer_cb, obj);
371 evas_object_data_set(obj, "test-timer", timer);
372 elm_object_text_set(obj, "Icon tooltip style, click to stop changed"
377 _tt_visible_lock_toggle(void *data __UNUSED__,
379 void *event_info __UNUSED__)
381 static int locked = 0;
386 elm_object_text_set(obj, "Locked tooltip visibility");
387 elm_object_tooltip_text_set(obj, "This tooltip is locked"
388 " visible,<br/> click the button"
390 elm_object_tooltip_show(obj);
394 elm_object_text_set(obj, "Unlocked tooltip visibility");
395 elm_object_tooltip_text_set(obj, "This tooltip is unlocked"
396 " visible,<br/> click the button"
398 elm_object_tooltip_hide(obj);
403 test_tooltip(void *data __UNUSED__,
404 Evas_Object *obj __UNUSED__,
405 void *event_info __UNUSED__)
407 Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
408 Elm_Object_Item *tb_it;
409 Elm_Object_Item *lit;
411 win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
412 elm_win_title_set(win, "Tooltip");
413 elm_win_autodel_set(win, EINA_TRUE);
415 bg = elm_bg_add(win);
416 elm_win_resize_object_add(win, bg);
417 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
419 evas_object_show(bg);
421 bx = elm_box_add(win);
422 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
424 elm_win_resize_object_add(win, bx);
425 evas_object_show(bx);
427 tb = elm_toolbar_add(win);
428 elm_toolbar_homogeneous_set(tb, 0);
429 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
430 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
431 elm_box_pack_end(bx, tb);
432 evas_object_show(tb);
434 tb_it = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL);
435 elm_object_item_tooltip_text_set(tb_it, "Opens a file");
437 tb_it = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL);
438 elm_object_item_tooltip_content_cb_set
439 (tb_it, _tt_item_icon, (void *)456L, _tt_item_icon_del);
440 elm_object_item_tooltip_style_set(tb_it, "transparent");
442 bt = elm_button_add(win);
443 elm_object_text_set(bt, "Simple text tooltip");
444 elm_object_tooltip_text_set(bt, "Simple text tooltip");
445 elm_box_pack_end(bx, bt);
446 evas_object_show(bt);
448 bt = elm_button_add(win);
449 elm_object_text_set(bt, "Simple text tooltip, click to change");
450 elm_object_tooltip_text_set(bt, "Initial");
451 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
452 elm_box_pack_end(bx, bt);
453 evas_object_show(bt);
455 bt = elm_button_add(win);
456 elm_object_text_set(bt, "Simple text tooltip, click to start"
458 elm_object_tooltip_text_set(bt, "Initial");
459 evas_object_smart_callback_add(bt, "clicked", _tt_text_replace_timed,
461 elm_box_pack_end(bx, bt);
462 evas_object_show(bt);
463 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
466 bt = elm_button_add(win);
467 elm_object_text_set(bt, "Icon tooltip");
468 elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
470 elm_box_pack_end(bx, bt);
471 evas_object_show(bt);
473 bt = elm_button_add(win);
474 elm_object_text_set(bt, "Icon tooltip, click to start changed timed");
475 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
476 evas_object_smart_callback_add(bt, "clicked", _tt_icon_replace_timed,
478 elm_box_pack_end(bx, bt);
479 evas_object_show(bt);
480 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
483 bt = elm_button_add(win);
484 elm_object_text_set(bt, "Transparent Icon tooltip");
485 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
486 elm_object_tooltip_style_set(bt, "transparent");
487 elm_box_pack_end(bx, bt);
488 evas_object_show(bt);
490 bt = elm_button_add(win);
491 elm_object_text_set(bt, "Icon tooltip style, click to start changed"
493 elm_object_tooltip_content_cb_set(bt, _tt_icon, NULL, NULL);
494 evas_object_smart_callback_add(bt, "clicked", _tt_style_replace_timed,
496 elm_box_pack_end(bx, bt);
497 evas_object_show(bt);
498 evas_object_event_callback_add(bt, EVAS_CALLBACK_DEL, _tt_timer_del,
501 bt = elm_button_add(win);
502 elm_object_text_set(bt, "Unlocked tooltip visibility");
503 elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,<br/>"
504 " click the button to lock!");
505 evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle,
507 elm_box_pack_end(bx, bt);
508 evas_object_show(bt);
510 se = elm_entry_add(win);
511 elm_entry_scrollable_set(se, EINA_TRUE);
512 evas_object_size_hint_weight_set(se, EVAS_HINT_EXPAND, 0.0);
513 evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5);
514 elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF,
515 ELM_SCROLLER_POLICY_OFF);
516 elm_object_text_set(se, "Hello, some scrolled entry here!");
517 elm_object_tooltip_text_set(se, "Type something here!");
519 elm_entry_single_line_set(se, 1);
521 elm_entry_single_line_set(se, EINA_TRUE);
522 >>>>>>> remotes/origin/upstream
523 elm_box_pack_end(bx, se);
524 evas_object_show(se);
526 lst = elm_list_add(win);
527 lit = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL);
528 elm_object_item_tooltip_content_cb_set(lit, _tt_item_label, NULL, NULL);
529 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
530 lit = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL);
531 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon, NULL, NULL);
532 lit = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL);
533 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon2, NULL, NULL);
534 elm_object_item_tooltip_style_set(lit, "transparent");
535 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
536 lit = elm_list_item_append(lst, "Insanely Big Icon Tooltip", NULL, NULL, NULL, NULL);
537 elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon3, NULL, NULL);
538 elm_object_item_tooltip_style_set(lit, "transparent");
539 elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE);
540 evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND,
542 evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL);
543 evas_object_size_hint_min_set(lst, 100, 100);
545 elm_box_pack_end(bx, lst);
546 evas_object_show(lst);
548 evas_object_resize(win, 320, 580);
549 evas_object_show(win);
553 test_tooltip2(void *data __UNUSED__,
554 Evas_Object *obj __UNUSED__,
555 void *event_info __UNUSED__)
557 Evas_Object *win, *bg, *bx, *grid, *gl;
558 Elm_Object_Item *glit1, *glit2, *glit3;
559 static Testitem ti[144];
575 win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC);
576 elm_win_title_set(win, "Tooltip 2");
577 elm_win_autodel_set(win, EINA_TRUE);
579 bg = elm_bg_add(win);
580 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
582 elm_win_resize_object_add(win, bg);
583 evas_object_show(bg);
585 bx = elm_box_add(win);
586 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
588 elm_win_resize_object_add(win, bx);
589 evas_object_show(bx);
591 grid = elm_gengrid_add(win);
592 elm_gengrid_item_size_set(grid, 100, 100);
593 elm_gengrid_horizontal_set(grid, EINA_FALSE);
594 elm_gengrid_multi_select_set(grid, EINA_TRUE);
595 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
596 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
599 gic.item_style = "default";
600 gic.func.text_get = grdt_lbl_get;
601 gic.func.content_get = grdt_content_get;
604 for (i = 0; i < 9; i++)
606 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
610 ti[i].path = eina_stringshare_add(buf);
611 ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL,
614 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
616 elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
618 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
621 elm_box_pack_end(bx, grid);
622 evas_object_show(grid);
624 gl = elm_genlist_add(win);
625 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
626 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND,
629 itct.item_style = "default";
630 itct.func.text_get = gltt_text_get;
632 glit1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL,
634 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
635 glit2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
636 ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
638 ELM_GENLIST_ITEM_TREE, NULL, NULL);
639 glit2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL,
640 ELM_GENLIST_ITEM_TREE, NULL, NULL);
641 >>>>>>> remotes/origin/upstream
642 glit3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL,
643 ELM_GENLIST_ITEM_NONE, NULL, NULL);
645 elm_genlist_item_tooltip_text_set(glit1, "Testing 1");
646 elm_genlist_item_tooltip_text_set(glit2, "Testing 2");
647 elm_genlist_item_tooltip_text_set(glit3, "Testing 3");
649 evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
650 evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,
652 evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
653 evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
655 elm_box_pack_end(bx, gl);
656 evas_object_show(gl);
658 evas_object_resize(win, 320, 480);
659 evas_object_show(win);