summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-29 15:00:32 +0200
committerCedric BAIL <cedric.bail@free.fr>2019-07-29 11:17:42 -0700
commit764f35b7a3e795e344d2414e252e280c3c34756d (patch)
tree9415e355ba2f570a788c0b98f8e61dae5be16b95 /src/bin
parent7f2ce2f99a345d4b3b667755db1d73f7db213f03 (diff)
elm_test: add a example that shows efl_ui_item instances
this is just a little showcase to show the possible items Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9430
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/meson.build1
-rw-r--r--src/bin/elementary/test.c3
-rw-r--r--src/bin/elementary/test_ui_items.c87
3 files changed, 91 insertions, 0 deletions
diff --git a/src/bin/elementary/meson.build b/src/bin/elementary/meson.build
index 10372d9154..9c26bc3eb4 100644
--- a/src/bin/elementary/meson.build
+++ b/src/bin/elementary/meson.build
@@ -157,6 +157,7 @@ elementary_test_src = [
157 'test_ui_tab_pager.c', 157 'test_ui_tab_pager.c',
158 'test_ui_relative_layout.c', 158 'test_ui_relative_layout.c',
159 'test_ui_item_container.c', 159 'test_ui_item_container.c',
160 'test_ui_items.c',
160 'test.h' 161 'test.h'
161] 162]
162 163
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index f4400695e5..1a332575da 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -402,6 +402,8 @@ void test_ui_relative_layout(void *data, Evas_Object *obj, void *event_info);
402void test_efl_ui_radio(void *data, Evas_Object *obj, void *event_info); 402void test_efl_ui_radio(void *data, Evas_Object *obj, void *event_info);
403void test_efl_ui_collection_list(void *data, Evas_Object *obj, void *event_info ); 403void test_efl_ui_collection_list(void *data, Evas_Object *obj, void *event_info );
404void test_efl_ui_collection_grid(void *data, Evas_Object *obj, void *event_info); 404void test_efl_ui_collection_grid(void *data, Evas_Object *obj, void *event_info);
405void test_efl_ui_item(void *data, Evas_Object *obj, void *event_info);
406
405static void _list_udpate(void); 407static void _list_udpate(void);
406 408
407static Evas_Object *win, *tbx, *entry; // TODO: refactoring 409static Evas_Object *win, *tbx, *entry; // TODO: refactoring
@@ -905,6 +907,7 @@ add_tests:
905 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Relative_Layout", test_ui_relative_layout); 907 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Relative_Layout", test_ui_relative_layout);
906 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Collection List", test_efl_ui_collection_list); 908 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Collection List", test_efl_ui_collection_list);
907 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Collection Grid", test_efl_ui_collection_grid); 909 ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Collection Grid", test_efl_ui_collection_grid);
910 ADD_TEST_EO(NULL, "Containers", "Items", test_efl_ui_item);
908 911
909 //------------------------------// 912 //------------------------------//
910 ADD_TEST_EO(NULL, "Events", "Event Refeed", test_events); 913 ADD_TEST_EO(NULL, "Events", "Event Refeed", test_events);
diff --git a/src/bin/elementary/test_ui_items.c b/src/bin/elementary/test_ui_items.c
new file mode 100644
index 0000000000..4c2254ad25
--- /dev/null
+++ b/src/bin/elementary/test_ui_items.c
@@ -0,0 +1,87 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6
7static Efl_Ui_Widget*
8_item_add(Eo *box, const Efl_Class *c, int i)
9{
10 Eo *check, *rect, *il = efl_add(c, box);
11 int r = 0, g = 0, b = 0;
12 char buf[PATH_MAX];
13
14 snprintf(buf, sizeof(buf), "%d - Test %d", i, i%13);
15 efl_text_set(il, buf);
16
17 rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(il));
18 switch (i % 5)
19 {
20 case 0:
21 r = 255;
22 break;
23 case 1:
24 g = 255;
25 break;
26 case 2:
27 b = 255;
28 break;
29 case 3:
30 r = g = b = 255;
31 break;
32 case 4:
33 r = g = b = 0;
34 break;
35 }
36 efl_gfx_color_set(rect, r, g, b, 255);
37 efl_content_set(il, rect);
38
39 check = efl_add(EFL_UI_CHECK_CLASS, il);
40 efl_content_set(efl_part(il, "extra"), check);
41
42 if (c == EFL_UI_GRID_DEFAULT_ITEM_CLASS)
43 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(100, 180));
44 else
45 efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));
46
47 return il;
48}
49
50void test_efl_ui_item(void *data EINA_UNUSED,
51 Evas_Object *obj EINA_UNUSED,
52 void *event_info EINA_UNUSED)
53{
54 Eo *win, *box, *o;
55
56 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
57 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
58 efl_text_set(efl_added, "Item examples"),
59 efl_ui_win_autodel_set(efl_added, EINA_TRUE)
60 );
61
62 box = efl_add(EFL_UI_BOX_CLASS, win,
63 efl_content_set(win, efl_added));
64
65 o = _item_add(box, EFL_UI_GRID_DEFAULT_ITEM_CLASS, 1);
66 efl_pack_end(box, o);
67
68 o = _item_add(box, EFL_UI_GRID_DEFAULT_ITEM_CLASS, 2);
69 efl_ui_widget_disabled_set(o, EINA_TRUE);
70 efl_pack_end(box, o);
71
72 o = _item_add(box, EFL_UI_LIST_DEFAULT_ITEM_CLASS, 3);
73 efl_pack_end(box, o);
74
75 o = _item_add(box, EFL_UI_LIST_DEFAULT_ITEM_CLASS, 4);
76 efl_ui_widget_disabled_set(o, EINA_TRUE);
77 efl_pack_end(box, o);
78
79 o = efl_add(EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS, box);
80 efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40));
81 efl_pack_end(box, o);
82
83 o = efl_add(EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS, box);
84 efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40));
85 efl_ui_widget_disabled_set(o, EINA_TRUE);
86 efl_pack_end(box, o);
87}