diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-05 11:25:21 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-17 14:35:29 +0900 |
commit | 1512741b488e212c825ccc78d626d8f666ab1344 (patch) | |
tree | 268de9d5f129c836f8a1b6784ca238f76b7e9cb6 /src | |
parent | 4453044d848fbc51e0827fc055617e8012decfcc (diff) |
evas: Implement filter_data_set for textblock
This is a function that allows passing variables from C or EDC
to the filter's Lua code. Useful in particular for color classes
from EDC.
This data would be the global data but we could eventually add
a markup tag to specify a data value per filter instance. For now
a single data value per tb object should be more than enough though.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/elementary/test_gfx_filters.c | 90 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_canvas_text.eo | 1 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_filter_mixin.c | 2 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 108 |
4 files changed, 174 insertions, 27 deletions
diff --git a/src/bin/elementary/test_gfx_filters.c b/src/bin/elementary/test_gfx_filters.c index a27cdf019f..1fc2cfd410 100644 --- a/src/bin/elementary/test_gfx_filters.c +++ b/src/bin/elementary/test_gfx_filters.c | |||
@@ -43,8 +43,9 @@ static const Filter_Image images_cloud[] = { | |||
43 | static const Filter templates[] = { | 43 | static const Filter templates[] = { |
44 | { "Custom", NULL, NULL }, | 44 | { "Custom", NULL, NULL }, |
45 | { "Black shadow", | 45 | { "Black shadow", |
46 | "if not myColor then myColor = color('yellow') end\n" | ||
46 | "blur { 6, ox = 2, oy = 2, color = 'black' }\n" | 47 | "blur { 6, ox = 2, oy = 2, color = 'black' }\n" |
47 | "blend {}", NULL }, | 48 | "blend { color = myColor }", NULL }, |
48 | { "Fire glow", | 49 | { "Fire glow", |
49 | "a = buffer { 'alpha' }\n" | 50 | "a = buffer { 'alpha' }\n" |
50 | "grow { 10, dst = a }\n" | 51 | "grow { 10, dst = a }\n" |
@@ -71,8 +72,8 @@ static const Filter templates[] = { | |||
71 | "blend { color = 'black' }\n" | 72 | "blend { color = 'black' }\n" |
72 | "mask { input, b }\n", NULL }, | 73 | "mask { input, b }\n", NULL }, |
73 | { "Rocking it", | 74 | { "Rocking it", |
74 | "padding_set { 40 }\n" | ||
75 | "local len = state.scale * 10\n\n" | 75 | "local len = state.scale * 10\n\n" |
76 | "padding_set { len * 2 }\n" | ||
76 | "a = buffer { 'alpha' }\n" | 77 | "a = buffer { 'alpha' }\n" |
77 | "grow { len / 2, dst = a }\n" | 78 | "grow { len / 2, dst = a }\n" |
78 | "blur { len * 2, oy = len, ox = len / 2, color = 'black', src = a }\n" | 79 | "blur { len * 2, oy = len, ox = len / 2, color = 'black', src = a }\n" |
@@ -221,12 +222,6 @@ _textblock_resize(void *data EINA_UNUSED, const Efl_Event *ev) | |||
221 | efl_gfx_size_hint_min_set(ev->object, w + l + r, h + t + b); | 222 | efl_gfx_size_hint_min_set(ev->object, w + l + r, h + t + b); |
222 | } | 223 | } |
223 | 224 | ||
224 | static Evas_Object * | ||
225 | _img_tooltip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *tt) | ||
226 | { | ||
227 | return efl_add(EFL_UI_TEXT_CLASS, tt, efl_text_set(efl_added, efl_name_get(tt))); | ||
228 | } | ||
229 | |||
230 | static void | 225 | static void |
231 | _img_click(void *data, const Efl_Event *ev) | 226 | _img_click(void *data, const Efl_Event *ev) |
232 | { | 227 | { |
@@ -274,6 +269,24 @@ _flip_click(void *data, const Efl_Event *ev EINA_UNUSED) | |||
274 | efl_ui_flip_go(flip, EFL_UI_FLIP_CROSS_FADE); | 269 | efl_ui_flip_go(flip, EFL_UI_FLIP_CROSS_FADE); |
275 | } | 270 | } |
276 | 271 | ||
272 | static void | ||
273 | _colsel_cb(void *data, const Efl_Event *ev) | ||
274 | { | ||
275 | Eo *win = data; | ||
276 | Eo *colsel = ev->object; | ||
277 | Eo *text, *tb; | ||
278 | int r = 0, g = 0, b = 0, a = 255; | ||
279 | char buf[64]; | ||
280 | |||
281 | text = efl_key_wref_get(win, "text"); | ||
282 | tb = efl_key_wref_get(win, "textblock"); | ||
283 | elm_colorselector_color_get(colsel, &r, &g, &b, &a); | ||
284 | sprintf(buf, "color(%d, %d, %d, %d)", r, g, b, a); | ||
285 | |||
286 | efl_gfx_filter_data_set(text, efl_name_get(colsel), buf, 1); | ||
287 | efl_gfx_filter_data_set(tb, efl_name_get(colsel), buf, 1); | ||
288 | } | ||
289 | |||
277 | void | 290 | void |
278 | test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 291 | test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
279 | { | 292 | { |
@@ -332,36 +345,63 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
332 | } | 345 | } |
333 | 346 | ||
334 | { | 347 | { |
335 | size_t k; | ||
336 | |||
337 | box2 = efl_add(EFL_UI_BOX_CLASS, win, | 348 | box2 = efl_add(EFL_UI_BOX_CLASS, win, |
338 | efl_orientation_set(efl_added, EFL_ORIENT_HORIZONTAL), | 349 | efl_orientation_set(efl_added, EFL_ORIENT_HORIZONTAL), |
339 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), | 350 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), |
340 | efl_gfx_size_hint_align_set(efl_added, 0.0, 0.5), | 351 | efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5), |
341 | efl_pack_padding_set(efl_added, 5, 5, 1), | 352 | efl_pack_padding_set(efl_added, 5, 5, 1), |
342 | efl_gfx_size_hint_margin_set(efl_added, 5, 5, 5, 5), | 353 | efl_gfx_size_hint_margin_set(efl_added, 5, 5, 5, 5), |
343 | efl_pack_align_set(efl_added, 0, 0.5)); | 354 | efl_pack_align_set(efl_added, 0, 0.5)); |
344 | efl_pack(box, box2); | 355 | efl_pack(box, box2); |
345 | 356 | ||
346 | for (k = 0; k < EINA_C_ARRAY_LENGTH(images); k++) | 357 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(images); k++) |
347 | { | 358 | { |
348 | char buf[PATH_MAX]; | 359 | char buf[PATH_MAX]; |
349 | 360 | ||
350 | if (!images[k].path) break; | 361 | if (!images[k].path) break; |
351 | snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), images[k].path); | 362 | snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), images[k].path); |
352 | o = efl_add(EFL_UI_IMAGE_CLASS, win, | 363 | o = efl_add(EFL_UI_IMAGE_CLASS, win, |
353 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0), | 364 | efl_gfx_size_hint_weight_set(efl_added, 0.0, 0.0), |
354 | efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5), | 365 | efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5), |
355 | efl_gfx_size_hint_max_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)), | 366 | efl_gfx_size_hint_max_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)), |
356 | efl_gfx_size_hint_min_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)), | 367 | efl_gfx_size_hint_min_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)), |
357 | efl_file_set(efl_added, buf, NULL), | 368 | efl_file_set(efl_added, buf, NULL), |
358 | efl_name_set(efl_added, images[k].src_name), | 369 | efl_name_set(efl_added, images[k].src_name), |
370 | elm_object_tooltip_text_set(efl_added, images[k].src_name), | ||
359 | efl_gfx_visible_set(efl_added, 1)); | 371 | efl_gfx_visible_set(efl_added, 1)); |
360 | elm_object_tooltip_content_cb_set(o, _img_tooltip, NULL, NULL); // GRRRRR | ||
361 | efl_event_callback_add(o, EFL_UI_EVENT_CLICKED, _img_click, win); | 372 | efl_event_callback_add(o, EFL_UI_EVENT_CLICKED, _img_click, win); |
362 | efl_pack(box2, o); | 373 | efl_pack(box2, o); |
363 | } | 374 | } |
364 | 375 | ||
376 | const struct { int r, g, b, a; } colors[] = { | ||
377 | { 255, 255, 255, 255 }, | ||
378 | { 0, 0, 0, 255 }, | ||
379 | { 64, 64, 64, 255 }, | ||
380 | { 128, 128, 128, 255 }, | ||
381 | { 196, 196, 196, 255 }, | ||
382 | { 255, 0, 0, 255 }, | ||
383 | { 0, 255, 0, 255 }, | ||
384 | { 0, 0, 255, 255 }, | ||
385 | { 255, 255, 0, 255 }, | ||
386 | { 255, 0, 255, 255 }, | ||
387 | { 0, 255, 255, 255 }, | ||
388 | { 0, 0, 0, 0 } | ||
389 | }; | ||
390 | |||
391 | o = efl_add(ELM_COLORSELECTOR_CLASS, win, | ||
392 | efl_gfx_size_hint_weight_set(efl_added, 1.0, 0), | ||
393 | efl_gfx_size_hint_align_set(efl_added, -1.0, 0), | ||
394 | elm_colorselector_mode_set(efl_added, ELM_COLORSELECTOR_PALETTE), | ||
395 | efl_gfx_size_hint_max_set(efl_added, -1, ELM_SCALE_SIZE(48 * 2)), | ||
396 | efl_name_set(efl_added, "myColor"), | ||
397 | elm_object_tooltip_text_set(efl_added, "Pick a color to use as variable 'myColor'"), | ||
398 | efl_event_callback_add(efl_added, ELM_COLORSELECTOR_EVENT_CHANGED, _colsel_cb, win), | ||
399 | efl_gfx_visible_set(efl_added, 1)); | ||
400 | efl_pack(box2, o); | ||
401 | |||
402 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(colors); k++) | ||
403 | elm_colorselector_palette_color_add(o, colors[k].r, colors[k].g, colors[k].b, colors[k].a); | ||
404 | |||
365 | efl_gfx_visible_set(box2, 1); | 405 | efl_gfx_visible_set(box2, 1); |
366 | } | 406 | } |
367 | 407 | ||
@@ -402,16 +442,16 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
402 | efl_pack_align_set(efl_added, 0.5, 0.5)); | 442 | efl_pack_align_set(efl_added, 0.5, 0.5)); |
403 | efl_pack(flip, box2); | 443 | efl_pack(flip, box2); |
404 | 444 | ||
405 | const char *codes[] = { | 445 | const struct { const char *name, *code; } programs [] = { |
406 | "padding_set{20} blur{3} blend{}", | 446 | { "one", "blur { 5, color = 'darkblue' } blend {}" }, |
407 | "blur{15,color='red'} blend{}", | 447 | { "two", "blur { 15, color = 'red' } blend {}" }, |
408 | "blend{}" | 448 | { "main", "blend {}" } |
409 | }; | 449 | }; |
410 | const char *names[] = { | 450 | |
411 | "one", | 451 | const struct { const char *name, *value; int exec; } prg_data [] = { |
412 | "two", | 452 | { "myColor", "color(255, 0, 255)", EINA_TRUE }, |
413 | "main" | ||
414 | }; | 453 | }; |
454 | |||
415 | const char *tbtxt = "Classic <gfx_filter='one'>hello</> world!<br>" | 455 | const char *tbtxt = "Classic <gfx_filter='one'>hello</> world!<br>" |
416 | "And <gfx_filter='two'>This filter over<br>" | 456 | "And <gfx_filter='two'>This filter over<br>" |
417 | "multiple lines</> :)<br/>" | 457 | "multiple lines</> :)<br/>" |
@@ -422,8 +462,10 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve | |||
422 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _textblock_resize, NULL); | 462 | efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _textblock_resize, NULL); |
423 | Evas_Textblock_Style *st = evas_textblock_style_new(); | 463 | Evas_Textblock_Style *st = evas_textblock_style_new(); |
424 | evas_textblock_style_set(st, "DEFAULT='font=Sans font_size=20 color=#FFF wrap=word'"); | 464 | evas_textblock_style_set(st, "DEFAULT='font=Sans font_size=20 color=#FFF wrap=word'"); |
425 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(codes); k++) | 465 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(programs); k++) |
426 | efl_gfx_filter_program_set(o, codes[k], names[k]); | 466 | efl_gfx_filter_program_set(o, programs[k].code, programs[k].name); |
467 | for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(prg_data); k++) | ||
468 | efl_gfx_filter_data_set(o, prg_data[k].name, prg_data[k].value, prg_data[k].exec); | ||
427 | evas_object_textblock_style_set(o, st); | 469 | evas_object_textblock_style_set(o, st); |
428 | evas_object_textblock_text_markup_set(o, tbtxt); | 470 | evas_object_textblock_text_markup_set(o, tbtxt); |
429 | efl_canvas_object_scale_set(o, elm_config_scale_get()); | 471 | efl_canvas_object_scale_set(o, elm_config_scale_get()); |
diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo index df926bd575..e39544ee54 100644 --- a/src/lib/evas/canvas/efl_canvas_text.eo +++ b/src/lib/evas/canvas/efl_canvas_text.eo | |||
@@ -368,6 +368,7 @@ class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text, Efl.Canvas.Filter.Internal) | |||
368 | Efl.Canvas.Object.paragraph_direction { get; set; } | 368 | Efl.Canvas.Object.paragraph_direction { get; set; } |
369 | Efl.Text.text { get; set; } | 369 | Efl.Text.text { get; set; } |
370 | Efl.Gfx.Filter.filter_program { get; set; } | 370 | Efl.Gfx.Filter.filter_program { get; set; } |
371 | Efl.Gfx.Filter.filter_data { get; set; } | ||
371 | Efl.Canvas.Filter.Internal.filter_dirty; | 372 | Efl.Canvas.Filter.Internal.filter_dirty; |
372 | Efl.Canvas.Filter.Internal.filter_input_render; | 373 | Efl.Canvas.Filter.Internal.filter_input_render; |
373 | Efl.Canvas.Filter.Internal.filter_state_prepare; | 374 | Efl.Canvas.Filter.Internal.filter_state_prepare; |
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c index 6f43129f60..1f6ea23216 100644 --- a/src/lib/evas/canvas/evas_filter_mixin.c +++ b/src/lib/evas/canvas/evas_filter_mixin.c | |||
@@ -461,6 +461,7 @@ _efl_canvas_filter_internal_efl_gfx_filter_filter_source_set(Eo *eo_obj, Evas_Fi | |||
461 | eina_hash_add(fcow->sources, pb->name, pb); | 461 | eina_hash_add(fcow->sources, pb->name, pb); |
462 | evas_filter_program_source_set_all(fcow->chain, fcow->sources); | 462 | evas_filter_program_source_set_all(fcow->chain, fcow->sources); |
463 | evas_filter_program_data_set_all(fcow->chain, fcow->data); | 463 | evas_filter_program_data_set_all(fcow->chain, fcow->data); |
464 | evas_filter_program_parse(fcow->chain, fcow->code); | ||
464 | 465 | ||
465 | // Update object | 466 | // Update object |
466 | update: | 467 | update: |
@@ -658,6 +659,7 @@ _efl_canvas_filter_internal_efl_gfx_filter_filter_data_set(Eo *eo_obj, Evas_Filt | |||
658 | fcow->data = eina_inlist_append(fcow->data, EINA_INLIST_GET(db)); | 659 | fcow->data = eina_inlist_append(fcow->data, EINA_INLIST_GET(db)); |
659 | } | 660 | } |
660 | evas_filter_program_data_set_all(fcow->chain, fcow->data); | 661 | evas_filter_program_data_set_all(fcow->chain, fcow->data); |
662 | evas_filter_program_parse(fcow->chain, fcow->code); | ||
661 | fcow->changed = 1; | 663 | fcow->changed = 1; |
662 | } | 664 | } |
663 | FCOW_END(fcow, pd); | 665 | FCOW_END(fcow, pd); |
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 7ad8030e89..bec6c8857c 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c | |||
@@ -597,6 +597,7 @@ struct _Evas_Object_Textblock | |||
597 | } formatted, native; | 597 | } formatted, native; |
598 | struct { | 598 | struct { |
599 | Efl_Canvas_Text_Filter_Program *programs; | 599 | Efl_Canvas_Text_Filter_Program *programs; |
600 | Evas_Filter_Data_Binding *data_bindings; | ||
600 | } gfx_filter; | 601 | } gfx_filter; |
601 | Eina_Bool redraw : 1; | 602 | Eina_Bool redraw : 1; |
602 | Eina_Bool changed : 1; | 603 | Eina_Bool changed : 1; |
@@ -4344,6 +4345,7 @@ _filter_program_find(Efl_Canvas_Text_Data *o, const char *name) | |||
4344 | { | 4345 | { |
4345 | Efl_Canvas_Text_Filter_Program *prg; | 4346 | Efl_Canvas_Text_Filter_Program *prg; |
4346 | 4347 | ||
4348 | if (!name) return NULL; | ||
4347 | EINA_INLIST_FOREACH(o->gfx_filter.programs, prg) | 4349 | EINA_INLIST_FOREACH(o->gfx_filter.programs, prg) |
4348 | { | 4350 | { |
4349 | if (eina_streq(name, prg->name)) | 4351 | if (eina_streq(name, prg->name)) |
@@ -4361,9 +4363,11 @@ _format_filter_program_get(Efl_Canvas_Text_Data *o, Evas_Object_Textblock_Format | |||
4361 | Evas_Filter_Program *pgm; | 4363 | Evas_Filter_Program *pgm; |
4362 | 4364 | ||
4363 | filter = fmt->gfx_filter; | 4365 | filter = fmt->gfx_filter; |
4364 | if (!filter->name) return NULL; | 4366 | if (!filter) return NULL; |
4365 | 4367 | ||
4366 | program = _filter_program_find(o, filter->name); | 4368 | program = _filter_program_find(o, filter->name); |
4369 | if (!program) return NULL; | ||
4370 | |||
4367 | if (program->changed) | 4371 | if (program->changed) |
4368 | { | 4372 | { |
4369 | evas_filter_program_del(program->pgm); | 4373 | evas_filter_program_del(program->pgm); |
@@ -4372,8 +4376,8 @@ _format_filter_program_get(Efl_Canvas_Text_Data *o, Evas_Object_Textblock_Format | |||
4372 | pgm = program->pgm; | 4376 | pgm = program->pgm; |
4373 | if (!pgm) | 4377 | if (!pgm) |
4374 | { | 4378 | { |
4375 | // TODO: data set | ||
4376 | pgm = evas_filter_program_new(program->name, EINA_FALSE); | 4379 | pgm = evas_filter_program_new(program->name, EINA_FALSE); |
4380 | evas_filter_program_data_set_all(pgm, EINA_INLIST_GET(o->gfx_filter.data_bindings)); | ||
4377 | if (!evas_filter_program_parse(pgm, program->code)) | 4381 | if (!evas_filter_program_parse(pgm, program->code)) |
4378 | { | 4382 | { |
4379 | evas_filter_program_del(pgm); | 4383 | evas_filter_program_del(pgm); |
@@ -12844,13 +12848,34 @@ _efl_canvas_text_efl_object_destructor(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_ | |||
12844 | efl_destructor(efl_super(eo_obj, MY_CLASS)); | 12848 | efl_destructor(efl_super(eo_obj, MY_CLASS)); |
12845 | } | 12849 | } |
12846 | 12850 | ||
12851 | // testing this macro... | ||
12852 | #define EINA_INLIST_REMOVE(l,i) do { l = (__typeof__(l)) eina_inlist_remove(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0) | ||
12853 | |||
12847 | static void | 12854 | static void |
12848 | evas_object_textblock_free(Evas_Object *eo_obj) | 12855 | evas_object_textblock_free(Evas_Object *eo_obj) |
12849 | { | 12856 | { |
12850 | Efl_Canvas_Text_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); | 12857 | Efl_Canvas_Text_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); |
12858 | Efl_Canvas_Text_Filter_Program *prg; | ||
12859 | Evas_Filter_Data_Binding *db; | ||
12851 | 12860 | ||
12852 | _evas_object_textblock_clear(eo_obj); | 12861 | _evas_object_textblock_clear(eo_obj); |
12853 | evas_object_textblock_style_set(eo_obj, NULL); | 12862 | evas_object_textblock_style_set(eo_obj, NULL); |
12863 | |||
12864 | EINA_INLIST_FREE(o->gfx_filter.programs, prg) | ||
12865 | { | ||
12866 | EINA_INLIST_REMOVE(o->gfx_filter.programs, prg); | ||
12867 | eina_stringshare_del(prg->name); | ||
12868 | eina_stringshare_del(prg->code); | ||
12869 | free(prg); | ||
12870 | } | ||
12871 | EINA_INLIST_FREE(o->gfx_filter.data_bindings, db) | ||
12872 | { | ||
12873 | EINA_INLIST_REMOVE(o->gfx_filter.data_bindings, db); | ||
12874 | eina_stringshare_del(db->name); | ||
12875 | eina_stringshare_del(db->value); | ||
12876 | free(db); | ||
12877 | } | ||
12878 | |||
12854 | while (evas_object_textblock_style_user_peek(eo_obj)) | 12879 | while (evas_object_textblock_style_user_peek(eo_obj)) |
12855 | { | 12880 | { |
12856 | evas_object_textblock_style_user_pop(eo_obj); | 12881 | evas_object_textblock_style_user_pop(eo_obj); |
@@ -13659,10 +13684,10 @@ _efl_canvas_text_efl_gfx_filter_filter_program_set(Eo *eo_obj, Efl_Canvas_Text_D | |||
13659 | } | 13684 | } |
13660 | eina_stringshare_replace(&prg->code, code); | 13685 | eina_stringshare_replace(&prg->code, code); |
13661 | prg->changed = EINA_TRUE; | 13686 | prg->changed = EINA_TRUE; |
13687 | |||
13662 | pd->format_changed = EINA_TRUE; | 13688 | pd->format_changed = EINA_TRUE; |
13663 | _evas_textblock_invalidate_all(pd); | 13689 | _evas_textblock_invalidate_all(pd); |
13664 | _evas_textblock_changed(pd, eo_obj); | 13690 | _evas_textblock_changed(pd, eo_obj); |
13665 | |||
13666 | evas_object_change(eo_obj, obj); | 13691 | evas_object_change(eo_obj, obj); |
13667 | } | 13692 | } |
13668 | 13693 | ||
@@ -13674,6 +13699,83 @@ _efl_canvas_text_efl_gfx_filter_filter_program_get(Eo *obj EINA_UNUSED, Efl_Canv | |||
13674 | ERR("Invalid API definition for this object! 'name' needs to be an @in or @inout value!"); | 13699 | ERR("Invalid API definition for this object! 'name' needs to be an @in or @inout value!"); |
13675 | } | 13700 | } |
13676 | 13701 | ||
13702 | static Evas_Filter_Data_Binding * | ||
13703 | _filter_data_binding_find(Efl_Canvas_Text_Data *pd, const char *name) | ||
13704 | { | ||
13705 | Evas_Filter_Data_Binding *db; | ||
13706 | |||
13707 | if (!name) return NULL; | ||
13708 | EINA_INLIST_FOREACH(pd->gfx_filter.data_bindings, db) | ||
13709 | if (!strcmp(db->name, name)) | ||
13710 | return db; | ||
13711 | |||
13712 | return NULL; | ||
13713 | } | ||
13714 | |||
13715 | EOLIAN static void | ||
13716 | _efl_canvas_text_efl_gfx_filter_filter_data_set(Eo *obj, Efl_Canvas_Text_Data *pd, const char *name, const char *value, Eina_Bool execute) | ||
13717 | { | ||
13718 | Efl_Canvas_Text_Filter_Program *prg; | ||
13719 | Evas_Filter_Data_Binding *db; | ||
13720 | |||
13721 | if (!name) return; | ||
13722 | db = _filter_data_binding_find(pd, name); | ||
13723 | if (db) | ||
13724 | { | ||
13725 | if (eina_streq(db->value, value) && (db->execute == execute)) | ||
13726 | return; | ||
13727 | if (!value) | ||
13728 | { | ||
13729 | EINA_INLIST_REMOVE(pd->gfx_filter.data_bindings, db); | ||
13730 | eina_stringshare_del(db->name); | ||
13731 | eina_stringshare_del(db->value); | ||
13732 | free(db); | ||
13733 | } | ||
13734 | } | ||
13735 | else if (!value) | ||
13736 | { | ||
13737 | return; | ||
13738 | } | ||
13739 | else | ||
13740 | { | ||
13741 | db = calloc(1, sizeof(*db)); | ||
13742 | pd->gfx_filter.data_bindings = (Evas_Filter_Data_Binding *) | ||
13743 | eina_inlist_append(EINA_INLIST_GET(pd->gfx_filter.data_bindings), EINA_INLIST_GET(db)); | ||
13744 | db->name = eina_stringshare_add(name); | ||
13745 | } | ||
13746 | eina_stringshare_replace(&db->value, value); | ||
13747 | db->execute = execute; | ||
13748 | |||
13749 | EINA_INLIST_FOREACH(pd->gfx_filter.programs, prg) | ||
13750 | { | ||
13751 | if (!prg->code) continue; | ||
13752 | if (strstr(prg->code, name)) | ||
13753 | prg->changed = EINA_TRUE; | ||
13754 | } | ||
13755 | |||
13756 | pd->format_changed = EINA_TRUE; | ||
13757 | _evas_textblock_invalidate_all(pd); | ||
13758 | _evas_textblock_changed(pd, obj); | ||
13759 | evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS)); | ||
13760 | } | ||
13761 | |||
13762 | EOLIAN static void | ||
13763 | _efl_canvas_text_efl_gfx_filter_filter_data_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *pd, const char *name, const char **value, Eina_Bool *execute) | ||
13764 | { | ||
13765 | Evas_Filter_Data_Binding *db; | ||
13766 | |||
13767 | db = _filter_data_binding_find(pd, name); | ||
13768 | if (!db) | ||
13769 | { | ||
13770 | if (value) *value = NULL; | ||
13771 | if (execute) *execute = EINA_FALSE; | ||
13772 | return; | ||
13773 | } | ||
13774 | |||
13775 | if (value) *value = db->value; | ||
13776 | if (execute) *execute = db->execute; | ||
13777 | } | ||
13778 | |||
13677 | static void | 13779 | static void |
13678 | evas_object_textblock_coords_recalc(Evas_Object *eo_obj, | 13780 | evas_object_textblock_coords_recalc(Evas_Object *eo_obj, |
13679 | Evas_Object_Protected_Data *obj, | 13781 | Evas_Object_Protected_Data *obj, |