summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-05-20 17:34:51 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-05-20 18:23:55 +0200
commit748b762697746638f4fa74efe17879eac435dca2 (patch)
treee0e6413bc539d36e553477b0ed62fbe364962564 /src
parentf9202f6dca07c3784b488519d24610ac609e0633 (diff)
elm_test: add efl.ui.image tests which mimic elm_image tests
Summary: these should look and feel the same as the original tests. should. Depends on D8914 Reviewers: segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8915
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/meson.build1
-rw-r--r--src/bin/elementary/test.c14
-rw-r--r--src/bin/elementary/test_ui_image.c671
3 files changed, 686 insertions, 0 deletions
diff --git a/src/bin/elementary/meson.build b/src/bin/elementary/meson.build
index 0f7fa3d340..cfc5071ea2 100644
--- a/src/bin/elementary/meson.build
+++ b/src/bin/elementary/meson.build
@@ -79,6 +79,7 @@ elementary_test_src = [
79 'test_icon_desktops.c', 79 'test_icon_desktops.c',
80 'test_icon_animated.c', 80 'test_icon_animated.c',
81 'test_image.c', 81 'test_image.c',
82 'test_ui_image.c',
82 'test_index.c', 83 'test_index.c',
83 'test_inwin.c', 84 'test_inwin.c',
84 'test_label.c', 85 'test_label.c',
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 146d7ef902..80af598173 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -310,6 +310,13 @@ void test_image_prescale(void *data, Evas_Object *obj, void *event_info);
310void test_remote_image(void *data, Evas_Object *obj, void *event_info); 310void test_remote_image(void *data, Evas_Object *obj, void *event_info);
311void test_click_image(void *data, Evas_Object *obj, void *event_info); 311void test_click_image(void *data, Evas_Object *obj, void *event_info);
312void test_load_image(void *data, Evas_Object *obj, void *event_info); 312void test_load_image(void *data, Evas_Object *obj, void *event_info);
313void test_ui_image(void *data, Evas_Object *obj, void *event_info);
314void test_ui_image_scale_type(void *data, Evas_Object *obj, void *event_info);
315void test_ui_image_swallow_align(void *data, Evas_Object *obj, void *event_info);
316void test_ui_image_prescale(void *data, Evas_Object *obj, void *event_info);
317void test_remote_ui_image(void *data, Evas_Object *obj, void *event_info);
318void test_click_ui_image(void *data, Evas_Object *obj, void *event_info);
319void test_load_ui_image(void *data, Evas_Object *obj, void *event_info);
313void test_external_button(void *data, Evas_Object *obj, void *event_info); 320void test_external_button(void *data, Evas_Object *obj, void *event_info);
314void test_external_slider(void *data, Evas_Object *obj, void *event_info); 321void test_external_slider(void *data, Evas_Object *obj, void *event_info);
315void test_external_scroller(void *data, Evas_Object *obj, void *event_info); 322void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
@@ -820,6 +827,13 @@ add_tests:
820 ADD_TEST(NULL, "Images", "Image Click", test_click_image); 827 ADD_TEST(NULL, "Images", "Image Click", test_click_image);
821 ADD_TEST(NULL, "Images", "Image Async Load", test_load_image); 828 ADD_TEST(NULL, "Images", "Image Async Load", test_load_image);
822 ADD_TEST(NULL, "Images", "Image Prescale", test_image_prescale); 829 ADD_TEST(NULL, "Images", "Image Prescale", test_image_prescale);
830 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image", test_ui_image);
831 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Scale Type", test_ui_image_scale_type);
832 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Align", test_ui_image_swallow_align);
833 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Remote", test_remote_ui_image);
834 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Click", test_click_ui_image);
835 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Async Load", test_load_ui_image);
836 ADD_TEST_EO(NULL, "Images", "EFL.UI.Image Prescale", test_ui_image_prescale);
823 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow); 837 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
824 ADD_TEST(NULL, "Images", "Video", test_video); 838 ADD_TEST(NULL, "Images", "Video", test_video);
825 839
diff --git a/src/bin/elementary/test_ui_image.c b/src/bin/elementary/test_ui_image.c
new file mode 100644
index 0000000000..8c2ffbd65e
--- /dev/null
+++ b/src/bin/elementary/test_ui_image.c
@@ -0,0 +1,671 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#include <Efl_Ui.h>
6
7static const struct {
8 Efl_Gfx_Orientation orient;
9 const char *name;
10} images_orient[] = {
11 { EFL_GFX_ORIENTATION_NONE, "None" },
12 { EFL_GFX_ORIENTATION_RIGHT, "Rotate 90" },
13 { EFL_GFX_ORIENTATION_DOWN, "Rotate 180" },
14 { EFL_GFX_ORIENTATION_LEFT, "Rotate 270" },
15 { EFL_GFX_ORIENTATION_FLIP_HORIZONTAL, "Horizontal Flip" },
16 { EFL_GFX_ORIENTATION_FLIP_VERTICAL, "Vertical Flip" },
17 { 0, NULL }
18};
19
20static Eo *
21win_add(const char *name, const char *title)
22{
23 return efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
24 efl_ui_win_name_set(efl_added, name),
25 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
26 efl_text_set(efl_added, title));
27}
28
29static Eo *
30img_add(Eo *win, const char *file)
31{
32 char buf[PATH_MAX];
33 Eo *im;
34
35 im = efl_add(EFL_UI_IMAGE_CLASS, win,
36 efl_gfx_hint_weight_set(efl_added, 1.0, 1.0),
37 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE)
38 );
39 if (file)
40 {
41 snprintf(buf, sizeof(buf), "%s%s", elm_app_data_dir_get(), file);
42 efl_file_simple_load(im, buf, NULL);
43 }
44 efl_key_data_set(win, "im", im);
45 return im;
46}
47
48static void
49my_im_ch(void *data, const Efl_Event *ev EINA_UNUSED)
50{
51 Eo *win = data;
52 Eo *im = efl_key_data_get(win, "im");
53 Eo *rdg = efl_key_data_get(win, "rdg");
54 Efl_Gfx_Orientation v = efl_ui_radio_state_value_get(efl_ui_radio_selected_object_get(rdg));
55
56 efl_gfx_orientation_set(im, v);
57 fprintf(stderr, "Set %i and got %i\n",
58 v, efl_gfx_orientation_get(im));
59}
60
61void
62test_ui_image(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
63{
64 Eo *win, *box, *im, *rd, *rdg = NULL;
65 int i;
66
67 win = win_add("image test", "Image Test");
68
69 box = efl_add(EFL_UI_BOX_CLASS, win);
70 efl_gfx_hint_weight_set(box, 1.0, 1.0);
71 efl_content_set(win, box);
72
73 im = img_add(win, "/images/logo.png");
74 efl_pack(box, im);
75
76 for (i = 0; images_orient[i].name; ++i)
77 {
78 rd = efl_add(EFL_UI_RADIO_CLASS, win);
79 efl_gfx_hint_fill_set(rd, EINA_TRUE, EINA_TRUE);
80 efl_gfx_hint_weight_set(rd, 1.0, 0.0);
81 efl_ui_radio_state_value_set(rd, images_orient[i].orient);
82 efl_text_set(rd, images_orient[i].name);
83 efl_pack(box, rd);
84 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, my_im_ch, win);
85 if (!rdg)
86 {
87 rdg = rd;
88 efl_key_data_set(win, "rdg", rdg);
89 }
90 else
91 {
92 efl_ui_radio_group_add(rd, rdg);
93 }
94 }
95
96 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 480));
97}
98
99
100static void
101im_align_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
102{
103 double h,v;
104 Eo *win = data;
105 Eo *im = efl_key_data_get(win, "im");
106 Eo *h_sl = efl_key_data_get(win, "h_sl");
107 Eo *v_sl = efl_key_data_get(win, "v_sl");
108
109 h = elm_slider_value_get(h_sl);
110 v = elm_slider_value_get(v_sl);
111 efl_gfx_hint_align_set(im, h, v);
112 efl_gfx_hint_align_get(im, &h, &v);
113 printf("align %.3f %.3f\n", h, v);
114}
115
116static const struct {
117 Efl_Gfx_Image_Scale_Type scale_type;
118 const char *name;
119} images_scale_type[] = {
120 { EFL_GFX_IMAGE_SCALE_TYPE_NONE, "None" },
121 { EFL_GFX_IMAGE_SCALE_TYPE_FILL, "Fill" },
122 { EFL_GFX_IMAGE_SCALE_TYPE_FIT_INSIDE, "Fit Inside" },
123 { EFL_GFX_IMAGE_SCALE_TYPE_FIT_OUTSIDE, "Fit Outside" },
124 { EFL_GFX_IMAGE_SCALE_TYPE_TILE, "Tile" },
125 { 0, NULL }
126};
127
128static void
129my_im_scale_ch(void *data, const Efl_Event *ev EINA_UNUSED)
130{
131 Eo *win = data;
132 Eo *im = efl_key_data_get(win, "im");
133 Eo *rdg = efl_key_data_get(win, "rdg");
134 int v = efl_ui_radio_state_value_get(efl_ui_radio_selected_object_get(rdg));
135
136 efl_gfx_image_scale_type_set(im, images_scale_type[v].scale_type);
137 fprintf(stderr, "Set %d[%s] and got %d\n",
138 images_scale_type[v].scale_type, images_scale_type[v].name, efl_gfx_image_scale_type_get(im));
139}
140
141void
142test_ui_image_scale_type(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
143{
144 Eo *win, *box, *im, *rd, *rdg = NULL;
145 int i;
146
147 win = win_add("image test scale type", "Image Test Scale Type");
148
149 box = efl_add(EFL_UI_BOX_CLASS, win);
150 efl_gfx_hint_weight_set(box, 1.0, 1.0);
151 efl_content_set(win, box);
152
153 im = efl_add(EFL_UI_IMAGE_CLASS, win);
154 char buf[PATH_MAX];
155 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
156 elm_image_file_set(im, buf, NULL);
157 efl_gfx_hint_weight_set(im, 1.0, 1.0);
158 efl_gfx_hint_fill_set(im, EINA_TRUE, EINA_TRUE);
159 efl_pack(box, im);
160
161 efl_key_data_set(win, "im", im);
162
163 for (i = 0; images_scale_type[i].name; ++i)
164 {
165 rd = efl_add(EFL_UI_RADIO_CLASS, win);
166 efl_gfx_hint_fill_set(rd, EINA_TRUE, EINA_TRUE);
167 efl_gfx_hint_weight_set(rd, 1.0, 0.0);
168 efl_ui_radio_state_value_set(rd, i);
169 efl_text_set(rd, images_scale_type[i].name);
170 efl_pack(box, rd);
171 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, my_im_scale_ch, win);
172 if (!rdg)
173 {
174 rdg = rd;
175 efl_key_data_set(win, "rdg", rdg);
176 }
177 else
178 {
179 efl_ui_radio_group_add(rd, rdg);
180 }
181 }
182
183 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 480));
184}
185
186void
187test_ui_image_swallow_align(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
188{
189 Eo *win, *box, *im, *ly, *sl;
190 char buf[PATH_MAX];
191
192 win = win_add("image align", "Test Align Inside Layout");
193
194 box = efl_add(EFL_UI_BOX_CLASS, win);
195 efl_gfx_hint_weight_set(box, 1.0, 1.0);
196 efl_content_set(win, box);
197
198 ly = efl_add(EFL_UI_LAYOUT_CLASS, win);
199 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
200 efl_file_simple_load(ly, buf, "image_align");
201 efl_gfx_hint_weight_set(ly, 1.0, 1.0);
202 efl_gfx_hint_fill_set(ly, EINA_TRUE, EINA_TRUE);
203 efl_pack(box, ly);
204
205 im = img_add(win, "/images/logo.png");
206 efl_gfx_hint_weight_set(im, 0, 0);
207 efl_gfx_hint_fill_set(im, EINA_FALSE, EINA_FALSE);
208 efl_content_set(efl_part(ly, "swallow"), im);
209
210 sl = elm_slider_add(win);
211 elm_slider_value_set(sl, 0.5);
212 efl_text_set(sl, "Horiz Align");
213 efl_gfx_hint_weight_set(sl, 1.0, 0.0);
214 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
215 evas_object_smart_callback_add(sl, "changed", im_align_cb, win);
216 efl_pack(box, sl);
217 evas_object_show(sl);
218 efl_key_data_set(win, "h_sl", sl);
219
220 sl = elm_slider_add(win);
221 elm_slider_value_set(sl, 0.5);
222 efl_text_set(sl, "Vert Align");
223 efl_gfx_hint_weight_set(sl, 1.0, 0.0);
224 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
225 evas_object_smart_callback_add(sl, "changed", im_align_cb, win);
226 efl_pack(box, sl);
227 evas_object_show(sl);
228 efl_key_data_set(win, "v_sl", sl);
229
230 efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 600));
231}
232
233static void
234_download_start_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
235{
236 Eo *win = data, *txt, *im;
237 const char *url = NULL;
238 char buf[4096] = {0};
239
240 txt = efl_key_data_get(win, "txt");
241 im = efl_key_data_get(win, "im");
242 url = efl_file_get(im);
243 snprintf(buf, sizeof(buf) - 1, "Remote image download started:\n%s", url);
244 efl_text_set(txt, buf);
245 printf("%s\n", buf);
246 fflush(stdout);
247}
248
249static void
250_download_progress_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info)
251{
252 Elm_Image_Progress *p = event_info;
253 Eo *win = data, *txt;
254 char buf[4096] = {0};
255
256 txt = efl_key_data_get(win, "txt");
257 snprintf(buf, sizeof(buf) - 1, "Remote image download progress %.2f/%.2f.", p->now, p->total);
258 efl_text_set(txt, buf);
259 printf("%s\n", buf);
260 fflush(stdout);
261}
262
263static void
264_download_done_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
265{
266 Eo *win = data, *txt;
267 char buf[4096] = {0};
268
269 txt = efl_key_data_get(win, "txt");
270 snprintf(buf, sizeof(buf) - 1, "Remote image download done.");
271 efl_text_set(txt, buf);
272 printf("%s\n", buf);
273 fflush(stdout);
274
275 evas_object_hide(txt);
276}
277
278static void
279_download_error_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
280{
281 Eo *win = data, *txt;
282 char buf[4096] = {0};
283
284 txt = efl_key_data_get(win, "txt");
285 snprintf(buf, sizeof(buf) - 1, "Remote image download failed.");
286 efl_text_set(txt, buf);
287 printf("%s\n", buf);
288 fflush(stdout);
289
290}
291
292static void
293_url_activate_cb(void *data, Eo *obj, void *event_info EINA_UNUSED)
294{
295 Eo *win = data, *txt, *im;
296 const char *url;
297
298 im = efl_key_data_get(win, "im");
299 txt = efl_key_data_get(win, "txt");
300
301 url = elm_object_text_get(obj);
302 elm_image_file_set(im, url, NULL);
303
304 evas_object_show(txt);
305}
306
307void
308test_remote_ui_image(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
309{
310 Eo *win, *box, *im, *rd, *rdg = NULL, *box2, *o;
311 int i;
312
313 win = win_add("image test", "Image Test");
314
315 box = efl_add(EFL_UI_BOX_CLASS, win);
316 efl_gfx_hint_weight_set(box, 1.0, 1.0);
317 efl_content_set(win, box);
318
319 o = efl_add(EFL_UI_TEXT_CLASS, box, efl_text_interactive_editable_set(efl_added, EINA_FALSE));
320 efl_text_wrap_set(o, EFL_TEXT_FORMAT_WRAP_MIXED);
321 efl_gfx_hint_weight_set(o, 1.0, 1.0);
322 efl_gfx_hint_fill_set(o, EINA_TRUE, EINA_TRUE);
323 efl_pack(box, o);
324 efl_key_data_set(win, "txt", o);
325 evas_object_hide(o);
326
327 im = o = img_add(win, NULL);
328 efl_pack(box, o);
329
330 evas_object_smart_callback_add(im, "download,start", _download_start_cb, win);
331 evas_object_smart_callback_add(im, "download,progress", _download_progress_cb, win);
332 evas_object_smart_callback_add(im, "download,done", _download_done_cb, win);
333 evas_object_smart_callback_add(im, "download,error", _download_error_cb, win);
334
335 for (i = 0; images_orient[i].name; ++i)
336 {
337 rd = efl_add(EFL_UI_RADIO_CLASS, win);
338 efl_gfx_hint_fill_set(rd, EINA_TRUE, EINA_TRUE);
339 efl_gfx_hint_weight_set(rd, 1.0, 0.0);
340 efl_ui_radio_state_value_set(rd, images_orient[i].orient);
341 efl_text_set(rd, images_orient[i].name);
342 efl_pack(box, rd);
343 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, my_im_ch, win);
344 if (!rdg)
345 {
346 rdg = rd;
347 efl_key_data_set(win, "rdg", rdg);
348 }
349 else
350 {
351 efl_ui_radio_group_add(rd, rdg);
352 }
353 }
354
355 box2 = o = efl_add(EFL_UI_BOX_CLASS, box);
356 efl_ui_direction_set(o, EFL_UI_DIR_RIGHT);
357 efl_gfx_hint_weight_set(o, 1.0, 0);
358 efl_gfx_hint_fill_set(o, EINA_TRUE, EINA_TRUE);
359
360 o = efl_add(EFL_UI_TEXT_CLASS, box2,
361 efl_text_interactive_editable_set(efl_added, EINA_FALSE)
362 );
363 efl_text_set(o, "URL:");
364 efl_pack(box2, o);
365
366 o = elm_entry_add(box2);
367 elm_entry_scrollable_set(o, 1);
368 elm_entry_single_line_set(o, 1);
369 efl_gfx_hint_weight_set(o, 1.0, 0);
370 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
371 //elm_entry_entry_set(o, "http://41.media.tumblr.com/29f1ecd4f98aaff73fb21f479b450d4c/tumblr_mqsxdciQmB1rrju89o1_1280.jpg");
372 elm_entry_entry_set(o, "http://68.media.tumblr.com/d14765b2cc4ec25d1e7d640f3ec77a40/tumblr_ohtpjtRNlm1rrju89o1_500.jpg");
373 evas_object_smart_callback_add(o, "activated", _url_activate_cb, win);
374 evas_object_show(o);
375 efl_pack(box2, o);
376
377 efl_pack(box, box2);
378
379 // set file now
380 _url_activate_cb(win, o, NULL);
381
382 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 480));
383}
384
385static void
386_img_clicked_cb(void *data EINA_UNUSED, Eo *obj, void *event_info EINA_UNUSED)
387{
388 fprintf(stderr, "%p - clicked\n", obj);
389}
390
391void
392test_click_ui_image(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
393{
394 Eo *win, *box, *im, *label;
395
396 win = win_add("image test", "Image Test");
397 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
398
399 box = efl_add(EFL_UI_BOX_CLASS, win);
400 efl_gfx_hint_weight_set(box, 1.0, 1.0);
401 efl_content_set(win, box);
402
403 im = img_add(win, "/images/logo.png");
404 elm_object_focus_allow_set(im, EINA_TRUE);
405 evas_object_smart_callback_add(im, "clicked", _img_clicked_cb, im);
406 efl_pack(box, im);
407 elm_object_focus_set(im, EINA_TRUE);
408
409 label = efl_add(EFL_UI_TEXT_CLASS, win, efl_text_interactive_editable_set(efl_added, EINA_FALSE));
410 efl_text_set(label, "<b>Press Return/Space/KP_Return key on image to transit.</b>");
411 efl_gfx_hint_weight_set(label, 0.0, 0.0);
412 efl_gfx_hint_fill_set(label, EINA_TRUE, EINA_TRUE);
413 efl_pack(box, label);
414
415 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 480));
416}
417
418#define STATUS_SET(obj, fmt) do { \
419 efl_text_set(obj, fmt); \
420 fprintf(stderr, "%s\n", fmt); fflush(stderr); \
421 } while (0)
422
423static void
424_img_load_open_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
425{
426 Eo *status_text = data;
427
428 STATUS_SET(status_text, "Async file open done.");
429}
430
431static void
432_img_load_ready_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
433{
434 Eo *status_text = data;
435
436 STATUS_SET(status_text, "Image is ready to show.");
437}
438
439static void
440_img_load_error_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
441{
442 Eo *status_text = data;
443
444 STATUS_SET(status_text, "Async file load failed.");
445}
446
447static void
448_img_load_cancel_cb(void *data, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
449{
450 Eo *status_text = data;
451
452 STATUS_SET(status_text, "Async file open has been cancelled.");
453}
454
455static void
456_create_image(Eo *data, Eina_Bool async, Eina_Bool preload, Eina_Bool logo)
457{
458 Eo *win = data;
459 Eo *im, *status_text;
460 Eo *box = efl_key_data_get(win, "box");
461 char buf[PATH_MAX] = {0};
462
463 im = img_add(win, NULL);
464 elm_image_async_open_set(im, async);
465 elm_image_preload_disabled_set(im, preload);
466
467 efl_pack_begin(box, im);
468
469 status_text = efl_key_data_get(win, "phld");
470 if (!status_text)
471 {
472 status_text = efl_add(EFL_UI_TEXT_CLASS, win, efl_text_interactive_editable_set(efl_added, EINA_FALSE));
473 efl_gfx_hint_weight_set(status_text, 1.0, 0);
474 efl_gfx_hint_fill_set(status_text, EINA_TRUE, EINA_TRUE);
475 efl_key_data_set(win, "phld", status_text);
476 efl_pack_after(box, status_text, im);
477 }
478
479 evas_object_smart_callback_add(im, "load,open", _img_load_open_cb, status_text);
480 evas_object_smart_callback_add(im, "load,ready", _img_load_ready_cb, status_text);
481 evas_object_smart_callback_add(im, "load,error", _img_load_error_cb, status_text);
482 evas_object_smart_callback_add(im, "load,cancel", _img_load_cancel_cb, status_text);
483
484 STATUS_SET(status_text, "Loading image...");
485 if (!logo)
486 snprintf(buf, sizeof(buf) - 1, "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
487 else
488 snprintf(buf, sizeof(buf) - 1, "%s/images/logo.png", elm_app_data_dir_get());
489 efl_file_simple_load(im, buf, NULL);
490}
491
492static void
493_reload_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
494{
495 Eo *win = data;
496 Eo *im = efl_key_data_get(win, "im");
497 Eo *chk1 = efl_key_data_get(win, "chk1");
498 Eo *chk2 = efl_key_data_get(win, "chk2");
499 Eina_Bool async = efl_ui_check_selected_get(chk1);
500 Eina_Bool preload = efl_ui_check_selected_get(chk2);
501 Eina_Bool logo = EINA_FALSE;
502 const char *file = NULL;
503
504 file = efl_file_get(im);
505 logo = (file && strstr(file, "logo"));
506
507 efl_del(im);
508 _create_image(win, async, preload, logo);
509}
510
511static void
512_switch_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
513{
514 Eo *win = data;
515 Eo *im = efl_key_data_get(win, "im");
516 Eo *chk1 = efl_key_data_get(win, "chk1");
517 Eo *chk2 = efl_key_data_get(win, "chk2");
518 Eina_Bool async = efl_ui_check_selected_get(chk1);
519 Eina_Bool preload = efl_ui_check_selected_get(chk2);
520 char buf[PATH_MAX] = {0};
521 Eina_Bool logo = EINA_FALSE;
522 const char *file = NULL;
523
524 file = efl_file_get(im);
525 logo = (file && strstr(file, "logo"));
526
527 if (logo)
528 {
529 snprintf(buf, sizeof(buf) - 1, "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
530 }
531 else
532 {
533 snprintf(buf, sizeof(buf) - 1, "%s/images/logo.png", elm_app_data_dir_get());
534 }
535
536 elm_image_async_open_set(im, async);
537 elm_image_preload_disabled_set(im, preload);
538 efl_file_simple_load(im, buf, NULL);
539}
540
541void
542test_load_ui_image(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
543{
544 Eo *win, *box, *hbox, *label, *chk1, *chk2, *bt;
545
546 win = win_add("image test", "Image Test");
547
548 box = efl_add(EFL_UI_BOX_CLASS, win);
549 efl_gfx_arrangement_content_align_set(box, 0.5, 1.0);
550 efl_gfx_hint_weight_set(box, 1.0, 1.0);
551 efl_content_set(win, box);
552 efl_key_data_set(win, "box", box);
553
554 _create_image(win, EINA_FALSE, EINA_FALSE, EINA_FALSE);
555
556 hbox = efl_add(EFL_UI_BOX_CLASS, win);
557 efl_ui_direction_set(hbox, EFL_UI_DIR_RIGHT);
558 efl_gfx_arrangement_content_align_set(hbox, 0, 0.5);
559 efl_gfx_hint_weight_set(hbox, 1.0, 0.0);
560 efl_gfx_hint_fill_set(hbox, EINA_TRUE, EINA_FALSE);
561 {
562 label = efl_add(EFL_UI_TEXT_CLASS, win,
563 efl_text_set(efl_added, "Async load options:"),
564 efl_gfx_hint_weight_set(efl_added, 0.0, 0.0),
565 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
566 efl_text_interactive_editable_set(efl_added, EINA_FALSE)
567 );
568 efl_pack(hbox, label);
569
570 chk1 = efl_add(EFL_UI_CHECK_CLASS, hbox,
571 efl_text_set(efl_added, "Async file open"),
572 efl_gfx_hint_weight_set(efl_added, 0.0, 0.0),
573 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE)
574 );
575 efl_pack(hbox, chk1);
576 efl_key_data_set(win, "chk1", chk1);
577
578 chk2 = efl_add(EFL_UI_CHECK_CLASS, hbox,
579 efl_text_set(efl_added, "Disable preload"),
580 efl_gfx_hint_weight_set(efl_added, 0.0, 0.0),
581 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE)
582 );
583 efl_pack(hbox, chk2);
584 efl_key_data_set(win, "chk2", chk2);
585 }
586 efl_pack(box, hbox);
587
588 hbox = efl_add(EFL_UI_BOX_CLASS, win);
589 efl_ui_direction_set(hbox, EFL_UI_DIR_RIGHT);
590 efl_gfx_arrangement_content_align_set(hbox, 0.5, 0.5);
591 efl_gfx_hint_weight_set(hbox, 1.0, 0.0);
592 efl_gfx_hint_fill_set(hbox, EINA_TRUE, EINA_FALSE),
593 efl_gfx_hint_align_set(hbox, 0.5, 0.0);
594 {
595 bt = efl_add(EFL_UI_BUTTON_CLASS, win,
596 efl_text_set(efl_added, "Image Reload"),
597 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _reload_clicked, win)
598 );
599 efl_pack(hbox, bt);
600
601 bt = efl_add(EFL_UI_BUTTON_CLASS, win,
602 efl_text_set(efl_added, "Image Switch"),
603 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _switch_clicked, win)
604 );
605 efl_pack(hbox, bt);
606 }
607 efl_pack(box, hbox);
608
609 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 480));
610}
611
612static void
613_cb_prescale_radio_changed(void *data, const Efl_Event *ev)
614{
615 Eo *o_bg = data;
616 int size;
617 size = efl_ui_radio_state_value_get(efl_ui_radio_selected_object_get(ev->object));
618 //FIXME
619 elm_image_prescale_set(o_bg, size);
620}
621
622void
623test_ui_image_prescale(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
624{
625 Eo *win, *im;
626 Eo *box, *hbox;
627 Eo *rd, *rdg;
628
629 win = win_add("image-prescale", "Image Prescale Test");
630
631 box = efl_add(EFL_UI_BOX_CLASS, win);
632 efl_content_set(win, box);
633
634 im = img_add(win, "/images/plant_01.jpg");
635 efl_pack(box, im);
636
637 hbox = efl_add(EFL_UI_BOX_CLASS, win);
638 efl_ui_direction_set(hbox, EFL_UI_DIR_RIGHT);
639 efl_gfx_hint_weight_set(hbox, 1.0, 1.0);
640 efl_gfx_hint_fill_set(hbox, EINA_TRUE, EINA_TRUE);
641
642 rd = efl_add(EFL_UI_RADIO_CLASS, win);
643 efl_ui_radio_state_value_set(rd, 50);
644 efl_text_set(rd, "50");
645 efl_gfx_hint_weight_set(rd, 1.0, 1.0);
646 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, _cb_prescale_radio_changed, im);
647 efl_pack(hbox, rd);
648 rdg = rd;
649
650 rd = efl_add(EFL_UI_RADIO_CLASS, win);
651 efl_ui_radio_state_value_set(rd, 100);
652 efl_ui_radio_group_add(rd, rdg);
653 efl_text_set(rd, "100");
654 efl_gfx_hint_weight_set(rd, 1.0, 1.0);
655 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, _cb_prescale_radio_changed, im);
656 efl_pack(hbox, rd);
657
658 rd = efl_add(EFL_UI_RADIO_CLASS, win);
659 efl_ui_radio_state_value_set(rd, 200);
660 efl_ui_radio_group_add(rd, rdg);
661 efl_text_set(rd, "200");
662 efl_gfx_hint_weight_set(rd, 1.0, 1.0);
663 efl_event_callback_add(rd, EFL_UI_RADIO_EVENT_CHANGED, _cb_prescale_radio_changed, im);
664 efl_pack(hbox, rd);
665
666 elm_radio_value_set(rdg, 200);
667
668 efl_pack(box, hbox);
669
670 efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));
671}