diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-04 19:54:48 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-17 14:35:28 +0900 |
commit | 4453044d848fbc51e0827fc055617e8012decfcc (patch) | |
tree | 9da1a81c59a36505e731433cd4237ad41c16c7ee /src | |
parent | 421df2eec6ffb573118f4be29946b805691ac9e7 (diff) |
elm_test: Improve gfx filter test case for tb & text
Now we can test both of those widgets with filters. We
could also add an image. This test case still needs some
improvement anyway.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/elementary/test_gfx_filters.c | 86 |
1 files changed, 65 insertions, 21 deletions
diff --git a/src/bin/elementary/test_gfx_filters.c b/src/bin/elementary/test_gfx_filters.c index 9ccdd71777..a27cdf019f 100644 --- a/src/bin/elementary/test_gfx_filters.c +++ b/src/bin/elementary/test_gfx_filters.c | |||
@@ -123,6 +123,18 @@ _spinner_fill(Eo *obj) | |||
123 | } | 123 | } |
124 | 124 | ||
125 | static void | 125 | static void |
126 | _filter_apply(Eo *win, const char *code, const char *name) | ||
127 | { | ||
128 | Eo *text, *tb; | ||
129 | |||
130 | text = efl_key_wref_get(win, "text"); | ||
131 | tb = efl_key_wref_get(win, "textblock"); | ||
132 | |||
133 | efl_gfx_filter_program_set(text, code, name); | ||
134 | efl_gfx_filter_program_set(tb, code, "main"); | ||
135 | } | ||
136 | |||
137 | static void | ||
126 | _spinner_cb(void *data, const Efl_Event *ev EINA_UNUSED) | 138 | _spinner_cb(void *data, const Efl_Event *ev EINA_UNUSED) |
127 | { | 139 | { |
128 | Eo *win = data; | 140 | Eo *win = data; |
@@ -137,7 +149,7 @@ _spinner_cb(void *data, const Efl_Event *ev EINA_UNUSED) | |||
137 | { | 149 | { |
138 | const Filter *f = &templates[k]; | 150 | const Filter *f = &templates[k]; |
139 | 151 | ||
140 | efl_gfx_filter_program_set(text, f->code, f->name); | 152 | _filter_apply(win, f->code, f->name); |
141 | efl_text_set(code, f->code); | 153 | efl_text_set(code, f->code); |
142 | 154 | ||
143 | if (f->images) | 155 | if (f->images) |
@@ -179,7 +191,7 @@ _code_changed(void *data, const Efl_Event *ev EINA_UNUSED) | |||
179 | } | 191 | } |
180 | 192 | ||
181 | elm_spinner_value_set(spinner, 0); | 193 | elm_spinner_value_set(spinner, 0); |
182 | efl_gfx_filter_program_set(text, source, elm_spinner_special_value_get(spinner, 0)); | 194 | _filter_apply(win, source, elm_spinner_special_value_get(spinner, 0)); |
183 | eina_strbuf_free(buf); | 195 | eina_strbuf_free(buf); |
184 | } | 196 | } |
185 | 197 | ||
@@ -252,10 +264,20 @@ _font_size_change(void *data, const Efl_Event *ev) | |||
252 | efl_text_properties_font_set(text, font, elm_spinner_value_get(ev->object)); | 264 | efl_text_properties_font_set(text, font, elm_spinner_value_get(ev->object)); |
253 | } | 265 | } |
254 | 266 | ||
267 | static void | ||
268 | _flip_click(void *data, const Efl_Event *ev EINA_UNUSED) | ||
269 | { | ||
270 | Eo *win = data; | ||
271 | Eo *flip = efl_key_wref_get(win, "flip"); | ||
272 | |||
273 | /* FIXME: The flip APIs don't make sense for N items (front!?) */ | ||
274 | efl_ui_flip_go(flip, EFL_UI_FLIP_CROSS_FADE); | ||
275 | } | ||
276 | |||
255 | void | 277 | void |
256 | test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 278 | test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
257 | { | 279 | { |
258 | Eo *win, *box, *box2, *o, *text = NULL, *spinner, *code, *split; | 280 | Eo *win, *box, *box2, *o, *text = NULL, *spinner, *code, *split, *flip, *tb; |
259 | 281 | ||
260 | win = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL, | 282 | win = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL, |
261 | efl_text_set(efl_added, "Gfx Filter Editor"), | 283 | efl_text_set(efl_added, "Gfx Filter Editor"), |
@@ -298,7 +320,14 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
298 | elm_spinner_value_set(efl_added, default_font_size), | 320 | elm_spinner_value_set(efl_added, default_font_size), |
299 | efl_event_callback_add(efl_added, ELM_SPINNER_EVENT_DELAY_CHANGED, _font_size_change, win), | 321 | efl_event_callback_add(efl_added, ELM_SPINNER_EVENT_DELAY_CHANGED, _font_size_change, win), |
300 | efl_gfx_visible_set(efl_added, 1)); | 322 | efl_gfx_visible_set(efl_added, 1)); |
323 | efl_pack(box2, o); | ||
301 | 324 | ||
325 | o = efl_add(ELM_BUTTON_CLASS, win, | ||
326 | efl_text_set(efl_added, "Flip"), | ||
327 | efl_gfx_size_hint_weight_set(efl_added, 0.0, 1.0), | ||
328 | efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5), | ||
329 | efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _flip_click, win), | ||
330 | efl_gfx_visible_set(efl_added, 1)); | ||
302 | efl_pack(box2, o); | 331 | efl_pack(box2, o); |
303 | } | 332 | } |
304 | 333 | ||
@@ -345,14 +374,20 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
345 | efl_pack(box, split); | 374 | efl_pack(box, split); |
346 | 375 | ||
347 | { | 376 | { |
348 | o = box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win, | 377 | flip = efl_add(EFL_UI_FLIP_CLASS, win, |
349 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), | 378 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), |
350 | efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0), | 379 | efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0), |
351 | efl_pack_align_set(efl_added, 0.5, 0.5)); | 380 | efl_gfx_visible_set(efl_added, 1)); |
352 | efl_content_set(efl_part(split, "top"), box2); | 381 | efl_content_set(efl_part(split, "top"), flip); |
353 | 382 | ||
354 | /* FIXME: No textblock support! TEXT is not part of EO public API. */ | 383 | box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win, |
355 | /* | 384 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), |
385 | efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0), | ||
386 | efl_pack_align_set(efl_added, 0.5, 0.5), | ||
387 | efl_gfx_visible_set(efl_added, 1)); | ||
388 | efl_pack(flip, box2); | ||
389 | |||
390 | // Note: No TEXT object with EO APIs | ||
356 | o = text = evas_object_text_add(evas_object_evas_get(win)); | 391 | o = text = evas_object_text_add(evas_object_evas_get(win)); |
357 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _text_resize, NULL); | 392 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _text_resize, NULL); |
358 | efl_text_properties_font_set(o, "Sans:style=Bold", default_font_size); | 393 | efl_text_properties_font_set(o, "Sans:style=Bold", default_font_size); |
@@ -360,25 +395,33 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
360 | efl_text_set(o, "EFL"); | 395 | efl_text_set(o, "EFL"); |
361 | efl_gfx_visible_set(o, 1); | 396 | efl_gfx_visible_set(o, 1); |
362 | efl_pack(box2, o); | 397 | efl_pack(box2, o); |
363 | // */ | 398 | |
399 | o = box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win, | ||
400 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), | ||
401 | efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0), | ||
402 | efl_pack_align_set(efl_added, 0.5, 0.5)); | ||
403 | efl_pack(flip, box2); | ||
364 | 404 | ||
365 | const char *codes[] = { | 405 | const char *codes[] = { |
366 | "fill{color='#0033'} padding_set{20} blur{3} blend{}", | 406 | "padding_set{20} blur{3} blend{}", |
367 | "blur{15,color='red'} blend{}" | 407 | "blur{15,color='red'} blend{}", |
408 | "blend{}" | ||
368 | }; | 409 | }; |
369 | const char *names[] = { | 410 | const char *names[] = { |
370 | "one", | 411 | "one", |
371 | "two" | 412 | "two", |
413 | "main" | ||
372 | }; | 414 | }; |
373 | const char *tbtxt = "Hey dude, <gfx_filter='one'>hello</> world!<br>" | 415 | const char *tbtxt = "Classic <gfx_filter='one'>hello</> world!<br>" |
374 | "<gfx_filter='two'>Wanna dance?<br>" | 416 | "And <gfx_filter='two'>This filter over<br>" |
375 | "What's going on here???</>"; | 417 | "multiple lines</> :)<br/>" |
418 | "<gfx_filter='main'>Main filter</>"; | ||
376 | 419 | ||
377 | /* EXPERIMENTAL TEXTBLOCK FILTER */ | 420 | // Experimental textblock support |
378 | o = evas_object_textblock_add(evas_object_evas_get(win)); | 421 | o = tb = evas_object_textblock_add(evas_object_evas_get(win)); |
379 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _textblock_resize, NULL); | 422 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _textblock_resize, NULL); |
380 | Evas_Textblock_Style *st = evas_textblock_style_new(); | 423 | Evas_Textblock_Style *st = evas_textblock_style_new(); |
381 | evas_textblock_style_set(st, "DEFAULT='font=Sans font_size=24 color=#FFF wrap=word'"); | 424 | evas_textblock_style_set(st, "DEFAULT='font=Sans font_size=20 color=#FFF wrap=word'"); |
382 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(codes); k++) | 425 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(codes); k++) |
383 | efl_gfx_filter_program_set(o, codes[k], names[k]); | 426 | efl_gfx_filter_program_set(o, codes[k], names[k]); |
384 | evas_object_textblock_style_set(o, st); | 427 | evas_object_textblock_style_set(o, st); |
@@ -387,7 +430,6 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
387 | efl_pack(box2, o); | 430 | efl_pack(box2, o); |
388 | evas_object_resize(o, 1, 1); | 431 | evas_object_resize(o, 1, 1); |
389 | efl_gfx_visible_set(o, 1); | 432 | efl_gfx_visible_set(o, 1); |
390 | // */ | ||
391 | } | 433 | } |
392 | 434 | ||
393 | { | 435 | { |
@@ -404,7 +446,9 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
404 | } | 446 | } |
405 | 447 | ||
406 | efl_key_wref_set(win, "text", text); | 448 | efl_key_wref_set(win, "text", text); |
449 | efl_key_wref_set(win, "textblock", tb); | ||
407 | efl_key_wref_set(win, "code", code); | 450 | efl_key_wref_set(win, "code", code); |
451 | efl_key_wref_set(win, "flip", flip); | ||
408 | efl_key_wref_set(win, "spinner", spinner); | 452 | efl_key_wref_set(win, "spinner", spinner); |
409 | efl_event_callback_add(spinner, ELM_SPINNER_EVENT_CHANGED, _spinner_cb, win); | 453 | efl_event_callback_add(spinner, ELM_SPINNER_EVENT_CHANGED, _spinner_cb, win); |
410 | elm_spinner_value_set(spinner, 1.0); | 454 | elm_spinner_value_set(spinner, 1.0); |