elm_test: Add a filter to the code entry
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 10 Jan 2017 10:04:46 +0000 (19:04 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 17 Jan 2017 05:35:30 +0000 (14:35 +0900)
Just because I can. It's the filter code editor after all, deserves
a filter of its own. Plus, it tests that we can embed a filter
in the default style, and edit text with a filter and everything
works as expected. Yay!

src/bin/elementary/test_gfx_filters.c

index 299b07d..2dd7d41 100644 (file)
@@ -494,13 +494,30 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
    }
 
    {
+      const char *code_filter =
+            "a = buffer { 'alpha' }"
+            "grow { 2, dst = a } "
+            "blur { 6, ox = 1, oy = 1, src = a, color = '#004' }"
+            "blur { 3, ox = 1, oy = 1, color = 'black' }"
+            "blend { color = 'lime' }";
+      Eina_Strbuf *buf;
+
       o = code = efl_add(EFL_UI_TEXT_EDITABLE_CLASS, win,
                          efl_gfx_size_hint_weight_set(efl_added, 1.0, 1.0),
                          efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0),
                          efl_ui_text_scrollable_set(efl_added, 1));
       efl_event_callback_add(o, EFL_UI_TEXT_EVENT_CHANGED_USER, _code_changed, win);
 
+      // Insert filter code inside style string: DEFAULT='blah blah <here>'
+      buf = eina_strbuf_new();
+      eina_strbuf_append(buf, efl_canvas_text_style_get(o, NULL));
+      eina_strbuf_insert(buf, " gfx_filter=code", eina_strbuf_length_get(buf) - 1);
+      efl_gfx_filter_program_set(o, code_filter, "code");
+      efl_canvas_text_style_set(o, NULL, eina_strbuf_string_get(buf));
+      eina_strbuf_free(buf);
+
       // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
+      // Efl.Ui.Text doesn't seem to trigger the proper events during edit
       efl_event_callback_add(o, EFL_EVENT_KEY_DOWN, _code_changed_hack, win);
 
       efl_content_set(efl_part(split, "bottom"), code);